• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# 3D OBB vs OBB collision data?

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

### #1BSiand  Members

Posted 26 January 2014 - 08:50 AM

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?

### #2Dirk Gregorius  Members

Posted 27 January 2014 - 04:42 PM

What you describe is correct. There is a bunch of other things to consider. You want to avoid feature flip-flops. Say you have two faces resting on each other. Take the simple case like a small box on a large ground box. Your axis of minimum penetration can come from both touching faces and a bunch of edge combinations since the results will be all very similar. You now want to favor face contacts over edge contacts and you also want to prefer one face over the other.

You can do this something along these lines:

float f1 = QueryFaceSeparation1();

float f2 = QueryFaceSeparation2();

float e = QueryEdgeSeperation();

if ( f2 > kRelFaceTol * f1 + kAbsTol )

{

if ( f2 > kRelEdgeTol * e + kAbsTol )

FaceContact( f2 )

else

EdgeContact( e )

}

else

{

if ( f1 > kRelEdgeTol * e + kAbsTol )

FaceContact( f1 )

else

EdgeContact( e )

}

Edited by Dirk Gregorius, 27 January 2014 - 06:47 PM.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.