Game Development Reference
F IGURE 16.2
Collisions can be missed if they aren't initially in contact.
when it can be resolved. Single-frame interpenetration isn't normally visible, but if
two or more contacts end up in a cycle, then the object can appear to be vibrating
into the surface.
The only way to deal with this situation is to make collision detection more pes-
simistic. In other words, collision detection should return contacts that are close but
not actually touching. This can be achieved by expanding the collision geometry
around an object and then using an offset for the penetration value. If the collision
geometry is one unit larger than the visual representation of the object, then 1 is sub-
tracted from the penetration value of detected collisions.
In practice it is rare to see any effects of this. The times that I have needed this
kind of modification (which crops up in all physics systems, regardless of the method
of collision resolution), it has been most noticeable in collisions between long, light
objects (such as poles) and the ground. It is a trivial change to move the ground
slightly higher for collision detection and subtract a small amount from generated
C HANGING M ATHEMATICAL A CCURACY
All the mathematics in our engine is being performed with limited mathematical pre-
cision. Floating-point numbers are stored in two parts: a series of significant digits
(called the “mantissa”) and an exponent. This means that numbers with very differ-
ent scales have very different accuracies.
For regular floating-point numbers (i.e., 32-bit on a 32-bit machine), adding
0.00001 to 1 will probably give you the correct answer; but adding 0.0001 to
10,000,000,000 will not. When you have calculations that involve numbers of very
different scales, the effects can be very poor. For example, if you move an object a