载入中...
搜索中...
未找到
GrassWind.cpp
浏览该文件的文档.
2#include <array>
3#include <string>
4#include "common/Assert.h"
5#include "graphics/Shader.h"
7namespace eve::graphics {
9 double seconds) {
10 auto packet = packVegetationWind(state, profile, seconds);
11 if (!packet.ok()) return Result<void>::failure(packet.status());
12 // Construct names before publication. Existing uniform writes only check schema and copy bytes.
13 static const std::array<std::string, 5> names = {"windGlobals", "windPhaseDistance", "windFlex", "windFrequency",
14 "windSineTime"};
15 constexpr std::array<int, 5> offsets{18, 22, 24, 27, 30};
16 constexpr std::array<int, 5> sizes{4, 2, 3, 3, 2};
17 for (size_t i = 0; i < names.size(); ++i) {
18 if (shader.usedFloats() != 32 || !shader.hasUniform(names[i]) ||
19 shader.getUniformIndex(names[i]) != offsets[i] || shader.getUniformFloatCount(names[i]) != sizes[i])
21 "grass.wind: canonical grass wind uniform layout required"));
22 }
23 for (size_t i = 0; i < names.size(); ++i) {
24 const size_t bytes = size_t(sizes[i]) * sizeof(float);
25 const int written = shader.sendToVar(names[i], packet.value().data() + offsets[i] - 18, bytes);
26 EV_ASSERT(written == int(bytes));
27 }
28 return Result<void>::success();
29}
30} // namespace eve::graphics
EVEngine assertion entry point, backed by zeroerr.
#define EV_ASSERT(cond,...)
Assert an internal engine invariant (state that must always hold).
Definition Assert.h:37
std::uint64_t bytes
Shader * shader
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
Custom GPU program.
Definition Shader.h:39
bool hasUniform(const std::string &name) const
Definition Shader.cpp:59
int usedFloats() const
Definition Shader.h:115
int getUniformIndex(const std::string &name) const
Definition Shader.cpp:61
int getUniformFloatCount(const std::string &name) const
Definition Shader.cpp:67
int sendToVar(const std::string &name, const void *data, size_t size)
Low-level blob write into a declared uniform (size must match declaration).
Definition Shader.cpp:73
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition Animation.h:25
Result< std::array< float, 14 > > packVegetationWind(const VegetationWindState &state, const VegetationWindProfile &profile, double seconds)
Pack a wind snapshot into the grass shader's final 14 float slots.
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
Caller-owned material wind controls; billboard suppresses source branch and leaf motion....
Caller-owned wind globals; no hidden clock, singleton or retained scene link.