So I'm playing around with the separating axis theorem and collision. Obviously the problem of what face it collided with arose. I need the unit normal which is tangent to that face it collided with to resolve depth penetration. For rectangles it's easy.
Update Y velocity If collision collision happened on the y axis. Update X velocity If collision collision happened on the x axis.
But I wanted a more general that would work with all cases. I came up with two solutions
1.) So I thought about the solution above with a triangle. Obviously it wouldn't work because the rectangles faces are axis aligned and a triangles faces are not. So I figured I could just project the face and velocity using the dot product to solve it like the rectangle but for every face with its own axis. This would of course involve checking collision with the whole shape again for each face.
2.) I also figured I could do Polygon v Ray collision detection to figure out what face it collided with.
My question is: Which solution is faster? Or is there a better one that hasn't come to my mind?
I don't know how to do Polygon v Ray collision but I would guess that foreach face, find intersection point between ray and segment of face.