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 transformsStructs§
- Fixed
Step Iter - Iterator over pending fixed simulation steps.
- Fixed
Timestep - Accumulates wall-clock time and yields fixed simulation steps.