cpu_voxel_raycaster
cpu_voxel_raycaster copied to clipboard
Bug in traversal of the rays along the axes.
When you traverse rays along x, y or z axis your algorithm behaves fully incorrectly. It could lead to missing triangles or voxels when rays are parallel to axes.
You can make a simple test with cube (0.0, 0.0, 0.0, 1.0, 1.0, 1.0) and try to traverse a ray to this cube with the following ray( position (0.49, 0.49, -1) , direction(0, 0, 2)) You will see that because of 0s in direction whole algorithm detect new node wrongly.
I've added if (FLOAT_EQUAL(rayDirection.x, 0.0f)) rayDirection.x = 0.0000001f; if (FLOAT_EQUAL(rayDirection.y, 0.0f)) rayDirection.y = 0.0000001f; if (FLOAT_EQUAL(rayDirection.z, 0.0f)) rayDirection.z = 0.0000001f;
this to avoid such bugs, but I do not like this solution.