Stepping the simulation correctly
s_w
 | Total Points: 688 Status Points: 188 Brown Belt | |
September 5, 2008 12:58 PM PDT
|
|
Hi Ross,
actually I'm a little bit confused now ;)
I'm running my game from my main loop. At the moment there is a procedure call "updatePhysics( timeSinceLastFrame in seconds )" inside the loop. "updatePhysics(...)" adds the timeSinceLastFrame to its time accumulator "elapsed". Now the loop inside updatePhysics() steps the world as often as required to get to the elapsed time, The remaining time is added to the physics time, because this should be the difference between the physics current time and the current frame time.
E.g. elapsed = 0.02s, timestep = 0.016s, so the loops is called once and 0.004s remain in elapsed, so after stepping the world I'm updating the graphics with: hkpWorld::getCurrentTime() + 0.004s because actually this is the time where the physics should be, but the timestep would have been too small for a step.
Is this the right track? Or is there something I've got wrong?
Thanks! S_W
|
|
|
|
|
|