[ODE] body auto disable

gl gl at ntlworld.com
Thu Jan 2 23:18:02 2003


Ewrin, I've just implemented this (from the outside), and it works well for
my current test scene, composed of sphere/box and compound objects (similar
to boxstack).  Here's the code I use (my units are real-world meters,
seconds and gravity):

 #define MIN_PHYSICS_VELOCITY  0.01 // in meters/s
 #define MIN_PHYSICS_VELOCITY_TIME 1  // in secs

(per world object, 'Dynamics' is a ptr to dBody)
   if(Dynamics->isEnabled())
    {
    vec3 &vel = AbsoluteVelocity().Absolute(); // (ie. fabs(x), fabs(y),
fabs(z))
    // if the object's velocity has dropped below the threshhold for
    //  long enough, auto-disable its dynamics calculations
    if((vel.x > MIN_PHYSICS_VELOCITY) ||
       (vel.y > MIN_PHYSICS_VELOCITY) ||
       (vel.z > MIN_PHYSICS_VELOCITY))
     LowVelocityTime = 0.f; // reset the count
    else{
     LowVelocityTime += time_step;
     if (LowVelocityTime > MIN_PHYSICS_VELOCITY_TIME) {
      Dynamics->disable();
      // note - I initially reset the count here too, but that resulted in
some objects constantly
      // retriggering each other, even though there was no useful movement
(eg blocks leaning
      // against one another).  Removing it avoided that.
      }
     }
    }

I definitely think this should be in ODE as standard, however I'd recommend
a global enable/disable with global parameters, with an optional per-body
disable.or custom parameters.  It should be possible to come up with good
conservative defaults that work in most/all cases, and just have it enabled
by default.
--
gl

----- Original Message -----
From: "Erwin de Vries" <erwin@vo.com>
To: <ode@q12.org>
Sent: Monday, December 23, 2002 11:57 AM
Subject: [ODE] body auto disable


> Hi,
>
> I'm thinking about what would be the best way to do this. I was thinking
> about a solution which basically does the following:
>
> - Add a dReal 'DisableTimer' to the dBody struct.
> - Add a dxBodyFlagAutoDisable which enables or disables this feature per
> body.
> - Each step add the steptime to this timer if the velocity is smaller than
> V. Else reset it to 0.
> - If the timer is larger than T disable the body.
>
> It could either be implemented that V is a user defined value, but it
could
> also be determined from the inertia matrix of the body, which would be a
> better solution i believe. Large objects get disabled sooner than small
> objects.
>
> T should be user defined i believe. It could default to something like 5
> time units (seconds).
>
> I'd think this would be fairly easy to implement. Any comments?
>
> Erwin
>
> _______________________________________________
> ODE mailing list
> ODE@q12.org
> http://q12.org/mailman/listinfo/ode
>