Game Development Reference
F IGURE 17.6
The fractures of a concrete block.
// Find out if we're block one or two in the contact structure, and
// therefore what the contact normal is.
cyclone::Vector3 normal = contact.contactNormal;
cyclone::RigidBody *body = contact.body;
if (body != target->body)
body = contact.body;
// Work out where on the body (in body coordinates) the contact is
// and its direction.
cyclone::Vector3 point =
normal = body->getDirectionInLocalSpace(normal);
// Work out the center of the split: this is the point coordinates
// for each of the axes perpendicular to the normal, and 0 for the
// axis along the normal.
point = point - normal * (point * normal);
// Take a copy of the half size, so we can create the new blocks.
cyclone::Vector3 size = target->halfSize;
// Take a copy also of the body's other data.