Just for fun, I'm tinkering with collision detection. I'd like to implement collision detection between two OBBs and between OBBs and convex polygons.
So far, all the helpful documentation I found is this:
This page details how to implement the separating axis theorem intersection test. It's quite helpful, but it leaves quite a few holes to be filled, in my opinion... Such as:
1) This is only an *intersection test*. If I'm doing this every frame, and objects are moving very fast, I could potentially have two objects going through each other, and no collision being detected. Nobody seems to be addressing this problem in any amount of detail anywhere on the web. People mention it, but provide no useful solution.
So far, my best idea is to construct an AABB around the whole space both objects could span and test those for intersection. This tells me if the two objects could "possibly intersect". If so, I could then go and subdivide the time frame into smaller intervals to test more thoroughly for collisions... This is not bulletproof, but reduces the likelihood of missing collisions a fair bit.
2) This intersection test only gives me boolean information (yes or no). It doesn't give me an intersection point. This seems problematic because it seems to me like if you want to have the objects properly react in terms of rotation when they collide, you'd want to know where they touch, relative to their center of mass.
3) I'm guessing you can use the separating axis theorem for testing polygons vs. OBBs, but I'm not sure how. Do you just take the two axes of the polygon to be two orthogonal vectors on its plane? Will that work?
As a second problem, I'm not quite sure how to implement collision reaction to take rotation into account. If we ignore rotation, what I did in the past was to just cancel component of a moving object's velocity that goes in the direction of the surface normal of the other object that was collided with.
In more realistic physical terms, it seems like energy has to be conserved. If two moving objects collide, the motion of both should be altered, but they might also acquire a rotational component. However, I'm not sure how to distribute the energy here. Clearly, making an object rotate faster requires energy, and so does making it move... So how should the energy be distributed between rotation and movement?
I'm guessing I also need to make my objects somewhat "bouncy" if I want my simulation to look anywhere near realistic.