Skip to content

cf_physics_step

Category: physics
GitHub: cute_physics.h


Steps a Box2D world using CF's clock.

void cf_physics_step(b2WorldId world, int substep_count);
Parameters Description
world The world to step.
substep_count Box2D solver sub-steps, typically 4.

Remarks

Physics wants a fixed timestep. The intended wiring is:

cf_set_fixed_timestep(60);
// Each frame:
cf_app_update(on_fixed_update); // CF calls it once per fixed tick.
// Inside on_fixed_update:
cf_physics_step(world, 4);

This steps by CF_DELTA_TIME_FIXED, so gameplay and physics share one clock (and Box2D v3's determinism actually holds). Without fixed timestep enabled it falls back to the variable CF_DELTA_TIME, which works but wobbles. When rendering between fixed ticks, interpolate transforms with CF_DELTA_TIME_INTERPOLANT.

cf_physics_draw
cf_set_fixed_timestep
CF_DELTA_TIME_FIXED
CF_DELTA_TIME_INTERPOLANT