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
impl SpringBoneSimulator
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Resets all simulated state; the next Self::update call re-initializes
from the avatar’s rest pose.
Sourcepub fn initialize(&mut self, avatar: &Avatar, _world_matrices: &[Mat4])
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.
Sourcepub fn update(
&mut self,
avatar: &Avatar,
world_matrices: &[Mat4],
dt: f32,
) -> Vec<BoneUpdate>
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.