[ODE] Gravity Issue

Dave Kerr aidave at telus.net
Sat Sep 27 17:20:56 MST 2003


Hey guys,

I have a slider to adjust the stepping speed of the ODE simulation.  The
problem is, the gravity is not applied evenly at different step values.  At
step of 1.0, gravity is applied fine.  At a step of 2.0, the gravity is
"heavier", and at a step of 0.001, the gravity is non-existent and objects
float away into the sky.   Am I doing something wrong?

In my own physics engine, I adjust the gravity by the step size, and it
works great.

Just taking a browse in the ODE code, I noticed that gravity is not affected
by step size:

step.cpp: dInternalStepIsland_x1

  // add the gravity force to all bodies
  for (i=0; i<nb; i++) {
    if ((body[i]->flags & dxBodyNoGravity)==0) {
      body[i]->facc[0] += body[i]->mass.mass * world->gravity[0];
      body[i]->facc[1] += body[i]->mass.mass * world->gravity[1];
      body[i]->facc[2] += body[i]->mass.mass * world->gravity[2];
    }
  }

It seems more appropriate, to multiple the gravity by the stepsize.  However
that is opposite of what is happening in the above scenarios.  So maybe the
solution is to divide by the stepsize?

  // add the gravity force to all bodies
  for (i=0; i<nb; i++) {
    if ((body[i]->flags & dxBodyNoGravity)==0) {
      body[i]->facc[0] += body[i]->mass.mass * world->gravity[0] / stepsize;
      body[i]->facc[1] += body[i]->mass.mass * world->gravity[1] / stepsize;
      body[i]->facc[2] += body[i]->mass.mass * world->gravity[2] / stepsize;
    }
  }

I'll be testing this once I get VC to build the dll

Dave




More information about the ODE mailing list