In both angular and azimuthal hit, we were calculating
p, p_end, v separately. These represent (respectively) the ray segment at time t, the ray segment at time t_end, and the free vector represented by p_end - p. I've replaced:
p ->P1p_end -> P2v -> ray_segment
P2 never changes since t_end never changes.
We can calculate P1, ray_segment once with each iteration, and pass it in each plane hit function respectively. This means we update P1, ray_segment once per iteration (using updateRaySegmentPoints() rather than twice per iteration, and P2 once per sphericalVoxelTraversal call.
Next, I've added a collinear_times array to get rid of two branch predictions per traversal and reduce a calculation to once per sphericalVoxelTraversal call rather than once per collinear hit.
In other news,
Some of the spacing in my file was wonky. This has been fixed.
Avoid copies when returning a Vec3 or similar by returning a const reference.
In both angular and azimuthal hit, we were calculating
p, p_end, v
separately. These represent (respectively) the ray segment at time t, the ray segment at time t_end, and the free vector represented byp_end - p
. I've replaced:p
->P1
p_end
->P2
v
->ray_segment
P2
never changes sincet_end
never changes. We can calculateP1, ray_segment
once with each iteration, and pass it in each plane hit function respectively. This means we updateP1, ray_segment
once per iteration (usingupdateRaySegmentPoints()
rather than twice per iteration, andP2
once per sphericalVoxelTraversal call.Next, I've added a collinear_times array to get rid of two branch predictions per traversal and reduce a calculation to once per sphericalVoxelTraversal call rather than once per collinear hit.
In other news,