More replacing assert() with POLYVOX_ASSERT

This commit is contained in:
David Williams 2013-01-01 15:34:34 +00:00
parent 29720c4568
commit 4ee55bba2e
7 changed files with 37 additions and 49 deletions

View File

@ -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<uint32_t>(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++;

View File

@ -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)

View File

@ -47,7 +47,7 @@ namespace PolyVox
template <typename VoxelType>
RawVolume<VoxelType>::RawVolume(const RawVolume<VoxelType>& /*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 <typename VoxelType>
RawVolume<VoxelType>& RawVolume<VoxelType>::operator=(const RawVolume<VoxelType>& /*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 <typename VoxelType>
VoxelType RawVolume<VoxelType>::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()];

View File

@ -48,7 +48,7 @@ namespace PolyVox
template <typename VoxelType>
SimpleVolume<VoxelType>::SimpleVolume(const SimpleVolume<VoxelType>& /*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 <typename VoxelType>
SimpleVolume<VoxelType>& SimpleVolume<VoxelType>::operator=(const SimpleVolume<VoxelType>& /*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 <typename VoxelType>
VoxelType SimpleVolume<VoxelType>::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 <typename VoxelType>
bool SimpleVolume<VoxelType>::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<VoxelType>::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 =

View File

@ -52,11 +52,11 @@ namespace PolyVox
template <typename VoxelType>
VoxelType SimpleVolume<VoxelType>::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 <typename VoxelType>
void SimpleVolume<VoxelType>::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<VoxelType>::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))

View File

@ -103,9 +103,9 @@ namespace PolyVox
void SurfaceMesh<VertexType>::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<VertexType>::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.

View File

@ -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()));