updateMassProperties method

void updateMassProperties()

Should be called whenever you change the body shape or mass.

Implementation

void updateMassProperties(){
  final halfExtents = _bodyUpdateMassPropertiesHalfExtents;

  invMass = mass > 0 ? 1.0 / mass : 0;
  final I = inertia;
  final fixed =fixedRotation;

  // Approximate with AABB box
  updateAABB();
  halfExtents.set(
    (aabb.upperBound.x - aabb.lowerBound.x) / 2,
    (aabb.upperBound.y - aabb.lowerBound.y) / 2,
    (aabb.upperBound.z - aabb.lowerBound.z) / 2
  );
  Box.calculateInertia(halfExtents, mass, I);

  invInertia.set(
    I.x > 0 && !fixed ? 1.0 / I.x : 0,
    I.y > 0 && !fixed ? 1.0 / I.y : 0,
    I.z > 0 && !fixed ? 1.0 / I.z : 0
  );
  updateInertiaWorld(true);
}