From 27968973a4984e47ee2ea5a2a9b40533e84dede2 Mon Sep 17 00:00:00 2001 From: David Williams Date: Sun, 1 May 2011 16:43:33 +0100 Subject: [PATCH] Made CubicSurfaceExtractor work with different volume types. --- .../PolyVoxCore/include/CubicSurfaceExtractor.h | 8 ++++---- .../include/CubicSurfaceExtractor.inl | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/library/PolyVoxCore/include/CubicSurfaceExtractor.h b/library/PolyVoxCore/include/CubicSurfaceExtractor.h index 9407711d..d0a63e15 100644 --- a/library/PolyVoxCore/include/CubicSurfaceExtractor.h +++ b/library/PolyVoxCore/include/CubicSurfaceExtractor.h @@ -38,11 +38,11 @@ namespace PolyVox int32_t uMaterial : 8; }; - template + template< template class VolumeType, typename VoxelType> class CubicSurfaceExtractor { public: - CubicSurfaceExtractor(LargeVolume* volData, Region region, SurfaceMesh* result); + CubicSurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh* result); void execute(); @@ -50,8 +50,8 @@ namespace PolyVox private: //The volume data and a sampler to access it. - LargeVolume* m_volData; - typename LargeVolume::Sampler m_sampVolume; + VolumeType* m_volData; + typename VolumeType::Sampler m_sampVolume; //Information about the region we are currently processing Region m_regSizeInVoxels; diff --git a/library/PolyVoxCore/include/CubicSurfaceExtractor.inl b/library/PolyVoxCore/include/CubicSurfaceExtractor.inl index e83d3d74..9dcdce90 100644 --- a/library/PolyVoxCore/include/CubicSurfaceExtractor.inl +++ b/library/PolyVoxCore/include/CubicSurfaceExtractor.inl @@ -29,11 +29,11 @@ freely, subject to the following restrictions: namespace PolyVox { - template - const uint32_t CubicSurfaceExtractor::MaxQuadsSharingVertex = 4; + template< template class VolumeType, typename VoxelType> + const uint32_t CubicSurfaceExtractor::MaxQuadsSharingVertex = 4; - template - CubicSurfaceExtractor::CubicSurfaceExtractor(LargeVolume* volData, Region region, SurfaceMesh* result) + template< template class VolumeType, typename VoxelType> + CubicSurfaceExtractor::CubicSurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh* result) :m_volData(volData) ,m_sampVolume(volData) ,m_regSizeInVoxels(region) @@ -42,8 +42,8 @@ namespace PolyVox m_meshCurrent->clear(); } - template - void CubicSurfaceExtractor::execute() + template< template class VolumeType, typename VoxelType> + void CubicSurfaceExtractor::execute() { uint32_t uArrayWidth = m_regSizeInVoxels.getUpperCorner().getX() - m_regSizeInVoxels.getLowerCorner().getX() + 2; uint32_t uArrayHeight = m_regSizeInVoxels.getUpperCorner().getY() - m_regSizeInVoxels.getLowerCorner().getY() + 2; @@ -175,8 +175,8 @@ namespace PolyVox m_meshCurrent->m_vecLodRecords.push_back(lodRecord); } - template - int32_t CubicSurfaceExtractor::addVertex(float fX, float fY, float fZ, uint8_t uMaterialIn, Array<3, IndexAndMaterial>& existingVertices) + template< template class VolumeType, typename VoxelType> + int32_t CubicSurfaceExtractor::addVertex(float fX, float fY, float fZ, uint8_t uMaterialIn, Array<3, IndexAndMaterial>& existingVertices) { uint32_t uX = static_cast(fX + 0.75f); uint32_t uY = static_cast(fY + 0.75f);