[ODE] adding forces with a fixed time step

Daniel Frith danfrith at gmail.com
Fri Jul 20 15:35:48 MST 2007


Previously I just put the frame rate varying delta time into
dWorldQuickStep. Now I'm trying to have a constant time step,
something like in the wiki:

    if (dt > 1.0) dt = 1.0; // limit of 1 FPS...

    const double simStep = 0.001;
    int stepCount = (int) ceilf(dt/simStep);

    for (int i = 0; i < stepCount; i ++)
        dSpaceCollide(dMainSpace, this, dNearCallback);
        dWorldQuickStep(dWorld, simStep);

However, when I change the simStep, the amount of force applied to the
bodies *apparently* changes (e.g. change to 0.01 and they move a lot
faster - 10 times I suppose).

It is the amount of force changing, because with the smaller simStep
an object is able to bump up over another one which it couldn't
before, hence it is not just a faster simulation.

I can only guess this is because I am adding forces (multiplied by
delta time) to the bodies only once per frame, but stepping the
simulation many times.

Is this the reason? How should I be adding forces?

If delta time is larger, then there will be more simulation steps, but
more force will have been added to the bodies (force*dt), so I thought
this would prevent any problems...


More information about the ODE mailing list