[ODE] AutoDisable

gl gl at ntlworld.com
Sun Feb 29 17:35:23 MST 2004


There is the remaining problem of what to do with disabled bodies that are
resting on one that has just been reenabled.  If the reenabled one doesn't
create a contact with the others (which automatically enables them too),
they will end up floating in mid-air.

One idea might be to extend a reenabled body's AABB a little, and checking
which disabled bodies' AABBs are now intersecting, then re-enabling those.
--
gl

----- Original Message ----- 
From: "Jani Laakso" <jani.laakso at itmill.com>
To: <ode at q12.org>
Sent: Sunday, February 29, 2004 1:00 PM
Subject: Re: [ODE] AutoDisable


> DjArcas wrote:
>
> > /* These functions are not yet implemented by ODE. */
> >
> > /*
> >
> > dReal dBodyGetAutoDisableThresholdSF1(dBodyID);
> >
> > void dBodySetAutoDisableStepsSF1(dBodyID, int AutoDisableSteps);
> >
> > int dBodyGetAutoDisableStepsSF1(dBodyID);
> >
> > void dBodySetAutoDisableSF1(dBodyID, int doAutoDisable);
> >
> > int dBodyGetAutoDisableSF1(dBodyID);
> >
> > */
> >
> > Are they lurking around anywhere as a patch or something? Seems like
> > autodisabling bodies should really be in there!
> >
> I assume you already know this but you can implement auto disabling
> without the upper methods already.
>
> Here's how I do it on Odejava project. Just before stepping the world I
> call autoDisableBodies method below. Each body has it's own setup for
> stepcount and threshold (angular/linear velocity). I assume this does
> exactly the same trick what upper not yet implemented methods should do,
> am I correct?
>
> // Automatically disable bodies which angular and linear velocities
> // are below threshold for n steps
> JNIEXPORT void JNICALL
> Java_org_odejava_collision_JavaCollision_autoDisableBodies
> (JNIEnv *env, jobject obj) {
>   for (int i=0; i < maxAutoDisableSize; i++) {
>     dBodyID b = autoDisableBodies[i];
>     if (!b) return;
>     if (dBodyIsEnabled(b)) {
>       // Check if slow enough linear velocity
>       const dReal *linVel = dBodyGetLinearVel(b);
>     dReal lspeed =
> linVel[0]*linVel[0]+linVel[1]*linVel[1]+linVel[2]*linVel[2];
>     if (lspeed < autoDisableBodiesThreshold[i]) {
>        // Check if slow enough angular velocity
>            const dReal *angVel = dBodyGetAngularVel(b);
>       dReal aspeed =
> angVel[0]*angVel[0]+angVel[1]*angVel[1]+angVel[2]*angVel[2];
>       if (aspeed < autoDisableBodiesThreshold[i]) {
>         autoDisableBodiesCurrentSteps[i]++;
>         // Check if body has been moving slow for long enough time
>         if (autoDisableBodiesCurrentSteps[i] > autoDisableBodiesSteps[i])
>             dBodyDisable(b);
>         } else {
>           autoDisableBodiesCurrentSteps[i] = 0;
>         }
>       } else {
>         autoDisableBodiesCurrentSteps[i] = 0;
>       }
>     }
>   }
> }
>
> This surely makes e.g. brick of walls more stable and stops bodies
> trembling against terrain on obvious cases when bodies should be
> completely stable, not moving (disabled).
>
> There's also some speed gain if most of your objects seem to be not
> moving, in other worlds they can be disabled most of the time of your
> simulation.
>
> -- 
> Jani Laakso / IT Mill Ltd | Tel. +358 40 5898086 | http://www.itmill.com
>
>
> _______________________________________________
> ODE mailing list
> ODE at q12.org
> http://q12.org/mailman/listinfo/ode
>
>



More information about the ODE mailing list