alecjacobson / computer-graphics-bounding-volume-hierarchy

Computer Graphics Assignment about Bounding Volume Hierarchies
125 stars 46 forks source link

What partitioning strategy should we use for AABB tree? #42

Open Alireza1997 opened 5 years ago

Alireza1997 commented 5 years ago

The assignment only mentions to split along the midpoint of the longest axis of the box, but doesn't mention how to deal with objects that fall in both halves. Are we supposed to come up with our own partitioning method in these situations, or is there one we are supposed to follow?

If we are making our own, somebody else mentioned an issue where all objects fall on the same side if there is a big object that determines the size of the longest axis of the box. In this case should we just pick any object that falls on one side of the tree and place it in the other to create overlapping sub trees, or is there a more optimal way?

Thanks,

abhimadan commented 5 years ago

The first thing to mention is that the key thing we're testing here is performance with regards to ray casting, nearest neighbour search, and object intersections. As you've pointed out, the partitioning scheme we tell you to use isn't very specific, as its only purpose is to make sure that your trees are reasonably balanced, or in other words, to ensure that most objects are either entirely in the left half or entirely the right half of the AABB. It doesn't especially matter which subtree you choose to place an object that overlaps both halves, since it won't affect the tree balance much.

The "all objects in one half" issue mentioned in the other issue tends to happen relatively deep in the tree, so the way you avoid infinite recursion doesn't matter much.