Sign in to follow this  
Tecla

OBB-OBB collisions (with depth of penetration)

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this