Expand description
Fixed-step clock with render interpolation.
The loop accumulates caller-supplied frame time as an exact Duration
and runs the fixed-step simulation in constant steps of 1/hz seconds
rounded to the nearest nanosecond. A clock picks one of two policies:
- Render-paced (
FixedClock::with_hz, the default): the per-frame delta fed into the accumulator is clamped to one fixed step, so the accumulator never routinely crosses the 2-step threshold when the render rate sits near the fixed rate — the proven fix for the 60 Hz “rubber-banding” cadence oscillation. The clamp trades real-time catch-up for visual stability: simulation runs slower than real time whenever frames are longer than a step. - Bounded catch-up (
FixedClock::with_catch_up): the whole delta is accumulated and a frame runs up toCatchUp::max_steps_per_framesteps, so simulation follows elapsed time while frames are slower than the tick rate. Time beyond that budget is discarded, apart from up toCatchUp::max_debt_stepswhole steps carried to later frames. For an authoritative or networked simulation that must keep pace with time.
Structs§
- CatchUp
- Bounded catch-up policy for
FixedClock::with_catch_up. - Fixed
Clock - A fixed-timestep accumulator + render interpolation factor.
Constants§
- DEFAULT_
HZ - Default simulation rate: 60 Hz.