I haven't tested but it should look something like the following:
Code:
class RaycastIntersectionFinder
{
public:
RaycastIntersectionFinder()
{
}
bool operator()(const SimpleVolume<int8_t>::Sampler& sampler)
{
// Store this so we can retrieve it later
v3dLastPosition = sampler.getPosition();
// If the ray is inside the volume then check if it has hit a solid voxel.
if(!sampler.isCurrentPositionValid())
{
if(sampler.getVoxel() > 0) // You can replace this with your own condition if you want to.
{
// We've hit something, so stop traversing.
return false;
}
}
// By default we continue traversing.
return true;
}
bool bFoundIntersection;
Vector3DInt32 v3dLastPosition;
};
You can use that as the callback for the raycast, and it basically keeps track of the last voxel that was examined. So you can check the return result of the raycast function and if it is RaycastResults::Interupted then you know the ray hit something, and you can find out what by then checking the 'v3dLastPosition' member of the callback above.
But yeah... I'll try and add some more documentation to the class.