Skip to main content

euv_core/game/snapshot/
trait.rs

1/// Trait for immutable simulation snapshots supporting smooth discontinuity-safe render interpolation.
2pub trait InterpolatableState: Clone {
3    /// Interpolates between `self` (previous fixed-step snapshot) and `next` (current fixed-step snapshot) at `alpha` in `[0.0, 1.0]`.
4    ///
5    /// # Arguments
6    ///
7    /// - `&Self` - Previous immutable simulation snapshot (`t - dt`).
8    /// - `&Self` - Current immutable simulation snapshot (`t`).
9    /// - `f32` - Render interpolation factor clamped to `[0.0, 1.0]`.
10    ///
11    /// # Returns
12    ///
13    /// - `Self` - Smoothly interpolated state for rendering without interpolating discontinuous events.
14    #[must_use]
15    fn interpolate(&self, next: &Self, alpha: f32) -> Self;
16}