globalPolygons method
The vertices of each polygon in the global coordinate system, see PolygonComponent.globalVertices.
Implementation
List<List<Vector2>> globalPolygons() {
final scale = absoluteScale;
final shouldReverse = scale.y.isNegative ^ scale.x.isNegative;
final angle = absoluteAngle;
final position = absoluteTopLeftPosition;
if (!_cachedGlobalPolygons.isCacheValid<dynamic>(<dynamic>[
position,
size,
scale,
angle,
])) {
for (var i = 0; i < _polygons.length; i++) {
final polygon = _polygons[i];
final globalPolygon = _globalPolygons[i];
for (var j = 0; j < polygon.length; j++) {
globalPolygon[j].setFrom(absolutePositionOf(polygon[j]));
}
if (shouldReverse) {
// Since the list will be clockwise we have to reverse it for it to
// become counterclockwise.
globalPolygon.reverse();
}
}
_cachedGlobalPolygons.updateCache<dynamic>(_globalPolygons, <dynamic>[
position.clone(),
size.clone(),
scale.clone(),
angle,
]);
}
return _cachedGlobalPolygons.value!;
}