From 659529787a4b1aaf96087a6de4edddfd336f23ab Mon Sep 17 00:00:00 2001 From: David Williams Date: Sat, 11 Jun 2011 18:49:56 +0100 Subject: [PATCH] Fixing some warnings in PolyVox. --- examples/OpenGL/Shapes.cpp | 6 +++--- .../include/PolyVoxCore/LargeVolume.inl | 2 +- .../include/PolyVoxCore/MeshDecimator.inl | 10 +++++----- .../include/PolyVoxCore/SurfaceExtractor.inl | 6 +++--- .../include/PolyVoxCore/SurfaceMesh.inl | 10 +++++----- .../PolyVoxCore/include/PolyVoxCore/Vector.inl | 4 ++-- library/PolyVoxCore/source/MeshDecimator.cpp | 16 ++++++++-------- 7 files changed, 27 insertions(+), 27 deletions(-) diff --git a/examples/OpenGL/Shapes.cpp b/examples/OpenGL/Shapes.cpp index dab8a35f..b0ebce02 100644 --- a/examples/OpenGL/Shapes.cpp +++ b/examples/OpenGL/Shapes.cpp @@ -30,7 +30,7 @@ using namespace PolyVox; void createSphereInVolume(LargeVolume& volData, float fRadius, uint8_t uValue) { //This vector hold the position of the center of the volume - Vector3DFloat v3dVolCenter(volData.getWidth() / 2, volData.getHeight() / 2, volData.getDepth() / 2); + Vector3DInt32 v3dVolCenter = (volData.getEnclosingRegion().getUpperCorner() - volData.getEnclosingRegion().getLowerCorner()) / 2; //This three-level for loop iterates over every voxel in the volume for (int z = 0; z < volData.getWidth(); z++) @@ -40,9 +40,9 @@ void createSphereInVolume(LargeVolume& volData, float fRa for (int x = 0; x < volData.getDepth(); x++) { //Store our current position as a vector... - Vector3DFloat v3dCurrentPos(x,y,z); + Vector3DInt32 v3dCurrentPos(x,y,z); //And compute how far the current position is from the center of the volume - float fDistToCenter = (v3dCurrentPos - v3dVolCenter).length(); + double fDistToCenter = (v3dCurrentPos - v3dVolCenter).length(); //If the current voxel is less than 'radius' units from the center //then we make it solid, otherwise we make it empty space. diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl index a6f4e0ec..a6577cb1 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl @@ -359,7 +359,7 @@ namespace PolyVox } Vector3DInt32 v3dSize = v3dEnd - v3dStart + Vector3DInt32(1,1,1); - int32_t numblocks = v3dSize.getX() * v3dSize.getY() * v3dSize.getZ(); + uint32_t numblocks = static_cast(v3dSize.getX() * v3dSize.getY() * v3dSize.getZ()); if(numblocks > m_uMaxNumberOfBlocksInMemory) { // cannot support the amount of blocks... so only load the maximum possible diff --git a/library/PolyVoxCore/include/PolyVoxCore/MeshDecimator.inl b/library/PolyVoxCore/include/PolyVoxCore/MeshDecimator.inl index 8e2cb9db..d3ee9287 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/MeshDecimator.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/MeshDecimator.inl @@ -85,7 +85,7 @@ namespace PolyVox //Build a list of all the triangles, complete with face normals. m_vecTriangles.clear(); m_vecTriangles.resize(m_pOutputMesh->m_vecTriangleIndices.size() / 3); - for(int triCt = 0; triCt < m_vecTriangles.size(); triCt++) + for(uint32_t triCt = 0; triCt < m_vecTriangles.size(); triCt++) { m_vecTriangles[triCt].v0 = m_pOutputMesh->m_vecTriangleIndices[triCt * 3 + 0]; m_vecTriangles[triCt].v1 = m_pOutputMesh->m_vecTriangleIndices[triCt * 3 + 1]; @@ -106,11 +106,11 @@ namespace PolyVox //For each vertex, determine which triangles are using it. trianglesUsingVertex.clear(); trianglesUsingVertex.resize(m_pOutputMesh->m_vecVertices.size()); - for(int ct = 0; ct < trianglesUsingVertex.size(); ct++) + for(uint32_t ct = 0; ct < trianglesUsingVertex.size(); ct++) { trianglesUsingVertex[ct].reserve(6); } - for(int ct = 0; ct < m_vecTriangles.size(); ct++) + for(uint32_t ct = 0; ct < m_vecTriangles.size(); ct++) { trianglesUsingVertex[m_vecTriangles[ct].v0].push_back(ct); trianglesUsingVertex[m_vecTriangles[ct].v1].push_back(ct); @@ -145,7 +145,7 @@ namespace PolyVox } //For each triangle... - for(int ctIter = 0; ctIter < m_vecTriangles.size(); ctIter++) + for(uint32_t ctIter = 0; ctIter < m_vecTriangles.size(); ctIter++) { if(attemptEdgeCollapse(m_vecTriangles[ctIter].v0, m_vecTriangles[ctIter].v1)) { @@ -166,7 +166,7 @@ namespace PolyVox if(noOfEdgesCollapsed > 0) { //Fix up the indices - for(int triCt = 0; triCt < m_pOutputMesh->m_vecTriangleIndices.size(); triCt++) + for(uint32_t triCt = 0; triCt < m_pOutputMesh->m_vecTriangleIndices.size(); triCt++) { uint32_t before = m_pOutputMesh->m_vecTriangleIndices[triCt]; uint32_t after = vertexMapper[m_pOutputMesh->m_vecTriangleIndices[triCt]]; diff --git a/library/PolyVoxCore/include/PolyVoxCore/SurfaceExtractor.inl b/library/PolyVoxCore/include/PolyVoxCore/SurfaceExtractor.inl index f0ae31ac..97aad2c2 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/SurfaceExtractor.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/SurfaceExtractor.inl @@ -450,7 +450,7 @@ namespace PolyVox const uint32_t uMaterial = v000.getMaterial() | v100.getMaterial(); //Because one of these is 0, the or operation takes the max. - PositionMaterialNormal surfaceVertex(v3dPosition, v3dNormal, uMaterial); + PositionMaterialNormal surfaceVertex(v3dPosition, v3dNormal, static_cast(uMaterial)); uint32_t uLastVertexIndex = m_meshCurrent->addVertex(surfaceVertex); m_pCurrentVertexIndicesX[iXVolSpace - m_regSizeInVoxels.getLowerCorner().getX()][iYVolSpace - m_regSizeInVoxels.getLowerCorner().getY()] = uLastVertexIndex; @@ -473,7 +473,7 @@ namespace PolyVox const uint32_t uMaterial = v000.getMaterial() | v010.getMaterial(); //Because one of these is 0, the or operation takes the max. - PositionMaterialNormal surfaceVertex(v3dPosition, v3dNormal, uMaterial); + PositionMaterialNormal surfaceVertex(v3dPosition, v3dNormal, static_cast(uMaterial)); uint32_t uLastVertexIndex = m_meshCurrent->addVertex(surfaceVertex); m_pCurrentVertexIndicesY[iXVolSpace - m_regSizeInVoxels.getLowerCorner().getX()][iYVolSpace - m_regSizeInVoxels.getLowerCorner().getY()] = uLastVertexIndex; @@ -496,7 +496,7 @@ namespace PolyVox const uint32_t uMaterial = v000.getMaterial() | v001.getMaterial(); //Because one of these is 0, the or operation takes the max. - PositionMaterialNormal surfaceVertex(v3dPosition, v3dNormal, uMaterial); + PositionMaterialNormal surfaceVertex(v3dPosition, v3dNormal, static_cast(uMaterial)); uint32_t uLastVertexIndex = m_meshCurrent->addVertex(surfaceVertex); m_pCurrentVertexIndicesZ[iXVolSpace - m_regSizeInVoxels.getLowerCorner().getX()][iYVolSpace - m_regSizeInVoxels.getLowerCorner().getY()] = uLastVertexIndex; diff --git a/library/PolyVoxCore/include/PolyVoxCore/SurfaceMesh.inl b/library/PolyVoxCore/include/PolyVoxCore/SurfaceMesh.inl index ff431cc2..a9158160 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/SurfaceMesh.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/SurfaceMesh.inl @@ -316,7 +316,7 @@ namespace PolyVox int SurfaceMesh::noOfDegenerateTris(void) { int count = 0; - for(int triCt = 0; triCt < m_vecTriangleIndices.size();) + for(uint32_t triCt = 0; triCt < m_vecTriangleIndices.size();) { int v0 = m_vecTriangleIndices[triCt]; triCt++; @@ -338,7 +338,7 @@ namespace PolyVox { int noOfNonDegenerate = 0; int targetCt = 0; - for(int triCt = 0; triCt < m_vecTriangleIndices.size();) + for(uint32_t triCt = 0; triCt < m_vecTriangleIndices.size();) { int v0 = m_vecTriangleIndices[triCt]; triCt++; @@ -369,7 +369,7 @@ namespace PolyVox vector isVertexUsed(m_vecVertices.size()); fill(isVertexUsed.begin(), isVertexUsed.end(), false); - for(int triCt = 0; triCt < m_vecTriangleIndices.size(); triCt++) + for(uint32_t triCt = 0; triCt < m_vecTriangleIndices.size(); triCt++) { int v = m_vecTriangleIndices[triCt]; isVertexUsed[v] = true; @@ -377,7 +377,7 @@ namespace PolyVox int noOfUsedVertices = 0; vector newPos(m_vecVertices.size()); - for(int vertCt = 0; vertCt < m_vecVertices.size(); vertCt++) + for(uint32_t vertCt = 0; vertCt < m_vecVertices.size(); vertCt++) { if(isVertexUsed[vertCt]) { @@ -389,7 +389,7 @@ namespace PolyVox m_vecVertices.resize(noOfUsedVertices); - for(int triCt = 0; triCt < m_vecTriangleIndices.size(); triCt++) + for(uint32_t triCt = 0; triCt < m_vecTriangleIndices.size(); triCt++) { m_vecTriangleIndices[triCt] = newPos[m_vecTriangleIndices[triCt]]; } diff --git a/library/PolyVoxCore/include/PolyVoxCore/Vector.inl b/library/PolyVoxCore/include/PolyVoxCore/Vector.inl index 2c45bf2e..3b473478 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Vector.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/Vector.inl @@ -94,7 +94,7 @@ namespace PolyVox /** This copy constructor allows casting between vectors with different data types. It is now possible to use code such as: - + Vector3DDouble v3dDouble(1.0,2.0,3.0); Vector3DFloat v3dFloat = static_cast(v3dDouble); //Casting @@ -106,7 +106,7 @@ namespace PolyVox { for(uint32_t ct = 0; ct < Size; ++ct) { - m_tElements[ct] = static_cast(vector.getElement(ct)); + m_tElements[ct] = static_cast(vector.getElement(ct)); } } diff --git a/library/PolyVoxCore/source/MeshDecimator.cpp b/library/PolyVoxCore/source/MeshDecimator.cpp index c1498828..1908f5ac 100644 --- a/library/PolyVoxCore/source/MeshDecimator.cpp +++ b/library/PolyVoxCore/source/MeshDecimator.cpp @@ -10,7 +10,7 @@ namespace PolyVox vecVertexMetadata.clear(); vecVertexMetadata.resize(m_pOutputMesh->m_vecVertices.size()); //Initialise the metadata - for(int ct = 0; ct < vecVertexMetadata.size(); ct++) + for(uint32_t ct = 0; ct < vecVertexMetadata.size(); ct++) { vecVertexMetadata[ct].normal.setElements(0,0,0); vecVertexMetadata[ct].isOnMaterialEdge = false; @@ -22,7 +22,7 @@ namespace PolyVox //CubicSurfaceExtractor in. Duplicates are now neighbours in the resulting list so just scan through for pairs. std::vector intVertices; intVertices.reserve(m_pOutputMesh->m_vecVertices.size()); - for(int ct = 0; ct < m_pOutputMesh->m_vecVertices.size(); ct++) + for(uint32_t ct = 0; ct < m_pOutputMesh->m_vecVertices.size(); ct++) { const Vector3DFloat& floatPos = m_pOutputMesh->m_vecVertices[ct].position; IntVertex intVertex(static_cast(floatPos.getX()), static_cast(floatPos.getY()), static_cast(floatPos.getZ()), ct); @@ -33,7 +33,7 @@ namespace PolyVox sort(intVertices.begin(), intVertices.end()); //Find neighbours which are duplicates. - for(int ct = 0; ct < intVertices.size() - 1; ct++) + for(uint32_t ct = 0; ct < intVertices.size() - 1; ct++) { const IntVertex& v0 = intVertices[ct+0]; const IntVertex& v1 = intVertices[ct+1]; @@ -46,7 +46,7 @@ namespace PolyVox } //Compute an approcimation to the normal, used when deciding if an edge can collapse. - for(int ct = 0; ct < m_pOutputMesh->m_vecVertices.size(); ct++) + for(uint32_t ct = 0; ct < m_pOutputMesh->m_vecVertices.size(); ct++) { Vector3DFloat sumOfNormals(0.0f,0.0f,0.0f); for(vector::const_iterator iter = trianglesUsingVertex[ct].cbegin(); iter != trianglesUsingVertex[ct].cend(); iter++) @@ -59,7 +59,7 @@ namespace PolyVox } //Identify those vertices on the edge of a region. Care will need to be taken when moving them. - for(int ct = 0; ct < vecVertexMetadata.size(); ct++) + for(uint32_t ct = 0; ct < vecVertexMetadata.size(); ct++) { Region regTransformed = m_pOutputMesh->m_Region; regTransformed.shift(regTransformed.getLowerCorner() * static_cast(-1)); @@ -83,7 +83,7 @@ namespace PolyVox vecVertexMetadata.resize(m_pOutputMesh->m_vecVertices.size()); //Initialise the metadata - for(int ct = 0; ct < vecVertexMetadata.size(); ct++) + for(uint32_t ct = 0; ct < vecVertexMetadata.size(); ct++) { vecVertexMetadata[ct].isOnRegionFace.reset(); vecVertexMetadata[ct].isOnMaterialEdge = false; @@ -91,7 +91,7 @@ namespace PolyVox } //Identify those vertices on the edge of a region. Care will need to be taken when moving them. - for(int ct = 0; ct < vecVertexMetadata.size(); ct++) + for(uint32_t ct = 0; ct < vecVertexMetadata.size(); ct++) { Region regTransformed = m_pOutputMesh->m_Region; regTransformed.shift(regTransformed.getLowerCorner() * static_cast(-1)); @@ -110,7 +110,7 @@ namespace PolyVox //If all three vertices have the same material then we are not on a material edge. If any vertex has a different //material then all three vertices are on a material edge. E.g. If one vertex has material 'a' and the other two //have material 'b', then the two 'b's are still on an edge (with 'a') even though they are the same as eachother. - for(int ct = 0; ct < m_vecTriangles.size(); ct++) + for(uint32_t ct = 0; ct < m_vecTriangles.size(); ct++) { uint32_t v0 = m_vecTriangles[ct].v0; uint32_t v1 = m_vecTriangles[ct].v1;