CapitalEx wrote: ↑Sun Mar 17, 2024 6:50 pm
You came up with your own algorithm? That's pretty impressive.
Yup! The first iteration actually used GJK and EPA but I was having a hard time trying to figure out how to produce a contact manifold from it.
I eventually found a source that instead uses clipping to compute the contact manifolds but it assumed I already had the separation normal and distance (either from EPA or SAT).
https://dyn4j.org/2011/11/contact-point ... -clipping/
I wanted a way to compute everything using only the clipping volume: collision detection, contact manifold, separation normal and separation distance. I eventually realized this was indeed possible.
First, collision detection can be done by checking if there are any remaining vertexes from the clipping. If everything is discarded it means there were no overlapping vertexes and therefor no collision.
Second, to get an approximate contact point I calculate the centroid of the clipping volume. As mentioned in that source I found.
Third, the separation normal can be obtained by getting the average normal of the overlapping faces from the clipped volume and using their surface area as the bias. Here is a 2D example of what I mean:
Last, once I have the separation normal, I can use that to find the furthest vertex along that direction and treat it as a plane. Then I find the furthest opposing vertex and calculate the distance from the plane via dot product. This gives me the separation distance.
And voila! All of this can be done using just the clipping volume. No need for GJK/EPA or SAT