Skip to main content

InterpolatableState

Trait InterpolatableState 

Source
pub trait InterpolatableState: Clone {
    // Required method
    fn interpolate(&self, next: &Self, alpha: f32) -> Self;

    // Provided methods
    fn copy_from_snapshot(&mut self, src: &Self) { ... }
    fn interpolate_into(&self, next: &Self, alpha: f32, out: &mut Self) { ... }
}
Expand description

Trait for simulation snapshots supporting discontinuity-safe render interpolation and zero-allocation in-place reuse.

Required Methods§

Source

fn interpolate(&self, next: &Self, alpha: f32) -> Self

Interpolates between self (previous fixed-step snapshot) and next (current fixed-step snapshot) at alpha in [0.0, 1.0].

§Arguments
  • &Self - Previous immutable simulation snapshot (t - dt).
  • &Self - Current immutable simulation snapshot (t).
  • f32 - Render interpolation factor clamped to [0.0, 1.0].
§Returns
  • Self - Smoothly interpolated state for rendering without interpolating discontinuous events.

Provided Methods§

Source

fn copy_from_snapshot(&mut self, src: &Self)

Copies src into self reusing existing internal buffer capacities without heap allocation whenever possible.

§Arguments
  • &Self - Mutable destination snapshot.
  • &Self - Source snapshot to copy from.
Source

fn interpolate_into(&self, next: &Self, alpha: f32, out: &mut Self)

Interpolates between self and next at alpha directly into pre-allocated out with zero steady-state allocations.

§Arguments
  • &Self - Previous fixed-step snapshot (t - dt).
  • &Self - Current fixed-step snapshot (t).
  • f32 - Render interpolation factor clamped to [0.0, 1.0].
  • &mut Self - Persistent destination snapshot overwritten in place.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl InterpolatableState for FluidSimSnapshot

Zero-allocation render-time snapshot interpolation for FluidSimSnapshot.

Source§

impl InterpolatableState for SkeletonPoseSnapshot

Discontinuity-safe skeletal joint interpolation for SkeletonPoseSnapshot.

Source§

impl InterpolatableState for World2DSnapshot

Discontinuity-safe render-time interpolation for World2DSnapshot.

Source§

impl InterpolatableState for World3DSnapshot

Discontinuity-safe render-time interpolation for World3DSnapshot.