Binary Space Partition (BSP) Tree
RayTreeIntersect(Ray ray, Node node, double min, double max)
return intersection of closest primitive in cell, or NULL if none
dist = distance of the ray point to split plane of node
near_child = child of node that contains the origin of Ray
far_child = other child of node
if the interval to look is on near side
return RayTreeIntersect(ray, near_child, min, max)
else if the interval to look is on far side
return RayTreeIntersect(ray, far_child, min, max)
else if the interval to look is on both side
if (RayTreeIntersect(ray, near_child, min, dist)) return …;
else return RayTreeIntersect(ray, far_child, dist, max)