pub struct FrameStep {
pub steps: u32,
pub dt: f32,
pub alpha: f32,
pub dropped_seconds: f64,
}Expand description
A fixed simulation step budget with a fractional render interpolation factor.
Fields§
§steps: u32§dt: f32§alpha: f32§dropped_seconds: f64Whole steps intentionally discarded to prevent a spiral of death.
Implementations§
Source§impl FrameStep
impl FrameStep
Sourcepub fn ticks(
self,
) -> impl ExactSizeIterator + DoubleEndedIterator + FusedIterator
pub fn ticks( self, ) -> impl ExactSizeIterator + DoubleEndedIterator + FusedIterator
Iterate over this frame’s scheduled ticks, yielding the fixed dt for each.
This iterator allocates nothing and excludes discarded catch-up time. It owns
a copy of the budget; iterating does not advance or otherwise mutate a clock.
Use Iterator::enumerate when an input edge should apply only on the first tick.
use ferravex_core::FixedClock;
let mut clock = FixedClock::try_new(64.0, 8)?;
let frame = clock.advance(3.0 / 64.0);
let mut position = 0.0;
let mut jumps = 0;
for (index, dt) in frame.ticks().enumerate() {
position += 2.0 * dt;
if index == 0 { jumps += 1; } // Consume a pending jump edge once.
}
assert_eq!(position, 6.0 / 64.0);
assert_eq!(jumps, 1);Trait Implementations§
Auto Trait Implementations§
impl Freeze for FrameStep
impl RefUnwindSafe for FrameStep
impl Send for FrameStep
impl Sync for FrameStep
impl Unpin for FrameStep
impl UnwindSafe for FrameStep
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more