i
i
i
i
i
i
i
i
804 17. Collision Detection
is illustrated in Figure 17.8. To make an efficient tree, an insertion point
in the tree must be found. This point should be selected so that the total
tree volume increase is minimized. A simple method for doing this is to
descend to the child that gives a smaller increase in the tree. This kind
of algorithm typically takes O(n log n) time. Randomizing the ordering
in which primitives are inserted can improve tree formation [417]. For
more sophisticated methods, see Omohundro’s work [966]. Little is known
about incremental tree-insertion in the context of collision detection, but
it has been used with good results in ray tracing [417] and in intersection
queries [966], so it probably works well for collision detection, too.
The top-down approach, which is used by the majority of hierarchy
construction algorithms, starts by finding a BV for all primitives of the
model, which then acts as the root of the tree. Then a divide-and-conquer
strategy is applied, where the BV is first split into k or fewer parts. For each
such part, all included primitives are found, and then a BV is created in the
same manner as for the root, i.e., the hierarchy is created recursively. It is
most common to find some axis along which the primitives should be split,
and then to find a good split point on this axis. In Section 16.4 geometric
probability is discussed, and this can be used when searching for a good split
point, which will result in better BVHs. Note that a potential advantage
of the top-down approach is that a hierarchy can be created lazily, i.e., on
an as-needed basis. This means that we construct the hierarchy only for
those parts of the scene where it is actually needed. But since this building
process is performed during runtime, whenever a part of the hierarchy is
created, the performance may go down significantly. This is not acceptable
for applications such as games with real-time requirements, but may be a
great time and memory saver for CAD applications or off-line calculations
such as path planning, animation, and more.
One challenge for CD algorithms is to find tight-fitting bounding vol-
umes and hierarchy construction methods that create balanced and efficient
trees. Note that balanced trees are expected to perform best on average
in all cases, since the depth of every leaf is the same (or almost the same).
This means that it takes an equal amount of time to traverse the hierarchy
down to any leaf (i.e., a primitive), and that the time of a collision query
will not vary depending on which leaves are accessed. In this sense, a bal-
anced tree is optimal. However, this does not mean that it is best for all
inputs. For example, if part of a model will seldom or never be queried for
a collision, then those parts can be located deep in an unbalanced tree, so
that the parts that are queried most often are closer to the root [434]. The
details of this procedure for an OBB tree is described on page 809.
Note also that several spatial data structures are described in relation
to accelerations algorithms in Section 14.1, and that BV creation is treated
in Section 16.3.