Well if you've found the MTD, the scalar representing the penetration, then the current axis you are projecting onto is going to be the axis you push the collision out on. The only thing you need to know is in which direction. This is done by testing the intervals of the boxes on that axis. Basically:
| float minA, maxA, minB, maxB; |
| |
| // This just gets the minimum and maximum interval of the given OBB by testing its vertices. You're finding lower/upper bounds here. |
| GetIntervals(OBB obbA, ref minA, ref maxA); |
| GetIntervals(OBB obbB, ref minB, ref maxB); |
| |
| float d0 = (maxA - minB); |
| float d1 = (minA - maxB); |
| float d = d0 > d1 ? -1 : 1; |
| |
| Vector2 pushVector = axis * mtdScalar * d; |
Note that this is all done within the local space of obbA, turning it into an AABB. This will tend to preserve one of the components of the original velocity, so your objects will slide along each other.