SafiTime
SafiTime is a singleton component the engine updates once per frame, just before running the variable-rate pipeline. Systems read it via ecs_singleton_get(world, SafiTime).
Type
Two clocks live in a single struct:
- Variable-rate —
delta,elapsed,frame_count. Wall-clock. Read this from gameplay, camera, input-driven, and rendering systems. - Fixed-rate —
fixed_delta,fixed_elapsed,fixed_overshoot. Driven by theSafiFixedUpdatephase. Read this from physics and any deterministic simulation.
The engine ticks the fixed stage with a classic accumulator — each frame, delta is added to an accumulator, and SafiFixedUpdate runs as many times as needed to drain it in fixed_delta slices. fixed_overshoot is the unconsumed remainder, always in [0, fixed_delta), and is useful as an interpolation alpha when rendering between fixed steps.
Configuration
fixed_delta and the spiral-of-death cap are set in SafiAppDesc:
Leaving them zero keeps the defaults (1/60 s, 4 max steps per frame).
Example — variable-rate system
it->delta_time
flecs already passes delta_time on the iterator. SafiTime is there for systems that need elapsed, frame_count, or the fixed-rate fields.
Example — fixed-rate system
See also
- SafiApp — updates
SafiTimeeach frame - Scheduler & Stages — how
SafiFixedUpdatefits into the per-frame pipeline - ECS resources