# What has the most efficient intersection test against an AABB tree - OBB, Cylinder or Capsule?

I'm currently trying to find collisions in 3D between a tighter volume than an AABB and a tree of AABB volumes. I just need to know whether they are intersecting, no closest distance or collision response. An OBB, Cylinder or Capsule would all roughly fit these purposes but Cylinder and Capsule were the first thing I thought of, which I have found little information about detecting intersections online. Am I right in thinking that they would always be more complex to perform Separating Axis Tests on even though they might seem like simpler shapes? I figure by the time I get my head around SAT for curved shapes I could have done the thing with OBBs but I wanted to find out for sure.

• It sounds like you're trying to merge your narrow and broad phases. It's usually acceptable to do an AABB test against the AABBTree to find potential collisions and then to use a more accurate (but more expensive) test against refined object shapes. May 4, 2012 at 16:10
• Yes I suppose you're right, there's not going to be a more efficient test to do on a potentially large number of AABBs than a few greater than or equal tests. May 5, 2012 at 17:52
• There are two types of efficiency here - efficiency of the test and efficiency of the culling. A faster test can have a looser cull, which in turn can have further performance impact elsewhere Mar 31, 2013 at 11:09

Little bit of necromancy here, but somehow it came back to the top of the list already today, and while a comment covers the idea, there aren't any actual answers yet. For the benefit of future readers:

The idea behind using an Axis Aligned Bounding Box, or in the 3D case a bounding cube, is that you can quickly disqualify some number of your potential collisions through a series of relatively cheap comparisons to the effect of if(A.top < B.bottom) continue;

The (hopefully) much smaller set of objects that pass the AABB collision test may then go on to more accurate, but computationally expensive checks. In my experience, the time you save by quickly disqualifying the obvious non-collisions will "almost always"(tm) be greater than the time you "waste" by testing some objects twice. "Usually"(tm) it is significantly greater.

For the super serious out there, use of "quotes"(tm) indicates evidence which is, at best, anecdotal, and should not be taken as The Final Word. Special cases abound. If you think you have one, profile it and find out if you're right.

For OBB to cylinder tests, you can use an OBB to line-segment/ray test and expand the OBB by the radius of the cylinder. This produces slight error in the corners but if you can suffer that little bit of accuracy loss, it is a pretty fast and simple way.

In Christer Ericson's book, "Real Time Collision Detection", He details how to test a line or ray against 3 slabs that intersect at the OBB. The OBB is simply a Matrix & 3 half-widths which are used to create the 3 slabs. If the line segment intersects all 3 slabs, you have a collision.

For a cylinder, when you expand the OBB, you expand each slab differently depending on the dot product of the line/ray to face normal times the radius... but for a capsule, you expand all 3 slabs by the radius.

EDIT. Of course, after re-reading your question, I thought your question was less general that it is. Sorry if I gave a mis-directed answer.

• You don't answer the question in title! Oct 31, 2012 at 17:20