Game Development Reference
In-Depth Information
F IGURE 13.4
The relationship between the collision point, collision normal, and penetration
depth.
of possible points. The selection of a point from the many options is largely
arbitrary and doesn't drastically affect the physics.
The collision normal This is the direction in which an impact impulse will be
felt between the two objects. When we saw collisions for non-rotating objects
in chapter 7, this was the direction in which interpenetrating objects should
be moved apart. In some cases (such as point-face contacts) this is simple to
calculate; in other cases it isn't clear which direction the normal should be
in. By convention, the contact normal points from the first object involved
toward the second. We will assume this convention throughout the contact
resolution code in this topic.
The penetration depth This is the amount that the two objects are interpen-
etrating. It is measured along the direction of the collision normal passing
through the collision point, as shown in figure 13.4.
These elements are stored in a contact data structure:
Excerpt from include/cyclone/contacts.h
/**
* A contact represents two bodies in contact. Resolving a
* contact removes their interpenetration, and applies sufficient
* impulse to keep them apart. Colliding bodies may also rebound.
* Contacts can be used to represent positional joints, by making
* the contact constraint keep the bodies in their correct
* orientation.
*/