载入中...
搜索中...
未找到
ClimbingAnchorAuthoring.cpp
浏览该文件的文档.
20Vec3 multiply(Vec3 value, float scale) { return {value.x * scale, value.y * scale, value.z * scale}; }
31 eve::DiagnosticCode::InvalidArgument, "vector must be finite", path, {}, "climbing.anchor_baker"));
35 eve::DiagnosticCode::InvalidArgument, "vector must be non-zero", path, {}, "climbing.anchor_baker"));
49 const int count = std::snprintf(buffer.data(), buffer.size(), "%.9g", static_cast<double>(value));
119 return !std::any_of(values.begin(), values.end(), [](const auto& value) { return value.empty(); }) &&
144bool readUInt32(const eve::Value::Object& object, std::string_view name, std::uint32_t& output) {
175bool readVecArray(const eve::Value::Object& object, std::string_view name, std::vector<Vec3>& output) {
188bool readStrings(const eve::Value::Object& object, std::string_view name, std::vector<std::string>& output) {
219ClimbingAnchorNodeDefinition ledgeNode(std::string id, ClimbingAnchorKind kind, Vec3 position, Vec3 normal,
279eve::Result<ClimbingAnchorBakeRequest> decodeClimbingAnchorBakeRequest(const eve::Value& value) {
283 eve::DiagnosticCode::ParseError, "anchor bake request must be an object", {}, {}, "climbing.anchor_baker"));
297 if (!readString(*root, "schemaId", schemaId) || schemaId != ClimbingAnchorBakeRequest::SchemaId ||
298 schemaVersion != ClimbingAnchorBakeRequest::SchemaVersion || !readString(*root, "graphId", request.graphId) ||
299 !readString(*root, "sourceGeometryContentId", request.sourceGeometryContentId) || !settings || !ledges ||
309 eve::Diagnostic::error(eve::DiagnosticCode::ParseError, "anchor bake request has missing or invalid fields",
316 if (!object || !readString(*object, "id", source.id) || !readVecArray(*object, "points", source.points) ||
333 !readFloat(*object, "rungSpacing", source.rungSpacing) || !readFloat(*object, "width", source.width) ||
343eve::Result<ClimbingAnchorBakeResult> bakeClimbingAnchorGraph(const ClimbingAnchorBakeRequest& request) {
346 eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "graph and source geometry ids are required",
353 eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "bake settings are outside supported bounds",
357 eve::DiagnosticCode::InvalidArgument, "at least one ledge or ladder source is required", "sources", {},
373 eve::DiagnosticCode::InvalidArgument, "ledge id/tags/normals are invalid or it needs two points", path,
382 const std::size_t previous = index == 0 ? (source.closed ? source.points.size() - 1 : 0) : index - 1;
383 const std::size_t next = index + 1 == source.points.size() ? (source.closed ? 0 : index) : index + 1;
384 const Vec3 normalValue = source.localNormals.empty() ? source.localNormal : source.localNormals[index];
386 if (!normalResult) return eve::Result<ClimbingAnchorBakeResult>::failure(normalResult.status());
393 if (!tangentResult) return eve::Result<ClimbingAnchorBakeResult>::failure(tangentResult.status());
397 if (!tangentResult) return eve::Result<ClimbingAnchorBakeResult>::failure(tangentResult.status());
430 if (source.id.empty() || !sourceIds.emplace(source.id).second || !finite(source.bottomCenter) ||
440 if (!normalResult) return eve::Result<ClimbingAnchorBakeResult>::failure(normalResult.status());
444 if (!tangentResult) return eve::Result<ClimbingAnchorBakeResult>::failure(tangentResult.status());
452 node.localPosition = add(source.bottomCenter, multiply(up, source.rungSpacing * static_cast<float>(index)));
474 add(source.bottomCenter, multiply(normal, request.settings.ladderMountOffset)), normal, tangent,
488 result.graph.edges.push_back({mountId, ids.front(), ClimbingAnchorEdgeKind::Mount, false, {}, {}});
490 result.graph.edges.push_back({ids[index], ids[index + 1], ClimbingAnchorEdgeKind::Climb, true, {}, {}});
Deterministic authoring primitives, baker, and renderer-neutral editor overlay for climbing anchors.
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.cpp:21
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
Result< float > readFloat(const Accessor &accessor, std::uint32_t element, std::uint32_t component)
Read one bounded finite FLOAT component.
Definition GltfDecode.cpp:223
const Value * field(const Value &value, const char *key)
Borrow an optional object field.
Definition BuildingSnapshot.cpp:96
Definition Climbing.cpp:20
eve::Result< ClimbingAnchorBakeResult > bakeClimbingAnchorGraph(const ClimbingAnchorBakeRequest &request)
Bakes deterministic ledge and ladder topology from owning semantic geometry samples.
Definition ClimbingAnchorAuthoring.cpp:343
eve::Result< eve::Value > encodeClimbingAnchorBakeRequest(const ClimbingAnchorBakeRequest &request)
Encodes an owning bake request for editor/script transport.
Definition ClimbingAnchorAuthoring.cpp:238
ClimbingAnchorKind
Authored semantic of one explicit climbing anchor.
Definition ClimbingAnchorGraph.h:31
eve::Result< ClimbingAnchorAuthoringOverlay > inspectClimbingAnchorGraphAuthoring(const ClimbingAnchorGraphDefinition &graph)
Builds a validated owning snapshot for an editor or debug-draw adapter.
Definition ClimbingAnchorAuthoring.cpp:505
eve::Result< void > validateClimbingAnchorGraphDefinition(const ClimbingAnchorGraphDefinition &graph)
Validates all graph identities, frames, slots, tags, and edge endpoints.
Definition ClimbingAnchorGraph.cpp:203
eve::Result< ClimbingAnchorBakeRequest > decodeClimbingAnchorBakeRequest(const eve::Value &value)
Decodes all known bake request fields without publishing a graph.
Definition ClimbingAnchorAuthoring.cpp:279
bool readString(const eve::Value::Object &object, const char *name, std::string &output)
Definition ArtifactProvider.cpp:21
ForceVector add(ForceVector a, ForceVector b)
Definition ForceMath.h:13
Result< bool > readBool(const Value::Object &object, std::string_view name)
Reads a required boolean.
Definition WorldSnapshotParsing.cpp:75
@ InvalidArgument
@ UnknownVersion
@ ParseError
Result< float > readFiniteFloatValue(const Value &value)
Convert an Integer or Double to a finite Float after validating its source range.
Definition Value.cpp:81
Result< bool > readBoolValue(const Value &value)
Read a Bool without coercing integers, strings or other kinds.
Definition Value.cpp:50
Result< std::string > readStringMember(const Value::Object &object, std::string_view name)
Read a required string field, including an empty string, as an owning value.
Definition Value.cpp:25
Result< std::uint32_t > readUInt32Value(const Value &value)
Read an Int64 as a range-checked UInt32 without numeric coercion.
Definition Value.cpp:65
Bounded owning editor snapshot; consumers may render it without retaining graph pointers.
Definition ClimbingAnchorAuthoring.h:99
std::vector< ClimbingAnchorOverlayNode > nodes
Definition ClimbingAnchorAuthoring.h:102
std::string buildSettingsHash
Definition ClimbingAnchorAuthoring.h:101
std::string graphId
Definition ClimbingAnchorAuthoring.h:100
Complete owning input transaction for deterministic anchor-graph baking.
Definition ClimbingAnchorAuthoring.h:50
static constexpr std::int64_t SchemaVersion
Current editor-to-baker transaction schema version.
Definition ClimbingAnchorAuthoring.h:54
static constexpr std::string_view SchemaId
Canonical schema id for editor-to-baker transactions.
Definition ClimbingAnchorAuthoring.h:52
Measured bake result used by tools and build telemetry.
Definition ClimbingAnchorAuthoring.h:71
ClimbingAnchorGraphDefinition graph
Definition ClimbingAnchorAuthoring.h:72
Versioned graph asset; topology is authoritative while collision remains owned by Physics.
Definition ClimbingAnchorGraph.h:74
One body-local anchor node with deterministic occupancy slots.
Definition ClimbingAnchorGraph.h:47
Body-local ladder description supplied by an editor geometry extractor.
Definition ClimbingAnchorAuthoring.h:38
Ordered body-local ledge samples supplied by an editor geometry extractor.
Definition ClimbingAnchorAuthoring.h:27
Small owning world-space vector used at climbing module boundaries.
Definition ClimbingPrimitives.h:18