Game Development Reference
problem in such a way so that the solver can find a solution more quickly. Some
engines maintain an explicit graph of how the objects connect, whereas other en-
gines temporarily tweak mass ratios, inertia, or gravity. There is a lot of creativity
in shock propagation, but the artifacts are usually similar.
Large stacks require many iterations because the impulses at the bottom of the
stack are many times bigger than they would be for any pair of objects solved in
isolation. It takes many iterations to build up these large impulses. With shock
propagation, objects at the bottom of a stack will not feel the entire weight of the
objects on top. This can show up as the unnatural behavior of stacks tipping over
and can also be very obvious when observing friction—an object at the bottom of
a stack can be as easily pulled out as one on top.
2.6 Collision Detection
The collision-detection problem is often broken down into two or three phases.
First a broad phase, detecting objects in close proximity, and then sometimes a
mid phase, breaking down structures into smaller parts, before the near phase,
computing the actual contact points.
Broad phase. Let us start with the broad phase, which has a relatively well-
defined task: report overlaps of bounding volumes, most often axis-aligned bound-
ing boxes. If the bounding box is too small, we might experience weird shootouts
as the broad phase reports nonoverlap until the objects are already in penetration.
Having the bounding boxes too big, on the other hand, has a performance impli-
cation, so we have to be sure to make them just right . Remember that if we use
continuous collision detection or intentional separation distance, these must be
included in the bounding-box computation, so that the bounding box is no longer
tight-fitting around the object. These errors can be hard to spot since it looks right
most of the time.
Mid phase. The mid phase often consists of a bounding-volume hierarchy to
find convex objects in close proximity. Again, incorrect bounding-box compu-
tation can lead to shootouts. Another common problem is that objects can get
stuck in between two convex parts of a compound geometry. Consider the object
consisting of two spheres in Figure 2.4. Convex geometries are usually treated in
isolation, causing two conflicting contact points with opposite normals and pene-
tration depths. Feeding this problem to the solver is a dead end—there is no valid
solution! The objects will start shaking violently and act very unstable. There