// float FindMinSeparation(int* indexA, int* indexB, float t) const
public float FindMinSeparation(int[] indexes, float t)
{
SweepA.GetTransform(xfa, t);
SweepB.GetTransform(xfb, t);
switch (Type)
{
case Type.Points:
{
Rot.MulTransUnsafe(xfa.Q, Axis, axisA);
Rot.MulTransUnsafe(xfb.Q, Axis.NegateLocal(), axisB);
Axis.NegateLocal();
indexes[0] = ProxyA.GetSupport(axisA);
indexes[1] = ProxyB.GetSupport(axisB);
localPointA.Set(ProxyA.GetVertex(indexes[0]));
localPointB.Set(ProxyB.GetVertex(indexes[1]));
Transform.MulToOutUnsafe(xfa, localPointA, pointA);
Transform.MulToOutUnsafe(xfb, localPointB, pointB);
float separation = Vec2.Dot(pointB.SubLocal(pointA), Axis);
return(separation);
}
case Type.FaceA:
{
Rot.MulToOutUnsafe(xfa.Q, Axis, normal);
Transform.MulToOutUnsafe(xfa, LocalPoint, pointA);
Rot.MulTransUnsafe(xfb.Q, normal.NegateLocal(), axisB);
normal.NegateLocal();
indexes[0] = -1;
indexes[1] = ProxyB.GetSupport(axisB);
localPointB.Set(ProxyB.GetVertex(indexes[1]));
Transform.MulToOutUnsafe(xfb, localPointB, pointB);
float separation = Vec2.Dot(pointB.SubLocal(pointA), normal);
return(separation);
}
case Type.FaceB:
{
Rot.MulToOutUnsafe(xfb.Q, Axis, normal);
Transform.MulToOutUnsafe(xfb, LocalPoint, pointB);
Rot.MulTransUnsafe(xfa.Q, normal.NegateLocal(), axisA);
normal.NegateLocal();
indexes[1] = -1;
indexes[0] = ProxyA.GetSupport(axisA);
localPointA.Set(ProxyA.GetVertex(indexes[0]));
Transform.MulToOutUnsafe(xfa, localPointA, pointA);
float separation = Vec2.Dot(pointA.SubLocal(pointB), normal);
return(separation);
}
default:
Debug.Assert(false);
indexes[0] = -1;
indexes[1] = -1;
return(0f);
}
}