Figure: (a) Ray object intersection (b) Ray object intersection with objects
enclosed in bounding volumes
In figure
(a) the two rays are tested against all the objects in
the scene, whereas in figure
(b), the rays are tested against
all the bounding volumes and only tested against objects C and E.
With collision detection, interpenetration between bounding volumes is tested
for instead of ray intersections.
As mentioned before, the advantage of using simple bounding volumes to enclose
complex objects is due to the computationally less expensive intersection
testing needed for the bounding volume. However, in choosing a bounding volume,
the simplicity of the intersection test shouldn't be the sole criteria for
selection. For example, spheres are a commonly used bounding volume because
of the ease of interpenetration testing. However if the object is a long thin
object (eg. a cylindrical shape), then the sphere encloses a great deal of
empty space. Any penetration by a ray (or object) into this empty space causes
unnecessary testing of the object enclosed by the bounding volume. This problem
can be alleviated by using tighter fitting bounding volumes
(See figure
).
Figure: (a) Spherical bounding volume resulting in unnecessary test (b)
Tighter bounding volume which eliminates the unnecessary test
As the bounding volume that encloses an object gets tighter, the number of needless intersection tests with the object decreases. However, the computational complexity of testing for penetration of the bounding volume increases. At one extreme, the number of unnecessary object tests can be eliminated by having the bounding volume fit the exact shape of the object so that the bounding volume test complexity is that of the original object --- which is what we wanted to avoid in the first place. At the other extreme, the bounding volume can enclose all of object space so that the bounding volume test is at its most simplest --- a constant yes. Again this will lead to the expensive object test being carried out in all cases. Therefore the choice of a bounding volume will fall somewhere between the two extremes, and is a compromise between simplicity of the bounding volume test, and tightness of fit.
Simply putting bounding volumes around all objects doesn't reduce the number of objects tested --- just the average time complexity of testing. Objects that are actually intersected have the cost of this test increased because of the extra test for the bounding volume; but this increase is more than made up for by the savings obtained by the decrease in the number of expensive full object intersection tests carried out.
To reduce the number of objects each object is tested against, hierarchical
bounding volumes
can be used. Individual objects have bounding volumes, and objects that are
close to each other are put together into groups within larger bounding
volumes, and these groups can themselves be placed together (if sufficiently
close enough) and enclosed in bounding volumes, and so on. This produces a
tree structure with the root node being a volume that encloses all of the
object space. The number of objects tested against is reduced in this scheme
because If a ray fails to
intersect a bounding volume, then it doesn't need to be tested against all
the bounding volumes and objects enclosed within it (see figure
).
Figure: Objects enclosed in hierarchical bounding volumes and the
secondary tree structure.
Setting up an efficient hierarchical bounding volume structure can be difficult and quite expensive (optimal bounding volume type, which objects/volumes are ``close'' enough to be grouped together, etc.) and according to Watt [WW92], requires considerable user investment. However Goldsmith and Salmon [GS87] presented a method for the automatic creation of a hierarchy based on heuristics.
Hierarchical bounding volume structures impose an ordering on a scene that allows a ray (which isn't part of the object database) to efficiently ``interact'' with the scene. The structure is constructed to be of optimum use to a ray, or a ``foreign'' object that isn't part of the structure. What about the usefulness of the structure to objects within the structure itself?
At a given node in the hierarchical tree structure, collision detection is only carried out between objects and other objects. Object against group testing, and group against group testing isn't carried out because in these cases the elements are disjoint. If two groups aren't disjoint, then this implies that some of the elements in the groups are close enough that they should have been grouped together, so the two groups should really be one. A similar argument holds for the case of object-group testing. Therefore at a node, only the objects within the node need be considered. In this way, the hierarchical bounding volume scheme reduces the number of object-object tests that need to be carried out when testing for object collisions.
Generally though, hierarchical bounding volume schemes aren't of much use for collision detection purposes. This is because in ray tracing, more time can be invested in setting up an efficient structure at the start of the ray tracing process, as this structure will be used throughout the rest of the process and doesn't change. With collision detection however, objects are moving and changing positions and orientations, so that the structure will possibly need to be altered after each time step. As noted before, creation of the hierarchical structure is a very expensive process, and can in some circumstances be difficult or impossible [WW92]. Having to create or alter the structure at every time step would clearly be too expensive.
The reduction in the number of objects tested against each other (outlined above) is really due to spatial coherence, rather than the bounding volume hierarchy.