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

Nguyen Binh ngbinh at glassegg.com
Wed May 26 16:33:35 MST 2004


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,

---------------------------------------------------------------------
   Nguyen Binh
   Software Engineer
   Glass Egg Digital Media
   
   E.Town Building  
   7th Floor, 364 CongHoa Street
   Tan Binh District,
   HoChiMinh City,
   VietNam,

   Phone : +84 8 8109018
   Fax   : +84 8 8109013

     www.glassegg.com
---------------------------------------------------------------------



More information about the ODE mailing list