Skip to main content

MuscleRig

Struct MuscleRig 

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

A complete muscle rig: a collection of MuscleDefinitions with current MuscleStates that can be evaluated into morph weights.

Implementations§

Source§

impl MuscleRig

Source

pub fn new() -> Self

Create an empty muscle rig.

Source

pub fn add_muscle(&mut self, def: MuscleDefinition)

Add a muscle definition to this rig. The state is initialised to the relaxed default.

Source

pub fn set_state(&mut self, name: &str, state: MuscleState)

Set the current state for a named muscle.

Source

pub fn get_state(&self, name: &str) -> Option<&MuscleState>

Get the current state for a named muscle, if it exists.

Source

pub fn muscle_names(&self) -> Vec<&str>

Return all muscle names in definition order.

Source

pub fn muscles_in_group(&self, group: &MuscleGroup) -> Vec<&MuscleDefinition>

Return all muscle definitions belonging to a given group.

Source

pub fn count(&self) -> usize

Total number of muscles in this rig.

Source

pub fn evaluate(&self) -> HashMap<String, f32>

Evaluate all muscle states and accumulate morph weights.

Multiple muscles can drive the same morph target; weights are additive and clamped to [0, 1] per morph.

Source

pub fn flex_group(&mut self, group: &MuscleGroup, amount: f32)

Flex all muscles in a group simultaneously to amount [0..1].

Source

pub fn relax_all(&mut self)

Set all muscle states to relaxed (zero flex, zero contract).

Source

pub fn default_rig() -> Self

Build a standard human muscle rig with approximately 20 named muscles.

Source

pub fn apply_fatigue(&mut self, threshold: f32, fatigue_rate: f32)

Apply fatigue to muscles whose flex exceeds threshold.

Each qualifying muscle has its fatigue increased by fatigue_rate, clamped to [0, 1].

Trait Implementations§

Source§

impl Default for MuscleRig

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.