Exposed 'VoxelType' in BaseVolume.
This commit is contained in:
parent
86b84339af
commit
309f270e67
@ -84,7 +84,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
//Extract the surface
|
||||
SurfaceMesh<PositionMaterialNormal> mesh;
|
||||
CubicSurfaceExtractorWithNormals<SimpleVolume, uint8_t > surfaceExtractor(&volData, volData.getEnclosingRegion(), &mesh);
|
||||
CubicSurfaceExtractorWithNormals< SimpleVolume<uint8_t> > surfaceExtractor(&volData, volData.getEnclosingRegion(), &mesh);
|
||||
surfaceExtractor.execute();
|
||||
|
||||
//Pass the surface to the OpenGL window
|
||||
|
@ -38,10 +38,12 @@ namespace PolyVox
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// More details to come...
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
template <typename VoxelType>
|
||||
template <typename _VoxelType>
|
||||
class BaseVolume
|
||||
{
|
||||
public:
|
||||
typedef _VoxelType VoxelType;
|
||||
|
||||
#ifndef SWIG
|
||||
template <typename DerivedVolumeType>
|
||||
class Sampler
|
||||
|
@ -31,6 +31,8 @@ freely, subject to the following restrictions:
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
|
||||
//FIXME - Make this a member of CubicSurfaceExtractorWithNormals?
|
||||
template<typename VoxelType>
|
||||
bool defaultIsQuadNeeded(VoxelType from, VoxelType to, float& materialToUse)
|
||||
{
|
||||
@ -45,20 +47,20 @@ namespace PolyVox
|
||||
}
|
||||
}
|
||||
|
||||
template< template<typename> class VolumeType, typename VoxelType>
|
||||
template<typename VolumeType>
|
||||
class CubicSurfaceExtractorWithNormals
|
||||
{
|
||||
public:
|
||||
CubicSurfaceExtractorWithNormals(VolumeType<VoxelType>* volData, Region region, SurfaceMesh<PositionMaterialNormal>* result, polyvox_function<bool(VoxelType from, VoxelType to, float& materialToUse)> funcIsQuadNeededCallback = defaultIsQuadNeeded<VoxelType>);
|
||||
CubicSurfaceExtractorWithNormals(VolumeType* volData, Region region, SurfaceMesh<PositionMaterialNormal>* result, polyvox_function<bool(typename VolumeType::VoxelType from, typename VolumeType::VoxelType to, float& materialToUse)> funcIsQuadNeededCallback = defaultIsQuadNeeded<VolumeType::VoxelType>);
|
||||
|
||||
void execute();
|
||||
|
||||
private:
|
||||
polyvox_function<bool(VoxelType voxel0, VoxelType voxel1, float& materialToUse)> m_funcIsQuadNeededCallback;
|
||||
polyvox_function<bool(typename VolumeType::VoxelType voxel0, typename VolumeType::VoxelType voxel1, float& materialToUse)> m_funcIsQuadNeededCallback;
|
||||
|
||||
//The volume data and a sampler to access it.
|
||||
VolumeType<VoxelType>* m_volData;
|
||||
typename VolumeType<VoxelType>::Sampler m_sampVolume;
|
||||
VolumeType* m_volData;
|
||||
typename VolumeType::Sampler m_sampVolume;
|
||||
|
||||
//The surface patch we are currently filling.
|
||||
SurfaceMesh<PositionMaterialNormal>* m_meshCurrent;
|
||||
|
@ -23,8 +23,8 @@ freely, subject to the following restrictions:
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
template< template<typename> class VolumeType, typename VoxelType>
|
||||
CubicSurfaceExtractorWithNormals<VolumeType, VoxelType>::CubicSurfaceExtractorWithNormals(VolumeType<VoxelType>* volData, Region region, SurfaceMesh<PositionMaterialNormal>* result, polyvox_function<bool(VoxelType from, VoxelType to, float& materialToUse)> funcIsQuadNeededCallback)
|
||||
template<typename VolumeType>
|
||||
CubicSurfaceExtractorWithNormals<VolumeType>::CubicSurfaceExtractorWithNormals(VolumeType* volData, Region region, SurfaceMesh<PositionMaterialNormal>* result, polyvox_function<bool(typename VolumeType::VoxelType from, typename VolumeType::VoxelType to, float& materialToUse)> funcIsQuadNeededCallback)
|
||||
:m_volData(volData)
|
||||
,m_sampVolume(volData)
|
||||
,m_meshCurrent(result)
|
||||
@ -34,8 +34,8 @@ namespace PolyVox
|
||||
assert(m_funcIsQuadNeededCallback);
|
||||
}
|
||||
|
||||
template< template<typename> class VolumeType, typename VoxelType>
|
||||
void CubicSurfaceExtractorWithNormals<VolumeType, VoxelType>::execute()
|
||||
template<typename VolumeType>
|
||||
void CubicSurfaceExtractorWithNormals<VolumeType>::execute()
|
||||
{
|
||||
m_meshCurrent->clear();
|
||||
|
||||
|
@ -31,7 +31,7 @@ namespace PolyVox
|
||||
{
|
||||
void extractCubicMesh(Volume& volume, const Region& region, Mesh& resultMesh)
|
||||
{
|
||||
CubicSurfaceExtractorWithNormals<SimpleVolume, MaterialDensityPair88 > surfaceExtractor(&volume, region, &resultMesh, MaterialDensityPair88::isQuadNeeded);
|
||||
CubicSurfaceExtractorWithNormals< SimpleVolume<MaterialDensityPair88> > surfaceExtractor(&volume, region, &resultMesh, MaterialDensityPair88::isQuadNeeded);
|
||||
surfaceExtractor.execute();
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ void testForType(SurfaceMesh<PositionMaterialNormal>& result)
|
||||
}
|
||||
}
|
||||
|
||||
CubicSurfaceExtractorWithNormals<SimpleVolume, VoxelType > extractor(&volData, volData.getEnclosingRegion(), &result, VoxelType::isQuadNeeded);
|
||||
CubicSurfaceExtractorWithNormals< SimpleVolume<VoxelType> > extractor(&volData, volData.getEnclosingRegion(), &result, VoxelType::isQuadNeeded);
|
||||
extractor.execute();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user