载入中...
搜索中...
未找到
EvpackClothModel.cpp
浏览该文件的文档.
2
4
6namespace {
7
8} // namespace
9
11 const asset::EvpackCapabilities& capabilities,
12 std::uint64_t maximumDecodedBytes) const {
13 auto payload = reader_.read(model, "eve.cloth-model/1", capabilities, maximumDecodedBytes);
15 if (payload.value().chunks.size() != 1 || payload.value().chunks.front().kind != asset::EvpackChunkKind::Definition)
17 Diagnostic::error(DiagnosticCode::ParseError, "eve.cloth-model/1 must contain exactly one definition chunk",
18 {}, {}, "asset.physics.cloth-model"));
19
21 limits.maximumBytes = maximumDecodedBytes;
22 auto definition = asset::decodeRuntimeDefinition(payload.value().chunks.front().bytes, limits);
23 if (!definition) return Result<LoadedClothModel>::failure(definition.status());
24 auto decoded = physics::ClothModel::fromValue(definition.value());
25 if (!decoded) return Result<LoadedClothModel>::failure(decoded.status());
26
28 {model, std::move(decoded).takeValue(), std::move(payload).takeValue().variant});
29}
30
31} // namespace eve::asset_physics
Value::Object payload
Runtime package adapter for cloth models.
glm::mat4 model
JSON-free versioned runtime metadata codec.
const AssetImportLimits & limits
Stable asset identity backed by PersistentId.
Definition ResourceRef.h:53
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
Result< RuntimeAssetPayload > read(const AssetRef &asset, std::string_view expectedType, const EvpackCapabilities &capabilities, std::uint64_t maximumDecodedBytes) const
Resolve, type-check, variant-select and decode a canonical runtime asset.
Result< LoadedClothModel > load(const AssetRef &model, const asset::EvpackCapabilities &capabilities, std::uint64_t maximumDecodedBytes=256ull *1024ull *1024ull) const
Decode one self-contained eve.cloth-model/1 definition atomically.
static eve::Result< ClothModel > fromValue(const eve::Value &value)
Decode strict eve.cloth-model/1 data; unknown fields are rejected.
Result< Value > decodeRuntimeDefinition(std::span< const std::uint8_t > bytes, const RuntimeDefinitionLimits &limits)
Decode a bounded EVDEF\0\1 metadata tree without a JSON parser.
Actual runtime device capabilities used for variant selection.
Definition Evpack.h:92
Structural and allocation limits for untrusted EVDEF metadata.