I am doing SAT in 3D, right now just between cuboids/3D rects (idk the terminology). I have intersection working fully, and static collision works as long as the projection axis is not zero. But if it is zero, I am unsure how to get the minimum translation vector and overlap.
Here is the function which returns the face normals, vertices are ordered counter-clockwise starting bottom left - z for face 1, then repeat for +z, where 4 is bottom left +z:
private float3[] GetAxesFromPoly( float3[] vertices )
{
float3[] axes = new float3[ 3 ];
axes[ 0 ] = math.normalize( ( vertices[ 1 ] - vertices[ 0 ] ) );
axes[ 1 ] = math.normalize( ( vertices[ 3 ] - vertices[ 0 ] ) );
axes[ 2 ] = math.normalize( ( vertices[ 4 ] - vertices[ 0 ] ) );
return axes;
}
And here is all axes I get to test:
float3[] axesA = GetAxesFromPoly( vertsA );
float3[] axesB = GetAxesFromPoly( vertsB );
float3[] allAxes = new float3[ 15 ];
allAxes[ 0 ] = axesA[ 0 ];
allAxes[ 1 ] = axesA[ 1 ];
allAxes[ 2 ] = axesA[ 2 ];
allAxes[ 3 ] = axesB[ 0 ];
allAxes[ 4 ] = axesB[ 1 ];
allAxes[ 5 ] = axesB[ 2 ];
allAxes[ 6 ] = math.cross( axesA[ 0 ] , axesB[ 0 ] );
allAxes[ 7 ] = math.cross( axesA[ 0 ] , axesB[ 1 ] );
allAxes[ 8 ] = math.cross( axesA[ 0 ] , axesB[ 2 ] );
allAxes[ 9 ] = math.cross( axesA[ 1 ] , axesB[ 0 ] );
allAxes[ 10 ] = math.cross( axesA[ 1 ] , axesB[ 1 ] );
allAxes[ 11 ] = math.cross( axesA[ 1 ] , axesB[ 2 ] );
allAxes[ 12 ] = math.cross( axesA[ 2 ] , axesB[ 0 ] );
allAxes[ 13 ] = math.cross( axesA[ 2 ] , axesB[ 1 ] );
allAxes[ 14 ] = math.cross( axesA[ 2 ] , axesB[ 2 ] );
```