A "Fast" Method for Culling of Oriented-Bounding
Boxes (OBBs) Against a Perspective Viewing Frustum
in Large "Walkthrough" Models

Kenny Hoff
5/23/96


Given the following preconditions:

We can perform a fast overlap test of the OBB and the viewing frustum by keeping a few simple guidelines in mind:

Now given a viewing-frustum (VF) and a single OBB here is the proposed implementation:

  1. Calculate the eight vertices of the OBB using the OBB axes and extents along these axes.
  2. Create a "in-out" 6-bit sequence (LRTBNF for left, right, top, bottom, near, and far respectively) for each vertex that is used to determine the vertex's location with respect to the six planes of the viewing-frustum (a set bit means it is "outside" of that respective plane). Initialize this sequence to zero for each vertex.
  3. Go for trivial rejection by repeating the following steps for each plane in the viewing frustum or until rejected. Process the planes in the following order: near, left, right, bottom, top, far (this order can be chosen arbitrarily, but we must try to eliminate OBBs as early as possible; it seems logical to proceed in this order for large models in which the viewer is totally immersed):
    1. "encode" the eight vertices (by properly setting the appropriate bit) as either "inside" or "outside" the current plane being tested. This simply involves the evaluation of the plane equation for each vertex (Ax+By+Cz+D : three multiplies and three adds), and we only need to know the sign of the result.
    2. if the logical AND of all eight of the 6-bit sequences is not equal to zero, then it is trivially REJECTED.
  4. By now, if the OBB was not trivially rejected, the 6-bit sequence should be properly encoded with respect to all six planes (remembering not to reset the sequence for each new plane being tested for in the trivial rejection tests). If ANY of the sequences equals zero, we can trivially ACCEPT (we must do so upon encountering the FIRST occurance).
  5. Now we must handle the three special cases:
    1. Test for frustum protrusion through an OBB face by checking each edge in the frustum (12 edges) for intersection with a polygonal face of the OBB. We can determine overlap upon the first occurance of an edge that intersects a single face of the OBB. So take each frustum edge in turn and check it against each face in the OBB. If all of the OBB faces miss the edge move on to the next frustum edge. It is possible to determine overlap, in best case, in one edge-face intersection test; and in worst case, 12 x 6 = 72 tests.
    2. If the frustum protrusion fails, check for containment of the frustum inside the OBB by just checking if the origin of the frustum (assuming viewplane lies between near and far planes) is inside the OBB. If the frustum is inside the OBB, then they most definitely overlap (ACCEPT). This requires evaluation of the "in-out" test for each plane of the OBB (six plane equation evaluations).
    3. If both of these test fail, REJECT the OBB because it does not overlap the viewing-frustum.

The special cases are computationally expensive, but should only occur for a small number of OBBs compared to the amount trivally rejected and accepted. The early, most frequent tests are VERY inexpensive requiring as little as 24 multiplies, 24 adds, and 7 logical operations (after computation of vertices) for trivial rejection. One of the most attractive features of this method is the fact that the frustum and OBB are left in their world coordinate orientations, thus eliminating the need for expensive transformations and projections.