In games at some point you will need mesh intersections, you might say "but I have boxes and spheres and pills" and your artists are going to say "Screw you!!!" and that is sometimes bad.
This class is a modified version of my ThreadSafeBoundingFrustum class from this article multithreading the BoundingFrustum post .
You can find at the bottom of the page the transformed class, the most important difference is the SupportMapping function that generates the point for the simplex :
internal void SupportMapping(ref Vector3 v, out Vector3 result)
Vector3.Transform(ref this.VerticesData, ref this.transform, out worldSpaceConvexData0);
int index = 0;
Vector3.Dot(ref worldSpaceConvexData0, ref v, out num3);
for (int i = 1; i < this.VerticesData.Length; i++)
Vector3.Transform(ref this.VerticesData[i], ref this.transform, out worldSpaceConvexDataI);
Vector3.Dot(ref worldSpaceConvexDataI, ref v, out num2);
if (num2 > num3)
index = i;
num3 = num2;
(ref this.VerticesData[index], ref this.transform,out worldSpaceConvexDataI);
result = worldSpaceConvexDataI;
The main thing changed is that we no longer test a limited 4 elements array we test against a list
this.VerticesData and we transform the point from local space to world space by multiplying
the given point with a transform that we store for each convex collision mesh.
Here is the code transformed for you to use in your projects, it's on Microsoft SkyDrive(if you have an account and you are not logged in you might not see them):