Hey everybody! I'm trying to implement OBB vs OBB intersection using SAT.

If the axis of least penetration is a face normal, I take this as the reference plane. Its normal is the collision normal. I then find the most antiparallel face, the incident plane. Then I clip the incident face vertices against the side planes of the reference plane, which gives me a new list of vertices. Of these vertices, I take the ones that are inside the reference shape (on the right side of the reference plane) and declare those as the contact points of the collision.

If the axis of least penetration is a cross product of two edges, I use that cross product, but normalized, as the collision normal. To prevent division by zero when normalizing, I check what the length of it is. If it is zero, this can not be a "best axis", so I just continue to the next one. Anyway, I then find a point each on the two lines that are touching by finding the support points in that direction. With that information I can find the two closest points on the lines. I then declare the midpoint of those to be the only point of contact.

This sounds good and everything, but it doesn't seem to work entirely.

Take a scenario like this

When it hits it, it starts spinning a bit and of course the rightmost contact point disappears (as it doesn't touch there anymore).

But then it sinks into it, starts flailing out and even starts spinning around the blue axis in the picture.

Has anybody here got something like this working? Can this be caused by bad frame coherence, or am I probably doing anything else wrong? For people who have gotten something like this working in 3D, did you do anything different than I did?