calculateMassInfo method

  1. @override
void calculateMassInfo(
  1. MassInfo out
)
override

Calculate the mass information of the shape.

Implementation

@override
void calculateMassInfo(MassInfo out ){
  /// I guess you could calculate box mass and split it
  /// in half for the tetra...
  aabb.setFromPoints(verts);
  List<double> p = aabb.elements;
  double x = p[3] - p[0];
  double y = p[4] - p[1];
  double z = p[5] - p[2];
  double mass = x * y * z * density;
  double divid = 1/12;
  out.mass = mass;
  out.inertia.set(
    mass * ( 2*y*2*y + 2*z*2*z ) * divid, 0, 0,
    0, mass * ( 2*x*2*x + 2*z*2*z ) * divid, 0,
    0, 0, mass * ( 2*y*2*y + 2*x*2*x ) * divid
  );
}