Game Development Reference
In-Depth Information
Our first guiding principle is that, although we know that in reality a
very large force acts for a short period of time, the period of time is so short
relative to our time step that we will consider the collision response to occur
instantaneously. That is, we will not be calculating a force, but rather an
impulse, which will result in an instantaneous change in momentum of the
objects.
The second guiding principle is given to us by Newton's third law: what-
ever (impulsive) force is applied to one object, the opposite force must be
applied to the other object. The conservation of momentum law essentially
says the same thing: if we change the momentum of one object, we must
make the opposite change in momentum to the other object so that the
total momentum of the system after the collision is the same as the total
momentum before the collision.
Thus, to resolve a collision between two objects, the game plan is to
compute an impulse with the proper magnitude and apply that impulse to
both objects, but in opposite directions. An impulse is a vector quantity,
and so we need to know its magnitude and direction. The direction is given
to us already: it is the surface normal provided by the collision detection
system. The details of selecting a surface normal is a matter of collision
detection, not response, and will not be discussed here. But notice that
if the objects move parallel to this normal, they are either making the
problem worse (penetrating further) or better (moving apart and resolving
the penetration). In contrast, if we assume the penetration distance is
relatively small and the surfaces are locally flat and perpendicular to the
normal near the point of contact, then any motion perpendicular to the
surface normal does not cause the penetration distance to change. So the
surface normal is really the only direction that matters.
In summary, our task is to determine the proper magnitude of an im-
pulse that will be directed along the surface normal and will resolve (or
prevent) the penetration. To merely prevent a penetration that has not yet
occurred, we need only remove any relative velocity acting parallel to the
surface normal. This portion of the relative velocity is the velocity that, if
applied to move the objects forward in time, would result in penetration.
Any relative velocity acting perpendicular to the normal is OK and does
not need to be counteracted, according to our assumption that the surfaces
are locally flat near the point of contact. As illustrated in Figure 12.13, the
velocity of m 1 relative to m 2 is computed as v rel = v 1 v 2 , and the length
of this projection onto the normal is given by n v rel .
Canceling the relative velocity will prevent penetration, but it's not al-
ways the correct response. When objects collide, they don't just come to
a stop next to each other—they bounce off each other. So we're missing
an ingredient that describes the difference in the collision responses of a
dropped beanbag and a dropped SuperBall. A simple and popular collision
Search WWH ::




Custom Search