[ODE] Framerate problem *again*

slipch slipch <slipch at gsc-game.kiev.ua>
Tue Feb 11 08:15:02 2003


Hello Marco,

Tuesday, February 11, 2003, 3:42:14 AM, you wrote:

MB> Hi all!

MB> I've read all the threads about which tecnique to use to keep the
MB> simulation time as much "real" as possible.
MB> I know I have to use little timesteps (5 - 10 ms) for dWorldStep().
MB> I know it should be constant and indipendent from the framerate.
MB> I know someone uses a separated thread and someone uses an
MB> "integration tecnique".

MB> Maybe I know all? :) No, sure, because my game has very different
MB> behaviors depending on frame rates. I can also run it in two different
MB> screen modes (with different refresh rates (60 and 85)) on the same
MB> (mine) computer and it seems to be two different games!!!

MB> So... here I post the code around dWorldStep() I use:

MB> //! Run the physic
MB> lCurrentTick=pTimer.GetCurrentTicks();  // current real ticks
MB> while (lSimTime<lCurrentTick) {
MB>         fDelta=lCurrentTick-lSimTime;
MB>         if (fDelta>=SIM_TICK*1000) {
MB>                 dWorldStep(odeWorld, SIM_TICK);
MB>                 lSimTime+=SIM_TICK*1000;
MB>         }
MB>         else {
MB>                 dWorldStep(odeWorld, fDelta/1000);
MB>                 lSimTime+=fDelta;
MB>         }
MB> }

MB> lSimTime is the accumulated simulation time;
MB> SIMTICK is defined as 0.01 secs (10 ms);
MB> As you can see I use the integration tecnique, but it doesn't work.
MB> Do you see something really wrong about that code?

MB> Please help... thank you!

  dWorldStep(odeWorld, fDelta/1000) - is not good at all;
  1) too small fDelta very tricky
  2) you normally get fDelta<0.
  
  Simply try to remove   dWorldStep(odeWorld, fDelta/1000);
  
  -something like this works for me all right.

-- 
Best regards,
 slipch                            mailto:slipch@gsc-game.kiev.ua