载入中...
搜索中...
未找到
GeometryCollectionAsset.cpp
浏览该文件的文档.
19bool hasExactFields(const eve::Value::Object& object, std::initializer_list<std::string_view> expected) {
30 eve::DiagnosticCode::InvalidArgument, "geometry-collection field must be an integer", std::string(name)));
38 eve::DiagnosticCode::InvalidArgument, "geometry-collection field must be numeric", std::string(name)));
39 const double parsed = value->isDouble() ? value->asDouble() : static_cast<double>(value->asInt());
52 eve::DiagnosticCode::InvalidArgument, "geometry-collection field must be boolean", std::string(name)));
56eve::Result<GeometryCollectionBone> decodeBone(const eve::Value& value, std::uint32_t schemaVersion) {
65 eve::DiagnosticCode::Unsupported, "geometry-collection bone schema version is unsupported", "bones"));
66 if (v1 && !hasExactFields(*object, {"halfExtentX", "halfExtentY", "halfExtentZ", "localX", "localY", "localZ",
69 eve::DiagnosticCode::InvalidArgument, "geometry-collection bone has unknown or missing fields", "bones"));
70 if (v2 && !hasExactFields(*object, {"halfExtentX", "halfExtentY", "halfExtentZ", "localX", "localY", "localZ",
74 eve::DiagnosticCode::InvalidArgument, "geometry-collection bone has unknown or missing fields", "bones"));
115 if (!fractureLevel) return eve::Result<GeometryCollectionBone>::failure(fractureLevel.status());
121 eve::DiagnosticCode::InvalidArgument, "geometry-collection cluster fields out of int range", "bones"));
135 eve::DiagnosticCode::InvalidArgument, "geometry-collection edge has unknown or missing fields", "edges"));
142 if (a.value() < std::numeric_limits<int>::min() || a.value() > std::numeric_limits<int>::max() ||
145 eve::DiagnosticCode::InvalidArgument, "geometry-collection edge bone index is out of int range", "edges"));
188 eve::DiagnosticCode::InvalidArgument, "geometry-collection exceeds the 4096-bone limit", "bones"));
191 eve::DiagnosticCode::InvalidArgument, "geometry-collection exceeds the 16384-edge limit", "edges"));
196 if (!finitePositive(bone.halfExtentX) || !finitePositive(bone.halfExtentY) || !finitePositive(bone.halfExtentZ))
198 eve::DiagnosticCode::InvalidArgument, "bone half-extents must be finite and positive", "bones"));
204 eve::DiagnosticCode::InvalidArgument, "bone mass and density must be finite and positive", "bones"));
219 eve::DiagnosticCode::InvalidArgument, "edge bone indices must name two distinct bones", "edges"));
222 eve::DiagnosticCode::InvalidArgument, "edge strainThreshold must be finite and positive", "edges"));
270 if (eve::schema::SchemaRegistry::resolve(std::string(SchemaId), static_cast<int>(SchemaVersion)))
277eve::Result<GeometryCollectionAsset> GeometryCollectionAsset::fromValue(const eve::Value& value) {
284 eve::DiagnosticCode::InvalidArgument, "geometry-collection asset has unknown or missing fields", "asset"));
294 eve::DiagnosticCode::Unsupported, "geometry-collection schema version is unsupported", "schemaVersion"));
326eve::Result<GeometryCollectionAsset> GeometryCollectionAsset::makeWeldedBoxesFixture(float strainThreshold) {
349eve::Result<GeometryCollectionAsset> GeometryCollectionAsset::makeClusterPillarFixture(float interClusterStrain) {
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
const T * getIf() const noexcept
Return a typed pointer, or nullptr when the kind differs.
Definition Value.h:180
static eve::Result< SchemaRegistrationStatus > registerVersioned(const SchemaDefinition &definition)
Registers a new exact (id, version) entry without replacing it.
Definition SchemaRegistry.cpp:864
static const SchemaDefinition * resolve(const std::string &schemaId, int schemaVersion)
Resolves one exact (schemaId, schemaVersion) pair, or nullptr.
Definition SchemaRegistry.cpp:879
bool decodeEdge(const EditorValue &value, std::uint32_t &id, std::vector< procgen::road::RoadControlPoint > &points)
Definition RoadNetworkEditTarget.cpp:209
const EditorValue * field(const EditorValue &value, const char *name)
Definition RoadNetworkEditTarget.cpp:15
EditorValue encodeEdge(std::uint32_t id, const std::vector< procgen::road::RoadControlPoint > &points)
Definition RoadNetworkEditTarget.cpp:159
@ InvalidArgument
@ Unsupported
Definition Container.h:602
Immutable cooked/authored geometry-collection asset.
Definition GeometryCollectionAsset.h:48
eve::Result< eve::Value > toValue() const
Encode the complete canonical version-2 value.
Definition GeometryCollectionAsset.cpp:227
static eve::Result< void > ensureSchemaRegistered()
Idempotently register version 2 in the process schema registry.
Definition GeometryCollectionAsset.cpp:269
static constexpr std::uint32_t SchemaVersion
Definition GeometryCollectionAsset.h:50
std::vector< GeometryCollectionEdge > edges
Definition GeometryCollectionAsset.h:54
static eve::Result< GeometryCollectionAsset > fromValue(const eve::Value &value)
Decode and validate version 2, or migrate version 1 (cluster fields = 0).
Definition GeometryCollectionAsset.cpp:277
std::vector< GeometryCollectionBone > bones
Definition GeometryCollectionAsset.h:53
static constexpr std::string_view SchemaId
Definition GeometryCollectionAsset.h:49
static constexpr std::uint32_t SchemaVersionV1
Definition GeometryCollectionAsset.h:51
static eve::Result< GeometryCollectionAsset > makeWeldedBoxesFixture(float strainThreshold=1.f)
Build a two-box welded fixture used by tests and the smoke example.
Definition GeometryCollectionAsset.cpp:326
static eve::Result< GeometryCollectionAsset > makeClusterPillarFixture(float interClusterStrain=0.8f)
Build a 2×3 anchored pillar with two cook clusters for demos.
Definition GeometryCollectionAsset.cpp:349
static eve::schema::SchemaDefinition schemaDefinition()
Build the tooling schema that mirrors validate().
Definition GeometryCollectionAsset.cpp:244
eve::Result< void > validate() const
Validate bone/edge topology and numeric ranges.
Definition GeometryCollectionAsset.cpp:181
One pre-authored leaf bone (box collision proxy) inside a geometry collection.
Definition GeometryCollectionAsset.h:16
float halfExtentX
Definition GeometryCollectionAsset.h:17
One undirected structural edge with a strain break threshold.
Definition GeometryCollectionAsset.h:35
Metadata and validation constraints for one object member.
Definition SchemaTypes.h:77
std::vector< FieldDefinition > fields
Definition SchemaTypes.h:99
bool additionalProperties
Definition SchemaTypes.h:98