calculateWorldAABB method

  1. @override
void calculateWorldAABB(
  1. Vector3 pos,
  2. Quaternion quat,
  3. Vector3 min,
  4. Vector3 max,
)
override

@todo use abstract for these kind of methods

Implementation

@override
void calculateWorldAABB(Vector3 pos, Quaternion quat,Vector3 min, Vector3 max) {
  final Vector3 e = halfExtents;
  _worldCornersTemp[0].setValues(e.x, e.y, e.z);
  _worldCornersTemp[1].setValues(-e.x, e.y, e.z);
  _worldCornersTemp[2].setValues(-e.x, -e.y, e.z);
  _worldCornersTemp[3].setValues(-e.x, -e.y, -e.z);
  _worldCornersTemp[4].setValues(e.x, -e.y, -e.z);
  _worldCornersTemp[5].setValues(e.x, e.y, -e.z);
  _worldCornersTemp[6].setValues(-e.x, e.y, -e.z);
  _worldCornersTemp[7].setValues(e.x, -e.y, e.z);

  final Vector3 wc = _worldCornersTemp[0];
  quat.vmult(wc, wc);
  pos.add2(wc, wc);
  max.setFrom(wc);
  min.setFrom(wc);
  for (int i = 1; i < 8; i++) {
    final Vector3 wc = _worldCornersTemp[i];
    quat.vmult(wc, wc);
    pos.add2(wc, wc);
    double x = wc.x;
    double y = wc.y;
    double z = wc.z;
    if (x > max.x) {
      max.x = x;
    }
    if (y > max.y) {
      max.y = y;
    }
    if (z > max.z) {
      max.z = z;
    }

    if (x < min.x) {
      min.x = x;
    }
    if (y < min.y) {
      min.y = y;
    }
    if (z < min.z) {
      min.z = z;
    }
  }
}