Thursday, December 29, 2016

Bounding Volume Hierarchy



Brief Overview
For this collision detection demo, I have implemented Axis Aligned Bounding Boxes which forms rectangular shape around the object by aligning the faces and normal to the coordinate system axis. Moving on with the application, I tried my hands on partition collection system that uses Splitting Along Object Mean Method.

Axis Aligned Bounding Boxes
It is one of the quickest and memory-efficient algorithm to determine whether two game entities are overlapping or not. It consists of wrapping game entities in non-rotated(thus axis-aligned) box, and checking the positions of these boxes in the 3D coordinate space to see if they're overlapping.

The implementation of AABB is quite easy, we can start by creating min and max point or have a center point and weight/height/depth. For this example, I will be using an AABB created with two point(min and max). The collision check between two AABB's is very simple and fast, since it has many early out's. The bad thing about AABB's is that they can't be rotated. Once they're rotated, they stop being AABB's since they're not aligned to the X, Y and Z axes anymore. For objects that rotate, a better option would be to use spheres, capsules or even OBBs(oriented bounding boxes).

To check if two AABB's are colliding, we just need to check that the first AABB's max point is greater than the second one's min point and that the first one's min point is less than the second one's max point. 

No comments:

Post a Comment