I'm making some changes to PolyVox to remove the use of template template (not a typo!) parameters. Many algorithms access to the type of the voxels in the volume on which they are operating. Currently the CubicSurfacExtractor is defined like this:
Code:
template< template<typename> class VolumeType, typename VoxelType>class CubicSurfaceExtractor
and the voxel type is used internally like this:
Code:
...
VoxelType currentVoxel = volumeSampler.getVoxel();
...
User code to create the CubicSurfaceExtractor looks like this:
Code:
CubicSurfaceExtractor<LargeVolume, Material8> cubicSurfaceExtractor(&volume, volume.getEnclosingRegion(), &result);
In the new version of the code the CubicSurfaceExtractor is only templatised on the VolumeType:
Code:
template<typename VolumeType>class CubicSurfaceExtractor
Because algorithms still need access to the VoxelType it is now provided as a member of the volume, and used as follows:
Code:
...
VolumeType::VoxelType currentVoxel = volumeSampler.getVoxel();
...
This is similar to how value_type can be used to determine the type of elements in an STL container. From a user code point of view, it means the creation of a CubicSurfaceExtractor should now be as follows
Code:
CubicSurfaceExtractor< LargeVolume<Material8> > cubicSurfaceExtractor(&volume, volume.getEnclosingRegion(), &result);
It's very similar to before, so you'll have to look carefully to spot the difference
The main motivation for this change is that template template parameters get complex and result in hard to read/write code inside PolyVox. Frankly, it was done using template template parameters I the first place because I didn't realise there was a another way. Another advantage (untested) is that you should be able to use typedefs of volume more easily:
Code:
typedef LargeVolume<Material8> MyVolume;
CubicSurfaceExtractor< MyVolume > cubicSurfaceExtractor(&volume, volume.getEnclosingRegion(), &result);
I'll probably change all of PolyVox's algorithms in this way, unless I come across some specific cases where it doesn't work.