Skip to main content

SpringBoneSimulator

Struct SpringBoneSimulator 

Source
pub struct SpringBoneSimulator { /* private fields */ }
Expand description

Stateful spring bone simulator (L3).

Owned by crate::AvatarRuntime, which drives it once per frame. Advanced consumers can drive it directly via Self::initialize / Self::update for a custom pipeline.

Simulates each spring chain with verlet integration: inertia is applied in the center node’s space, stiffness and gravity in world space, and the bone axis is derived from the avatar’s rest pose. Each joint pair (joints[n], joints[n+1]) becomes one simulated joint; the last entry in joints is only a tail marker and is never simulated itself.

Implementations§

Source§

impl SpringBoneSimulator

Source

pub fn new() -> Self

Creates an uninitialized simulator with no retained motion state.

Source

pub fn reset(&mut self)

Resets all simulated state; the next Self::update call re-initializes from the avatar’s rest pose.

Source

pub fn initialize(&mut self, avatar: &Avatar, _world_matrices: &[Mat4])

Builds the simulated chains from the avatar’s rest pose. The rest data (bone axis, bone length, initial rotations) is derived from the static node tree, so the passed world matrices are not required.

Source

pub fn update( &mut self, avatar: &Avatar, world_matrices: &[Mat4], dt: f32, ) -> Vec<BoneUpdate>

Advances every chain by dt seconds and returns the resulting head-node rotations as BoneUpdates (deltas on top of the initial rotation).

The simulation is stateful: pass the same dt and pose each frame and the chains keep their velocity. See Self::reset to return to rest.

Trait Implementations§

Source§

impl Default for SpringBoneSimulator

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.