[ODE] auto-disable implemented (again)
Aras Pranckevicius
nearaz at interamotion.com
Mon Mar 1 12:31:02 MST 2004
Hi,
So, I just sat down and implemented auto-disabling again. Now, I don't
really know how I could make a "patch" (and too lazy to install
TortoiseCVS).
So, I though: what if I just send the modified ODE source
files (taken today from public CVS, modified)? It's here:
http://www.gim.ktu.lt/nesnausk/nearaz/files/ode-auto-disable-040301.zip
(watch our for url wrapping).
Auto-disabling has these features now:
* A body is a candidate for disabling, if it's linear velocity squared
length is below "linear treshold" AND it's angular velocity squared length
is below "angular treshold".
* When a body has remained a disable-candidate for certain number of
successive steps, it gets disabled.
* The two tresholds and "steps" parameters are per-body.
* Newly created bodies get "default" auto-disabling parameters from the
world. The world's parameters can also be changed. There's also a
convenience function dBodySetAutoDisableDefaults that sets parameters from
world again.
* Default auto-disable parameters: linear treshold = 0.015, angular treshold
= 0.008, steps = 50. These seemed to be reasonable for test_boxstack. I
guess they depend heavily on your timestep, CFM, ERP etc.
* Both step and stepfast have auto-disabling.
* Auto-disabling of bodies is enabled by default, but can be turned off for
any body. I don't know whether default should be the opposite (i.e.
auto-disabling is not enabled).
Now, for auto-disabling to be really effective, you have to take some care
in your collision callback as well (that saves time for collision checking
also). That's because if enabled body collides (creates contact joint) with
a disabled body, both become enabled. In test_boxstack I've done it like
this:
// -----------------
static void nearCallback (void *data, dGeomID o1, dGeomID o2) {
// usual stuff...
// exit without doing anything if the two bodies are connected by a joint
dBodyID b1 = dGeomGetBody(o1);
dBodyID b2 = dGeomGetBody(o2);
if (b1 && b2 && dAreConnectedExcluding (b1,b2,dJointTypeContact)) return;
// take care of disabled bodies
if( b1 && !b2 && !dBodyIsEnabled(b1) )
return; // b1 is disabled and collides with no-body
if( b2 && !b1 && !dBodyIsEnabled(b2) )
return; // b2 is disabled and collides with no-body
if( b1 && b2 && !dBodyIsEnabled(b1) && !dBodyIsEnabled(b2) )
return; // both b1 and b2 are disabled
// the rest of code...
// -----------------
This way, even big piles of colliding and non-moving bodies eventually get
disabled. Add this to test_boxstack, increase max body count to 200 and
begin dropping boxes/composites to see it ;)
Now, what remains is updating the documentation. I've seen that the doc is
in a similar-to-doxygen format. Should I update it now, or wait while
someone tests this whole auto-disabling?
Aras Pranckevicius aka NeARAZ
http://www.gim.ktu.lt/nesnausk/nearaz/
More information about the ODE
mailing list