[ODE] Infinite sliding... ?
Jon Watte (ODE)
hplus-ode at mindcontrol.org
Wed Aug 16 16:09:34 MST 2006
Jeff Kershner wrote:
> Second: This is the third time I have heard that stepping at variable times
> is very wrong. I can't find the FAQ about this except that it is wrong. In
> a normal game loop that is operation almost all the time at 75 Hz, how much
> should the step size be and how often should it be called every frame?
If you know you run at 75 Hz, then set step size to 1/75. For the cases
where you drop frames, step more than once. An alternative is to set
step size to, say, 1/150, and step 2 or 3 times depending on frame
duration. Over time, the accumulated physics time should be the same as
the accumulated frame time.
The reason non-equal step size is bad, is that objects keep falling into
ground (because of gravity), but "stabilize" at a small depth into the
ground. When step sizes vary, the ideal "stable" position will change
each step, and thus the object will jitter (and may very well gain energy!)
> Third: can't do this since I need to interact with the bodies after they lay
> at rest.
You can re-enable them when you want to interact with them. In the
collision callback function, for example, if you collide with a
> This is what I do:
> const dReal* v = dBodyGetLinearVel(it->body);
> dBodyAddForce(it->body, v * -0.01, v * -0.01, v * -0.01);
> // Also so this for angular vel with a coefficient greater than 1
> const dReal* av = dBodyGetLinearVel(it->body);
> dBodyAddForce(it->body, av * 2.0, av * 2.0, av * 2.0);
Lookas all wrong. First, it uses the linear velocity. Second, it ADDS to
the velocity (because 2.0 is not negative). Third, it still uses force.
You probably want to write this as:
dReal const * av = dBodyGetAngularVel(it->body);
dBodyAddTorque(it->body, av * -0.03, av * -0.03, av * -0.03);
However, you really DO need to enable auto-sleeping. That's how you get
things to "stick" rock solid, in any simulator I've seen.
More information about the ODE