[ODE] AutoDisable

Tyler Streeter tylerstreeter at gmail.com
Fri Dec 17 17:11:17 MST 2004


On Thu, 16 Dec 2004 20:59:21 -0700, Megan Fox <shalinor at gmail.com> wrote:
> If you have one body disabled and one body enabled, the contact
> between them would be capable of waking the sleeping body up - so yes,
> you'll want to add that contact.
> 
> However, if you have two sleeping/disabled objects, there should
> typically never be a valid contact between them - and so you can
> early-out of your callback.
> 
> If you work this right, you can get the same check to early-out on
> static/static geometry collision attempts as well (which will never
> result in anything useful, since neither has a body).  The code would
> look something like:
> 
> dBodyID body1, body2
> bool obj1Active = false, obj2Active = false
> 
> body1 = dGeomGetBody(geom1)
> body2 = dGeomGetBody(geom2)
> 
> if (body1)
>   obj1Active = GetBodyDisabled(body1)
> if (body2)
>   obj2Active = GetBodyDisabled(body2)
> 
> if (!obj1Active && !obj2Active)
>    return

To expand on that, sometimes you might want collisions generated
between two static geoms (without bodies).  For example, if your
camera/player uses a static geom and you want to use collision
detection to trigger certain events.  In case anyone is interested,
these are the cases that I check in my collision callback:

1. two static objects (neither geom has a body)
2. two geoms that are part of the same object (they share a body)
3. two sleeping objects
4. two joined objects (but not joined with contact joints)
5. object1 is static and object2 is sleeping
6. object1 is sleeping and object2 is static

Each of these situations generates an early-out.  Note that cases 5
and 6 will keep static solids from waking up sleeping solids.  This is
a problem if your static geom camera/player bumps into sleeping
objects but can save CPU time in some situations (e.g. huge outdoor
scenes with tons of static objects and potentially sleeping objects).

Are there any other cases people check to jump out of collision checks early?

Tyler


More information about the ODE mailing list