Jump to content
  • Advertisement
Sign in to follow this  
BSiand

3D OBB vs OBB collision data?

This topic is 2088 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Uv45Os2.png

 

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?

Share this post


Link to post
Share on other sites
Advertisement

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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!