Accelerate the expensive part of ray tracing
A naive ray tracer tests every triangle against every ray. The k-d tree reduces that work by recursively partitioning space, but constructing a high-quality tree can itself become expensive.
I implemented the Surface Area Heuristic as the cost model for choosing split planes. The exact variant evaluates all triangle bounds; the approximate variant uses bucketing to limit the number of candidates in large nodes. This creates a controlled trade-off between build time and traversal quality.


