Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

The title says it all, is it even possible to get the colliding sides?

I'm checking for collisions between two OABBs, which works fine using SAT. Now I want to set the moving object's velocity to the reflection vector of it's velocity, but for that I need the normal of the surface it collided with.

Edit:

I guess it's better if I add a bit of context. Using SAT with unaligned boxes, I check for collisions on the two axes of each object, i.e. four in total. For each axis, I determine the minimum and maximum projection of both objects on that axis and then see if they overlap. If they overlap on every axis, it's a collision.

To resolve collisions, I used a somewhat hacky approach: I'm keeping track of the overlap on each axis, then move the moving object out on the axis with the smallest penetration. Strictly speaking, that's not correct, but it works pretty well in practice so far.

What I do now is use the inverted, normalised penetration vector as my unit normal and apply the law of reflection. It works surprisingly well, but it's even wronger.

So, is there a proper way to get the colliding sides or their normals using SAT? Or should I switch to a different approach to do it properly?

share|improve this question

1 Answer 1

Box2D Lite has a good example of an OBB to OBB collision test. To answer your question, yes it's possible and that's the entire reason SAT is used.

A slightly new and more optimized approach to implementing the SAT is to make use of the idea of support points. See Dirk Gregorius's 2013 GDC slides for implementation details (hosted on Box2D.org as well).

I also implemented the SAT for generic 2D convex polygons and have an example open source physics engine here: http://www.randygaul.net/impulse-engine/

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.