Skip to main content

Module time

Module time 

Source
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 to CatchUp::max_steps_per_frame steps, so simulation follows elapsed time while frames are slower than the tick rate. Time beyond that budget is discarded, apart from up to CatchUp::max_debt_steps whole 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.
FixedClock
A fixed-timestep accumulator + render interpolation factor.

Constants§

DEFAULT_HZ
Default simulation rate: 60 Hz.