Collision Detection Using AABB or OBB doubts

gmemario picture gmemario · Sep 25, 2011 · Viewed 8.3k times · Source

I have readed something about it i wanna to do some implementation using this. But i have a few doubts. The problem with de AABB is that the objects must be axis aligned, otherwise you have to be recalculating the bbox every frame, is that right? Is that recalculation expensive? And what about the precision, can you make a collision tree subdividing the bbox? How it works with AABB?

The OBB is oriented to the object rotation, right? You have to build the tree before the game iniatializates. I readed its a lot harder to implement and bit expensive but i gain a lot in precision. But what if the object rotates in the game, does the bbox will recalculate its rotation 'automatically'?

Wich one is most used in games and why?

Thank you in advance :)

Answer

BenC picture BenC · Nov 14, 2011

The choice between AABBs, OBBs, Spheres, Capsules... depends on the kind of simulation you are running and what your constraints (usually real-time applications) are.

You need to evaluate pros and cons and do your choice accordingly. For instance, tests with AABBs are very fast, but you need to recompute the AABBs when your object rotates. However, if you are handling very complex objects and deal with BVH, updating an AABB-tree is quite fast since you only need to recompute ("from scratch") the bottom AABBs, the higher ones being constructed from the child AABBs. With OBBs, tests are costlier but you will not need to recompute your OBBs if you are dealing with rigid objects.

If you decide to use deformable objects, the AABB tree (or Sphere tree) is definitely a better idea, since your tree will need to be updated anyway.

The question is : what will be costlier, the overhead resulting from the updating AABB-tree or from the overlap tests with OBBs? All of this depends on your simulations : objects complexity, average CD tests per sec etc... You can find some benchmarks of different CD libraries based on different methods (BVH, grids...) with different shapes, tested on particular problems. Here is an example that you might find interesting.

Concerning the implementation, since all of this has been researched years ago and implemented in many libraries, you should not have any troubles. You could take a look at Real-Time Collision Detection by Christer Ericson, all of those questions are answered and explained very clearly.

You can also use a mix between different shapes, e.g. one for the broad phase and another one for the narrow phase (once you reach leaves), but you will probably not need something like this.