calculateWorldAABB method

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

@todo use abstract for these kind of methods

Implementation

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

  final Vec3 wc = _worldCornersTemp[0];
  quat.vmult(wc, wc);
  pos.vadd(wc, wc);
  max.copy(wc);
  min.copy(wc);
  for (int i = 1; i < 8; i++) {
    final Vec3 wc = _worldCornersTemp[i];
    quat.vmult(wc, wc);
    pos.vadd(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;
    }
  }
}