Optimized voxel traversal code.