载入中...
搜索中...
未找到
ClimbingECS.cpp
浏览该文件的文档.
1// eve-hot-path
3
4#include <algorithm>
5
6namespace eve::climbing {
7namespace {
8
9} // namespace
10
13 if (candidates.size() > Capacity)
15 "climbing candidate buffer capacity exceeded",
16 "candidates", {}, "climbing.ecs"));
17 ClimbingCandidateSet replacement;
18 for (const ClimbingCandidate& candidate : candidates) replacement.consider(candidate);
19 replacement.sortAndLimit(Capacity);
20 values_.swap(replacement);
21 tick_ = tick;
23}
24
27 auto probed = runtime.probeInto(world, pose, values_, tick);
28 if (!probed) return eve::Result<void>::failure(probed.status());
29 tick_ = tick;
31}
32
40
42 if (!runtime.isValid())
44 "climbing state has no runtime to release",
45 "state.runtime", {}, "climbing.ecs"));
46 auto released = Climbing::release(runtime);
47 if (!released) return eve::Result<void>::failure(released.status());
48 runtime = {};
49 lastAdvance = {};
52}
53
56 if (events.size() > Capacity)
58 "climbing event batch capacity exceeded", "events", {},
59 "climbing.ecs"));
60 std::array<ClimbingEvent, Capacity> replacement{};
61 std::copy(events.begin(), events.end(), replacement.begin());
62 values_ = std::move(replacement);
63 size_ = events.size();
64 tick_ = tick;
66}
67
68std::span<const ClimbingSystemContract> climbingSystemContracts() noexcept {
69 static constexpr ClimbingSystemContract contracts[] = {
70 {"climbing.input", "caller-selected existing domain root",
71 "View<EntityRoot, ClimbingIntent>", "owning command queue; SimulationTick", "ClimbingIntent",
72 "none", "none", "SimulationStep", "input", "bit-exact for identical command streams"},
73 {"climbing.probe", "caller-selected existing domain root",
74 "View<EntityRoot, ClimbingBody, ClimbingIntent, ClimbingState, ClimbingLinks, ClimbingCandidateBuffer>",
75 "Body; Intent; State runtime; Links; Physics world", "ClimbingCandidateBuffer", "none", "none",
76 "Physics owning queries; SimulationTick", "pre_physics",
77 "stable identity/order; geometry tolerance-bounded"},
78 {"climbing.selection", "caller-selected existing domain root",
79 "View<EntityRoot, ClimbingBody, ClimbingIntent, ClimbingState, ClimbingLinks>",
80 "Body; Intent; definitions; Physics world", "Intent consumed edge; State runtime", "none",
81 "ClimbingStarted queued only after commit", "Physics; definitions; optional resource adapters",
82 "pre_physics", "quantized cost and stable identity tie-break"},
83 {"climbing.motion", "caller-selected existing domain root",
84 "View<EntityRoot, ClimbingBody, ClimbingIntent, ClimbingState, ClimbingLinks>",
85 "State execution; Body; Intent; Links; animation desired root delta",
86 "Body; State runtime; linked Physics body",
87 "none", "contact/land/cancel to bounded runtime queue", "Physics mover; SimulationStep", "physics",
88 "fixed-tick replay stable; Physics contacts tolerance-bounded"},
89 {"climbing.pose", "caller-selected existing domain root",
90 "View<EntityRoot, ClimbingState, ClimbingPoseProjection, ClimbingEventBatch>",
91 "State actual motion and contact anchors", "derived pose projection; owning event batch", "none",
92 "drain only; external dispatch occurs after View closes", "Animation; optional IK", "post_physics",
93 "gameplay state independent of final skin pose"},
94 };
95 return contracts;
96}
97
98} // namespace eve::climbing
eve::EntitySpatialPose pose
Composition-only ECS components and fixed-phase climbing systems.
std::vector< particles::ParticleRecordEvent > events
int created
std::map< std::array< int, 4 >, std::vector< const Subject * > > candidates
Definition Sensing.cpp:32
SimulationTick tick
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Move-only operation result carrying either a value or Status.
Definition Result.h:176
static Result success(T value)
Construct a successful result owning value.
Definition Result.h:185
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
static constexpr std::size_t Capacity
Definition ClimbingECS.h:68
eve::Result< void > replace(std::span< const ClimbingCandidate > candidates, eve::SimulationTick tick)
Atomically replace the buffer; oversize input leaves the old contents unchanged.
eve::Result< void > probe(ClimbingRuntime &runtime, physics::World3D &world, const ClimbingPose &pose, eve::SimulationTick tick)
Fill retained storage through the allocation-free production probe path.
eve::SimulationTick tick() const noexcept
Tick that produced the current projection.
Definition ClimbingECS.h:83
Fixed-capacity owning candidate set used by the production probe hot path.
Definition Climbing.h:329
void consider(ClimbingCandidate candidate)
Consider one candidate and retain it only when it belongs to the best fixed-capacity set.
Definition Climbing.cpp:40
void swap(ClimbingCandidateSet &other) noexcept
Exchange complete owning slot storage without allocating.
Definition Climbing.cpp:73
void sortAndLimit(std::size_t limit)
Sort by canonical deterministic selection key and clamp to a validated limit.
Definition Climbing.cpp:66
eve::SimulationTick tick() const noexcept
Simulation tick at which the runtime queue was drained.
eve::Result< void > replace(std::span< const ClimbingEvent > events, eve::SimulationTick tick)
Atomically replace the event batch or reject an impossible oversize input.
static constexpr std::size_t Capacity
Owner-thread climbing planner and executor for one character.
Definition Climbing.h:659
static eve::Result< void > release(ClimbingRuntimeHandleRef reference)
Releases a module-owned runtime and invalidates its reference.
static eve::Result< ClimbingRuntimeHandleRef > newRuntime()
Creates a module-owned runtime and returns its generation-qualified reference.
static constexpr StrongUint64 zero() noexcept
Returns the zero value for this strong type.
Box3D rigid-body world. Script coordinates are meters (Box3D native), unlike 2D World which uses pixe...
Definition World3D.h:47
std::span< const ClimbingSystemContract > climbingSystemContracts() noexcept
Return immutable process-lifetime contracts for the four climbing ECS phases.
Owning, replayable climbing candidate; contains no borrowed query pointers.
Definition Climbing.h:290
Input pose used for one deterministic candidate probe.
Definition Climbing.h:275
Hot authoritative execution component holding the module-owned runtime identity.
Definition ClimbingECS.h:96
ClimbingRuntimeHandleRef runtime
Definition ClimbingECS.h:97
eve::Result< void > releaseRuntime()
Release the runtime once and clear this component's handle.
eve::SimulationTick lastAdvanceTick
Definition ClimbingECS.h:99
ClimbingAdvance lastAdvance
Definition ClimbingECS.h:98
static eve::Result< ClimbingState > create()
Create the canonical module-owned runtime referenced by this component.
Static review/tooling description of one concrete climbing ECS phase.
constexpr bool isValid() const noexcept
Returns whether both the handle and its registry epoch are set.