载入中...
搜索中...
未找到
Weather.cpp
浏览该文件的文档.
186 bool pcgMode = false, pcgWeatherEnabled = false, pcgRain = false, pcgSnow = false, pcgWindOverride = false;
213const char *const Weather::kPresetNames[] = {"clear", "drizzle", "rain", "storm", "snow", "fog", "wind", "blizzard"};
364PhotoModeFieldAcceptance Weather::acceptsPhotoModeField(const PhotoModeAssignment& a)const noexcept{
371 if(a.field=="m_pcgWeatherEnabled"){auto*v=std::get_if<bool>(&a.value);if(!v)return bad();impl_->pcgWeatherEnabled=*v;}
372 else if(a.field=="m_pcgWeatherRain"){auto*v=std::get_if<bool>(&a.value);if(!v)return bad();impl_->pcgRain=*v;}
373 else if(a.field=="m_pcgWeatherSnow"){auto*v=std::get_if<bool>(&a.value);if(!v)return bad();impl_->pcgSnow=*v;}
374 else if(a.field=="m_pcgWindSettingsOverride"){auto*v=std::get_if<bool>(&a.value);if(!v)return bad();impl_->pcgWindOverride=*v;}
375 else if(a.field=="m_pcgWindDirection"){auto*v=std::get_if<float>(&a.value);if(!v||!std::isfinite(*v))return bad();impl_->windDirDeg=*v;}
424 impl_->currentReverbPreset = inside ? impl_->interiorReverbPreset : impl_->exteriorReverbPreset;
489 const float cloudiness = (impl_->preset >= 1 && impl_->preset <= 3) ? impl_->intensityCur : 0.f;
503 const bool pcgPrecipitation=impl_->pcgMode&&impl_->pcgWeatherEnabled&&(impl_->pcgRain||impl_->pcgSnow);
535 pushWeatherParams(impl_->rainMat, time, windX, windZ, speed, windOn ? 9.0f : 0.65f, windOn ? 1.1f : 0.045f,
550 impl_->snowWindOverride?-impl_->snowWindY:1.15f, 0.22f, 0.22f, intensity, fogR, fogG, fogB, fogD,
583 const float cloudiness = (impl_->preset >= 1 && impl_->preset <= 3) ? impl_->intensityCur : 0.f;
606 auto interior = table.addClass("PcgInteriorWeatherVolume", ssq::Class::Ctor<PcgInteriorWeatherVolume()>());
608 float x,float y,float z,float sx,float sy,float sz,int mode,int insideReverb,int outsideReverb) {
609 return eve::script::projectResult(vm,self->configureBox(x,y,z,sx,sy,sz,mode,insideReverb,outsideReverb));
613 return eve::script::projectResult(vm,self->configureSphere(x,y,z,radius,mode,insideReverb,outsideReverb));
618 auto settings = table.addClass("ThunderStrikeSettings", ssq::Class::Ctor<ThunderStrikeSettings()>());
629 :Result<ThunderStrikeReceipt>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"state and settings required"));
630 return eve::script::projectResult(vm, std::move(result), [](const ThunderStrikeReceipt &value) {
640 table.addFunc("advanceThunderStrike", [vm=table.getHandle()](ThunderStrikeState* state,float dt) {
687 cls.addFunc("isInteriorWeatherCollisionRequested",&Weather::isInteriorWeatherCollisionRequested);
The single Squirrel projection for common Result, Status and Value.
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.cpp:21
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
Definition Graphics.h:134
virtual std::string getBackendName() const =0
Renderer backend id used by sibling modules (e.g. Gpgpu).
virtual void setDirectionalLight(float dx, float dy, float dz, float r=1.f, float g=1.f, float b=1.f)
Sets the directional light.
Definition Graphics.cpp:273
virtual Shader * newMeshShaderFromSpv(const std::vector< uint32_t > &vertSpv, const std::vector< uint32_t > &fragSpv)=0
Create a Mesh3D custom shader (MeshVertex + Frame UBO + albedo). Empty vert → default mesh3d....
virtual void setBackgroundColorRGBA(float r, float g, float b, float a=1.f)
Sets the background color rgba.
Definition Graphics.cpp:1896
virtual Texture * newTexture(int width, int height, const uint8_t *rgba, bool repeatU=false, bool repeatV=false)=0
Creates a texture. @ownership Caller deletes unless documented otherwise.
Material * newMaterial()
Create a Material asset (shading model + textures + PBR knobs). Caller owns Material*; not tracked by...
Definition Graphics.cpp:277
virtual Mesh * newMeshFromArrays(const float *posXYZ, const float *nrmXYZ, const float *uvST, int vertexCount, const uint32_t *indices, int indexCount)=0
Upload a triangle mesh from packed CPU arrays. Owned by Graphics. posXYZ required (vertexCount*3)....
virtual Shader * newMeshShaderFromWgsl(const std::string &vertWgsl, const std::string &fragWgsl)=0
Create a Mesh3D custom shader from WGSL source (WebGPU backend). The WGSL must declare the engine's F...
Packages shading method + surface parameters into one attachable asset.
Definition Material.h:38
void setAlbedoTexture(Texture *texture)
Set the borrowed material texture. @ownership Graphics factory owns the resource. @lifetime Keep aliv...
Definition Material.h:123
void setShadingModel(const std::string &model)
"pbr" | "unlit" | "hair" | "custom" (unknown → pbr).
Definition Material.cpp:106
void setShader(Shader *shader)
Set an optional Mesh3D / hair shader; nullptr selects the built-in shading path.
Definition Material.h:227
void setMaterial(Material *material)
Attach a Material that packages shading method + surface params.
Definition Renderable3D.cpp:55
GPU texture created via Graphics::newTexture. Owns GPU resources through an opaque backend handle.
Definition Texture.h:15
Caller-owned, immutable-after-configuration Pcg interior-weather volume. @ownership This value owns a...
Definition PcgInteriorWeatherVolume.h:22
bool contains(float x, float y, float z) const noexcept
Return whether a finite world-space position lies inside, including the boundary.
Definition PcgInteriorWeatherVolume.cpp:55
Weather module — real-time precipitation / lightning / wind system.
Definition Weather.h:36
void clearInteriorWeather()
Clear interior state and restore the last sampled exterior reverb preset.
Definition Weather.cpp:440
void init(graphics::Graphics *gfx)
Idempotent; builds meshes/shaders on first call.
Definition Weather.cpp:262
Result< void > setSnowWind(float x, float y, float z)
Override snow world velocity exactly as Pcg SnowWindDir.
Definition Weather.cpp:406
bool getPcgWindOverride() const
Return whether photo mode overrides the captured wind.
Definition Weather.cpp:383
void clearSnowWind()
Return to horizontal wind plus the native default fall speed.
Definition Weather.cpp:413
bool getPcgSnowEnabled() const
Return Pcg's independent snow playback state.
Definition Weather.cpp:382
Result< PcgInteriorWeatherTransition > setInteriorVolumeState(const PcgInteriorWeatherVolume &volume, bool inside)
Apply a trigger-driven enter/exit event without retaining the volume.
Definition Weather.cpp:419
void setEnvironmentEnabled(bool enabled)
Enable legacy weather-owned sky and directional lighting.
Definition Weather.cpp:485
int getCurrentWeatherReverbPreset() const
Returns the current weather reverb preset.
Definition Weather.cpp:448
Result< PcgInteriorWeatherTransition > applyInteriorVolume(const PcgInteriorWeatherVolume &volume, float x, float y, float z)
Sample a bounds-driven interior volume and atomically apply an enter/exit transition.
Definition Weather.cpp:432
bool isInteriorWeatherCollisionRequested() const
True when interior weather collision requested.
Definition Weather.cpp:445
float getFlash() const
How bright the current flash is (0..1), sampled by the scene for a key light.
Definition Weather.cpp:463
float getAmbientBrightness() const
Ambient multiplier that the example should feed into camera.setAmbient().
Definition Weather.cpp:488
PhotoModeFieldAcceptance acceptsPhotoModeField(const PhotoModeAssignment &assignment) const noexcept override
Return whether this module owns a Pcg weather photo-mode field.
Definition Weather.cpp:364
void update(float dt, graphics::Graphics *gfx)
Advance sim + push per-frame uniforms; must run before gfx.render3D().
Definition Weather.cpp:497
bool hasSnowWind() const
Return whether a Pcg snow velocity override is active.
Definition Weather.cpp:414
void setWindDirection(float degrees)
Wind direction in degrees; 0 = toward +Z, 90 = toward -X.
Definition Weather.cpp:404
bool getPcgRainEnabled() const
Return Pcg's independent rain playback state.
Definition Weather.cpp:381
bool getPcgWeatherEnabled() const
Return Pcg's master weather-enabled state.
Definition Weather.cpp:380
Result< void > applyPhotoModeField(const PhotoModeAssignment &assignment) override
Atomically apply one Pcg weather field to this authoritative weather state.
Definition Weather.cpp:367
constexpr HexDirection next(HexDirection d) noexcept
The next direction clockwise (NW wraps to NE).
Definition HexMetrics.h:76
ssq::Table projectResult(HSQUIRRELVM vm, Result< void > &&result)
Consume and project a void native Result using the common schema.
Definition SquirrelBinding.cpp:540
constexpr const char * kWeatherFragWgsl
Definition WeatherWgsl.h:54
constexpr const char * kWeatherVertWgsl
Definition WeatherWgsl.h:5
Definition LightingTarget.h:19
EVENGINE_API_ORCHESTRATION float lightningEnvelope(float age)
Weather return-stroke envelope, normalized age [0,1]; side-effect free.
Definition LightningGeometry.cpp:15
PcgInteriorWeatherMode
Interior precipitation policy mirrored from Pcg.
Definition PcgInteriorWeatherVolume.h:11
@ DisableVfx
void exposeLightning(ssq::Table &table, ssq::Class &weather)
Register preparation/settings and owned Lightning methods on Weather.
Definition LightningBindings.cpp:9
EVENGINE_API_ORCHESTRATION Result< LightningGeometry > buildLightningGeometry(const LightningSettings &settings, unsigned variant)
Deterministic CPU preparation, explicit variant stream; identical inputs give identical geometry on o...
Definition LightningGeometry.cpp:23
Result< void > advanceThunderStrike(ThunderStrikeState &state, float dt)
Apply Pcg's clamped Lerp(intensity,0,dt*2) decay and 0.15 stop threshold.
Definition ThunderStrike.cpp:35
@ InvalidArgument
PhotoModeFieldAcceptance
Capability implemented by the composition root that routes assignments to domain owners.
Definition PcgPhotoModeApply.h:32
@ Accepted
@ Rejected
@ Weather
One reversible field assignment in a photo-mode transaction.
Definition PcgPhotoModeApply.h:15
Copied preparation settings. Width and displacement are world units, independent of endpoint distance...
Definition Lightning.h:16
Definition Weather.cpp:166
PcgInteriorWeatherMode interiorMode
Definition Weather.cpp:188
std::vector< graphics::Renderable3D * > bolts
Definition Weather.cpp:202
std::vector< graphics::Material * > boltMats
Definition Weather.cpp:205