getMassData method

void getMassData (MassData data)

Get the mass data of the body. The rotational inertia is relative to the center of mass.

@return a struct containing the mass, inertia and center of the body.

Implementation

void getMassData(MassData data) {
  // data.mass = _mass;
  // data.I = _I + _mass * Vec2.dot(_sweep.localCenter, _sweep.localCenter);
  // data.center.set(_sweep.localCenter);

  data.mass = _mass;
  data.I = _I +
      _mass *
          (_sweep.localCenter.x * _sweep.localCenter.x +
              _sweep.localCenter.y * _sweep.localCenter.y);
  data.center.x = _sweep.localCenter.x;
  data.center.y = _sweep.localCenter.y;
}