Made BVH traversal slightly faster.

The ray tests and partitioning are done in a single pass now, instead of
taking two full passes through the rays.