载入中...
搜索中...
未找到
EvpackInstanceSetLoader.cpp
浏览该文件的文档.
33 auto payload = reader_.read(instanceRef, "eve.instance-set/5", capabilities, limits.maximumDecodedBytes);
36 payload = reader_.read(instanceRef, "eve.instance-set/4", capabilities, limits.maximumDecodedBytes);
39 payload = reader_.read(instanceRef, "eve.instance-set/3", capabilities, limits.maximumDecodedBytes);
42 payload = reader_.read(instanceRef, "eve.instance-set/2", capabilities, limits.maximumDecodedBytes);
45 payload = reader_.read(instanceRef, "eve.instance-set/1", capabilities, limits.maximumDecodedBytes);
73 if (count > limits.maximumInstances || reserved != 0 || count > (bulk->bytes.size() - 16) / minimumRecordBytes)
86 if (!schema || !schema->isString() || schema->asString() != "eve.instance-set" || !version || !version->isInt64() ||
87 (version->asInt() != 1 && version->asInt() != 2 && version->asInt() != 3 && version->asInt() != 4 &&
104 if (!std::isfinite(parsed) || parsed < 0 || parsed > std::numeric_limits<float>::max()) return std::nullopt;
138 DiagnosticCode::ParseError, "instance prototype table is invalid", {}, {}, "asset.procgen.instances"));
159 !isValidUtf8(id->asString(), Utf8NullPolicy::Reject) || !prototypeIds.emplace(id->asString()).second ||
169 if (!resource || !resource->isString() || resource->asString().size() > limits.maximumStringBytes ||
184 if (!minWidth || !maxWidth || !minHeight || !maxHeight || !noiseSpread || !density || !align || !jitter ||
191 RuntimeInstancePrototype prototype{id->asString(), mode->asString(), mesh->asBool(), instancing->asBool(),
235 if (stringBytes == 0 || stringBytes > limits.maximumStringBytes || stringBytes > bulk->bytes.size() - cursor ||
241 instance.prototype.assign(reinterpret_cast<const char*>(bulk->bytes.data() + cursor), stringBytes);
246 // Unity tree instances and mesh-backed terrain Details both use unity-guid:. A GUID absent from the
247 // Detail prototype table is therefore a tree prototype; texture-backed Details have an unambiguous prefix.
271 std::all_of(instance.scale.begin(), instance.scale.end(), [](float value) { return std::isfinite(value); });
273 std::sqrt(instance.rotation[0] * instance.rotation[0] + instance.rotation[1] * instance.rotation[1] +
275 if (!finite || qLength < 0.999f || qLength > 1.001f || instance.scale[0] == 0.f || instance.scale[1] == 0.f ||
278 Diagnostic::error(DiagnosticCode::InvalidArgument, "instance TRS is invalid", std::to_string(index), {},
284 DiagnosticCode::ParseError, "instance payload has trailing bytes", {}, {}, "asset.procgen.instances"));
Runtime decoding of canonical static instances.
JSON-free versioned runtime metadata codec.
Strict allocation-free UTF-8 validation.
static Result< AssetRef > parse(std::string_view text)
Parse an asset://<canonical UUID> reference.
Definition ResourceRef.cpp:20
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
const std::string & asString() const
Return the string payload; the caller must have checked the kind.
Definition Value.cpp:87
std::int64_t asInt() const
Return the Int64 payload; the caller must have checked the kind.
Definition Value.cpp:69
bool asBool() const
Return the boolean payload; the caller must have checked the kind.
Definition Value.cpp:81
const T * getIf() const noexcept
Return a typed pointer, or nullptr when the kind differs.
Definition Value.h:180
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.
Definition EvpackResourceReader.cpp:10
Result< LoadedInstanceSet > load(const AssetRef &instances, const asset::EvpackCapabilities &capabilities, const InstanceSetLoadLimits &limits={}) const
Validate metadata, exact byte layout and every TRS record transactionally.
Definition EvpackInstanceSetLoader.cpp:30
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.
Definition RuntimeDefinition.cpp:246
@ Definition
@ InvalidArgument
@ TypeMismatch
A stable reference resolved to a different canonical domain type.
@ NotFound
@ ParseError
@ Conflict
bool isValidUtf8(std::string_view text, Utf8NullPolicy nullPolicy) noexcept
Validate shortest-form UTF-8, Unicode scalar range and optional NUL exclusion.
Definition Utf8Validation.cpp:5
@ Reject
Actual runtime device capabilities used for variant selection.
Definition Evpack.h:92
One decoded runtime chunk with its admitted semantic metadata.
Definition EvpackResourceReader.h:13
std::vector< std::uint8_t > bytes
Definition EvpackResourceReader.h:16
Structural and allocation limits for untrusted EVDEF metadata.
Definition RuntimeDefinition.h:17
std::uint64_t maximumBytes
Definition RuntimeDefinition.h:18
Bounds applied before allocating untrusted instance records and strings.
Definition EvpackInstanceSetLoader.h:42
Owning exact static-instance set selected for one runtime variant.
Definition EvpackInstanceSetLoader.h:49
Runtime vegetation prototype metadata retained from the source terrain.
Definition EvpackInstanceSetLoader.h:24
One exact canonical static instance using meters and an XYZW quaternion.
Definition EvpackInstanceSetLoader.h:16
std::array< float, 3 > scale
Definition EvpackInstanceSetLoader.h:20
std::string prototype
Definition EvpackInstanceSetLoader.h:17
std::array< float, 4 > rotation
Definition EvpackInstanceSetLoader.h:19
std::array< float, 3 > position
Definition EvpackInstanceSetLoader.h:18