intersectWorld method

bool intersectWorld(
  1. World world,
  2. RayOptions options
)

Do itersection against all bodies in the given World. @return True if the ray hit anything, otherwise false.

Implementation

bool intersectWorld(World world, RayOptions options) {
  mode = options.mode ?? RayMode.any;
  result = options.result ?? RaycastResult();
  skipBackfaces = options.skipBackfaces ?? true;
  collisionFilterMask = options.collisionFilterMask ?? -1;
  collisionFilterGroup = options.collisionFilterGroup ?? -1;
  checkCollisionResponse = options.checkCollisionResponse ?? true;

  if (options.from != null) {
    from.copy(options.from!);
  }
  if (options.to != null) {
    to.copy(options.to!);
  }

  callback = options.callback ?? (RaycastResult result){};
  hasHit = false;

  result.reset();
  _updateDirection();

  getAABB(_tmpAABB);
  _tmpArray.clear();
  world.broadphase.aabbQuery(world, _tmpAABB, _tmpArray);
  intersectBodies(_tmpArray);

  return hasHit;
}