pub struct DoubleBufferedSnapshot<S> { /* private fields */ }Expand description
Three-slot double-buffered snapshot store decoupling fixed-step simulation commits from zero-allocation high-refresh render interpolation.
Implementations§
Source§impl<S> DoubleBufferedSnapshot<S>where
S: Clone,
Construction, zero-allocation in-place capture, discontinuity handling, and interpolation sampling for DoubleBufferedSnapshot.
impl<S> DoubleBufferedSnapshot<S>where
S: Clone,
Construction, zero-allocation in-place capture, discontinuity handling, and interpolation sampling for DoubleBufferedSnapshot.
Sourcepub fn commit(&mut self, next: S)
pub fn commit(&mut self, next: S)
Commits a continuous fixed-step snapshot, promoting the prior curr_state into prev_state.
§Arguments
&Self- Mutable snapshot buffer.S- New immutable simulation state snapshot.
Sourcepub fn capture_into<F>(&mut self, capture_fn: F)
pub fn capture_into<F>(&mut self, capture_fn: F)
Rotates curr_state into prev_state and populates the recycled curr_state slot in place via capture_fn with zero heap allocations.
§Arguments
&Self- Mutable snapshot buffer.F- Closure overwriting the recycled&mut Sslot in place.
Sourcepub fn capture_discontinuous_into<F>(&mut self, capture_fn: F)
pub fn capture_discontinuous_into<F>(&mut self, capture_fn: F)
Captures a discontinuous snapshot in place via capture_fn, preventing interpolation across the boundary without reallocating backing vectors.
§Arguments
&Self- Mutable snapshot buffer.F- Closure overwritingcurr_statein place.
Sourcepub fn commit_discontinuous(&mut self, next: S)
pub fn commit_discontinuous(&mut self, next: S)
Commits a discontinuous snapshot (teleport, scene reset, or hard camera cut), preventing interpolation across the boundary.
§Arguments
&Self- Mutable snapshot buffer.S- New immutable simulation state snapshot.
Sourcepub fn sample_into(&self, alpha: f32, out: &mut S)where
S: InterpolatableState,
pub fn sample_into(&self, alpha: f32, out: &mut S)where
S: InterpolatableState,
Samples the render-time state at normalized alpha in [0.0, 1.0] directly into pre-allocated out with zero heap allocations.
§Arguments
&Self- Snapshot buffer reference.f32- Normalized interpolation factor between previous and current fixed steps.&mut S- Persistent destination snapshot overwritten in place.
Sourcepub fn sample_cached(&mut self, alpha: f32) -> &Swhere
S: InterpolatableState,
pub fn sample_cached(&mut self, alpha: f32) -> &Swhere
S: InterpolatableState,
Samples the render-time state at alpha into the internal third persistent interp_scratch slot and borrows it with zero allocations.
§Arguments
&Self- Mutable snapshot buffer.f32- Normalized interpolation factor in[0.0, 1.0].
§Returns
&S- Borrowed interpolated snapshot stored in the persistent scratch slot.