Stepping the simulation correctly

s_w
Total Points: 688
Status Points: 188
Brown Belt
September 5, 2008 12:58 PM PDT
Rate
 
#8 Reply to #7
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

Forum Statistics

4477 users have contributed to 24011 threads and 69949 posts to date.
In the past 24 hours, we have 41 new thread(s) 204 new posts(s), and 259 new user(s).

In the past 3 days, the most popular thread for everyone has been Catastrophic error The most posts were made to Intel License Manager for FlexLM under CentOS 5.2 The post with the most views is You can report them here if

Please welcome our newest member jenni80