Here's the behind-the-scenes magic (BVH with top-down SweepSAH algorithm, and some good depth-first traversal):