pub struct FixedClock {
pub fixed_dt: f32,
pub alpha: f32,
pub steps_this_frame: u32,
/* private fields */
}Expand description
A fixed-timestep accumulator + render interpolation factor.
Usage per rendered frame:
clock.begin_frame(real_dt);
while clock.step() { /* one fixed sim step of clock.fixed_dt */ }
clock.finish();
let alpha = clock.alpha; // overstep fraction: lerp(prev, curr, alpha)Fields§
§fixed_dt: f32Constant simulation step, 1 / hz seconds.
alpha: f32Overstep fraction in [0, 1), set by finish; the
render interpolation alpha.
steps_this_frame: u32Fixed steps consumed during the current frame (cadence diagnostic).
Implementations§
Source§impl FixedClock
impl FixedClock
Sourcepub fn begin_frame(&mut self, real_dt: f32)
pub fn begin_frame(&mut self, real_dt: f32)
Begin a rendered frame: add real_dt (clamped) to the accumulator and
reset the per-frame step counter.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FixedClock
impl RefUnwindSafe for FixedClock
impl Send for FixedClock
impl Sync for FixedClock
impl Unpin for FixedClock
impl UnsafeUnpin for FixedClock
impl UnwindSafe for FixedClock
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