Small optimizations to BVH4 code.

Moved a couple of things outside the ray test loop.