What is going on here? And when did quads come into the picture?
A BVH is a data structure that groups geometry into bounding boxes and organizes them hierarchically in a tree. Tracing into these bounding boxes (traversing the tree) is a lot simpler then against triangles and allows you to quickly discard geometry that your ray will not hit.
Exactly. I've been making my own BVH structures for game engines.
Simplified explanation:
It's basically a "collision accelerator".
Imagine you want to know if 2 objects are hitting each other, but each object is made of thousands of polygons (triangles btw).
It would be very inefficient to check if for each polygon of object 1, there's an intersection with each polygon of object 2.
If we put a big box around object 1, and then a big box around object 2, then we can very quickly check if box1 intersects box2 (especially if those boxes are axis aligned => AABB = axis aligned bounding box), and if not, then we know there is no collision and don't need to check further.
Now with BVH, it's the same idea but each big bounding box is made of smaller bounding boxes, so we keep checking recursively.
Overall, instead of doing a million checks, we end up with something like a logarithm of that (complexity goes from O(n2) to something like n*log
), which is obviously way faster.