pub struct AnimationMixer {
pub time: f32,
pub time_scale: f32,
pub enabled: bool,
/* private fields */
}Expand description
Manages playback and blending of multiple animation actions.
The mixer drives time advancement for all active actions, accumulates sampled animation data into per-node blend buffers, and applies the final blended result to scene nodes once per frame.
§Rest Pose & State Restoration
The mixer tracks which nodes were animated in the previous frame. When a node loses all animation influence (e.g. an action is stopped), it is automatically restored to its rest pose.
§Blending
When multiple actions are active simultaneously, their contributions are combined using weight-based accumulation. If the total accumulated weight for a property is less than 1.0, the rest pose value fills the remainder.
§Events
Animation events fired during the frame are collected and can be
consumed via drain_events.
Fields§
§time: f32Global mixer time in seconds.
time_scale: f32Global time scale multiplier applied to all actions.
enabled: boolImplementations§
Source§impl AnimationMixer
impl AnimationMixer
pub fn new() -> AnimationMixer
Sourcepub fn set_rig(&mut self, rig: Rig)
pub fn set_rig(&mut self, rig: Rig)
Sets the logical skeleton used for bone-index → node-handle lookup.
Sourcepub fn list_animations(&self) -> Vec<String>
pub fn list_animations(&self) -> Vec<String>
Returns a list of all registered animation clip names.
Sourcepub fn add_action(&mut self, action: AnimationAction) -> ActionHandle
pub fn add_action(&mut self, action: AnimationAction) -> ActionHandle
Registers an action and returns its handle.
Sourcepub fn get_action(&self, name: &str) -> Option<&AnimationAction>
pub fn get_action(&self, name: &str) -> Option<&AnimationAction>
Read-only access to an action by clip name.
Sourcepub fn get_action_by_handle(
&self,
handle: ActionHandle,
) -> Option<&AnimationAction>
pub fn get_action_by_handle( &self, handle: ActionHandle, ) -> Option<&AnimationAction>
Read-only access to an action by handle.
Sourcepub fn action(&mut self, name: &str) -> Option<ActionControl<'_>>
pub fn action(&mut self, name: &str) -> Option<ActionControl<'_>>
Returns a chainable control wrapper for the named action.
Sourcepub fn any_action(&mut self) -> Option<ActionControl<'_>>
pub fn any_action(&mut self) -> Option<ActionControl<'_>>
Returns a control wrapper for the first registered action.
Sourcepub fn get_control(&mut self, handle: ActionHandle) -> Option<ActionControl<'_>>
pub fn get_control(&mut self, handle: ActionHandle) -> Option<ActionControl<'_>>
Returns a control wrapper for an existing handle.
pub fn get_control_by_name(&mut self, name: &str) -> Option<ActionControl<'_>>
Sourcepub fn stop(&mut self, name: &str)
pub fn stop(&mut self, name: &str)
Stops the named animation and removes it from the active set.
Sourcepub fn drain_events(&mut self) -> Vec<FiredEvent>
pub fn drain_events(&mut self) -> Vec<FiredEvent>
Drains all events fired during the most recent update.
Sourcepub fn events(&self) -> &[FiredEvent]
pub fn events(&self) -> &[FiredEvent]
Returns a read-only slice of events fired during the most recent update.
Sourcepub fn update(&mut self, dt: f32, target: &mut dyn AnimationTarget)
pub fn update(&mut self, dt: f32, target: &mut dyn AnimationTarget)
Advances all active actions and applies blended results to the target.
This is the core per-frame entry point. The update proceeds in four phases:
- Time advancement: Each active action’s time is advanced. Animation
events that fall within the
[t_prev, t_curr]window are collected. - Sampling & accumulation: Active actions sample their tracks and
accumulate weighted results into the blend buffer. Track-to-node
mapping uses
crate::binding::ClipBinding+Rigfor O(1) lookup. - Application: Blended values are mixed with the rest pose and written to scene nodes.
- Restoration: Nodes that were animated last frame but received no contributions this frame are reset to their rest pose.
Trait Implementations§
Source§impl Default for AnimationMixer
impl Default for AnimationMixer
Source§fn default() -> AnimationMixer
fn default() -> AnimationMixer
Auto Trait Implementations§
impl Freeze for AnimationMixer
impl RefUnwindSafe for AnimationMixer
impl Send for AnimationMixer
impl Sync for AnimationMixer
impl Unpin for AnimationMixer
impl UnsafeUnpin for AnimationMixer
impl UnwindSafe for AnimationMixer
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt 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().