载入中...
搜索中...
未找到
ClimbingAnchorGraph.cpp
浏览该文件的文档.
25float lengthSquared(Vec3 value) { return value.x * value.x + value.y * value.y + value.z * value.z; }
155bool readStringArray(const eve::Value::Object& object, std::string_view name, std::vector<std::string>& output) {
179 return !std::any_of(values.begin(), values.end(), [](const auto& value) { return value.empty(); }) &&
186 std::sort(graph.nodes.begin(), graph.nodes.end(), [](const auto& lhs, const auto& rhs) { return lhs.id < rhs.id; });
195bool sameEdgeIdentity(const ClimbingAnchorEdgeDefinition& lhs, const ClimbingAnchorEdgeDefinition& rhs) {
203eve::Result<void> validateClimbingAnchorGraphDefinition(const ClimbingAnchorGraphDefinition& graph) {
204 if (graph.id.empty() || graph.sourceGeometryContentId.empty() || graph.buildSettingsHash.empty())
209 if (graph.nodes.empty() || graph.nodes.size() > maxGraphNodes || graph.edges.size() > maxGraphEdges)
211 eve::DiagnosticCode::InvalidArgument, "anchor graph node and edge counts exceed supported bounds",
228 if (std::fabs(normalLength - 1.f) > frameTolerance || std::fabs(tangentLength - 1.f) > frameTolerance ||
231 eve::DiagnosticCode::InvalidArgument, "anchor normal and tangent must form an orthonormal local frame",
251 if (edge.from.empty() || edge.to.empty() || edge.from == edge.to || !nodeIds.contains(edge.from) ||
254 eve::DiagnosticCode::InvalidArgument, "anchor edge endpoints must name two distinct existing nodes",
311eve::Result<ClimbingAnchorGraphDefinition> decodeClimbingAnchorGraphDefinition(const eve::Value& value) {
315 eve::Diagnostic::error(eve::DiagnosticCode::ParseError, "anchor graph definition must be an object", {}, {},
324 if (!readString(*root, "schemaId", schemaId) || schemaId != ClimbingAnchorGraphDefinition::SchemaId ||
327 version != ClimbingAnchorGraphDefinition::SchemaVersion - 1) || !readString(*root, "id", graph.id) ||
332 eve::DiagnosticCode::UnknownVersion, "anchor graph schema version is unsupported", "schemaVersion", {},
335 eve::DiagnosticCode::ParseError, "anchor graph envelope has missing or invalid known fields", {}, {},
368 if (!object || !readString(*object, "from", edge.from) || !readString(*object, "to", edge.to) ||
375 edge.extensionMetadata = unknownFields(*object, {"from", "to", "kind", "bidirectional", "requiredTags"});
386eve::Result<ClimbingAnchorGraphInstance> ClimbingAnchorGraphInstance::bind(ClimbingAnchorGraphDefinition graph,
393 eve::Diagnostic::error(eve::DiagnosticCode::StaleHandle, "anchor graph target body handle is stale", "body",
403const ClimbingAnchorNodeDefinition* ClimbingAnchorGraphInstance::findNode(std::string_view nodeId) const noexcept {
409eve::Result<ClimbingAnchorNodeRef> ClimbingAnchorGraphInstance::nodeRef(std::string_view nodeId) const {
412 eve::DiagnosticCode::NotFound, "anchor node was not found", "nodeId", {}, "climbing.anchor_graph"));
413 return eve::Result<ClimbingAnchorNodeRef>::success({graph_.id, std::string(nodeId), generation_});
430 eve::Diagnostic::error(eve::DiagnosticCode::Conflict, "anchor node reference belongs to another graph",
439 eve::Diagnostic::error(eve::DiagnosticCode::NotFound, "anchor node was not found", "reference.nodeId", {},
443 eve::DiagnosticCode::StaleHandle, "anchor graph belongs to another or stale Physics world", "world", {},
448 eve::Diagnostic::error(eve::DiagnosticCode::StaleHandle, "anchor graph target body handle is stale", "body",
488 eve::Diagnostic::error(eve::DiagnosticCode::Conflict, "anchor node reference belongs to another graph",
496 eve::Diagnostic::error(eve::DiagnosticCode::NotFound, "anchor node was not found", "reference.nodeId", {},
519 eve::Diagnostic::error(eve::DiagnosticCode::Conflict, "route endpoints belong to another anchor graph",
521 if (request.start.graphGeneration != generation_ || request.goal.graphGeneration != generation_)
523 eve::DiagnosticCode::StaleHandle, "route endpoints belong to a stale graph generation", "request", {},
527 eve::DiagnosticCode::NotFound, "route endpoint was not found", "request", {}, "climbing.anchor_graph"));
536 eve::DiagnosticCode::InvalidArgument, "route requester must provide both agent and execution ids",
606 eve::Diagnostic::error(eve::DiagnosticCode::NotFound, "no permitted anchor route reaches the goal",
617 eve::Diagnostic::error(eve::DiagnosticCode::InvariantViolation, "route predecessor chain is incomplete",
640 eve::Diagnostic::error(eve::DiagnosticCode::Conflict, "anchor node reference belongs to another graph",
649 eve::Diagnostic::error(eve::DiagnosticCode::NotFound, "anchor node was not found", "reference.nodeId", {},
653 eve::DiagnosticCode::InvalidArgument, "anchor reservation requires non-zero agent and execution ids",
661 eve::Diagnostic::error(eve::DiagnosticCode::Conflict, "occupant already owns a slot on this anchor",
668 eve::Diagnostic::error(eve::DiagnosticCode::Conflict, "all anchor occupancy slots are reserved",
673 eve::DiagnosticCode::PreconditionViolation, "anchor reservation identity is exhausted", "reservationId", {},
680 {id, generation_, 1, node->id, slot, occupant}, eve::Status::success(eve::StatusCode::Applied));
683eve::Result<void> ClimbingAnchorGraphInstance::release(const ClimbingAnchorReservation& reservation) {
703 record.occupant != reservation.occupant || record.claimGeneration != reservation.claimGeneration)
735 eve::Diagnostic::error(eve::DiagnosticCode::NotFound, "snapshot reservation node was not found",
737 if (reservation.id.isZero() || reservation.claimGeneration == 0 || reservation.occupant.agentId.isZero() ||
740 eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "snapshot reservation credential is invalid",
758 eve::DiagnosticCode::PreconditionViolation, "anchor reservation identity is exhausted", "reservationId", {},
770eve::Result<std::uint32_t> ClimbingAnchorGraphInstance::releaseOccupant(ClimbingAnchorOccupant occupant) {
773 eve::DiagnosticCode::InvalidArgument, "release requires non-zero agent and execution ids", "occupant", {},
788eve::Result<ClimbingAnchorGraphReload> ClimbingAnchorGraphInstance::reload(ClimbingAnchorGraphDefinition graph) {
793 eve::Diagnostic::error(eve::DiagnosticCode::PreconditionViolation, "anchor graph generation is exhausted",
EVEngine assertion entry point, backed by zeroerr.
#define EV_ASSERT(cond,...)
Assert an internal engine invariant (state that must always hold).
Definition Assert.h:37
Versioned body-local climbing topology, dynamic resolution, and deterministic occupancy.
std::vector< std::unique_ptr< ScriptClimbingEventSink > > live
Definition ClimbingServices.cpp:187
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
constexpr bool isValid() const noexcept
Returns whether both coordinates are usable handle values.
Definition RuntimeHandle.h:146
static Status success(StatusCode code=StatusCode::Ok)
Construct a successful status with an explicit non-error outcome.
Definition Status.cpp:19
const T * getIf() const noexcept
Return a typed pointer, or nullptr when the kind differs.
Definition Value.h:209
Runtime instance binding one immutable graph generation to one Physics body.
Definition ClimbingAnchorGraph.h:198
eve::Result< std::vector< ClimbingAnchorEdgeDefinition > > edgesFrom(const ClimbingAnchorNodeRef &reference) const
Returns deterministic outgoing edges for a current-generation node reference.
Definition ClimbingAnchorGraph.cpp:484
eve::Result< ClimbingAnchorNodeRef > nodeRef(std::string_view nodeId) const
Returns a current-generation reference for a stable node id.
Definition ClimbingAnchorGraph.cpp:409
physics::PhysicsBodyHandle body() const noexcept
Target Physics body handle; stale detection occurs during resolve.
Definition ClimbingAnchorGraph.h:261
static eve::Result< ClimbingAnchorGraphInstance > bind(ClimbingAnchorGraphDefinition graph, physics::World3D &world, physics::PhysicsBodyHandle body)
Validates and binds a graph snapshot to an existing Physics body.
Definition ClimbingAnchorGraph.cpp:386
eve::Result< ResolvedClimbingAnchorNode > resolveNodeKinematics(physics::World3D &world, const ClimbingAnchorNodeRef &reference) const
Resolves per-tick anchor transforms without copying cold tag metadata.
Definition ClimbingAnchorGraph.cpp:426
eve::Result< ResolvedClimbingAnchorNode > resolveNode(physics::World3D &world, const ClimbingAnchorNodeRef &reference) const
Resolves a current node from body-local to world space after validating world/body generation.
Definition ClimbingAnchorGraph.cpp:416
eve::Result< ClimbingAnchorRoute > planRoute(const ClimbingAnchorRouteRequest &request) const
Finds the shortest occupancy-aware route using stable edge-kind/node-id tie breaking.
Definition ClimbingAnchorGraph.cpp:515
constexpr bool isZero() const noexcept
Returns whether this value is zero.
Definition StrongUint64.h:28
Backend-neutral 3D rigid body in meter-space coordinates (+Y up by convention). Owned by a World3D; c...
Definition Body3D.h:31
Box3D rigid-body world. Script coordinates are meters (Box3D native), unlike 2D World which uses pixe...
Definition World3D.h:47
const char * nodeKindName(NodeKind kind) noexcept
Stable wire name for a node kind. @ownership Non-owning pointer to a static string literal; do not fr...
Definition ArchSpaceTypes.h:208
const Value * field(const Value &value, const char *key)
Borrow an optional object field.
Definition BuildingSnapshot.cpp:96
Value stringArray(const std::vector< std::string > &values)
Definition BuildingSnapshot.cpp:22
Definition Climbing.cpp:20
ClimbingAnchorEdgeKind
Allowed authored transition between two explicit anchors.
Definition ClimbingAnchorGraph.h:34
eve::Result< ClimbingAnchorGraphDefinition > decodeClimbingAnchorGraphDefinition(const eve::Value &value)
Decodes and validates a complete owning graph candidate transactionally.
Definition ClimbingAnchorGraph.cpp:311
ClimbingAnchorKind
Authored semantic of one explicit climbing anchor.
Definition ClimbingAnchorGraph.h:31
@ LadderRung
@ CornerInner
@ CornerOuter
eve::Result< void > validateClimbingAnchorGraphDefinition(const ClimbingAnchorGraphDefinition &graph)
Validates all graph identities, frames, slots, tags, and edge endpoints.
Definition ClimbingAnchorGraph.cpp:203
eve::Result< eve::Value > encodeClimbingAnchorGraphDefinition(const ClimbingAnchorGraphDefinition &graph)
Encodes a validated graph to its canonical owning Value representation.
Definition ClimbingAnchorGraph.cpp:268
bool readString(const eve::Value::Object &object, const char *name, std::string &output)
Definition ArtifactProvider.cpp:21
Result< std::int64_t > readInt64(const Value::Object &object, std::string_view name)
Reads a required signed decimal integer string.
Definition WorldSnapshotParsing.cpp:42
Result< bool > readBool(const Value::Object &object, std::string_view name)
Reads a required boolean.
Definition WorldSnapshotParsing.cpp:75
@ InvalidArgument
@ NotFound
@ UnknownVersion
@ PreconditionViolation
@ AlreadyExists
@ InvariantViolation
@ ParseError
@ StaleHandle
@ Conflict
@ NoOp
@ Applied
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::int64_t > readInt64Value(const Value &value)
Read an Int64 without narrowing or numeric coercion.
Definition Value.cpp:57
Definition Container.h:602
Directed authored transition in a climbing anchor graph.
Definition ClimbingAnchorGraph.h:63
std::string from
Definition ClimbingAnchorGraph.h:64
Versioned graph asset; topology is authoritative while collision remains owned by Physics.
Definition ClimbingAnchorGraph.h:74
eve::Value::Object extensionMetadata
Unknown schema fields retained across decode and encode.
Definition ClimbingAnchorGraph.h:86
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
static constexpr std::int64_t SchemaVersion
Current schema version.
Definition ClimbingAnchorGraph.h:78
Atomic graph-reload outcome and owners whose old-generation reservations were invalidated.
Definition ClimbingAnchorGraph.h:186
std::uint64_t oldGeneration
Definition ClimbingAnchorGraph.h:187
One body-local anchor node with deterministic occupancy slots.
Definition ClimbingAnchorGraph.h:47
Generation-qualified reference to an authored anchor node.
Definition ClimbingAnchorGraph.h:121
Compound occupancy owner; execution ids are only unique inside one agent/runtime.
Definition ClimbingAnchorGraph.h:111
ClimbingAnchorAgentId agentId
Definition ClimbingAnchorGraph.h:112
ClimbingExecutionId executionId
Definition ClimbingAnchorGraph.h:113
Owning reservation credential; release validates every field.
Definition ClimbingAnchorGraph.h:128
std::uint32_t slot
Definition ClimbingAnchorGraph.h:133
std::string nodeId
Definition ClimbingAnchorGraph.h:132
std::uint64_t claimGeneration
Definition ClimbingAnchorGraph.h:131
ClimbingAnchorOccupant occupant
Definition ClimbingAnchorGraph.h:134
ClimbingAnchorReservationId id
Definition ClimbingAnchorGraph.h:129
std::uint64_t graphGeneration
Definition ClimbingAnchorGraph.h:130
Read-only route request over one current anchor-graph generation.
Definition ClimbingAnchorGraph.h:141
World-space projection of a body-local anchor at one synchronous resolve point.
Definition ClimbingAnchorGraph.h:171
ClimbingAnchorNodeRef reference
Definition ClimbingAnchorGraph.h:172