Skip to main content

Module anim_graph

Module anim_graph 

Source
Expand description

The animation state machine: what an AnimationGraph asset compiles into, the blendspace members a state can play, and the cursor that walks it.

A CompiledGraph is read-only once built, except for the clip-duration refresh a hot-reload applies. A GraphCursor is the live position in one: the client’s animation system owns one per graph target, advances it each frame, and samples the blended pose through sample_graph_pose_into.

Structs§

Blend1D
A 1D blendspace: members at ascending thresholds positions along one parameter. The parameter picks the bracketing pair and lerps their weights; outside the range the nearest end member plays alone.
Blend2D
A 2D blendspace: members on a regular grid over two parameters, weighted bilinearly across the four members surrounding the parameter point. plays is row-major: plays[iy * x_values.len() + ix] sits at (x_values[ix], y_values[iy]).
ClipPlay
One playable member: a clip index in the target’s clip list plus its duration, copied at compile time for wrap / phase math (refreshed on clip hot-reload).
CompiledCondition
One compiled transition condition: parameter names are resolved to indices into the graph’s parameter vector at compile time, so evaluation is a direct slice read (the runtime blob interner is empty; nothing resolves names at runtime).
CompiledGraph
A compiled animation state machine. Built once from the AnimationGraph asset; read-only afterwards except for clip-duration refresh on hot-reload.
CompiledState
One compiled state: what it plays (a clip or a blendspace, at rate) and its outgoing transitions in declaration order (first match wins).
CompiledTransition
One compiled outgoing transition. Conditions AND together; an empty list is always true (useful with exit_time alone).
GraphCursor
The live position in a graph: current state, its clock, and any in-flight crossfade. One per graph target, owned by the client’s AnimationSystem.
ParamSpec
A graph parameter: a named float, seeded to default.
StateFade
An in-flight crossfade from the previous state. The outgoing state’s clock keeps advancing during the fade so its pose stays live rather than frozen.

Enums§

CmpOp
Comparison operator for a transition condition, evaluated as parameter <op> value. eq / ne compare exactly and are mainly useful for flag-like parameters holding whole numbers such as 0 and 1.
StatePlay
What a compiled state plays.

Functions§

blend1d_weights
1D blendspace weights: x against ascending thresholds. Outside the range the nearest end gets full weight; inside, the bracketing pair lerps. At most two weights are nonzero.
blend2d_weights
2D blendspace weights: bilinear over the grid cell containing (x, y), clamped to the grid edges. Row-major to match Blend2D::plays; at most four weights are nonzero.
cursor_root_delta
The displacement covered between the cursor snapshots taken before and after one advance, in the mesh’s local space. A frame that took a transition contributes nothing (the clocks reset mid-frame; one frame of root motion at a state change is imperceptible and never wrong-direction). While a fade is in flight the outgoing state’s displacement blends in by the fade’s progress, matching the pose crossfade.
normalized_time
A state’s normalized time in [0, 1]: the fraction of one full pass covered by the clock. Looping states report the fraction within the current pass, so an exit_time gate re-opens every loop; a non-looping state saturates at one. Blendspace passes are measured against the weight-averaged member duration at the current parameters.
sample_graph_pose_into
Sample the cursor’s blended pose into scratch.locals. clip_at maps a member’s clip index to the actual clip (the caller owns clip storage). The remaining scratch buffers hold the fade’s outgoing pose and the per-member samples, so a warm scratch samples without allocating.