Jump to content
  • Advertisement
Sign in to follow this  
Tecla

OBB-OBB collisions (with depth of penetration)

This topic is 4651 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

I have a rigid body physics engine I'm slowly working on, and currently the biggest missing piece is that my box-box collisions aren't behaving properly yet. I have collisions between planes, spheres, and boxes (except for box-box), and I have code (inspired by oliii, so thank you!) that does the separating axis test between OBBs to tell me if I've got an intersection. I can even store off which axes of the 15 tagged the collision. However, my engine uses penalty forces for resting contact, so I need an efficient way to squeeze the depth of penetration and the exact point(s) of collision out of the usual OBB-OBB test. Can anybody give me an overview of what needs to be done to pull that out? (When I manage to get that working I'll be sure to post a quick demo of the actual engine so you all can see it.) (On a side note, I nearly went and just tried to use OPCODE for the OBB collisions, but I'm really interested in understanding this totally.) -Tecla

Share this post


Link to post
Share on other sites
Advertisement
Once you have a collision, you can determine the penetrating volume using volume clipping. That is, simply clip the parts of box A that are outside box B, and vice versa. You're going to have the case where one or more of the 8 points defining one of the boxes, is inside the other box. Let's say a corner from box A is inside box B. Determine which sides box A penetrated box B through, and determine the penetration depth either using the maximum axial penetration, or using the velocity of box A as the penetration direction.

The above is just off the top of my head, so it might not be the most efficiently way of getting this done. For example, the actual clipping would be somewhat expensive and you could probably find which corners are inside the other box just using successive half-plane checks. And once you have those points, you wouldn't even need to find which sides of the box were penetrated because you clip the velocity vector by the box and determine a more accurate penetration. There might be degenerate cases I haven't thought of either. But that should get you going I hope.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!