doBoundingSphereBroadphase method

void doBoundingSphereBroadphase(
  1. Body bodyA,
  2. Body bodyB,
  3. List<Body> pairs1,
  4. List<Body> pairs2,
)

Check if the bounding spheres of two bodies are intersecting. pairs1 bodyA is appended to this array if intersection pairs2 bodyB is appended to this array if intersection

Implementation

void doBoundingSphereBroadphase(Body bodyA, Body bodyB, List<Body> pairs1, List<Body> pairs2) {
  final r = _broadphaseCollisionPairsR;
  bodyB.position.vsub(bodyA.position, r);
  final boundingRadiusSum2 = math.pow(bodyA.boundingRadius + bodyB.boundingRadius,2);
  final norm2 = r.lengthSquared();
  if (norm2 < boundingRadiusSum2) {
    pairs1.add(bodyA);
    pairs2.add(bodyB);
  }
}