rayIntersection method
Returns whether the RaycastResult if the ray intersects the polygon.
If out is defined that is used to populate with the result and then
returned, to minimize the creation of new objects.
Whether the ray starts inside the polygon is decided by the parity of the edges that it crosses, which works for concave polygons as well.
Implementation
RaycastResult<ShapeHitbox>? rayIntersection(
Ray2 ray, {
RaycastResult<ShapeHitbox>? out,
}) {
return intersectPolygon(
ray,
globalVertices(),
hitbox: this as T,
normal: _temporaryNormal,
out: out,
);
}