dilevin / computer-graphics-bounding-volume-hierarchy

Computer Graphics Assignment about Bounding Volume Hierarchies
6 stars 5 forks source link

Finding the mid point for AABB tree axis #59

Closed pjsmith97 closed 4 years ago

pjsmith97 commented 4 years ago

I see that there is a center function for Bounding box, but the idea of the AABB function is that we're building the bounding box. So how should I compute the mid point? I thought about iterating over all the objects to find the most extreme min and max corners, but then at that point I figured I would just bound them all in a box if I had all that information and there wouldn't be any point to finding a mid point. I'm super confused here.

honglin-c commented 4 years ago

When you compute the axis to split AABB tree, your bounding box's min_corner and max_corner have already been known (they are updated each time when you add an object to the box). All you need to do is to find the longest axis in (box.max_corner - box.min_corner), then get the split axis's midpoint value by center[split_axis], since the center function just computes the center of the AABB as 0.5*(max_corner + min_corner).

pjsmith97 commented 4 years ago

Okay so the AABB function goes that you first check the cases of whether the objects array is size 1 or 2. If it's 1, the box is the object's box, and if it's 2, it's the combination of the two object's boxes. That I understand fine.

So when I get to the third case where the array size is larger than 2, is adding all the objects into AABB's box the first thing I do? Is that correct? Because then I'd have a box to find the center of.