Skip to main content

Module timestep

Module timestep 

Source
Expand description

Fixed timestep accumulator for physics and simulation.

Call FixedTimestep::advance each frame with the wall-clock delta. Iterate the returned FixedStepIter to consume as many fixed steps as the accumulator has filled. After iteration, FixedTimestep::alpha gives the blend factor for transform interpolation when rendering between steps.

§Example

use viewport_lib::runtime::FixedTimestep;

let mut ts = FixedTimestep::new(60.0);

let wall_dt = 0.016_f32;
for step_dt in ts.advance(wall_dt) {
    // run physics for step_dt seconds
    let _ = step_dt;
}
let alpha = ts.alpha(); // use this to lerp between previous and current transforms

Structs§

FixedStepIter
Iterator over pending fixed simulation steps.
FixedTimestep
Accumulates wall-clock time and yields fixed simulation steps.