intersect method
Set<Vector2>
intersect(
- PolygonComponent polygonA,
- PolygonComponent polygonB, {
- Rect? overlappingRect,
override
Returns the intersection points of polygonA
and polygonB
The two polygons are required to be convex
If they share a segment of a line, both end points and the center point of
that line segment will be counted as collision points
Implementation
@override
Set<Vector2> intersect(
PolygonComponent polygonA,
PolygonComponent polygonB, {
Rect? overlappingRect,
}) {
final intersectionPoints = <Vector2>{};
final intersectionsA = polygonA.possibleIntersectionVertices(
overlappingRect,
);
final intersectionsB = polygonB.possibleIntersectionVertices(
overlappingRect,
);
for (final lineA in intersectionsA) {
for (final lineB in intersectionsB) {
intersectionPoints.addAll(lineA.intersections(lineB));
}
}
return intersectionPoints;
}