[ODE] plane class with half space aabb - the 2nd

Tim Schmidt tisch at uni-paderborn.de
Tue Jul 29 08:36:02 2003


Hi!

I do not want to obtrude myself, but apart from Pierre's positiv 
reaction I haven't got any reply concerning my enhanced 
dxPlane::computeAABB(), which I still consider quite useful.

Because of the fact that probably many people use planes in there 
applications, the use of half spaces as bounding boxes should save a lot 
of expensive collision tests.
Remember that the current version of this function defines the bounding 
box of a plane to be infinite in all directions, which results in 
collision tests with every single object in the world. (I hope that I am 
right with this assertion)

Maybe someone with CVS access can decide, if this function is worth to 
be integrated.

regards,
	Tim


---- (collision_std.cpp:) ----

void dxPlane::computeAABB()
{
   aabb[0] = -dInfinity;
   aabb[1] = dInfinity;
   aabb[2] = -dInfinity;
   aabb[3] = dInfinity;
   aabb[4] = -dInfinity;
   aabb[5] = dInfinity;
   if (p[0] == 0)
   {
     if (p[2] == 0) // plane is xz-plane ... (which is most probable)
     {
       if (p[1] > 0)     // ... and points upwards
       {
         aabb[3] = p[3];
       }
       else              // ... and points downwards
       {
         aabb[2] = -p[3];
       }
     }
     else if (p[1] == 0) // plane is xy-plane
     {
       if (p[2] > 0)     // ... and points towards the viewer
       {
         aabb[5] = p[3];
       }
       else              // ... and points away from the viewer
       {
         aabb[4] = -p[3];
       }
     }
   }
   else if (p[1] == 0)
   {
     if (p[2] == 0) // plane is yz-plane ...
     {
       if (p[0] > 0)     // ... and points to the right
       {
         aabb[1] = p[3];
       }
       else              // ... and points to the left
       {
         aabb[0] = -p[3];
       }
     }
   }
}