Struct FootPlant

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

Allocation-free presentation contact state. The caller supplies support queries and elapsed presentation time; this never changes body motion.

Implementations§

Source§

impl FootPlant

Source

pub fn new( max_correction: f32, half_life: f32, ) -> Result<FootPlant, AnimationError>

Uses the original single cutoff: maximum correction distance, upward normal component strictly above 0.5, and no contact-loss grace period. Use Self::with_thresholds to opt into hysteresis.

Source

pub fn with_thresholds( max_correction: f32, half_life: f32, thresholds: FootPlantThresholds, ) -> Result<FootPlant, AnimationError>

Creates a plant with validated hysteresis. Maximum correction must be in 0.001..=10 world units and half-life in 0.001..=1 seconds. Invalid or non-finite configuration returns AnimationError::InvalidPose. See FootPlantThresholds for a compiling usage example and field limits.

Source

pub fn clear(&mut self)

Discards the anchor, normal, weight, grace timer and correction. The unweighted target returns to the origin; use Self::reset on teleport.

Source

pub fn reset(&mut self, animated: Vec3) -> Result<FootPose, AnimationError>

Clears all contact history at a new animated position. A non-finite position returns AnimationError::InvalidPose without changing state.

use ferravex_math::Vec3;
use ferravex_play::animation::FootPlant;
let mut foot = FootPlant::new(0.5, 0.05)?;
let pose = foot.reset(Vec3::X * 10.)?;
assert_eq!(pose.position, Vec3::X * 10.);
assert_eq!(pose.weight, 0.);
assert_eq!(foot.support(), None);
assert_eq!(foot.correction(), Vec3::ZERO);
foot.clear();
assert_eq!(foot.pose().position, Vec3::ZERO);
Source

pub fn pose(&self) -> FootPose

Returns the last unweighted target, normal and blend weight.

Source

pub fn support(&self) -> Option<u64>

Returns the accepted support, including while held during a grace period.

Source

pub fn thresholds(&self) -> FootPlantThresholds

Returns the validated acquisition/retention configuration.

Source

pub fn correction(&self) -> Vec3

Weighted translation from the last positive-time update’s animated position: (pose.position - animated) * pose.weight. Add this to that animated position to apply the contact blend. Zero after clear/reset. It is bounded by max_correction, subject to floating-point rounding.

Source

pub fn update( &mut self, animated: Vec3, contact: Option<FootContact>, plant: bool, dt: f32, ) -> Result<FootPose, AnimationError>

Updates presentation state with finite positions, a unit contact normal (squared-length tolerance 0.001), and dt in 0..=0.25 seconds. Invalid input leaves all state unchanged; zero time validates input but holds all state, so a support delta is not consumed while paused.

Once acquired, an anchor follows the same support’s delta exactly once per positive-time update, independently of blend weight. Query position jitter does not move that anchor. If support motion takes the anchor out of range, a usable contact reanchors it within the correction limit.

Missing/marginal contact holds a bounded anchor for less than release_delay seconds; absent queries imply no known support motion. A valid contact resets that timer. plant = false, a different support, or an out-of-range anchor bypasses the grace period. Release restores the animated position/up normal immediately while the blend weight decays.

Trait Implementations§

Source§

impl Clone for FootPlant

Source§

fn clone(&self) -> FootPlant

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FootPlant

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Copy for FootPlant

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.