载入中...
搜索中...
未找到
GrassWindBindings.cpp
浏览该文件的文档.
3#include "graphics/Shader.h"
4#include "graphics/TreeWind.h"
6namespace eve::graphics {
7namespace {
8} // namespace
9void exposeGrassWindBindings(ssq::Table& table) {
10 auto state = table.addClass("VegetationWindState", ssq::Class::Ctor<VegetationWindState()>());
11 state.addVar("strength", &VegetationWindState::strength);
12 state.addVar("phase", &VegetationWindState::phase);
13 state.addVar("updatePhase", &VegetationWindState::updatePhase);
14 state.addFunc("setDirection", [](VegetationWindState* s, float x, float y, float z) { s->direction = {x, y, z}; });
15 state.addFunc("getDirectionX", [](const VegetationWindState* s) { return s->direction.x; });
16 state.addFunc("getDirectionY", [](const VegetationWindState* s) { return s->direction.y; });
17 state.addFunc("getDirectionZ", [](const VegetationWindState* s) { return s->direction.z; });
18 auto audioState = table.addClass("VegetationWindAudioState", ssq::Class::Ctor<VegetationWindAudioState()>());
19 audioState.addVar("currentWindSpeed", &VegetationWindAudioState::currentWindSpeed);
20 audioState.addVar("anchorVolume", &VegetationWindAudioState::anchorVolume);
21 audioState.addVar("volume", &VegetationWindAudioState::volume);
22 audioState.addVar("processing", &VegetationWindAudioState::processing);
23 audioState.addVar("playing", &VegetationWindAudioState::playing);
24 auto profile = table.addClass("VegetationWindProfile", ssq::Class::Ctor<VegetationWindProfile()>());
25 profile.addVar("maximumDistance", &VegetationWindProfile::maximumDistance);
26 profile.addVar("enabled", &VegetationWindProfile::enabled);
27 profile.addVar("billboard", &VegetationWindProfile::billboard);
28 profile.addVar("alphaTest", &VegetationWindProfile::alphaTest);
29 profile.addFunc("setFlex", [](VegetationWindProfile* p, float x, float y, float z) { p->flex = {x, y, z}; });
30 profile.addFunc("setFrequency",
31 [](VegetationWindProfile* p, float x, float y, float z) { p->frequency = {x, y, z}; });
32 auto tree = table.addClass("TreeWindProfile", ssq::Class::Ctor<TreeWindProfile()>());
33 tree.addVar("bendFactor", &TreeWindProfile::bendFactor);
34 tree.addFunc("setDimensions", [](TreeWindProfile* p, float width, float height) {
35 p->widthHeight = {width, height};
36 });
37 table.addFunc("advanceVegetationWind", [vm = table.getHandle()](VegetationWindState* s, float x, float y, float z,
38 float strength, float dt) {
39 auto result = s ? advanceVegetationWind(*s, {x, y, z}, strength, dt) : Result<void>::failure(
40 Diagnostic::error(DiagnosticCode::InvalidArgument, "grass.wind: non-null shader, state and profile required"));
41 return eve::script::projectResult(vm, std::move(result));
42 });
43 table.addFunc("initializeVegetationWind",
44 [vm = table.getHandle()](VegetationWindState* s, float x, float y, float z, float strength) {
45 auto result = s ? initializeVegetationWind(*s, {x, y, z}, strength) : Result<void>::failure(
46 Diagnostic::error(DiagnosticCode::InvalidArgument, "grass.wind: non-null shader, state and profile required"));
47 return eve::script::projectResult(vm, std::move(result));
48 });
49 table.addFunc("applyGrassWind", [vm = table.getHandle()](Shader* shader, const VegetationWindState* s,
50 const VegetationWindProfile* p, float seconds) {
51 auto result = shader && s && p ? applyGrassWind(*shader, *s, *p, seconds) : Result<void>::failure(
52 Diagnostic::error(DiagnosticCode::InvalidArgument, "grass.wind: non-null shader, state and profile required"));
53 return eve::script::projectResult(vm, std::move(result));
54 });
55 table.addFunc("applyTreeWind",
56 [vm = table.getHandle()](Shader* shader, const VegetationWindState* s,
57 const VegetationWindProfile* p, const TreeWindProfile* treeProfile,
58 float seconds) {
59 auto result = shader && s && p && treeProfile
60 ? applyTreeWind(*shader, *s, *p, *treeProfile, seconds)
61 : Result<void>::failure(
62 Diagnostic::error(DiagnosticCode::InvalidArgument, "grass.wind: non-null shader, state and profile required"));
63 return eve::script::projectResult(vm, std::move(result));
64 });
65 table.addFunc("advanceVegetationWindAudio",
66 [vm = table.getHandle()](VegetationWindAudioState* state, float strength, float transitionTime,
67 float dt, bool enabled, bool clipAvailable) {
68 auto result = state ? advanceVegetationWindAudio(*state, strength, transitionTime, dt, enabled,
69 clipAvailable)
70 : Result<void>::failure(
71 Diagnostic::error(DiagnosticCode::InvalidArgument, "grass.wind: non-null shader, state and profile required"));
72 return eve::script::projectResult(vm, std::move(result));
73 });
74}
75} // namespace eve::graphics
float y
Definition AnimClip.cpp:738
float x
Definition AnimClip.cpp:738
float z
Definition AnimClip.cpp:738
const std::string & s
glm::vec4 p[6]
HSQUIRRELVM vm
Definition ECS.cpp:20
std::uint32_t height
std::uint32_t width
std::string error
Definition Package.cpp:60
Shader * shader
The single Squirrel projection for common Result, Status and Value.
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
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
eve::Diagnostic Diagnostic
eve::Result< T > Result
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition Animation.h:25
Result< void > applyTreeWind(Shader &shader, const VegetationWindState &state, const VegetationWindProfile &vegetation, const TreeWindProfile &tree, double seconds)
Atomically publish one validated tree wind snapshot to CPU-side shader parameters.
Definition TreeWind.cpp:13
Result< void > initializeVegetationWind(VegetationWindState &state, glm::vec3 forward, float strength)
Apply Pcg WindManager.InstantWindApply semantics without smoothing.
Result< void > advanceVegetationWindAudio(VegetationWindAudioState &state, float windStrength, float transitionTime, float dt, bool enabled, bool clipAvailable)
Advance Pcg WindManager CheckWindVolume and ProcessWindAudio as a pure state transition.
EVENGINE_API_BACKENDS void exposeGrassWindBindings(ssq::Table &table)
Register wind state/profile and checked operations on the VM owner thread, retaining no table referen...
Result< void > applyGrassWind(Shader &shader, const VegetationWindState &state, const VegetationWindProfile &profile, double seconds)
Atomically apply a validated wind snapshot to a grass shader's CPU uniform storage.
Definition GrassWind.cpp:8
std::unordered_map< std::string, SkillDefinition > & table()
Definition Skill.cpp:65
ssq::Table projectResult(HSQUIRRELVM vm, Result< void > &&result)
Consume and project a void native Result using the common schema.
DiagnosticCode
Stable machine-readable diagnostic codes.
Definition Diagnostic.h:47
bool enabled
Caller-owned tree prototype wind geometry matching Pcg ResourceProtoTree inputs.
Definition TreeWind.h:12
float bendFactor
Pcg tree prototype bend factor. Zero disables deformation.
Definition TreeWind.h:16
Caller-owned state for Pcg WindManager's looping wind-audio volume controller.
Caller-owned material wind controls; billboard suppresses source branch and leaf motion....
Caller-owned wind globals; no hidden clock, singleton or retained scene link.
float updatePhase
WindManager's private update accumulator; InstantWindApply deliberately preserves it.
float phase
Phase currently published to shaders.