updateProxy method

  1. @override
void updateProxy()
override

Update the proxy of the shape.

Implementation

@override
void updateProxy() {
  List<double> te = rotation.elements;
  double len, wx, hy, dz, xx, yy, zz, w, h, d, p;

  xx = te[1] * te[1];
  yy = te[4] * te[4];
  zz = te[7] * te[7];

  normalDirection.set( te[1], te[4], te[7] );
  halfDirection.scale(normalDirection, halfHeight);

  wx = 1 - xx;
  len = math.sqrt(wx*wx + xx*yy + xx*zz);
  if(len>0) len = radius/len;
  wx *= len;
  hy = 1 - yy;
  len = math.sqrt(yy*xx + hy*hy + yy*zz);
  if(len>0) len = radius/len;
  hy *= len;
  dz = 1 - zz;
  len = math.sqrt(zz*xx + zz*yy + dz*dz);
  if(len>0) len = radius/len;
  dz *= len;

  w = halfDirection.x < 0 ? -halfDirection.x : halfDirection.x;
  h = halfDirection.y < 0 ? -halfDirection.y : halfDirection.y;
  d = halfDirection.z < 0 ? -halfDirection.z : halfDirection.z;

  w = wx < 0 ? w - wx : w + wx;
  h = hy < 0 ? h - hy : h + hy;
  d = dz < 0 ? d - dz : d + dz;

  p = aabbProx;

  aabb.set(
    position.x - w - p, position.x + w + p,
    position.y - h - p, position.y + h + p,
    position.z - d - p, position.z + d + p
  );

  if(proxy != null) proxy!.update();
}