void fillPointFaceBoxBox( const CollisionBox &one, const CollisionBox &two, const Vector3 &toCentre, CollisionData *data, unsigned best, real pen ) { // This method is called when we know that a vertex from // box two is in contact with box one. Contact* contact = data->contacts; // We know which axis the collision is on (i.e. best), // but we need to work out which of the two faces on // this axis. Vector3 normal = one.getAxis(best); if (one.getAxis(best) * toCentre > 0) { normal = normal * -1.0f; } // Work out which vertex of box two we're colliding with. // Using toCentre doesn't work! Vector3 vertex = two.halfSize; if (two.getAxis(0) * normal < 0) vertex.x = -vertex.x; if (two.getAxis(1) * normal < 0) vertex.y = -vertex.y; if (two.getAxis(2) * normal < 0) vertex.z = -vertex.z; // Create the contact data contact->contactNormal = normal; contact->penetration = pen; contact->contactPoint = two.getTransform() * vertex; contact->setBodyData(one.body, two.body, data->friction, data->restitution); }