[ODE] Gravity Issue
Gary R. Van Sickle
g.r.vansickle at worldnet.att.net
Sat Sep 27 21:00:59 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.
No, F=ma. Note the comment on what this code is doing: "add[ing] the gravity
*force* to all bodies". Instantaneous forces don't depend on stepsize.
Stepsize comes in later, when the accumulated F is being integrated into the
body's acceleration/velocity/position.
--
Gary R. Van Sickle
Brewer. Patriot.
More information about the ODE
mailing list