pub struct AnimationGraph {
pub asset_id: AssetId,
pub target: Option<SkinnedMeshHandle>,
pub parameters: Vec<AnimationParam>,
pub initial: String,
pub states: Vec<AnimationState>,
pub transitions: Vec<AnimationTransition>,
pub ik_chains: Vec<AnimationIkChain>,
}Expand description
An animation state machine for one SkinnedMesh.
While a plain set of Animation clips blends every clip all
the time, a graph plays exactly one state at a time and moves between
states along declared transitions, crossfading poses over each
transition’s duration_secs. Transitions fire when their conditions –
comparisons against the graph’s named float parameters – pass. Gameplay
systems write parameter values each frame (the anim-param debug command
does the same from a cn debug session).
A graph owns its target: every Animation targeting the
graph’s mesh must be referenced by exactly one state, and at most one
graph may target a given mesh (both are build errors otherwise). Clip
weight and fade_in_secs have no effect under a graph.
Transitions are checked in declaration order and the first match wins. A state with no outgoing transitions (or none passing) keeps playing; looping states wrap, non-looping states hold their final pose.
AnimationGraph {
initial: "idle".into(),
..Default::default()
};Fields§
§asset_id: AssetIdAsset identity; injected via inject_name. Not part of args.
target: Option<SkinnedMeshHandle>The SkinnedMesh asset this graph animates.
parameters: Vec<AnimationParam>Named float parameters transitions compare against.
initial: StringName of the state the graph starts in. Defaults to the first state.
states: Vec<AnimationState>The graph’s states. At least one is required.
transitions: Vec<AnimationTransition>Directed transitions between states.
ik_chains: Vec<AnimationIkChain>Two-bone IK chains applied on top of every state’s pose; see AnimationIkChain.
Implementations§
Source§impl AnimationGraph
impl AnimationGraph
Sourcepub fn compile(
&self,
resolve_clip: impl Fn(AssetId) -> Option<(usize, f32, bool)>,
) -> Result<CompiledGraph, String>
pub fn compile( &self, resolve_clip: impl Fn(AssetId) -> Option<(usize, f32, bool)>, ) -> Result<CompiledGraph, String>
Compile the authored graph into the runtime representation, resolving
state and parameter names to indices and clip references through
resolve_clip, which maps an Animation asset id to its
index, duration, and looping flag in the target’s clip list. Structural
problems (unknown names, missing clips, non-positive rates) are
reported as errors; the build validates the same rules earlier, so a
runtime failure here means the world blob and the clip list disagree.
Trait Implementations§
Source§impl Clone for AnimationGraph
impl Clone for AnimationGraph
Source§fn clone(&self) -> AnimationGraph
fn clone(&self) -> AnimationGraph
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Component for AnimationGraph
impl Component for AnimationGraph
Source§const NAME: &'static str = "AnimationGraph"
const NAME: &'static str = "AnimationGraph"
Source§fn inject_name(&mut self, id: AssetId)
fn inject_name(&mut self, id: AssetId)
Source§fn from_baked(bytes: &[u8]) -> Result<AnimationGraph, CnResult>
fn from_baked(bytes: &[u8]) -> Result<AnimationGraph, CnResult>
Source§fn inject_locator(&mut self, _locator: PayloadLocator)
fn inject_locator(&mut self, _locator: PayloadLocator)
Source§impl ComponentSlot for AnimationGraph
impl ComponentSlot for AnimationGraph
Source§const DISCRIMINANT: u8
const DISCRIMINANT: u8
ComponentId.Source§fn slot(s: &ComponentStorage) -> &Column<AnimationGraph>
fn slot(s: &ComponentStorage) -> &Column<AnimationGraph>
Source§fn slot_mut(s: &mut ComponentStorage) -> &mut Column<AnimationGraph>
fn slot_mut(s: &mut ComponentStorage) -> &mut Column<AnimationGraph>
Source§impl Debug for AnimationGraph
impl Debug for AnimationGraph
Source§impl Default for AnimationGraph
impl Default for AnimationGraph
Source§fn default() -> AnimationGraph
fn default() -> AnimationGraph
Source§impl<'de> Deserialize<'de> for AnimationGraphwhere
AnimationGraph: Default,
impl<'de> Deserialize<'de> for AnimationGraphwhere
AnimationGraph: Default,
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<AnimationGraph, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<AnimationGraph, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl From<AnimationGraph> for ComponentAsset
impl From<AnimationGraph> for ComponentAsset
Source§fn from(c: AnimationGraph) -> ComponentAsset
fn from(c: AnimationGraph) -> ComponentAsset
impl RuntimeComponent for AnimationGraph
Source§impl Serialize for AnimationGraph
impl Serialize for AnimationGraph
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for AnimationGraph
impl RefUnwindSafe for AnimationGraph
impl Send for AnimationGraph
impl Sync for AnimationGraph
impl Unpin for AnimationGraph
impl UnsafeUnpin for AnimationGraph
impl UnwindSafe for AnimationGraph
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().