Making Controller a template parameter of SurfaceExtractor.

This commit is contained in:
David Williams 2012-07-08 11:28:31 +02:00
parent 1aa1978de1
commit 949528b07a
3 changed files with 16 additions and 15 deletions

View File

@ -129,7 +129,7 @@ namespace PolyVox
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// SurfaceExtractor // SurfaceExtractor
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template<typename VolumeType> class SurfaceExtractor; template<typename VolumeType, typename Controller> class SurfaceExtractor;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// SurfaceMesh // SurfaceMesh

View File

@ -33,7 +33,7 @@ freely, subject to the following restrictions:
namespace PolyVox namespace PolyVox
{ {
template< typename VolumeType> template< typename VolumeType, typename Controller = SurfaceExtractionController<typename VolumeType::VoxelType> >
class SurfaceExtractor class SurfaceExtractor
{ {
public: public:
@ -212,7 +212,8 @@ namespace PolyVox
typename SurfaceExtractionController<typename VolumeType::VoxelType>::DensityType m_tThreshold; typename SurfaceExtractionController<typename VolumeType::VoxelType>::DensityType m_tThreshold;
//Used to convert arbitrary voxel types in densities and materials. //Used to convert arbitrary voxel types in densities and materials.
SurfaceExtractionController<typename VolumeType::VoxelType> m_controller; //SurfaceExtractionController<typename VolumeType::VoxelType> m_controller;
Controller m_controller;
}; };
} }

View File

@ -23,8 +23,8 @@ freely, subject to the following restrictions:
namespace PolyVox namespace PolyVox
{ {
template<typename VolumeType> template<typename VolumeType, typename Controller>
SurfaceExtractor<VolumeType>::SurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh<PositionMaterialNormal>* result) SurfaceExtractor<VolumeType, Controller>::SurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh<PositionMaterialNormal>* result)
:m_volData(volData) :m_volData(volData)
,m_sampVolume(volData) ,m_sampVolume(volData)
,m_meshCurrent(result) ,m_meshCurrent(result)
@ -38,8 +38,8 @@ namespace PolyVox
m_tThreshold = m_controller.getThreshold(); m_tThreshold = m_controller.getThreshold();
} }
template<typename VolumeType> template<typename VolumeType, typename Controller>
void SurfaceExtractor<VolumeType>::execute() void SurfaceExtractor<VolumeType, Controller>::execute()
{ {
m_meshCurrent->clear(); m_meshCurrent->clear();
@ -127,9 +127,9 @@ namespace PolyVox
m_meshCurrent->m_vecLodRecords.push_back(lodRecord); m_meshCurrent->m_vecLodRecords.push_back(lodRecord);
} }
template<typename VolumeType> template<typename VolumeType, typename Controller>
template<bool isPrevZAvail> template<bool isPrevZAvail>
uint32_t SurfaceExtractor<VolumeType>::computeBitmaskForSlice(const Array2DUint8& pPreviousBitmask, Array2DUint8& pCurrentBitmask) uint32_t SurfaceExtractor<VolumeType, Controller>::computeBitmaskForSlice(const Array2DUint8& pPreviousBitmask, Array2DUint8& pCurrentBitmask)
{ {
m_uNoOfOccupiedCells = 0; m_uNoOfOccupiedCells = 0;
@ -193,9 +193,9 @@ namespace PolyVox
return m_uNoOfOccupiedCells; return m_uNoOfOccupiedCells;
} }
template<typename VolumeType> template<typename VolumeType, typename Controller>
template<bool isPrevXAvail, bool isPrevYAvail, bool isPrevZAvail> template<bool isPrevXAvail, bool isPrevYAvail, bool isPrevZAvail>
void SurfaceExtractor<VolumeType>::computeBitmaskForCell(const Array2DUint8& pPreviousBitmask, Array2DUint8& pCurrentBitmask) void SurfaceExtractor<VolumeType, Controller>::computeBitmaskForCell(const Array2DUint8& pPreviousBitmask, Array2DUint8& pCurrentBitmask)
{ {
uint8_t iCubeIndex = 0; uint8_t iCubeIndex = 0;
@ -393,8 +393,8 @@ namespace PolyVox
} }
} }
template<typename VolumeType> template<typename VolumeType, typename Controller>
void SurfaceExtractor<VolumeType>::generateVerticesForSlice(const Array2DUint8& pCurrentBitmask, void SurfaceExtractor<VolumeType, Controller>::generateVerticesForSlice(const Array2DUint8& pCurrentBitmask,
Array2DInt32& m_pCurrentVertexIndicesX, Array2DInt32& m_pCurrentVertexIndicesX,
Array2DInt32& m_pCurrentVertexIndicesY, Array2DInt32& m_pCurrentVertexIndicesY,
Array2DInt32& m_pCurrentVertexIndicesZ) Array2DInt32& m_pCurrentVertexIndicesZ)
@ -511,8 +511,8 @@ namespace PolyVox
} }
} }
template<typename VolumeType> template<typename VolumeType, typename Controller>
void SurfaceExtractor<VolumeType>::generateIndicesForSlice(const Array2DUint8& pPreviousBitmask, void SurfaceExtractor<VolumeType, Controller>::generateIndicesForSlice(const Array2DUint8& pPreviousBitmask,
const Array2DInt32& m_pPreviousVertexIndicesX, const Array2DInt32& m_pPreviousVertexIndicesX,
const Array2DInt32& m_pPreviousVertexIndicesY, const Array2DInt32& m_pPreviousVertexIndicesY,
const Array2DInt32& m_pPreviousVertexIndicesZ, const Array2DInt32& m_pPreviousVertexIndicesZ,