[ODE] continuous forces w/ constant step size
John Miles
jmiles at pop.net
Fri Sep 17 10:13:01 MST 2004
>
> Here's the problem with it: The continuously-applied
> forces and the input only get updated once per frame,
> not once per time step, which yields different results
> depending on the frame rate. These things need to get
> applied per time step to get consistent results.
Actually, they don't. What you're missing is that ODE's idea of the passage
of time is different than your game's. Try something like this:
wall_clock = 0 // or whatever time your simulation begins at...
physics_clock = wall_clock // if saving states, you need to restore this
instead!
while (1)
wall_clock += frame_dT // actual amount of time taken by last frame
// get input, apply forces, etc.
while (physics_clock < wall_clock)
physics_clock += fixed_timestep_msec
// generate collisions
// step the world (fixed_timestep_msec)
end
// render, etc.
end
This will quantize the ODE timebase without keeping it locked to your game's
frame rate.
-- jm
More information about the ODE
mailing list