pub struct DoubleBufferedSnapshot<TextValue> { /* 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<TextValue> DoubleBufferedSnapshot<TextValue>where
TextValue: Clone,
Construction, zero-allocation in-place capture, discontinuity handling, and interpolation sampling for DoubleBufferedSnapshot.
impl<TextValue> DoubleBufferedSnapshot<TextValue>where
TextValue: Clone,
Construction, zero-allocation in-place capture, discontinuity handling, and interpolation sampling for DoubleBufferedSnapshot.
Sourcepub fn commit(&mut self, next: TextValue)
pub fn commit(&mut self, next: TextValue)
Commits a continuous fixed-step snapshot, promoting the prior curr_state into prev_state.
§Arguments
&Self- Mutable snapshot buffer.TextValue- New immutable simulation state snapshot.
Sourcepub fn capture_into<CallbackFn>(&mut self, capture_fn: CallbackFn)where
CallbackFn: FnOnce(&mut TextValue),
pub fn capture_into<CallbackFn>(&mut self, capture_fn: CallbackFn)where
CallbackFn: FnOnce(&mut TextValue),
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.CallbackFn- Closure overwriting the recycled&mut Sslot in place.
Sourcepub fn capture_discontinuous_into<CallbackFn>(&mut self, capture_fn: CallbackFn)where
CallbackFn: FnOnce(&mut TextValue),
pub fn capture_discontinuous_into<CallbackFn>(&mut self, capture_fn: CallbackFn)where
CallbackFn: FnOnce(&mut TextValue),
Captures a discontinuous snapshot in place via capture_fn, preventing interpolation across the boundary without reallocating backing vectors.
§Arguments
&Self- Mutable snapshot buffer.CallbackFn- Closure overwritingcurr_statein place.
Sourcepub fn commit_discontinuous(&mut self, next: TextValue)
pub fn commit_discontinuous(&mut self, next: TextValue)
Commits a discontinuous snapshot (teleport, scene reset, or hard camera cut), preventing interpolation across the boundary.
§Arguments
&Self- Mutable snapshot buffer.TextValue- New immutable simulation state snapshot.
Sourcepub fn sample_into(&self, alpha: f32, out: &mut TextValue)where
TextValue: InterpolatableState,
pub fn sample_into(&self, alpha: f32, out: &mut TextValue)where
TextValue: 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 TextValue- Persistent destination snapshot overwritten in place.
Sourcepub fn sample_cached(&mut self, alpha: f32) -> &TextValuewhere
TextValue: InterpolatableState,
pub fn sample_cached(&mut self, alpha: f32) -> &TextValuewhere
TextValue: 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
&TextValue- Borrowed interpolated snapshot stored in the persistent scratch slot.