载入中...
搜索中...
未找到
EnvironmentDayNightRuntime.cpp
浏览该文件的文档.
2
3#include "daynight/DayNight.h"
4
5#include <utility>
6
8
10 daynight::DayNight* environment) const {
11 if (!environment)
12 return eve::editing::failed<void>(EditorStatus::Rejected, RuleId("editor.environment.daynight-required"),
13 "Runtime DayNight environment is required");
14 const auto* mode = document.value("environment.mode")->getIf<std::string>();
15 if (!mode || *mode != "daynight")
16 return eve::editing::failed<void>(EditorStatus::Rejected, RuleId("editor.environment.mode-mismatch"),
17 "Environment document is not in daynight mode");
18 const auto diagnostics = document.validate();
19 for (const EditorDiagnostic& diagnostic : diagnostics)
20 if (diagnostic.severity() == DiagnosticSeverity::Error)
21 return Result<void>::failure(eve::Status(EditorStatus::Rejected, diagnostics));
22 environment->setTimeOfDay(static_cast<float>(*document.value("daynight.time")->getIf<double>()));
23 environment->setSpeed(static_cast<float>(*document.value("daynight.speed")->getIf<double>()));
24 environment->setPaused(*document.value("daynight.paused")->getIf<bool>());
25 environment->setTurbidity(static_cast<float>(*document.value("daynight.turbidity")->getIf<double>()));
26 environment->setMieStrength(static_cast<float>(*document.value("daynight.mie")->getIf<double>()));
27 environment->setSkyExposure(static_cast<float>(*document.value("environment.exposure")->getIf<double>()));
28 environment->setSkyboxEnabled(*document.value("daynight.skybox")->getIf<bool>());
29 return eve::editing::applied<void>(diagnostics);
30}
31
32} // namespace eve::lighting_editing
A structured explanation of a failed, degraded, or noteworthy result.
Definition Diagnostic.h:94
Move-only operation result carrying either a value or Status.
Definition Result.h:155
Structured status and zero or more diagnostics for an operation.
Definition Status.h:68
DayNight module — a time-of-day cycle that drives the sun, sky and light.
Definition DayNight.h:94
void setPaused(bool paused)
Sets the paused.
Definition DayNight.cpp:302
void setSkyboxEnabled(bool enabled)
Sets the skybox enabled.
Definition DayNight.cpp:644
void setTurbidity(float turbidity)
Set aerosol turbidity. 1.5 is very clear; 10 is hazy.
Definition DayNight.cpp:444
void setSkyExposure(float exposure)
Exposure used when mapping physical sky radiance to the RGBA8 sky cubemap.
Definition DayNight.cpp:449
void setSpeed(float hoursPerRealHour)
Sets the speed.
Definition DayNight.cpp:300
void setMieStrength(float strength)
Relative Mie aerosol density; controls horizon haze and solar halo.
Definition DayNight.cpp:454
void setTimeOfDay(float hours)
Sets the time of day.
Definition DayNight.cpp:293
const T * getIf() const
Return an immediately borrowed typed value.
Serializable shared environment target for static, DayNight and Weather modes.
std::vector< EditorDiagnostic > validate() const
Validate mode-dependent atmosphere and weather settings.
Result< void > applyDayNight(const EnvironmentDocumentTarget &document, daynight::DayNight *environment) const
Applies day night.
const EditorValue * value(const std::string &path) const
Read a typed runtime-neutral property value by path.
editing::RuleId RuleId