setupInertia method

void setupInertia(
  1. Vec3 tmpV,
  2. bool adjustPosition
)

Implementation

void setupInertia(Vec3 tmpV,bool adjustPosition){
  inverseMass = 1 / mass;
  tmpV.scaleEqual(inverseMass);

  if(adjustPosition){
    position.add(tmpV);
    for(Shape? shape = shapes; shape != null; shape = shape.next){
      shape.relativePosition.subEqual(tmpV);
    }

    // subtract offset inertia
    localInertia.subOffset(mass, tmpV );
  }

  inverseLocalInertia.invert(localInertia );

  if(isStatic){
    inverseMass = 0;
    inverseLocalInertia.set(0,0,0,0,0,0,0,0,0);
  }

  syncShapes();
  awake();
}