diff --git a/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.inl b/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.inl index 12bcdc2c..211498c9 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.inl @@ -58,10 +58,6 @@ namespace PolyVox memset(m_previousSliceVertices.getRawData(), 0xff, m_previousSliceVertices.getNoOfElements() * sizeof(IndexAndMaterial)); memset(m_currentSliceVertices.getRawData(), 0xff, m_currentSliceVertices.getNoOfElements() * sizeof(IndexAndMaterial)); - uint32_t uRegionWidth = m_regSizeInVoxels.getUpperCorner().getX() - m_regSizeInVoxels.getLowerCorner().getX() + 1; - uint32_t uRegionHeight = m_regSizeInVoxels.getUpperCorner().getY() - m_regSizeInVoxels.getLowerCorner().getY() + 1; - uint32_t uRegionDepth = m_regSizeInVoxels.getUpperCorner().getZ() - m_regSizeInVoxels.getLowerCorner().getZ() + 1; - m_vecQuads[NegativeX].resize(m_regSizeInVoxels.getUpperCorner().getX() - m_regSizeInVoxels.getLowerCorner().getX() + 2); m_vecQuads[PositiveX].resize(m_regSizeInVoxels.getUpperCorner().getX() - m_regSizeInVoxels.getLowerCorner().getX() + 2); @@ -96,20 +92,20 @@ namespace PolyVox // X if(m_funcIsQuadNeededCallback(currentVoxel, negXVoxel, material)) { - uint32_t v0 = addVertex(regX - 0.5f, regY - 0.5f, regZ - 0.5f, material, m_previousSliceVertices); - uint32_t v1 = addVertex(regX - 0.5f, regY - 0.5f, regZ + 0.5f, material, m_currentSliceVertices); - uint32_t v2 = addVertex(regX - 0.5f, regY + 0.5f, regZ + 0.5f, material, m_currentSliceVertices); - uint32_t v3 = addVertex(regX - 0.5f, regY + 0.5f, regZ - 0.5f, material, m_previousSliceVertices); + uint32_t v0 = addVertex(static_cast(regX) - 0.5f, static_cast(regY) - 0.5f, static_cast(regZ) - 0.5f, material, m_previousSliceVertices); + uint32_t v1 = addVertex(static_cast(regX) - 0.5f, static_cast(regY) - 0.5f, static_cast(regZ) + 0.5f, material, m_currentSliceVertices); + uint32_t v2 = addVertex(static_cast(regX) - 0.5f, static_cast(regY) + 0.5f, static_cast(regZ) + 0.5f, material, m_currentSliceVertices); + uint32_t v3 = addVertex(static_cast(regX) - 0.5f, static_cast(regY) + 0.5f, static_cast(regZ) - 0.5f, material, m_previousSliceVertices); m_vecQuads[NegativeX][regX].push_back(Quad(v0, v1, v2, v3)); } if(m_funcIsQuadNeededCallback(negXVoxel, currentVoxel, material)) { - uint32_t v0 = addVertex(regX - 0.5f, regY - 0.5f, regZ - 0.5f, material, m_previousSliceVertices); - uint32_t v1 = addVertex(regX - 0.5f, regY - 0.5f, regZ + 0.5f, material, m_currentSliceVertices); - uint32_t v2 = addVertex(regX - 0.5f, regY + 0.5f, regZ + 0.5f, material, m_currentSliceVertices); - uint32_t v3 = addVertex(regX - 0.5f, regY + 0.5f, regZ - 0.5f, material, m_previousSliceVertices); + uint32_t v0 = addVertex(static_cast(regX) - 0.5f, static_cast(regY) - 0.5f, static_cast(regZ) - 0.5f, material, m_previousSliceVertices); + uint32_t v1 = addVertex(static_cast(regX) - 0.5f, static_cast(regY) - 0.5f, static_cast(regZ) + 0.5f, material, m_currentSliceVertices); + uint32_t v2 = addVertex(static_cast(regX) - 0.5f, static_cast(regY) + 0.5f, static_cast(regZ) + 0.5f, material, m_currentSliceVertices); + uint32_t v3 = addVertex(static_cast(regX) - 0.5f, static_cast(regY) + 0.5f, static_cast(regZ) - 0.5f, material, m_previousSliceVertices); m_vecQuads[PositiveX][regX].push_back(Quad(v0, v3, v2, v1)); } @@ -117,20 +113,20 @@ namespace PolyVox // Y if(m_funcIsQuadNeededCallback(currentVoxel, negYVoxel, material)) { - uint32_t v0 = addVertex(regX - 0.5f, regY - 0.5f, regZ - 0.5f, material, m_previousSliceVertices); - uint32_t v1 = addVertex(regX + 0.5f, regY - 0.5f, regZ - 0.5f, material, m_previousSliceVertices); - uint32_t v2 = addVertex(regX + 0.5f, regY - 0.5f, regZ + 0.5f, material, m_currentSliceVertices); - uint32_t v3 = addVertex(regX - 0.5f, regY - 0.5f, regZ + 0.5f, material, m_currentSliceVertices); + uint32_t v0 = addVertex(static_cast(regX) - 0.5f, static_cast(regY) - 0.5f, static_cast(regZ) - 0.5f, material, m_previousSliceVertices); + uint32_t v1 = addVertex(static_cast(regX) + 0.5f, static_cast(regY) - 0.5f, static_cast(regZ) - 0.5f, material, m_previousSliceVertices); + uint32_t v2 = addVertex(static_cast(regX) + 0.5f, static_cast(regY) - 0.5f, static_cast(regZ) + 0.5f, material, m_currentSliceVertices); + uint32_t v3 = addVertex(static_cast(regX) - 0.5f, static_cast(regY) - 0.5f, static_cast(regZ) + 0.5f, material, m_currentSliceVertices); m_vecQuads[NegativeY][regY].push_back(Quad(v0, v1, v2, v3)); } if(m_funcIsQuadNeededCallback(negYVoxel, currentVoxel, material)) { - uint32_t v0 = addVertex(regX - 0.5f, regY - 0.5f, regZ - 0.5f, material, m_previousSliceVertices); - uint32_t v1 = addVertex(regX + 0.5f, regY - 0.5f, regZ - 0.5f, material, m_previousSliceVertices); - uint32_t v2 = addVertex(regX + 0.5f, regY - 0.5f, regZ + 0.5f, material, m_currentSliceVertices); - uint32_t v3 = addVertex(regX - 0.5f, regY - 0.5f, regZ + 0.5f, material, m_currentSliceVertices); + uint32_t v0 = addVertex(static_cast(regX) - 0.5f, static_cast(regY) - 0.5f, static_cast(regZ) - 0.5f, material, m_previousSliceVertices); + uint32_t v1 = addVertex(static_cast(regX) + 0.5f, static_cast(regY) - 0.5f, static_cast(regZ) - 0.5f, material, m_previousSliceVertices); + uint32_t v2 = addVertex(static_cast(regX) + 0.5f, static_cast(regY) - 0.5f, static_cast(regZ) + 0.5f, material, m_currentSliceVertices); + uint32_t v3 = addVertex(static_cast(regX) - 0.5f, static_cast(regY) - 0.5f, static_cast(regZ) + 0.5f, material, m_currentSliceVertices); m_vecQuads[PositiveY][regY].push_back(Quad(v0, v3, v2, v1)); } @@ -138,20 +134,20 @@ namespace PolyVox // Z if(m_funcIsQuadNeededCallback(currentVoxel, negZVoxel, material)) { - uint32_t v0 = addVertex(regX - 0.5f, regY - 0.5f, regZ - 0.5f, material, m_previousSliceVertices); - uint32_t v1 = addVertex(regX - 0.5f, regY + 0.5f, regZ - 0.5f, material, m_previousSliceVertices); - uint32_t v2 = addVertex(regX + 0.5f, regY + 0.5f, regZ - 0.5f, material, m_previousSliceVertices); - uint32_t v3 = addVertex(regX + 0.5f, regY - 0.5f, regZ - 0.5f, material, m_previousSliceVertices); + uint32_t v0 = addVertex(static_cast(regX) - 0.5f, static_cast(regY) - 0.5f, static_cast(regZ) - 0.5f, material, m_previousSliceVertices); + uint32_t v1 = addVertex(static_cast(regX) - 0.5f, static_cast(regY) + 0.5f, static_cast(regZ) - 0.5f, material, m_previousSliceVertices); + uint32_t v2 = addVertex(static_cast(regX) + 0.5f, static_cast(regY) + 0.5f, static_cast(regZ) - 0.5f, material, m_previousSliceVertices); + uint32_t v3 = addVertex(static_cast(regX) + 0.5f, static_cast(regY) - 0.5f, static_cast(regZ) - 0.5f, material, m_previousSliceVertices); m_vecQuads[NegativeZ][regZ].push_back(Quad(v0, v1, v2, v3)); } if(m_funcIsQuadNeededCallback(negZVoxel, currentVoxel, material)) { - uint32_t v0 = addVertex(regX - 0.5f, regY - 0.5f, regZ - 0.5f, material, m_previousSliceVertices); - uint32_t v1 = addVertex(regX - 0.5f, regY + 0.5f, regZ - 0.5f, material, m_previousSliceVertices); - uint32_t v2 = addVertex(regX + 0.5f, regY + 0.5f, regZ - 0.5f, material, m_previousSliceVertices); - uint32_t v3 = addVertex(regX + 0.5f, regY - 0.5f, regZ - 0.5f, material, m_previousSliceVertices); + uint32_t v0 = addVertex(static_cast(regX) - 0.5f, static_cast(regY) - 0.5f, static_cast(regZ) - 0.5f, material, m_previousSliceVertices); + uint32_t v1 = addVertex(static_cast(regX) - 0.5f, static_cast(regY) + 0.5f, static_cast(regZ) - 0.5f, material, m_previousSliceVertices); + uint32_t v2 = addVertex(static_cast(regX) + 0.5f, static_cast(regY) + 0.5f, static_cast(regZ) - 0.5f, material, m_previousSliceVertices); + uint32_t v3 = addVertex(static_cast(regX) + 0.5f, static_cast(regY) - 0.5f, static_cast(regZ) - 0.5f, material, m_previousSliceVertices); m_vecQuads[PositiveZ][regZ].push_back(Quad(v0, v3, v2, v1)); } @@ -217,7 +213,7 @@ namespace PolyVox } //If we have an existing vertex and the material matches then we can return it. - if(rEntry.uMaterial == uMaterialIn) + if(rEntry.uMaterial == static_cast(uMaterialIn)) { return rEntry.iIndex; } diff --git a/library/PolyVoxCore/include/PolyVoxCore/DefaultMarchingCubesController.h b/library/PolyVoxCore/include/PolyVoxCore/DefaultMarchingCubesController.h index d6b314d6..3da41519 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/DefaultMarchingCubesController.h +++ b/library/PolyVoxCore/include/PolyVoxCore/DefaultMarchingCubesController.h @@ -107,7 +107,7 @@ namespace PolyVox /// The default implementation of this function just returns the constant '1'. There's not much else it can do, as it needs to work with primitive /// types and the actual value of the type is already being considered to be the density. Specialisations of this class can modify this behaviour. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - MaterialType convertToMaterial(VoxelType voxel) + MaterialType convertToMaterial(VoxelType /*voxel*/) { return 1; } diff --git a/library/PolyVoxCore/include/PolyVoxCore/Density.h b/library/PolyVoxCore/include/PolyVoxCore/Density.h index 0ae3d82a..9f266c37 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Density.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Density.h @@ -159,7 +159,7 @@ namespace PolyVox return voxel.getDensity(); } - MaterialType convertToMaterial(Density voxel) + MaterialType convertToMaterial(Density /*voxel*/) { return 1; } diff --git a/library/PolyVoxCore/include/PolyVoxCore/Vector.inl b/library/PolyVoxCore/include/PolyVoxCore/Vector.inl index b6d92c15..f550a6ec 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Vector.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/Vector.inl @@ -602,15 +602,15 @@ namespace PolyVox template inline void Vector::normalise(void) throw() { - double length = this->length(); + Type tLength = this->length(); //FIXME - throw div by zero exception? - if(length < 0.0001f) + if(tLength < 0.0001f) { return; } for(uint32_t ct = 0; ct < Size; ++ct) { - m_tElements[ct] /= static_cast(length); + m_tElements[ct] /= tLength; } } }//namespace PolyVox diff --git a/library/PolyVoxCore/source/MeshDecimator.cpp b/library/PolyVoxCore/source/MeshDecimator.cpp index daf6867b..8df0ca39 100644 --- a/library/PolyVoxCore/source/MeshDecimator.cpp +++ b/library/PolyVoxCore/source/MeshDecimator.cpp @@ -141,8 +141,8 @@ namespace PolyVox uint32_t v2 = m_vecTriangles[ct].v2; bool allMatch = - (m_pOutputMesh->m_vecVertices[v0].material == m_pOutputMesh->m_vecVertices[v1].material) && - (m_pOutputMesh->m_vecVertices[v1].material == m_pOutputMesh->m_vecVertices[v2].material); + (m_pOutputMesh->m_vecVertices[v0].material - m_pOutputMesh->m_vecVertices[v1].material < 0.001f) && + (m_pOutputMesh->m_vecVertices[v1].material - m_pOutputMesh->m_vecVertices[v2].material < 0.001f); if(!allMatch) { diff --git a/tests/TestCubicSurfaceExtractor.cpp b/tests/TestCubicSurfaceExtractor.cpp index 7a7557de..0d806fe9 100644 --- a/tests/TestCubicSurfaceExtractor.cpp +++ b/tests/TestCubicSurfaceExtractor.cpp @@ -104,7 +104,6 @@ void TestCubicSurfaceExtractor::testExecute() const static uint32_t uExpectedIndices = 9936; const static uint32_t uMaterialToCheck = 3000; const static float fExpectedMaterial = 42.0f; - const static float fNoMaterial = 1.0f; const static uint32_t uIndexToCheck = 2000; const static uint32_t uExpectedIndex = 1334; diff --git a/tests/TestSurfaceExtractor.cpp b/tests/TestSurfaceExtractor.cpp index fdc6c595..ea657394 100644 --- a/tests/TestSurfaceExtractor.cpp +++ b/tests/TestSurfaceExtractor.cpp @@ -50,7 +50,7 @@ public: return voxel; } - float convertToMaterial(float voxel) + float convertToMaterial(float /*voxel*/) { return 1; } @@ -83,7 +83,7 @@ void writeDensityValueToVoxel(int valueToWrite, MaterialDensityPair88& voxel) } template -void writeMaterialValueToVoxel(int valueToWrite, VoxelType& voxel) +void writeMaterialValueToVoxel(int /*valueToWrite*/, VoxelType& /*voxel*/) { //Most types don't have a material return;