载入中...
搜索中...
未找到
ClimbingExecution.cpp
浏览该文件的文档.
13eve::Result<ClimbingAdvance> ClimbingRuntime::advance(physics::World3D& world, eve::SimulationStep step,
22 return eve::Result<ClimbingAdvance>::failure(eve::Diagnostic::error(eve::DiagnosticCode::PreconditionViolation,
33 eve::DiagnosticCode::Conflict, "simulation tick must increase exactly once per update", "step.tick", {},
37 eve::DiagnosticCode::InvalidArgument, "simulation delta must be positive", "step.delta", {}, "climbing"));
42 (!motion.hasRootMotion && (motion.rootMotionPolicy != ClimbingRootMotionPolicy::ApplyActionWarp ||
45 eve::DiagnosticCode::InvalidArgument, "motion policies require valid enum values and authored root motion",
47 if (!isFinite(motion.rootTranslation) || !isFinite(motion.facing) || !isFinite(motion.pelvisOffset) ||
48 !isFinite(motion.rootYawRadians) || length(motion.pelvisOffset) > profile_.maxPelvisDeviation + epsilon)
51 "authored motion must be finite and pelvis deviation must remain inside the profile limit", "motion", {},
56 eve::DiagnosticCode::StaleHandle, "traversed shape is stale; collision exclusion was not applied",
62 const bool graphBound = execution.anchorGraph.isValid() && !execution.anchorReservation.id.isZero();
92 eve::DiagnosticCode::StaleHandle, "graph anchor or occupancy reservation is stale", "execution.anchor",
113 resolved.value().normal * (profile_.capsuleRadius + profile_.skin + execution.action.hangBodyOffset);
114 execution.candidate.landingFeet.y = resolved.value().position.y - execution.action.hangFeetBelowLedge;
130 enqueueEvent({ClimbingEventKind::Cancelled, execution.candidate.actionId, step.tick, execution.executionId});
148 enqueueEvent({ClimbingEventKind::Cancelled, execution.candidate.actionId, step.tick, execution.executionId});
157 eve::DiagnosticCode::PreconditionViolation, "climbing target exceeded the platform speed limit",
162 execution.candidate.bodyLocalTop.x, execution.candidate.bodyLocalTop.y, execution.candidate.bodyLocalTop.z);
171 execution.candidate.topPoint - execution.candidate.surfaceNormal * execution.action.landingForward;
173 execution.candidate.landingFeet = {worldLanding.value().x, worldLanding.value().y, worldLanding.value().z};
176 execution.candidate.topPoint - execution.candidate.surfaceTangent * (execution.action.handSpacing * 0.5f);
178 execution.candidate.topPoint + execution.candidate.surfaceTangent * (execution.action.handSpacing * 0.5f);
182 phase_ == ClimbingPhase::Hanging || phase_ == ClimbingPhase::Balanced || phase_ == ClimbingPhase::Swinging;
190 holding ? 1.f : static_cast<float>(std::clamp(nextElapsed.seconds() / execution.duration.seconds(), 0.0, 1.0));
193 !feetReleased && activeContactWeight(execution.action, ClimbingContactTarget::LeftFoot, contactTime) > 0.f;
195 !feetReleased && activeContactWeight(execution.action, ClimbingContactTarget::RightFoot, contactTime) > 0.f;
248 if (phase_ == ClimbingPhase::Hanging || phase_ == ClimbingPhase::Balanced || phase_ == ClimbingPhase::Swinging) {
250 const float upperY = execution.currentFeet.y + profile_.capsuleHeight - profile_.capsuleRadius + profile_.skin;
252 world.queryCapsuleOwned(execution.currentFeet.x, lowerY, execution.currentFeet.z, execution.currentFeet.x,
266 enqueueEvent({ClimbingEventKind::Failed, execution.candidate.actionId, step.tick, execution.executionId});
279 ClimbingAdvance output{phase_, execution.candidate.actionId, execution.currentFeet, {}, {}, {}, 1.f, false,
295 output.leftFootWeight = activeContactWeight(execution.action, ClimbingContactTarget::LeftFoot, 1.f);
296 output.rightFootWeight = activeContactWeight(execution.action, ClimbingContactTarget::RightFoot, 1.f);
297 output.pelvisWeight = activeContactWeight(execution.action, ClimbingContactTarget::Pelvis, 1.f);
298 output.contactWeight = std::max({output.leftHandWeight, output.rightHandWeight, output.leftFootWeight,
352 enqueueEvent({ClimbingEventKind::Completed, output.actionId, step.tick, execution.executionId});
363 const float t = static_cast<float>(std::clamp(execution.elapsed.seconds() / durationSeconds, 0.0, 1.0));
364 const Vec3 planned = detail::trajectoryPoint(execution.startFeet, execution.candidate, execution.action, profile_,
368 if (motion.hasRootMotion && motion.rootMotionPolicy == ClimbingRootMotionPolicy::PreserveSuppliedDelta) {
380 const WarpChannels channels = motion.rootMotionPolicy == ClimbingRootMotionPolicy::PreserveSuppliedDelta
387 const float remaining = std::max(0.f, execution.action.horizontalWarpBudget - execution.horizontalWarpUsed);
388 horizontal = clampMagnitude(horizontal, std::min(execution.action.maxTranslationWarpPerTick, remaining));
393 const float remaining = std::max(0.f, execution.action.verticalWarpBudget - execution.verticalWarpUsed);
394 appliedWarp.y = std::clamp(warpError.y, -std::min(execution.action.maxTranslationWarpPerTick, remaining),
398 std::max(0.f, profile_.maxTotalWarpBudget - execution.horizontalWarpUsed - execution.verticalWarpUsed);
399 appliedWarp = clampMagnitude(appliedWarp, std::min(execution.action.maxTranslationWarpPerTick, remainingTotalWarp));
407 const float yawError = signedHorizontalAngle(motion.facing, targetFacing) - motion.rootYawRadians;
408 const float remaining = std::max(0.f, execution.action.facingWarpBudgetRadians - execution.facingWarpUsed);
409 const float correction = std::clamp(yawError, -std::min(execution.action.maxYawWarpRadiansPerTick, remaining),
414 const float authoredLeftHand = activeContactWeight(execution.action, ClimbingContactTarget::LeftHand, t);
415 const float authoredRightHand = activeContactWeight(execution.action, ClimbingContactTarget::RightHand, t);
422 execution.action.branchWindows.empty() ? execution.branchWindowOpen : activeBranchWindow(execution.action, t);
440 const float collisionHeight = compactForTick ? profile_.compactCapsuleHeight : profile_.capsuleHeight;
464 boundedDebugPush(motionEvidence_, ClimbingMotionEvidence{step.tick, planned, execution.currentFeet, residual,
508 return detail::cornerPathPoint(source, target, sourceAnchor->normal, execution.candidate.surfaceNormal,
515 transfer(ClimbingContactTarget::RightHand, sourceAnchor->rightHandSocket, output.rightHandAnchor);
520 enqueueEvent({ClimbingEventKind::ContactLeftHand, output.actionId, step.tick, execution.executionId});
524 enqueueEvent({ClimbingEventKind::ContactRightHand, output.actionId, step.tick, execution.executionId});
528 output.leftHandWeight = execution.leftContactEmitted && !execution.landContactReleased ? 1.f : 0.f;
529 output.rightHandWeight = execution.rightContactEmitted && !execution.landContactReleased ? 1.f : 0.f;
533 output.leftFootWeight = activeContactWeight(execution.action, ClimbingContactTarget::LeftFoot, t);
534 output.rightFootWeight = activeContactWeight(execution.action, ClimbingContactTarget::RightFoot, t);
537 output.contactWeight = std::max({output.leftHandWeight, output.rightHandWeight, output.leftFootWeight,
542 if (const std::string* comboTag = activeBranchComboTag(execution.action, t)) output.branchComboTag = *comboTag;
559 if (length(execution.accumulatedResidual) > profile_.maxWarpResidual + epsilon || authoredWarpMissed) {
581 enqueueEvent({execution.candidate.kind == ClimbingActionKind::LedgeGrab ? ClimbingEventKind::Hanging
594 enqueueEvent({ClimbingEventKind::Completed, output.actionId, step.tick, execution.executionId});
std::map< std::string, std::vector< Key >, std::less<> > channels
Definition AnimCurveLibrary.cpp:21
Deterministic climbing/parkour planning and capsule-constrained execution.
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.cpp:21
Result< Duration > tryAdd(Duration other) const
Add two durations with overflow validation.
Definition Time.cpp:31
double seconds() const noexcept
Return this duration as seconds for legacy/presentation APIs.
Definition Time.cpp:29
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
eve::Result< ClimbingAdvance > advance(physics::World3D &world, eve::SimulationStep step)
Advances the active trajectory through the world's capsule mover.
Definition ClimbingExecution.cpp:9
static eve::script::Borrowed< ClimbingAnchorGraphInstance > resolveAnchorGraph(ClimbingAnchorGraphHandleRef reference) noexcept
Resolves a live graph instance as a synchronous non-owning observation.
Definition ClimbingRegistry.cpp:40
RuntimeTelemetryScope public API.
Definition ClimbingRuntimeInternal.h:17
Backend-neutral 3D rigid body in meter-space coordinates (+Y up by convention). Owned by a World3D; c...
Definition Body3D.h:31
eve::Result< PhysicsVector3D > localToWorldPointOwned(float x, float y, float z) const
Converts a local point to an allocation-free owning value with structured stale/input failure.
Definition Body3D.cpp:169
Box3D rigid-body world. Script coordinates are meters (Box3D native), unlike 2D World which uses pixe...
Definition World3D.h:47
Vec3 trajectoryPoint(Vec3 start, const ClimbingCandidate &candidate, const ClimbingActionDefinition &action, const ClimbingProfileDefinition &profile, float normalizedTime, Vec3 sourceNormal={}) noexcept
Definition ClimbingTrajectory.h:43
Vec3 cornerPathPoint(Vec3 start, Vec3 end, Vec3 sourceNormal, Vec3 targetNormal, float normalizedTime) noexcept
Definition ClimbingTrajectory.h:24
WarpChannels activeWarpChannels(const ClimbingActionDefinition &action, float normalizedTime)
Active warp channels.
Definition ClimbingRuntimeInternal.h:85
float activeContactWeight(const ClimbingActionDefinition &action, ClimbingContactTarget target, float normalizedTime)
Active contact weight.
Definition ClimbingRuntimeInternal.h:111
const std::string * activeBranchComboTag(const ClimbingActionDefinition &action, float normalizedTime)
Optional combo tag. @borrowed From action; lifetime ends when the caller-owned action changes or is d...
Definition ClimbingRuntimeInternal.h:103
float finalWarpWindowEnd(const ClimbingActionDefinition &action)
Final warp window end.
Definition ClimbingRuntimeInternal.h:139
constexpr float epsilon
Definition ClimbingRuntimeInternal.h:13
Vec3 clampMagnitude(Vec3 value, float maximum)
Clamp magnitude.
Definition ClimbingRuntimeInternal.h:72
void boundedDebugPush(std::vector< T > &values, T value)
Bounded debug push.
Definition ClimbingRuntimeInternal.h:42
bool isActivePhase(ClimbingPhase phase)
True when active phase.
Definition ClimbingRuntimeInternal.h:155
bool activeBranchWindow(const ClimbingActionDefinition &action, float normalizedTime)
Active branch window.
Definition ClimbingRuntimeInternal.h:94
float signedHorizontalAngle(Vec3 from, Vec3 to)
Signed horizontal angle.
Definition ClimbingRuntimeInternal.h:144
Vec3 terminalVelocityFor(const ClimbingActionDefinition &action, Vec3 actualDelta, float inverseDelta)
Terminal velocity for.
Definition ClimbingRuntimeInternal.h:123
bool isAnchorHangEnd(ClimbingActionKind kind)
True when anchor hang end.
Definition ClimbingRuntimeInternal.h:174
Definition Climbing.cpp:20
@ IgnoreTraversedShape
@ LadderRung
@ Completed
@ Recovering
@ Swinging
@ Aligning
@ Cancelled
@ Climbing
@ Balanced
@ Launching
@ Dropping
ClimbingNotifyKind
Stable animation notify semantics accepted from a validated climbing clip.
Definition Climbing.h:503
@ BranchClose
@ CollisionCompact
@ ContactRightHand
@ BranchOpen
@ ContactLeftHand
@ PreserveSuppliedDelta
@ ApplyActionWarp
@ Completed
@ AnchorReached
@ Cancelled
@ ContactRightHand
@ ContactLeftHand
@ LedgeGrab
@ PoleSwing
@ LadderDismount
@ CornerInner
@ BeamBalance
@ CornerOuter
@ InvalidArgument
@ PreconditionViolation
@ StaleHandle
@ Conflict
Geometry-query evidence suitable for an engine debug-draw adapter.
Definition Climbing.h:609
One planned-versus-actual capsule sample from an authoritative execution tick.
Definition Climbing.h:629
Per-tick authored animation motion supplied before climbing warp and collision.
Definition Climbing.h:540
ClimbingObstacleCollision obstacleCollision
Definition Climbing.h:549
std::vector< ClimbingNotifyKind > notifies
Owning semantic notifies crossed by the animation player during this exact simulation step.
Definition Climbing.h:547
ClimbingRootMotionPolicy rootMotionPolicy
Definition Climbing.h:548
float maxPelvisDeviation
Definition Climbing.h:237
physics::QueryFilter3D queryFilter
Definition Climbing.h:254
float maxPlatformSpeed
Definition Climbing.h:232
float maxTotalWarpBudget
Definition Climbing.h:247
std::string cameraCueProfile
Definition Climbing.h:253
float maxWarpResidual
Definition Climbing.h:231
float compactCapsuleHeight
Definition Climbing.h:226
static constexpr std::uint32_t Active
Definition ClimbingTelemetry.h:30
Vec3 warpResidual
Definition ClimbingTelemetry.h:51
std::uint32_t moverIterations
Definition ClimbingTelemetry.h:52
std::uint32_t queryBudget
Definition ClimbingTelemetry.h:53
ClimbingWorkload workload
Definition ClimbingTelemetry.h:45
std::uint32_t queryCount
Definition ClimbingTelemetry.h:48
std::int64_t selectedCost
Definition ClimbingTelemetry.h:50
Small owning world-space vector used at climbing module boundaries.
Definition ClimbingPrimitives.h:18
WarpChannels public API.
Definition ClimbingRuntimeInternal.h:78
Owning result of continuous capsule movement.
Definition OwnedQuery3D.h:101
Query filter applied atomically for one owning query operation.
Definition OwnedQuery3D.h:47