intersectsPlane method

bool intersectsPlane(
  1. Plane plane
)

Implementation

bool intersectsPlane(Plane plane) {
  // check if the ray lies on the plane first

  final distToPoint = plane.distanceToPoint(origin);

  if (distToPoint == 0) {
    return true;
  }

  final denominator = plane.normal.dot(direction);

  if (denominator * distToPoint < 0) {
    return true;
  }

  // ray origin is behind the plane (and is pointing behind it)

  return false;
}