needBroadphaseCollision method

bool needBroadphaseCollision(
  1. Body bodyA,
  2. Body bodyB
)

Check if a body pair needs to be intersection tested at all.

Implementation

bool needBroadphaseCollision(Body bodyA, Body bodyB) {
  // Check collision filter masks
  if (
    (bodyA.collisionFilterGroup & bodyB.collisionFilterMask) == 0 ||
    (bodyB.collisionFilterGroup & bodyA.collisionFilterMask) == 0
  ) {
    return false;
  }

  // Check types
  if (
    (bodyA.type == BodyTypes.static || bodyA.sleepState == BodySleepStates.sleeping) &&
    (bodyB.type == BodyTypes.static || bodyB.sleepState == BodySleepStates.sleeping)
  ) {
    // Both bodies are static or sleeping. Skip.
    return false;
  }

  return true;
}