findMinSeparation method

double findMinSeparation(
  1. List<int> indexes,
  2. double t
)

Implementation

double findMinSeparation(List<int> indexes, double t) {
  sweepA.getTransform(_xfa, t);
  sweepB.getTransform(_xfb, t);

  switch (type) {
    case SeparationFunctionType.points:
      _axisA.setFrom(Rot.mulTransVec2(_xfa.q, axis));
      _axisB.setFrom(Rot.mulTransVec2(_xfb.q, axis..negate()));
      axis.negate();

      indexes[0] = proxyA.getSupport(_axisA);
      indexes[1] = proxyB.getSupport(_axisB);

      _localPointA.setFrom(proxyA.getVertex(indexes[0]));
      _localPointB.setFrom(proxyB.getVertex(indexes[1]));

      _pointA.setFrom(Transform.mulVec2(_xfa, _localPointA));
      _pointB.setFrom(Transform.mulVec2(_xfb, _localPointB));

      return (_pointB..sub(_pointA)).dot(axis);
    case SeparationFunctionType.faceA:
      _normal.setFrom(Rot.mulVec2(_xfa.q, axis));
      _pointA.setFrom(Transform.mulVec2(_xfa, localPoint));

      _axisB.setFrom(Rot.mulTransVec2(_xfb.q, _normal..negate()));
      _normal.negate();

      indexes[0] = -1;
      indexes[1] = proxyB.getSupport(_axisB);

      _localPointB.setFrom(proxyB.getVertex(indexes[1]));
      _pointB.setFrom(Transform.mulVec2(_xfb, _localPointB));

      return (_pointB..sub(_pointA)).dot(_normal);
    case SeparationFunctionType.faceB:
      _normal.setFrom(Rot.mulVec2(_xfb.q, axis));
      _pointB.setFrom(Transform.mulVec2(_xfb, localPoint));

      _axisA.setFrom(Rot.mulTransVec2(_xfa.q, _normal..negate()));
      _normal.negate();

      indexes[1] = -1;
      indexes[0] = proxyA.getSupport(_axisA);

      _localPointA.setFrom(proxyA.getVertex(indexes[0]));
      _pointA.setFrom(Transform.mulVec2(_xfa, _localPointA));

      return (_pointA..sub(_pointB)).dot(_normal);
    default:
      assert(false);
      indexes[0] = -1;
      indexes[1] = -1;
      return 0.0;
  }
}