Game Development Reference

In-Depth Information

Edge-Edge Contact Generation

Determining edge-edge contacts is not much more complex. We again take each edge

from one object in turn and check it against the other object. In this case we check it

against edges in the other object.

We can easily calculate the distance between the two edges, but the distance alone

doesn't tell us whether the edges are separated by that distance or interpenetrating by

that distance. We need to add an extra check. The distance calculation also provides us

with the point on each edge that is closest to the other edge. If the edges are interpen-

etrating, then this point on object A will be closer to the center of object B than ob-

ject B's edge point, and vice versa. Figure 13.19 illustrates this. We use this check to de-

termine the sign of the distance and to work out whether it is interpenetrating or not.

Just as we saw in figure 13.18 for point-face contacts, an edge-edge contact will

be detected for multiple edges. We only need to use the shallowest edge-edge contact.

The algorithm works in this way:

1.
Consider each edge E of object A.

2.
Work out its interpenetration with each edge of object B.

3.
The shallowest such interpenetration is the interpenetration of E.

4.
The edge from object A with the deepest such interpenetration is retained.

We don't need to repeat the process from object B's point of view because we are

checking edges against edges; we will have checked all edge combinations already.

F
IGURE
13.19

Determining edge-edge contacts.