[ODE] Performance patch : not checking collision between disabled bodies

Oles V. Shishkovtsov oles at gsc-game.kiev.ua
Wed May 26 17:22:34 MST 2004


Hello Joe,

This is exactly the same thing as we do in S.T.A.L.K.E.R. :)
And I have to admit it works really well, so it is proven to work.

And another one thing to note: enabling can be done at collision
level, that way you don't have any issues with bodies enabled after
collision phase and missing contact info for one physics step.

BTW, what is the current situation with joint-feedback in quick-step?
Russ?

JA> I think this optimization should be handled at a different level.

JA> CollideAABBs happens after broad-phase culling, so essentially if you have
JA> large scenes with a lot of static geometry and lot of sleeping bodies, you
JA> will still waste a lot of time in the broad phase culling.

JA> In my opinion a better solution is to use two spaces.
JA> A disabled space and and enabled space.

JA> When objects begin sleeping they are moved to the disabled space.
JA> When objects awake they are moved into the enabled space.

JA> Then you collide the enabledspace with itself.
JA> And the enabledspace with the disabled space.
JA> But you don¹t collide any disabled objects with each other.

JA> For a typical game like situation eg. First person shooters lots of static
JA> geometry and lots of sleeping bodies and few moving rigid bodies is normal.

JA> Thus broad phase culling can become a major factor and it has been in one of
JA> the projects I have worked on with ode.

JA> I have implemented the enable / disable callback functions in ode.
JA> In the disable / enable callbacks I add remove the geoms from
JA> enabled/disabled space.

JA> Once that is working the performance optimization you propose will not be
JA> necessary anymore thus I think it could just as well be left out. (Aside
JA> from that you can do the same test inside near callback if you want to.)

JA> Joe Ante
JA> www.otee.dk

>> Hi Russ,
>> 
>>  Another performance patch.
>> 
>>  The situation is:
>>  Now, ODE checks collision between all objects in the scene even
>>  between two disabled bodies.
>> 
>>  Here is a small patch for the case :
>>  search in collision_space_internal.h
>> 
>> static void collideAABBs (dxGeom *g1, dxGeom *g2,
>>                         void *data, dNearCallback *callback)
>> {
>> dIASSERT((g1->gflags & GEOM_AABB_BAD)==0);
>> dIASSERT((g2->gflags & GEOM_AABB_BAD)==0);
>> 
>> // no contacts if both geoms on the same body, and the body is not 0
>> if (g1->body == g2->body && g1->body) return;
>> 
>> // Add those lines
>> // no collision between geom of disable body
>> if (g1->body == 0) // g2->body must be != 0 and must not be disable
>> {
>>         if ((g2->body->flags & dxBodyDisabled)!=0)
>>         {
>>                 return;
>>         }
>> }
>> else if (g2->body == 0) // g2->body must be != 0 and must not be disable
>> {
>>         if ((g1->body->flags & dxBodyDisabled)!=0)
>>         {
>>                 return;
>>         }
>> }
>> else
>> {
>>         // two bodies are valid
>>         if (((g2->body->flags & dxBodyDisabled)!=0)
>>                 && ((g1->body->flags & dxBodyDisabled)!=0))
>>         {
>>                 // two bodies are disable so don't bother collide them
>>                 return;
>>         }
>> }
>> // End add code
>> 
>> // test if the category and collide bitfields match
>> if ( ((g1->category_bits & g2->collide_bits) ||
>>       (g2->category_bits & g1->collide_bits)) == 0) {
>>   return;
>> }   
>> 
>> This patch comes with new auto-disable method will boost ODE
>> performance in many real life cases.

-- 
Best regards,
 Oles V. Shishkovtsov
 GSC-Game World
 oles at gsc-game.kiev.ua



More information about the ODE mailing list