setTransform method

void setTransform (Vector2 position, double angle)

Set the position of the body's origin and rotation. This breaks any contacts and wakes the other bodies. Manipulating a body's transform may cause non-physical behavior. Note: contacts are updated on the next call to World.step().

@param position the world position of the body's local origin. @param angle the world rotation in radians.

Implementation

void setTransform(Vector2 position, double angle) {
  assert(world.isLocked() == false);
  if (world.isLocked() == true) {
    return;
  }

  _transform.q.setAngle(angle);
  _transform.p.setFrom(position);

  // _sweep.c0 = _sweep.c = Mul(_xf, _sweep.localCenter);
  Transform.mulToOutUnsafeVec2(_transform, _sweep.localCenter, _sweep.c);
  _sweep.a = angle;

  _sweep.c0.setFrom(_sweep.c);
  _sweep.a0 = _sweep.a;

  BroadPhase broadPhase = world._contactManager.broadPhase;
  for (Fixture f = _fixtureList; f != null; f = f._next) {
    f.synchronize(broadPhase, _transform, _transform);
  }
}