sphereOverlapsSphere function Physics

bool sphereOverlapsSphere(
  1. Vector3 center,
  2. double radius,
  3. Vector3 otherCenter,
  4. double otherRadius,
)

Whether the closed ball at center of radius overlaps a sphere of otherRadius centered at otherCenter.

Implementation

bool sphereOverlapsSphere(
  Vector3 center,
  double radius,
  Vector3 otherCenter,
  double otherRadius,
) {
  final sum = radius + otherRadius;
  return (center - otherCenter).length2 <= sum * sum;
}