载入中...
搜索中...
未找到
PcgGraphicsPhotoMode.cpp
浏览该文件的文档.
2#include <cmath>
3
4#include "common/Capability.h"
6#include "graphics/Graphics.h"
9
10namespace eve::graphics {
12 if (authority_) cap::removeListener<IPhotoModeFieldSink>(this);
13}
14
16 graphics_ = graphics;
17 control_ = control;
18 camera_ = camera;
19 project();
20}
21
23 if (enabled == authority_) return;
24 if (enabled)
25 cap::addListener<IPhotoModeFieldSink>(this);
26 else
27 cap::removeListener<IPhotoModeFieldSink>(this);
28 authority_ = enabled;
29}
30
32 const PhotoModeAssignment& assignment) const noexcept {
33 return assignment.domain == PhotoModeDomain::Graphics ||
34 (assignment.domain == PhotoModeDomain::Lighting &&
35 assignment.field == "m_globalShadowDistanceMultiplier")
38}
39
41 auto fail = [&](const char* message) {
43 {}, "graphics.pcgPhotoMode"));
44 };
45 auto next = state_;
46 const auto* value = std::get_if<float>(&assignment.value);
47 const auto* mode = std::get_if<int64_t>(&assignment.value);
48 if (assignment.field == "m_lodBias") {
49 if (!value || !std::isfinite(*value) || *value <= 0) return fail("LOD bias must be positive and finite");
50 next.lodBias = *value;
51 } else if (assignment.field == "m_antiAliasing") {
52 if (!mode || *mode < 0 || *mode > 3) return fail("anti-aliasing mode must be in [0,3]");
53 next.antiAliasing = *mode;
54 } else if (assignment.field == "m_shadowDistance") {
55 if (!value || !std::isfinite(*value) || *value < 0)
56 return fail("shadow distance must be finite and non-negative");
57 next.shadowDistance = *value;
58 } else if (assignment.field == "m_shadowResolution") {
59 if (!mode || *mode < 0 || *mode > 3) return fail("shadow resolution must be in [0,3]");
60 next.shadowResolution = *mode;
61 } else if (assignment.field == "m_shadowCascades") {
62 if (!mode || *mode < 0 || *mode > 4) return fail("shadow cascades must be in [0,4]");
63 next.shadowCascades = *mode;
64 } else if (assignment.field == "m_globalShadowDistanceMultiplier") {
65 if (!value || !std::isfinite(*value) || *value < 0 || *value > 5)
66 return fail("global shadow distance multiplier must be in [0,5]");
67 next.globalShadowDistanceMultiplier = *value;
68 } else {
69 return fail("unsupported graphics photo-mode field");
70 }
71 state_ = next;
72 project();
73 return Result<void>::success();
74}
75
76void PcgGraphicsPhotoModeAuthority::project() {
77 if (camera_) {
78 camera_->data()->lodBias = state_.lodBias;
79 const float shadowDistance = state_.shadowDistance * state_.globalShadowDistanceMultiplier;
80 for (int layer = 0; layer < 32; ++layer) camera_->setShadowLayerCullDistance(layer, shadowDistance);
81 }
82 if (!graphics_ || !control_) return;
83 auto* antiAliasing = graphics_->pipelineAntiAliasing();
84 const int mode = int(state_.antiAliasing);
85 if (mode == 0) {
86 control_->disable("aa");
87 control_->disable("taa");
88 } else {
89 control_->enable("aa");
90 control_->enable(mode == 3 ? "taa" : "aa");
91 if (mode != 3) control_->disable("taa");
92 antiAliasing->setMode(mode == 2 ? "smaa" : mode == 3 ? "taa" : "fxaa");
93 }
94 control_->compile();
95}
96} // namespace eve::graphics
double value
std::string message
float camera[2]
TileLayer * layer
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
Move-only operation result carrying either a value or Status.
Definition Result.h:155
static Result success(T value)
Construct a successful result owning value.
Definition Result.h:164
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
EVENGINE_API_BACKENDS public API.
void setShadowLayerCullDistance(int layer, float distance)
Set the shadow-caster cull distance for one render layer; zero disables it.
AntiAliasing * pipelineAntiAliasing()
Pipeline anti aliasing.
PhotoModeFieldAcceptance acceptsPhotoModeField(const PhotoModeAssignment &) const noexcept override
Accepts photo mode field.
Result< void > applyPhotoModeField(const PhotoModeAssignment &) override
Applies photo mode field.
void setAuthority(bool enabled)
Register or revoke the unique graphics photo-mode authority.
void setTargets(Graphics *graphics, RenderControl *control, Camera3D *camera)
Bind borrowed owner-thread render targets; none are retained past this authority's lifetime.
~PcgGraphicsPhotoModeAuthority() override
Pcg graphics photo mode authority.
Declarative, compilable 3D render control.
void compile()
Rebuild the executable pass list from current feature flags.
void enable(const std::string &feature)
Enables .
void disable(const std::string &feature)
Disables .
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition Animation.h:25
PhotoModeFieldAcceptance
Capability implemented by the composition root that routes assignments to domain owners.
bool enabled
One reversible field assignment in a photo-mode transaction.