
314 Chapter 13 Generating Contacts
)
{
// Make sure we have contacts.
if (data->contactsLeft <= 0) return 0;
// Check for intersection.
if (!IntersectionTests::boxAndHalfSpace(box, plane))
{
return 0;
}
// We have an intersection, so find the intersection points. We can
make
// do with only checking vertices. If the box is resting on a plane
// or on an edge, it will be reported as four or two contact points.
// Go through each combination of + and - for each half-size.
static real mults[8][3] = {{1,1,1},{-1,1,1},{1,-1,1},{-1,-1,1},
{1,1,-1},{-1,1,-1},{1,-1,-1},{-1,-1,-1}};
Contact* contact = data->contacts;
unsigned contactsUsed = 0;
for (unsigned i = 0; i