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

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

1. 1
Rutin
19
2. 2
JoeJ
15
3. 3
4. 4
5. 5

• 23
• 20
• 13
• 13
• 17
• ### Forum Statistics

• Total Topics
631699
• Total Posts
3001775
×