computeAABB method

  1. @override
void computeAABB(
  1. AABB aabb,
  2. Transform transform,
  3. int childIndex
)
override

Given a transform, compute the associated axis aligned bounding box for a child shape.

Implementation

@override
void computeAABB(AABB aabb, Transform transform, int childIndex) {
  final tq = transform.q;
  final tp = transform.p;
  final px = tq.cos * position.x - tq.sin * position.y + tp.x;
  final py = tq.sin * position.x + tq.cos * position.y + tp.y;

  aabb.lowerBound.x = px - radius;
  aabb.lowerBound.y = py - radius;
  aabb.upperBound.x = px + radius;
  aabb.upperBound.y = py + radius;
}