From 29720c4568ae55ebc3c37802f3658ea333012939 Mon Sep 17 00:00:00 2001 From: David Williams Date: Tue, 1 Jan 2013 14:50:58 +0000 Subject: [PATCH] More replacing assert() with POLYVOX_ASSERT. --- .../include/PolyVoxCore/BaseVolume.inl | 22 +++++++++---------- .../include/PolyVoxCore/BaseVolumeSampler.inl | 2 +- .../include/PolyVoxCore/ConstVolumeProxy.h | 8 +++---- .../PolyVoxCore/CubicSurfaceExtractor.inl | 2 +- .../include/PolyVoxCore/Interpolation.h | 10 ++++----- .../include/PolyVoxCore/LargeVolume.inl | 19 ++++++++-------- .../PolyVoxCore/LargeVolumeSampler.inl | 2 +- 7 files changed, 33 insertions(+), 32 deletions(-) diff --git a/library/PolyVoxCore/include/PolyVoxCore/BaseVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/BaseVolume.inl index 7d5d48fa..77949413 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/BaseVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/BaseVolume.inl @@ -38,14 +38,14 @@ namespace PolyVox //////////////////////////////////////////////////////////////////////////////// /// This function should never be called. Copying volumes by value would be expensive, and we want to prevent users from doing /// it by accident (such as when passing them as paramenters to functions). That said, there are times when you really do want to - /// make a copy of a volume and in this case you should look at the Volumeresampler. + /// make a copy of a volume and in this case you should look at the VolumeResampler. /// /// \sa VolumeResampler //////////////////////////////////////////////////////////////////////////////// template BaseVolume::BaseVolume(const BaseVolume& /*rhs*/) { - assert(false); // See function comment above. + POLYVOX_ASSERT(false, "Copy constructor not implemented."); // See function comment above. } //////////////////////////////////////////////////////////////////////////////// @@ -66,7 +66,7 @@ namespace PolyVox template BaseVolume& BaseVolume::operator=(const BaseVolume& /*rhs*/) { - assert(false); // See function comment above. + POLYVOX_ASSERT(false, "Assignment operator not implemented."); // See function comment above. } //////////////////////////////////////////////////////////////////////////////// @@ -162,7 +162,7 @@ namespace PolyVox template VoxelType BaseVolume::getVoxel(int32_t /*uXPos*/, int32_t /*uYPos*/, int32_t /*uZPos*/) const { - assert(false); + POLYVOX_ASSERT(false, "You should never call the base class version of this function."); return VoxelType(); } @@ -173,7 +173,7 @@ namespace PolyVox template VoxelType BaseVolume::getVoxel(const Vector3DInt32& /*v3dPos*/) const { - assert(false); + POLYVOX_ASSERT(false, "You should never call the base class version of this function."); return VoxelType(); } @@ -186,7 +186,7 @@ namespace PolyVox template VoxelType BaseVolume::getVoxelAt(int32_t /*uXPos*/, int32_t /*uYPos*/, int32_t /*uZPos*/) const { - assert(false); + POLYVOX_ASSERT(false, "You should never call the base class version of this function."); return VoxelType(); } @@ -197,7 +197,7 @@ namespace PolyVox template VoxelType BaseVolume::getVoxelAt(const Vector3DInt32& /*v3dPos*/) const { - assert(false); + POLYVOX_ASSERT(false, "You should never call the base class version of this function."); return VoxelType(); } @@ -210,7 +210,7 @@ namespace PolyVox template VoxelType BaseVolume::getVoxelWithWrapping(int32_t /*uXPos*/, int32_t /*uYPos*/, int32_t /*uZPos*/, WrapMode /*eWrapMode*/, VoxelType /*tBorder*/) const { - assert(false); + POLYVOX_ASSERT(false, "You should never call the base class version of this function."); return VoxelType(); } @@ -221,7 +221,7 @@ namespace PolyVox template VoxelType BaseVolume::getVoxelWithWrapping(const Vector3DInt32& /*v3dPos*/, WrapMode /*eWrapMode*/, VoxelType /*tBorder*/) const { - assert(false); + POLYVOX_ASSERT(false, "You should never call the base class version of this function."); return VoxelType(); } @@ -244,7 +244,7 @@ namespace PolyVox template bool BaseVolume::setVoxelAt(int32_t /*uXPos*/, int32_t /*uYPos*/, int32_t /*uZPos*/, VoxelType /*tValue*/) { - assert(false); + POLYVOX_ASSERT(false, "You should never call the base class version of this function."); return false; } @@ -256,7 +256,7 @@ namespace PolyVox template bool BaseVolume::setVoxelAt(const Vector3DInt32& /*v3dPos*/, VoxelType /*tValue*/) { - assert(false); + POLYVOX_ASSERT(false, "You should never call the base class version of this function."); return false; } diff --git a/library/PolyVoxCore/include/PolyVoxCore/BaseVolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/BaseVolumeSampler.inl index fb7fe6b1..ef136db8 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/BaseVolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/BaseVolumeSampler.inl @@ -375,7 +375,7 @@ namespace PolyVox default: { //Should never happen - assert(false); + POLYVOX_ASSERT(false, "Invalid case."); return VoxelType(0); } } diff --git a/library/PolyVoxCore/include/PolyVoxCore/ConstVolumeProxy.h b/library/PolyVoxCore/include/PolyVoxCore/ConstVolumeProxy.h index e778bbcf..63cc16ca 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/ConstVolumeProxy.h +++ b/library/PolyVoxCore/include/PolyVoxCore/ConstVolumeProxy.h @@ -37,25 +37,25 @@ namespace PolyVox public: VoxelType getVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos) const { - assert(m_regValid.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos))); + POLYVOX_ASSERT(m_regValid.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos)), "Position is outside valid region"); return m_pVolume.getVoxelAt(uXPos, uYPos, uZPos); } VoxelType getVoxelAt(const Vector3DInt32& v3dPos) const { - assert(m_regValid.containsPoint(v3dPos)); + POLYVOX_ASSERT(m_regValid.containsPoint(v3dPos), "Position is outside valid region"); return getVoxelAt(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ()); } void setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue) const { - assert(m_regValid.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos))); + POLYVOX_ASSERT(m_regValid.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos)), "Position is outside valid region"); m_pVolume.setVoxelAtConst(uXPos, uYPos, uZPos, tValue); } void setVoxelAt(const Vector3DInt32& v3dPos, VoxelType tValue) const { - assert(m_regValid.containsPoint(v3dPos)); + POLYVOX_ASSERT(m_regValid.containsPoint(v3dPos), "Position is outside valid region"); setVoxelAt(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), tValue); } private: diff --git a/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.inl b/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.inl index c9b793f5..5cf72fc6 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.inl @@ -224,7 +224,7 @@ namespace PolyVox // If we exit the loop here then apparently all the slots were full but none of them matched. I don't think // this can happen so let's put an assert to make sure. If you hit this assert then please report it to us! - assert(false); + POLYVOX_ASSERT(false, "All slots full but no matches."); return -1; //Should never happen. } diff --git a/library/PolyVoxCore/include/PolyVoxCore/Interpolation.h b/library/PolyVoxCore/include/PolyVoxCore/Interpolation.h index 09c063c9..b0574dd8 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Interpolation.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Interpolation.h @@ -33,7 +33,7 @@ namespace PolyVox const Type& v0,const Type& v1, const float x) { - assert((x >= 0.0f) && (x <= 1.0f)); + POLYVOX_ASSERT((x >= 0.0f) && (x <= 1.0f), "Interpolation input out of 0.0 to 1.0 range."); //Interpolate along X Type v0_1 = (v1 - v0) * x + v0; @@ -46,8 +46,8 @@ namespace PolyVox const Type& v00,const Type& v10,const Type& v01,const Type& v11, const float x, const float y) { - assert((x >= 0.0f) && (y >= 0.0f) && - (x <= 1.0f) && (y <= 1.0f)); + POLYVOX_ASSERT((x >= 0.0f) && (y >= 0.0f) && + (x <= 1.0f) && (y <= 1.0f), "Interpolation input out of 0.0 to 1.0 range."); // Linearly interpolate along x Type v00_10 = lerp(v00, v10, x); @@ -65,8 +65,8 @@ namespace PolyVox const Type& v001,const Type& v101,const Type& v011,const Type& v111, const float x, const float y, const float z) { - assert((x >= 0.0f) && (y >= 0.0f) && (z >= 0.0f) && - (x <= 1.0f) && (y <= 1.0f) && (z <= 1.0f)); + POLYVOX_ASSERT((x >= 0.0f) && (y >= 0.0f) && (z >= 0.0f) && + (x <= 1.0f) && (y <= 1.0f) && (z <= 1.0f), "Interpolation input out of 0.0 to 1.0 range."); // Bilinearly interpolate along Y Type v000_v100__v010_v110 = bilerp(v000, v100, v010, v110, x, y); diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl index fc476908..5cc06a9a 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl @@ -87,7 +87,7 @@ namespace PolyVox template LargeVolume::LargeVolume(const LargeVolume& /*rhs*/) { - assert(false); // See function comment above. + POLYVOX_ASSERT(false, "Copy constructor not implemented."); // See function comment above. } //////////////////////////////////////////////////////////////////////////////// @@ -109,7 +109,7 @@ namespace PolyVox template LargeVolume& LargeVolume::operator=(const LargeVolume& /*rhs*/) { - assert(false); // See function comment above. + POLYVOX_ASSERT(false, "Assignment operator not implemented."); // See function comment above. } //////////////////////////////////////////////////////////////////////////////// @@ -121,7 +121,7 @@ namespace PolyVox template VoxelType LargeVolume::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; @@ -225,7 +225,7 @@ namespace PolyVox default: { //Should never happen - assert(false); + POLYVOX_ASSERT(false, "Invlaid case."); return VoxelType(0); } } @@ -303,7 +303,7 @@ namespace PolyVox template bool LargeVolume::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; @@ -468,7 +468,8 @@ namespace PolyVox void LargeVolume::initialise(const Region& regValidRegion, uint16_t uBlockSideLength) { //Debug mode validation - assert(uBlockSideLength > 0); + POLYVOX_ASSERT(uBlockSideLength > 0, "Block side length cannot be zero."); + POLYVOX_ASSERT(isPowerOf2(uBlockSideLength), "Block side length must be a power of two."); //Release mode validation if(uBlockSideLength == 0) @@ -583,7 +584,7 @@ namespace PolyVox //This check should also provide a significant speed boost as usually it is true. if((v3dBlockPos == m_v3dLastAccessedBlockPos) && (m_pLastAccessedBlock != 0)) { - assert(m_pLastAccessedBlock->m_tUncompressedData); + POLYVOX_ASSERT(m_pLastAccessedBlock->m_tUncompressedData, "Block has no uncompressed data"); return m_pLastAccessedBlock; } @@ -643,7 +644,7 @@ namespace PolyVox if(loadedBlock.block.m_bIsCompressed == false) { - assert(m_pLastAccessedBlock->m_tUncompressedData); + POLYVOX_ASSERT(m_pLastAccessedBlock->m_tUncompressedData, "Block has no uncompressed data"); return m_pLastAccessedBlock; } @@ -680,7 +681,7 @@ namespace PolyVox loadedBlock.block.uncompress(); m_pLastAccessedBlock = &(loadedBlock.block); - assert(m_pLastAccessedBlock->m_tUncompressedData); + POLYVOX_ASSERT(m_pLastAccessedBlock->m_tUncompressedData, "Block has no uncompressed data"); return m_pLastAccessedBlock; } diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl index b6f3fc4f..024b3cdb 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl @@ -143,7 +143,7 @@ namespace PolyVox }*/ //Need to think what effect this has on any existing iterators. - assert(false); + POLYVOX_ASSERT(false, "This function cnnot be used on LargeVolume samplers."); return false; }