setAsBoxXY method

void setAsBoxXY(
  1. double halfWidth,
  2. double halfHeight
)

Build vertices to represent an axis-aligned box.

Implementation

void setAsBoxXY(double halfWidth, double halfHeight) {
  vertices.clear();
  vertices.addAll([
    Vector2(-halfWidth, -halfHeight),
    Vector2(halfWidth, -halfHeight),
    Vector2(halfWidth, halfHeight),
    Vector2(-halfWidth, halfHeight),
  ]);
  normals.clear();
  normals.addAll([
    Vector2(0.0, -1.0),
    Vector2(1.0, 0.0),
    Vector2(0.0, 1.0),
    Vector2(-1.0, 0.0),
  ]);
  centroid.setZero();
}