Game Development Reference

In-Depth Information

struct
ContactPoint

{
Vector
point;
// world
−
space contact point

Vector
normal;
// from object
B
to object
A

float
penetration;
// negative for separated objects

}

Listing 4.1.
A contact point.

affect the torques or angular impulses acting on the contacting bodies. Physical

simulation is discrete and must accommodate small errors. The rigid bodies may

penetrate (or not exactly touch, but be very close) at the point of contact.

Coordinates of the point of contact, the normal, and the penetration are the

main components of a contact point.

Collision response (the reaction, or how the objects bounce off of each other)

depends on relative velocities or accelerations at the point of contact (the action,

or how the objects push each other). This response is computed in the solver (see

Section 4.3), where it's better not to access the geometric shape data (vertices,

edges, faces) for performance reasons. Computing penetration at a point is non-

trivial and requires the knowledge of the geometric shape [Ganjugunte 07]. This

is why
penetration
is part of the
ContactPoint
structure in Listing 4.1.

Relative velocity and acceleration aren't in the
ContactPoint
structure,

although they could be. They are easy to compute in the solver, thus trading CPU

for memory bandwidth. And a discrete collision-detection routine doesn't need

access to velocity or accelerations.

A contact manifold is a set of contact points between a pair of objects. It's

not necessary to generate all contact points, only the corners of the contact shape

is enough. More specifically, for any set of contact points with the same friction

cone, it's enough to only generate the points forming a convex hull enclosing all

the other points; for example, all of the shapes in Figure 4.1 should ideally have

just four contact points generated, which are shown by their normal vectors. The

shape in Figure 4.1(d) is very irregular, and the contact area's convex hull is a

slightly rounded rectangle, but for a game simulation, it's still best approximated

by a rectangle. Some useless contacts from the interior of the convex hull are

marked with the

symbol. They don't contribute to the contact area/volume

convex hull (the wavy shapes), assuming their friction cones are the same. They

eat up time during the dynamic solver stage, and although an iterative solver may

be more stable with them, they generally need to be culled.

∅