The two current raycast functions were presumably added specifically for the purpose of facilitating the ambient occlusion calculator. However, for a number of common cases, they're not as usable -- requiring saving state in a callback functor for example.
I propose adding a new (set of) functions(s) to make a few common cases directly easy. For example, during work on the Python example using the cubic extractor, the most common case for needing a raycast is to either find out the voxel that the cursor is currently pointing at (in order to change material or remove it) or to find the last non-empty voxel before it (in order to set the voxel value from empty to some value).
To this end, I'm thinking of a function which looks something like:
Vector3DUint32 raycastPickVoxel(VolumeType* volData, const Vector3DFloat& v3dStart, const Vector3DFloat& v3dDirAndLength);
This would return the first non-empty voxel it came across. Perhaps to make it more flexible, instead of being fixed to return the first non-empty voxel, it could take an argument for the a voxel value to count as a hit:
Vector3DUint32 raycastPickVoxel(VolumeType* volData, const Vector3DFloat& v3dStart, const Vector3DFloat& v3dDirAndLength, VoxelType valueThatIsAHit);
or, in fact instead of a value, it could take a simple callback which returns a bool depending on whether it's a hit or not. In this last case it is very similar to the current function except the raycast returns a position instead of a RayCastResult.
Perhaps, given this last fact, the new raycast could simply be implemented as a wrapper around the existing functions. Regardless of the specifice, it would be nice to have a simple picking function available in my Python example.
Any thoughts about the API or even the usefulness of such functions?