载入中...
搜索中...
未找到
ClimbingAnchorAuthoring.cpp
浏览该文件的文档.
19Vec3 multiply(Vec3 value, float scale) { return {value.x * scale, value.y * scale, value.z * scale}; }
30 eve::DiagnosticCode::InvalidArgument, "vector must be finite", path, {}, "climbing.anchor_baker"));
34 eve::DiagnosticCode::InvalidArgument, "vector must be non-zero", path, {}, "climbing.anchor_baker"));
48 const int count = std::snprintf(buffer.data(), buffer.size(), "%.9g", static_cast<double>(value));
118 return !std::any_of(values.begin(), values.end(), [](const auto& value) { return value.empty(); }) &&
152bool readUInt32(const eve::Value::Object& object, std::string_view name, std::uint32_t& output) {
155 if (!integer || *integer < 0 || static_cast<std::uint64_t>(*integer) > std::numeric_limits<std::uint32_t>::max())
182bool readVecArray(const eve::Value::Object& object, std::string_view name, std::vector<Vec3>& output) {
195bool readStrings(const eve::Value::Object& object, std::string_view name, std::vector<std::string>& output) {
226ClimbingAnchorNodeDefinition ledgeNode(std::string id, ClimbingAnchorKind kind, Vec3 position, Vec3 normal,
286eve::Result<ClimbingAnchorBakeRequest> decodeClimbingAnchorBakeRequest(const eve::Value& value) {
290 eve::DiagnosticCode::ParseError, "anchor bake request must be an object", {}, {}, "climbing.anchor_baker"));
304 if (!readString(*root, "schemaId", schemaId) || schemaId != ClimbingAnchorBakeRequest::SchemaId ||
305 schemaVersion != ClimbingAnchorBakeRequest::SchemaVersion || !readString(*root, "graphId", request.graphId) ||
306 !readString(*root, "sourceGeometryContentId", request.sourceGeometryContentId) || !settings || !ledges ||
316 eve::Diagnostic::error(eve::DiagnosticCode::ParseError, "anchor bake request has missing or invalid fields",
323 if (!object || !readString(*object, "id", source.id) || !readVecArray(*object, "points", source.points) ||
340 !readFloat(*object, "rungSpacing", source.rungSpacing) || !readFloat(*object, "width", source.width) ||
350eve::Result<ClimbingAnchorBakeResult> bakeClimbingAnchorGraph(const ClimbingAnchorBakeRequest& request) {
353 eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "graph and source geometry ids are required",
360 eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "bake settings are outside supported bounds",
364 eve::DiagnosticCode::InvalidArgument, "at least one ledge or ladder source is required", "sources", {},
380 eve::DiagnosticCode::InvalidArgument, "ledge id/tags/normals are invalid or it needs two points", path,
389 const std::size_t previous = index == 0 ? (source.closed ? source.points.size() - 1 : 0) : index - 1;
390 const std::size_t next = index + 1 == source.points.size() ? (source.closed ? 0 : index) : index + 1;
391 const Vec3 normalValue = source.localNormals.empty() ? source.localNormal : source.localNormals[index];
393 if (!normalResult) return eve::Result<ClimbingAnchorBakeResult>::failure(normalResult.status());
400 if (!tangentResult) return eve::Result<ClimbingAnchorBakeResult>::failure(tangentResult.status());
404 if (!tangentResult) return eve::Result<ClimbingAnchorBakeResult>::failure(tangentResult.status());
437 if (source.id.empty() || !sourceIds.emplace(source.id).second || !finite(source.bottomCenter) ||
447 if (!normalResult) return eve::Result<ClimbingAnchorBakeResult>::failure(normalResult.status());
451 if (!tangentResult) return eve::Result<ClimbingAnchorBakeResult>::failure(tangentResult.status());
459 node.localPosition = add(source.bottomCenter, multiply(up, source.rungSpacing * static_cast<float>(index)));
481 add(source.bottomCenter, multiply(normal, request.settings.ladderMountOffset)), normal, tangent,
495 result.graph.edges.push_back({mountId, ids.front(), ClimbingAnchorEdgeKind::Mount, false, {}, {}});
Deterministic authoring primitives, baker, and renderer-neutral editor overlay for climbing anchors.
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
Result< float > readFloat(const Accessor &accessor, std::uint32_t element, std::uint32_t component)
Read one bounded finite FLOAT component.
Definition GltfDecode.cpp:221
Definition Climbing.cpp:19
eve::Result< ClimbingAnchorBakeResult > bakeClimbingAnchorGraph(const ClimbingAnchorBakeRequest &request)
Bakes deterministic ledge and ladder topology from owning semantic geometry samples.
Definition ClimbingAnchorAuthoring.cpp:350
eve::Result< eve::Value > encodeClimbingAnchorBakeRequest(const ClimbingAnchorBakeRequest &request)
Encodes an owning bake request for editor/script transport.
Definition ClimbingAnchorAuthoring.cpp:245
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:512
eve::Result< void > validateClimbingAnchorGraphDefinition(const ClimbingAnchorGraphDefinition &graph)
Validates all graph identities, frames, slots, tags, and edge endpoints.
Definition ClimbingAnchorGraph.cpp:208
eve::Result< ClimbingAnchorBakeRequest > decodeClimbingAnchorBakeRequest(const eve::Value &value)
Decodes all known bake request fields without publishing a graph.
Definition ClimbingAnchorAuthoring.cpp:286
bool readString(const eve::Value::Object &object, const char *name, std::string &output)
Definition ArtifactProvider.cpp:20
const EditorValue * field(const EditorValue &value, const char *name)
Definition RoadNetworkEditTarget.cpp:15
@ InvalidArgument
@ UnknownVersion
@ ParseError
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
std::uint32_t ladderNodeCount
Definition ClimbingAnchorAuthoring.h:74
ClimbingAnchorGraphDefinition graph
Definition ClimbingAnchorAuthoring.h:72
std::uint32_t ledgeNodeCount
Definition ClimbingAnchorAuthoring.h:73
Versioned graph asset; topology is authoritative while collision remains owned by Physics.
Definition ClimbingAnchorGraph.h:74
std::vector< ClimbingAnchorNodeDefinition > nodes
Definition ClimbingAnchorGraph.h:83
std::vector< ClimbingAnchorEdgeDefinition > edges
Definition ClimbingAnchorGraph.h:84
std::string sourceGeometryContentId
Definition ClimbingAnchorGraph.h:81
std::string buildSettingsHash
Definition ClimbingAnchorGraph.h:82
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