[ODE] Making simulation speed independant from computer speed

Megan Fox shalinor at gmail.com
Wed Nov 10 11:34:28 MST 2004


Try code something like this:

timeAccum += elapsedTimeSinceLastFrame
while (timeAccum > STEP_SIZE)
{
 dWorldStep(STEP_SIZE)
 timeAccum -= STEP_SIZE
}

This gives you consistent physical updating regardless of frame rate.
And you want the step size to remain consistent, it can screw up a lot
of your sim if you start changing it.

In addition to this, you might want to add something like if
elapsedTime > definedCutoff, elapsedTime = definedCutoff.  This avoids
the "Well of Despair", where each world update takes progressively
more time, quickly spiralling into a case you'll need to reboot to fix
- though it does temporaril desync your game from real time, of
course, causing a visual appearance of "slow-mo" (which can actually
be quite cool, depending on your game, and is almost always better
than framerate death regardless).


On Wed, 10 Nov 2004 18:35:44 +0100, Kevin Frugier
<kevin.frugier at insa-lyon.fr> wrote:
> My first question is : what is the unit of the stepsize ?
> My second : what kind of calcul should I do to make the simulation speed
> being the same on others computers, for example if I get the time
> elapsed in millisecond.
> 
> I think that is the typical question when you want to develop a game not
> only for you, so I hope my question is not too stupid.
> 
> Thank you.
> 
> Kevin
> 
> _______________________________________________
> ODE mailing list
> ODE at q12.org
> http://q12.org/mailman/listinfo/ode
>


More information about the ODE mailing list