diff --git a/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.h b/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.h index c2ba3481..71571038 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.h +++ b/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.h @@ -113,7 +113,7 @@ namespace PolyVox /// /// Another scenario which sometimes results in confusion is when you wish to extract a region which corresponds to the whole volume, partcularly when solid voxels extend right to the edge of the volume. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - template + template class CubicSurfaceExtractor { struct IndexAndMaterial @@ -150,9 +150,9 @@ namespace PolyVox // This is a bit ugly - it seems that the C++03 syntax is different from the C++11 syntax? See this thread: http://stackoverflow.com/questions/6076015/typename-outside-of-template // Long term we should probably come back to this and if the #ifdef is still needed then maybe it should check for C++11 mode instead of MSVC? #if defined(_MSC_VER) - CubicSurfaceExtractor(VolumeType* volData, Region region, Mesh >* result, WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = VolumeType::VoxelType(), bool bMergeQuads = true, IsQuadNeeded isQuadNeeded = IsQuadNeeded()); + CubicSurfaceExtractor(VolumeType* volData, Region region, MeshType* result, WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = VolumeType::VoxelType(), bool bMergeQuads = true, IsQuadNeeded isQuadNeeded = IsQuadNeeded()); #else - CubicSurfaceExtractor(VolumeType* volData, Region region, Mesh >* result, WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = typename VolumeType::VoxelType(), bool bMergeQuads = true, IsQuadNeeded isQuadNeeded = IsQuadNeeded()); + CubicSurfaceExtractor(VolumeType* volData, Region region, MeshType* result, WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = typename VolumeType::VoxelType(), bool bMergeQuads = true, IsQuadNeeded isQuadNeeded = IsQuadNeeded()); #endif @@ -172,7 +172,7 @@ namespace PolyVox Region m_regSizeInVoxels; //The surface patch we are currently filling. - Mesh >* m_meshCurrent; + MeshType* m_meshCurrent; //Used to avoid creating duplicate vertices. Array<3, IndexAndMaterial> m_previousSliceVertices; @@ -198,8 +198,9 @@ namespace PolyVox template Mesh > extractCubicMesh(VolumeType* volData, Region region, WrapMode eWrapMode, typename VolumeType::VoxelType tBorderValue, bool bMergeQuads, IsQuadNeeded isQuadNeeded) { - Mesh > result; - CubicSurfaceExtractor extractor(volData, region, &result, eWrapMode, tBorderValue, bMergeQuads, isQuadNeeded); + typedef Mesh > MeshType; + MeshType result; + CubicSurfaceExtractor extractor(volData, region, &result, eWrapMode, tBorderValue, bMergeQuads, isQuadNeeded); extractor.execute(); return result; } diff --git a/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.inl b/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.inl index 5e00a572..6ebec5ef 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.inl @@ -32,11 +32,11 @@ namespace PolyVox // happens when we have a 2x2x2 group of voxels, all with different materials and some/all partially transparent. // The vertex position at the center of this group is then going to be used by all eight voxels all with different // materials. - template - const uint32_t CubicSurfaceExtractor::MaxVerticesPerPosition = 8; + template + const uint32_t CubicSurfaceExtractor::MaxVerticesPerPosition = 8; - template - CubicSurfaceExtractor::CubicSurfaceExtractor(VolumeType* volData, Region region, Mesh >* result, WrapMode eWrapMode, typename VolumeType::VoxelType tBorderValue, bool bMergeQuads, IsQuadNeeded isQuadNeeded) + template + CubicSurfaceExtractor::CubicSurfaceExtractor(VolumeType* volData, Region region, MeshType* result, WrapMode eWrapMode, typename VolumeType::VoxelType tBorderValue, bool bMergeQuads, IsQuadNeeded isQuadNeeded) :m_volData(volData) ,m_regSizeInVoxels(region) ,m_meshCurrent(result) @@ -53,8 +53,8 @@ namespace PolyVox POLYVOX_THROW_IF(region.getDepthInVoxels() > maxReionDimension, std::invalid_argument, "Requested extraction region exceeds maximum dimensions"); } - template - void CubicSurfaceExtractor::execute() + template + void CubicSurfaceExtractor::execute() { Timer timer; m_meshCurrent->clear(); @@ -204,8 +204,8 @@ namespace PolyVox << "x" << m_regSizeInVoxels.getDepthInVoxels() << ")"); } - template - int32_t CubicSurfaceExtractor::addVertex(uint32_t uX, uint32_t uY, uint32_t uZ, typename VolumeType::VoxelType uMaterialIn, Array<3, IndexAndMaterial>& existingVertices) + template + int32_t CubicSurfaceExtractor::addVertex(uint32_t uX, uint32_t uY, uint32_t uZ, typename VolumeType::VoxelType uMaterialIn, Array<3, IndexAndMaterial>& existingVertices) { for(uint32_t ct = 0; ct < MaxVerticesPerPosition; ct++) { @@ -236,8 +236,8 @@ namespace PolyVox return -1; //Should never happen. } - template - bool CubicSurfaceExtractor::performQuadMerging(std::list& quads) + template + bool CubicSurfaceExtractor::performQuadMerging(std::list& quads) { bool bDidMerge = false; for(typename std::list::iterator outerIter = quads.begin(); outerIter != quads.end(); outerIter++) @@ -266,8 +266,8 @@ namespace PolyVox return bDidMerge; } - template - bool CubicSurfaceExtractor::mergeQuads(Quad& q1, Quad& q2) + template + bool CubicSurfaceExtractor::mergeQuads(Quad& q1, Quad& q2) { //All four vertices of a given quad have the same data, //so just check that the first pair of vertices match. diff --git a/library/PolyVoxCore/include/PolyVoxCore/Mesh.h b/library/PolyVoxCore/include/PolyVoxCore/Mesh.h index 45f78930..34dc50b4 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Mesh.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Mesh.h @@ -49,16 +49,16 @@ namespace PolyVox Mesh(); ~Mesh(); - const std::vector& getIndices(void) const; + const std::vector& getIndices(void) const; uint32_t getNoOfIndices(void) const; - uint32_t getNoOfVertices(void) const; + IndexType getNoOfVertices(void) const; const std::vector& getVertices(void) const; const Vector3DInt32& getOffset(void) const; void setOffset(const Vector3DInt32& offset); - void addTriangle(uint32_t index0, uint32_t index1, uint32_t index2); - uint32_t addVertex(const VertexType& vertex); + void addTriangle(IndexType index0, IndexType index1, IndexType index2); + IndexType addVertex(const VertexType& vertex); void clear(void); bool isEmpty(void) const; void removeUnusedVertices(void); @@ -66,17 +66,17 @@ namespace PolyVox Vector3DInt32 m_offset; public: - std::vector m_vecTriangleIndices; + std::vector m_vecTriangleIndices; std::vector m_vecVertices; }; template - Mesh< Vertex< typename MeshType::VertexType::DataType > > decode(const MeshType& mesh) + Mesh< Vertex< typename MeshType::VertexType::DataType >, typename MeshType::IndexType > decode(const MeshType& mesh) { - Mesh< Vertex< typename MeshType::VertexType::DataType > > result; + Mesh< Vertex< typename MeshType::VertexType::DataType >, typename MeshType::IndexType > result; result.m_vecVertices.resize(mesh.m_vecVertices.size()); - for(uint32_t ct = 0; ct < mesh.m_vecVertices.size(); ct++) + for(MeshType::IndexType ct = 0; ct < mesh.m_vecVertices.size(); ct++) { result.m_vecVertices[ct] = decode(mesh.m_vecVertices[ct]); } diff --git a/library/PolyVoxCore/include/PolyVoxCore/Mesh.inl b/library/PolyVoxCore/include/PolyVoxCore/Mesh.inl index 7a57c748..cd93f878 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Mesh.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/Mesh.inl @@ -34,7 +34,7 @@ namespace PolyVox } template - const std::vector& Mesh::getIndices(void) const + const std::vector& Mesh::getIndices(void) const { return m_vecTriangleIndices; } @@ -46,7 +46,7 @@ namespace PolyVox } template - uint32_t Mesh::getNoOfVertices(void) const + IndexType Mesh::getNoOfVertices(void) const { return m_vecVertices.size(); } @@ -70,7 +70,7 @@ namespace PolyVox } template - void Mesh::addTriangle(uint32_t index0, uint32_t index1, uint32_t index2) + void Mesh::addTriangle(IndexType index0, IndexType index1, IndexType index2) { //Make sure the specified indices correspond to valid vertices. POLYVOX_ASSERT(index0 < m_vecVertices.size(), "Index points at an invalid vertex."); @@ -83,7 +83,7 @@ namespace PolyVox } template - uint32_t Mesh::addVertex(const VertexType& vertex) + IndexType Mesh::addVertex(const VertexType& vertex) { m_vecVertices.push_back(vertex); return m_vecVertices.size() - 1; @@ -116,7 +116,7 @@ namespace PolyVox int noOfUsedVertices = 0; std::vector newPos(m_vecVertices.size()); - for(uint32_t vertCt = 0; vertCt < m_vecVertices.size(); vertCt++) + for(IndexType vertCt = 0; vertCt < m_vecVertices.size(); vertCt++) { if(isVertexUsed[vertCt]) { diff --git a/library/PolyVoxCore/include/PolyVoxCore/PolyVoxForwardDeclarations.h b/library/PolyVoxCore/include/PolyVoxCore/PolyVoxForwardDeclarations.h index e4555893..16151e4c 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/PolyVoxForwardDeclarations.h +++ b/library/PolyVoxCore/include/PolyVoxCore/PolyVoxForwardDeclarations.h @@ -76,7 +76,7 @@ namespace PolyVox // CubicSurfaceExtractor //////////////////////////////////////////////////////////////////////////////// template class DefaultIsQuadNeeded; - template > class CubicSurfaceExtractor; + template > class CubicSurfaceExtractor; //////////////////////////////////////////////////////////////////////////////// // CubicVertex