From 4ee55bba2ec243ae0e23a48298eca9fe342f02ce Mon Sep 17 00:00:00 2001 From: David Williams Date: Tue, 1 Jan 2013 15:34:34 +0000 Subject: [PATCH] More replacing assert() with POLYVOX_ASSERT --- .../include/PolyVoxCore/LowPassFilter.inl | 4 ++-- .../MarchingCubesSurfaceExtractor.inl | 12 ---------- .../include/PolyVoxCore/RawVolume.inl | 14 ++++++------ .../include/PolyVoxCore/SimpleVolume.inl | 22 +++++++++---------- .../include/PolyVoxCore/SimpleVolumeBlock.inl | 18 +++++++-------- .../include/PolyVoxCore/SurfaceMesh.inl | 14 ++++++------ library/PolyVoxCore/source/Region.cpp | 2 +- 7 files changed, 37 insertions(+), 49 deletions(-) diff --git a/library/PolyVoxCore/include/PolyVoxCore/LowPassFilter.inl b/library/PolyVoxCore/include/PolyVoxCore/LowPassFilter.inl index a3cb81b1..cb455921 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LowPassFilter.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/LowPassFilter.inl @@ -39,11 +39,11 @@ namespace PolyVox ,m_uKernelSize(uKernelSize) { //Kernel size must be at least three - assert(m_uKernelSize >= 3); + POLYVOX_ASSERT(m_uKernelSize >= 3, "Kernel size must be at least three"); m_uKernelSize = std::max(m_uKernelSize, static_cast(3)); //For release builds //Kernel size must be odd - assert(m_uKernelSize % 2 == 1); + POLYVOX_ASSERT(m_uKernelSize % 2 == 1, "Kernel size must be odd"); if(m_uKernelSize % 2 == 0) //For release builds { m_uKernelSize++; diff --git a/library/PolyVoxCore/include/PolyVoxCore/MarchingCubesSurfaceExtractor.inl b/library/PolyVoxCore/include/PolyVoxCore/MarchingCubesSurfaceExtractor.inl index 1ca352eb..78e90c0a 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/MarchingCubesSurfaceExtractor.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/MarchingCubesSurfaceExtractor.inl @@ -550,62 +550,50 @@ namespace PolyVox if (edgeTable[iCubeIndex] & 1) { indlist[0] = m_pPreviousVertexIndicesX[uXRegSpace][uYRegSpace]; - //assert(indlist[0] != -1); } if (edgeTable[iCubeIndex] & 2) { indlist[1] = m_pPreviousVertexIndicesY[uXRegSpace+1][uYRegSpace]; - //assert(indlist[1] != -1); } if (edgeTable[iCubeIndex] & 4) { indlist[2] = m_pPreviousVertexIndicesX[uXRegSpace][uYRegSpace+1]; - //assert(indlist[2] != -1); } if (edgeTable[iCubeIndex] & 8) { indlist[3] = m_pPreviousVertexIndicesY[uXRegSpace][uYRegSpace]; - //assert(indlist[3] != -1); } if (edgeTable[iCubeIndex] & 16) { indlist[4] = m_pCurrentVertexIndicesX[uXRegSpace][uYRegSpace]; - //assert(indlist[4] != -1); } if (edgeTable[iCubeIndex] & 32) { indlist[5] = m_pCurrentVertexIndicesY[uXRegSpace+1][uYRegSpace]; - //assert(indlist[5] != -1); } if (edgeTable[iCubeIndex] & 64) { indlist[6] = m_pCurrentVertexIndicesX[uXRegSpace][uYRegSpace+1]; - //assert(indlist[6] != -1); } if (edgeTable[iCubeIndex] & 128) { indlist[7] = m_pCurrentVertexIndicesY[uXRegSpace][uYRegSpace]; - //assert(indlist[7] != -1); } if (edgeTable[iCubeIndex] & 256) { indlist[8] = m_pPreviousVertexIndicesZ[uXRegSpace][uYRegSpace]; - //assert(indlist[8] != -1); } if (edgeTable[iCubeIndex] & 512) { indlist[9] = m_pPreviousVertexIndicesZ[uXRegSpace+1][uYRegSpace]; - //assert(indlist[9] != -1); } if (edgeTable[iCubeIndex] & 1024) { indlist[10] = m_pPreviousVertexIndicesZ[uXRegSpace+1][uYRegSpace+1]; - //assert(indlist[10] != -1); } if (edgeTable[iCubeIndex] & 2048) { indlist[11] = m_pPreviousVertexIndicesZ[uXRegSpace][uYRegSpace+1]; - //assert(indlist[11] != -1); } for (int i=0;triTable[iCubeIndex][i]!=-1;i+=3) diff --git a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl index 8a0a2e34..17e300e6 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl @@ -47,7 +47,7 @@ namespace PolyVox template RawVolume::RawVolume(const RawVolume& /*rhs*/) { - assert(false); // See function comment above. + POLYVOX_ASSERT(false, "Copy constructor not implemented."); // See function comment above. } //////////////////////////////////////////////////////////////////////////////// @@ -70,7 +70,7 @@ namespace PolyVox template RawVolume& RawVolume::operator=(const RawVolume& /*rhs*/) { - assert(false); // See function comment above. + POLYVOX_ASSERT(false, "Assignment operator not implemented."); // See function comment above. } //////////////////////////////////////////////////////////////////////////////// @@ -82,7 +82,7 @@ namespace PolyVox template VoxelType RawVolume::getVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos) const { - assert(this->m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos))); + POLYVOX_ASSERT(this->m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos)), "Position is outside valid region"); const Vector3DInt32& v3dLowerCorner = this->m_regValidRegion.getLowerCorner(); int32_t iLocalXPos = uXPos - v3dLowerCorner.getX(); @@ -186,7 +186,7 @@ namespace PolyVox default: { //Should never happen - assert(false); + POLYVOX_ASSERT(false, "Invalid case."); return VoxelType(0); } } @@ -255,9 +255,9 @@ namespace PolyVox this->m_regValidRegion = regValidRegion; //Ensure dimensions of the specified Region are valid - assert(this->getWidth() > 0); - assert(this->getHeight() > 0); - assert(this->getDepth() > 0); + POLYVOX_ASSERT(this->getWidth() > 0, "Volume width must be greater than zero."); + POLYVOX_ASSERT(this->getHeight() > 0, "Volume width must be greater than zero."); + POLYVOX_ASSERT(this->getDepth() > 0, "Volume width must be greater than zero."); //Create the data m_pData = new VoxelType[this->getWidth() * this->getHeight()* this->getDepth()]; diff --git a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl index a818d70b..938cd997 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl @@ -48,7 +48,7 @@ namespace PolyVox template SimpleVolume::SimpleVolume(const SimpleVolume& /*rhs*/) { - assert(false); // See function comment above. + POLYVOX_ASSERT(false, "Copy constructor not implemented."); // See function comment above. } //////////////////////////////////////////////////////////////////////////////// @@ -70,7 +70,7 @@ namespace PolyVox template SimpleVolume& SimpleVolume::operator=(const SimpleVolume& /*rhs*/) { - assert(false); // See function comment above. + POLYVOX_ASSERT(false, "Assignment operator not implemented."); // See function comment above. } //////////////////////////////////////////////////////////////////////////////// @@ -82,7 +82,7 @@ namespace PolyVox template VoxelType SimpleVolume::getVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos) const { - assert(this->m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos))); + POLYVOX_ASSERT(this->m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos)), "Position is outside valid region"); const int32_t blockX = uXPos >> m_uBlockSideLengthPower; const int32_t blockY = uYPos >> m_uBlockSideLengthPower; @@ -186,7 +186,7 @@ namespace PolyVox default: { //Should never happen - assert(false); + POLYVOX_ASSERT(false, "Invalid case."); return VoxelType(0); } } @@ -212,7 +212,7 @@ namespace PolyVox template bool SimpleVolume::setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue) { - assert(this->m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos))); + POLYVOX_ASSERT(this->m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos)), "Position is outside valid region"); const int32_t blockX = uXPos >> m_uBlockSideLengthPower; const int32_t blockY = uYPos >> m_uBlockSideLengthPower; @@ -248,9 +248,9 @@ namespace PolyVox void SimpleVolume::initialise(const Region& regValidRegion, uint16_t uBlockSideLength) { //Debug mode validation - assert(uBlockSideLength >= 8); - assert(uBlockSideLength <= 256); - assert(isPowerOf2(uBlockSideLength)); + POLYVOX_ASSERT(uBlockSideLength >= 8, "Block side length should be at least 8"); + POLYVOX_ASSERT(uBlockSideLength <= 256, "Block side length should not be more than 256"); + POLYVOX_ASSERT(isPowerOf2(uBlockSideLength), "Block side length must be a power of two."); //Release mode validation if(uBlockSideLength < 8) @@ -308,9 +308,9 @@ namespace PolyVox uBlockY -= m_regValidRegionInBlocks.getLowerCorner().getY(); uBlockZ -= m_regValidRegionInBlocks.getLowerCorner().getZ(); - assert(uBlockX >= 0); - assert(uBlockY >= 0); - assert(uBlockZ >= 0); + POLYVOX_ASSERT(uBlockX >= 0, "Block coordinate must not be negative."); + POLYVOX_ASSERT(uBlockY >= 0, "Block coordinate must not be negative."); + POLYVOX_ASSERT(uBlockZ >= 0, "Block coordinate must not be negative."); //Compute the block index uint32_t uBlockIndex = diff --git a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeBlock.inl b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeBlock.inl index e603ff81..c65ca4cb 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeBlock.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeBlock.inl @@ -52,11 +52,11 @@ namespace PolyVox template VoxelType SimpleVolume::Block::getVoxelAt(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos) const { - assert(uXPos < m_uSideLength); - assert(uYPos < m_uSideLength); - assert(uZPos < m_uSideLength); + POLYVOX_ASSERT(uXPos < m_uSideLength, "Position is outside of the block."); + POLYVOX_ASSERT(uYPos < m_uSideLength, "Position is outside of the block."); + POLYVOX_ASSERT(uZPos < m_uSideLength, "Position is outside of the block."); - assert(m_tUncompressedData); + POLYVOX_ASSERT(m_tUncompressedData, "No uncompressed data available"); return m_tUncompressedData [ @@ -75,11 +75,11 @@ namespace PolyVox template void SimpleVolume::Block::setVoxelAt(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos, VoxelType tValue) { - assert(uXPos < m_uSideLength); - assert(uYPos < m_uSideLength); - assert(uZPos < m_uSideLength); + POLYVOX_ASSERT(uXPos < m_uSideLength, "Position is outside of the block."); + POLYVOX_ASSERT(uYPos < m_uSideLength, "Position is outside of the block."); + POLYVOX_ASSERT(uZPos < m_uSideLength, "Position is outside of the block."); - assert(m_tUncompressedData); + POLYVOX_ASSERT(m_tUncompressedData, "No uncompressed data available"); m_tUncompressedData [ @@ -106,7 +106,7 @@ namespace PolyVox void SimpleVolume::Block::initialise(uint16_t uSideLength) { //Debug mode validation - assert(isPowerOf2(uSideLength)); + POLYVOX_ASSERT(isPowerOf2(uSideLength), "Block side length must be a power of two."); //Release mode validation if(!isPowerOf2(uSideLength)) diff --git a/library/PolyVoxCore/include/PolyVoxCore/SurfaceMesh.inl b/library/PolyVoxCore/include/PolyVoxCore/SurfaceMesh.inl index 1b9f2bd0..1f48a9e2 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/SurfaceMesh.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/SurfaceMesh.inl @@ -103,9 +103,9 @@ namespace PolyVox void SurfaceMesh::addTriangle(uint32_t index0, uint32_t index1, uint32_t index2) { //Make sure the specified indices correspond to valid vertices. - assert(index0 < m_vecVertices.size()); - assert(index1 < m_vecVertices.size()); - assert(index2 < m_vecVertices.size()); + POLYVOX_ASSERT(index0 < m_vecVertices.size(), "Index points at an invalid vertex."); + POLYVOX_ASSERT(index1 < m_vecVertices.size(), "Index points at an invalid vertex."); + POLYVOX_ASSERT(index2 < m_vecVertices.size(), "Index points at an invalid vertex."); m_vecTriangleIndices.push_back(index0); m_vecTriangleIndices.push_back(index1); @@ -116,9 +116,9 @@ namespace PolyVox void SurfaceMesh::addTriangleCubic(uint32_t index0, uint32_t index1, uint32_t index2) { //Make sure the specified indices correspond to valid vertices. - assert(index0 < m_vecVertices.size()); - assert(index1 < m_vecVertices.size()); - assert(index2 < m_vecVertices.size()); + POLYVOX_ASSERT(index0 < m_vecVertices.size(), "Index points at an invalid vertex."); + POLYVOX_ASSERT(index1 < m_vecVertices.size(), "Index points at an invalid vertex."); + POLYVOX_ASSERT(index2 < m_vecVertices.size(), "Index points at an invalid vertex."); m_vecTriangleIndices.push_back(index0); m_vecTriangleIndices.push_back(index1); @@ -408,7 +408,7 @@ namespace PolyVox return result; } - assert(inputMesh.m_vecLodRecords.size() == 1); + POLYVOX_ASSERT(inputMesh.m_vecLodRecords.size() == 1, "Number of LOD records must equal one."); if(inputMesh.m_vecLodRecords.size() != 1) { //If we have done progressive LOD then it's too late to split into subsets. diff --git a/library/PolyVoxCore/source/Region.cpp b/library/PolyVoxCore/source/Region.cpp index 143a537a..6d896d7a 100644 --- a/library/PolyVoxCore/source/Region.cpp +++ b/library/PolyVoxCore/source/Region.cpp @@ -79,7 +79,7 @@ namespace PolyVox */ void Region::accumulate(const Region& reg) { - assert(reg.isValid()); //The result of accumulating an invalid region is not defined. + POLYVOX_ASSERT(reg.isValid(), "You cannot accumulate an invalid region."); //The result of accumulating an invalid region is not defined. m_iLowerX = ((std::min)(m_iLowerX, reg.getLowerX())); m_iLowerY = ((std::min)(m_iLowerY, reg.getLowerY()));