Game Development Reference
One approach is to handle these contacts one by one, making sure each works
well on its own. This is called the “iterative approach,” and it has the advantage of
speed. Each contact is fast to resolve, and with only a few tens of contacts the whole
set can be resolved quickly. It has the downside that one contact can affect another,
and sometimes these interactions can be significant. This is the easiest approach to
implement and can form the basis of more complex methods. It is the technique we
will use in the engine in this topic.
A more physically realistic way is to calculate the exact interaction between differ-
ent contacts and calculate an overall set of effects to apply to all objects at the same
time. This is called a “Jacobian-based” approach, but it suffers from being very time
consuming: the mathematics involved is very complex, and solving the equations can
involve millions of calculations. Even worse, in some cases there is simply no valid an-
swer, and the developer needs to add special code to fall back on when the equations
can't be solved. Several physics middleware packages use this approach, and each has
its own techniques for solving the equations and dealing with inconsistencies.
A third option is to calculate a new set of equations based on the contacts and
constraints between objects. Rather than use Newton's laws of motion, we can cre-
ate our own set of laws for just the specific configuration of objects we are dealing
with. These equations will be different for every frame, and most of the effort for
the physics engine goes into creating them (even though solving them is no picnic
either). This is called a “reduced coordinate approach.” Some physics systems have
been created with this approach, and it is the most common one used in engineering
software to do really accurate simulation. Unfortunately, it is very slow and isn't very
useful in games applications, where speed and believability are more important than
We'll return to other approaches in chapter 18, after we've looked at the physics
involved in the first approach.
I MPULSES AND F ORCES
The third distinction lies in how the engine actually resolves contacts. This takes a
little explaining, so bear with me.
When a book rests on a table, the table is pushing it upward with a force equal
to the gravity pulling it down. If there were no force from the table to the topic, then
the topic would sink into the table. This force is constantly pushing up on the topic
as long as it is sitting there. The speed of the topic doesn't change.
Contrast this with the way a ball bounces on the ground. The ball collides with the
ground, the ground pushes back on the ball, accelerating it upward until it bounces
back off the floor with an upward velocity. This change in velocity is caused by a force,
but the force acts for such a small fraction of a second that it is easier to think of it as
simply a change in velocity. This is called an “impulse.”
Some physics engines use forces for resting contacts and impulses for collisions.
This is relatively rare because it involves treating forces and impulses differently. More