worldBounds method
This node's world-space AABB for shape, given its already-computed
transform (see absoluteTransform).
The returned AABB is owned by this node and should not be retained.
Implementation
Aabb2 worldBounds(Shape shape, Matrix3 transform) {
final bounds = _lastWorldBounds;
final width = shape.width;
final height = shape.height;
// The anchor rides in the transform, so the shape's center sits at half its
// extent in the node's own space.
_CENTER_SCRATCH
..setValues(width / 2, height / 2)
..transform(transform);
// Compute the shape's half-extents, adjusted for absolute rotation (*not* transform).
_HALF_EXTENTS_SCRATCH
..setValues(width / 2, height / 2)
..absoluteRotate(transform);
bounds.setCenterAndHalfExtents(_CENTER_SCRATCH, _HALF_EXTENTS_SCRATCH);
return bounds;
}