void Sphere::Enclose(const Capsule &capsule) { // Capsule is a convex object spanned by the endpoint spheres - enclosing // the endpoint spheres will also cause this Sphere to enclose the middle // section since Sphere is convex as well. float da = pos.DistanceSq(capsule.l.a); float db = pos.DistanceSq(capsule.l.b); // Enclose the farther Sphere of the Capsule first, and the closer one second to retain the tightest fit. if (da > db) { Enclose(capsule.SphereA()); Enclose(capsule.SphereB()); } else { Enclose(capsule.SphereB()); Enclose(capsule.SphereA()); } }