Hello. I recently implemented the GJK algorithm for collision detection in my 3D engine, basing my implementation on a great video located here. The algorithm is robust, and seems to work for all convex objects and all cases so far. Now I need to determine the contact point, normal, and penetration depth of the collision. EPA seems like a good algorithm for this, because it uses the same principles of the Minkowski Sum and support mappings that GJK does.
Here are the only two resources I have been able to find that give much detail about EPA...
The idea behind EPA is very simple. It starts with the tetrahedron simplex that GJK terminates with. It then projects the origin onto each triangle of the simplex. Lets call this point v. It then finds the triangle whose v is closest to the origin, and calls the support function using v as the direction. The triangle is subdivided, and new triangles are creating using the result of the support function as a new vertex. This is repeated over and over, so the algorithm essentially expands the simplex inside the Minkowski Sum. Once the distance between v and the support point is less than a certain threshold, we have found the penetration depth, and can easily determine the contact point and normal.
The only issue I'm having with EPA is the subdivision of the triangles. The only two resources I've found give two completely different methods for subdivision....
The first says to subdivide the edges of the triangle and use the support point to create 6 new triangles. The problem with this is, what the hell do you do with the adjacent triangles? They will have to be subdivided too, or else the mesh will have holes in it. This is a very ugly problem to solve, and he does not give much detail about the rest of the subdivision process.
The second one gives a more detailed explanation, but is completely different. Instead of subdividing the single triangle, we find every triangle whose normal is facing toward the support point. We then delete all of those triangles, and then create new triangles that all converge at the support point to fill the hole. This is what I'm trying to implement right now. It just doesn't seem like it would be very efficient. EPA is an iterative algorithm, and this must be done many times per frame.
I've looked and looked, and those were the only two decent resources I could find, and I cannot come up with a better method myself. Bullet uses EPA and I've looked at their source code, but it's utterly unreadable. So my question is, does anybody who has experience with EPA the best way of doing this? Or can anybody point me to a place with a different method? I'm not sure who came up with EPA, and I'm unable to find an official paper from the original author documenting the correct way to do it. Any help would be greatly appreciated.
Edit: I'm using method two now, and now I understand the methods they use to make it more efficient. I will post an explanation of the algorithm with sample code when I'm done
Edited by janzdott, 11 November 2013 - 02:19 PM.