[ODE] Improved plane AABB

Andres James andres.james+ode at gmail.com
Sat Aug 19 20:36:39 MST 2006


Makes axis-aligned planes more efficient in sweep and prune collision spaces:

void dxPlane::computeAABB()
{
  aabb[0] = -dInfinity;
  aabb[1] = dInfinity;
  aabb[2] = -dInfinity;
  aabb[3] = dInfinity;
  aabb[4] = -dInfinity;
  aabb[5] = dInfinity;

  // planes that have normal vectors aligned along an axis can use a
  // less comprehensive (half space) bounding box.
  if (p[1] == 0.0f && p[2] == 0.0f) {
    // normal aligned with x-axis
    aabb[0] = (p[0] > 0) ? -dInfinity : -p[3];
    aabb[1] = (p[0] > 0) ? p[3] : dInfinity;
  } else
  if (p[0] == 0.0f && p[2] == 0.0f) {
    // normal aligned with y-axis
    aabb[2] = (p[1] > 0) ? -dInfinity : -p[3];
    aabb[3] = (p[1] > 0) ? p[3] : dInfinity;
  } else
  if (p[0] == 0.0f && p[1] == 0.0f) {
    // normal aligned with z-axis
    aabb[4] = (p[2] > 0) ? -dInfinity : -p[3];
    aabb[5] = (p[2] > 0) ? p[3] : dInfinity;
  }
}


More information about the ODE mailing list