Replaced some assert()s with POLYVOX_ASSERT()s.
This commit is contained in:
parent
5be6a8ba44
commit
858a9c0e1b
@ -21,6 +21,8 @@ freely, subject to the following restrictions:
|
||||
distribution.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "PolyVoxCore/Impl/ErrorHandling.h"
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -296,14 +298,14 @@ namespace PolyVox
|
||||
hVal = SixConnectedCost(a, b);
|
||||
break;
|
||||
default:
|
||||
assert(false); //Invalid case.
|
||||
POLYVOX_ASSERT(false, "Invalid case");
|
||||
}
|
||||
|
||||
//Sanity checks in debug mode. These can come out eventually, but I
|
||||
//want to make sure that the heuristics I've come up with make sense.
|
||||
assert((a-b).length() <= TwentySixConnectedCost(a,b));
|
||||
assert(TwentySixConnectedCost(a,b) <= EighteenConnectedCost(a,b));
|
||||
assert(EighteenConnectedCost(a,b) <= SixConnectedCost(a,b));
|
||||
POLYVOX_ASSERT((a-b).length() <= TwentySixConnectedCost(a,b), "A* heuristic error.");
|
||||
POLYVOX_ASSERT(TwentySixConnectedCost(a,b) <= EighteenConnectedCost(a,b), "A* heuristic error.");
|
||||
POLYVOX_ASSERT(EighteenConnectedCost(a,b) <= SixConnectedCost(a,b), "A* heuristic error.");
|
||||
|
||||
//Apply the bias to the computed h value;
|
||||
hVal *= m_params.hBias;
|
||||
|
@ -39,9 +39,9 @@ namespace PolyVox
|
||||
uint16_t uIndexIncreament;
|
||||
|
||||
//Make sure that the size of the volume is an exact multiple of the size of the array.
|
||||
assert(volInput->getWidth() % arrayResult->getDimension(0) == 0);
|
||||
assert(volInput->getHeight() % arrayResult->getDimension(1) == 0);
|
||||
assert(volInput->getDepth() % arrayResult->getDimension(2) == 0);
|
||||
POLYVOX_ASSERT(volInput->getWidth() % arrayResult->getDimension(0) == 0, "Volume width must be an exact multiple of array width.");
|
||||
POLYVOX_ASSERT(volInput->getHeight() % arrayResult->getDimension(1) == 0, "Volume height must be an exact multiple of array height.");
|
||||
POLYVOX_ASSERT(volInput->getDepth() % arrayResult->getDimension(2) == 0, "Volume depth must be an exact multiple of array depth.");
|
||||
|
||||
//Our initial indices. It doesn't matter exactly what we set here, but the code below makes
|
||||
//sure they are different for different regions which helps reduce tiling patterns in the results.
|
||||
@ -116,7 +116,7 @@ namespace PolyVox
|
||||
else
|
||||
{
|
||||
fVisibility = static_cast<float>(uVisibleDirections) / static_cast<float>(uNoOfSamplesPerOutputElement);
|
||||
assert((fVisibility >= 0.0f) && (fVisibility <= 1.0f));
|
||||
POLYVOX_ASSERT((fVisibility >= 0.0f) && (fVisibility <= 1.0f), "Visibility value out of range.");
|
||||
}
|
||||
|
||||
(*arrayResult)[z / iRatioZ][y / iRatioY][x / iRatioX] = static_cast<uint8_t>(255.0f * fVisibility);
|
||||
|
@ -73,7 +73,7 @@ namespace PolyVox
|
||||
template <uint32_t noOfDims, typename ElementType>
|
||||
SubArray<noOfDims-1, ElementType> Array<noOfDims, ElementType>::operator[](uint32_t uIndex)
|
||||
{
|
||||
assert(uIndex<m_pDimensions[0]);
|
||||
POLYVOX_ASSERT(uIndex < m_pDimensions[0], "Index out of range");
|
||||
return
|
||||
SubArray<noOfDims-1, ElementType>(&m_pElements[uIndex*m_pOffsets[0]],
|
||||
m_pDimensions+1, m_pOffsets+1);
|
||||
@ -91,7 +91,7 @@ namespace PolyVox
|
||||
template <uint32_t noOfDims, typename ElementType>
|
||||
const SubArray<noOfDims-1, ElementType> Array<noOfDims, ElementType>::operator[](uint32_t uIndex) const
|
||||
{
|
||||
assert(uIndex<m_pDimensions[0]);
|
||||
POLYVOX_ASSERT(uIndex < m_pDimensions[0], "Index out of range");
|
||||
return
|
||||
SubArray<noOfDims-1, ElementType>(&m_pElements[uIndex*m_pOffsets[0]],
|
||||
m_pDimensions+1, m_pOffsets+1);
|
||||
@ -139,7 +139,7 @@ namespace PolyVox
|
||||
m_uNoOfElements = 1;
|
||||
for (uint32_t i = 0; i<noOfDims; i++)
|
||||
{
|
||||
assert(pDimensions[i] != 0);
|
||||
POLYVOX_ASSERT(pDimensions[i] != 0, "Invalid dimension");
|
||||
|
||||
m_uNoOfElements *= pDimensions[i];
|
||||
m_pDimensions[i] = pDimensions[i];
|
||||
@ -186,7 +186,7 @@ namespace PolyVox
|
||||
template <uint32_t noOfDims, typename ElementType>
|
||||
uint32_t Array<noOfDims, ElementType>::getDimension(uint32_t uDimension)
|
||||
{
|
||||
assert(uDimension < noOfDims);
|
||||
POLYVOX_ASSERT(uDimension < noOfDims, "Dimension out of range");
|
||||
return m_pDimensions[uDimension];
|
||||
}
|
||||
|
||||
@ -198,14 +198,14 @@ namespace PolyVox
|
||||
,m_uNoOfElements(0)
|
||||
{
|
||||
//Not implemented
|
||||
assert(false);
|
||||
POLYVOX_ASSERT(false, "Not implemented.");
|
||||
}
|
||||
|
||||
template <uint32_t noOfDims, typename ElementType>
|
||||
Array<noOfDims, ElementType>& Array<noOfDims, ElementType>::operator=(const Array<noOfDims, ElementType>& rhs)
|
||||
{
|
||||
//Not implemented
|
||||
assert(false);
|
||||
POLYVOX_ASSERT(false, "Not implemented.");
|
||||
|
||||
return *this;
|
||||
}
|
||||
@ -251,14 +251,14 @@ namespace PolyVox
|
||||
template <typename ElementType>
|
||||
ElementType& Array<1, ElementType>::operator[] (uint32_t uIndex)
|
||||
{
|
||||
assert(uIndex<m_pDimensions[0]);
|
||||
POLYVOX_ASSERT(uIndex < m_pDimensions[0], "Index out of range");
|
||||
return m_pElements[uIndex];
|
||||
}
|
||||
|
||||
template <typename ElementType>
|
||||
const ElementType& Array<1, ElementType>::operator[] (uint32_t uIndex) const
|
||||
{
|
||||
assert(uIndex<m_pDimensions[0]);
|
||||
POLYVOX_ASSERT(uIndex < m_pDimensions[0], "Index out of range");
|
||||
return m_pElements[uIndex];
|
||||
}
|
||||
|
||||
@ -307,14 +307,14 @@ namespace PolyVox
|
||||
,m_pDimensions(0)
|
||||
{
|
||||
//Not implemented
|
||||
assert(false);
|
||||
POLYVOX_ASSERT(false, "Not implemented.");
|
||||
}
|
||||
|
||||
template <typename ElementType>
|
||||
Array<1, ElementType>& Array<1, ElementType>::operator=(const Array<1, ElementType>& rhs)
|
||||
{
|
||||
//Not implemented
|
||||
assert(false);
|
||||
POLYVOX_ASSERT(false, "Not implemented.");
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
@ -24,7 +24,8 @@ freely, subject to the following restrictions:
|
||||
#include "PolyVoxCore/Impl/Utility.h"
|
||||
#include "PolyVoxCore/Vector.h"
|
||||
|
||||
#include <cassert>
|
||||
#include "PolyVoxCore/Impl/ErrorHandling.h"
|
||||
|
||||
#include <cstring> //For memcpy
|
||||
#include <limits>
|
||||
#include <stdexcept> //for std::invalid_argument
|
||||
@ -54,11 +55,11 @@ namespace PolyVox
|
||||
template <typename VoxelType>
|
||||
VoxelType Block<VoxelType>::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, "Supplied position is outside of the block");
|
||||
POLYVOX_ASSERT(uYPos < m_uSideLength, "Supplied position is outside of the block");
|
||||
POLYVOX_ASSERT(uZPos < m_uSideLength, "Supplied position is outside of the block");
|
||||
|
||||
assert(m_tUncompressedData);
|
||||
POLYVOX_ASSERT(m_tUncompressedData, "No uncompressed data - block must be decompressed before accessing voxels.");
|
||||
|
||||
return m_tUncompressedData
|
||||
[
|
||||
@ -77,11 +78,11 @@ namespace PolyVox
|
||||
template <typename VoxelType>
|
||||
void Block<VoxelType>::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, "Supplied position is outside of the block");
|
||||
POLYVOX_ASSERT(uYPos < m_uSideLength, "Supplied position is outside of the block");
|
||||
POLYVOX_ASSERT(uZPos < m_uSideLength, "Supplied position is outside of the block");
|
||||
|
||||
assert(m_tUncompressedData);
|
||||
POLYVOX_ASSERT(m_tUncompressedData, "No uncompressed data - block must be decompressed before accessing voxels.");
|
||||
|
||||
m_tUncompressedData
|
||||
[
|
||||
@ -125,7 +126,7 @@ namespace PolyVox
|
||||
void Block<VoxelType>::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))
|
||||
@ -151,8 +152,8 @@ namespace PolyVox
|
||||
template <typename VoxelType>
|
||||
void Block<VoxelType>::compress(void)
|
||||
{
|
||||
assert(m_bIsCompressed == false);
|
||||
assert(m_tUncompressedData != 0);
|
||||
POLYVOX_ASSERT(m_bIsCompressed == false, "Attempted to compress block which is already flagged as compressed.");
|
||||
POLYVOX_ASSERT(m_tUncompressedData != 0, "No uncompressed data is present.");
|
||||
|
||||
//If the uncompressed data hasn't actually been
|
||||
//modified then we don't need to redo the compression.
|
||||
@ -197,8 +198,8 @@ namespace PolyVox
|
||||
template <typename VoxelType>
|
||||
void Block<VoxelType>::uncompress(void)
|
||||
{
|
||||
assert(m_bIsCompressed == true);
|
||||
assert(m_tUncompressedData == 0);
|
||||
POLYVOX_ASSERT(m_bIsCompressed == true, "Attempted to uncompress block which is not flagged as compressed.");
|
||||
POLYVOX_ASSERT(m_tUncompressedData == 0, "Uncompressed data already exists.");
|
||||
m_tUncompressedData = new VoxelType[m_uSideLength * m_uSideLength * m_uSideLength];
|
||||
|
||||
VoxelType* pUncompressedData = m_tUncompressedData;
|
||||
|
@ -21,14 +21,14 @@ misrepresented as being the original software.
|
||||
distribution.
|
||||
*******************************************************************************/
|
||||
|
||||
#include <cassert>
|
||||
#include "PolyVoxCore/Impl/ErrorHandling.h"
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
template <uint32_t noOfDims, typename ElementType>
|
||||
SubArray<noOfDims-1, ElementType> SubArray<noOfDims, ElementType>::operator[](uint32_t uIndex)
|
||||
{
|
||||
assert(uIndex<m_pDimensions[0]);
|
||||
POLYVOX_ASSERT(uIndex < m_pDimensions[0], "Index out of range");
|
||||
return
|
||||
SubArray<noOfDims-1, ElementType>(&m_pElements[uIndex*m_pOffsets[0]],
|
||||
m_pDimensions+1, m_pOffsets+1);
|
||||
@ -37,7 +37,7 @@ namespace PolyVox
|
||||
template <uint32_t noOfDims, typename ElementType>
|
||||
const SubArray<noOfDims-1, ElementType> SubArray<noOfDims, ElementType>::operator[](uint32_t uIndex) const
|
||||
{
|
||||
assert(uIndex<m_pDimensions[0]);
|
||||
POLYVOX_ASSERT(uIndex < m_pDimensions[0], "Index out of range");
|
||||
return
|
||||
SubArray<noOfDims-1, ElementType>(&m_pElements[uIndex*m_pOffsets[0]],
|
||||
m_pDimensions+1, m_pOffsets+1);
|
||||
@ -56,14 +56,14 @@ namespace PolyVox
|
||||
template <typename ElementType>
|
||||
ElementType& SubArray<1, ElementType>::operator[] (uint32_t uIndex)
|
||||
{
|
||||
assert(uIndex<m_pDimensions[0]);
|
||||
POLYVOX_ASSERT(uIndex < m_pDimensions[0], "Index out of range");
|
||||
return m_pElements[uIndex];
|
||||
}
|
||||
|
||||
template <typename ElementType>
|
||||
const ElementType& SubArray<1, ElementType>::operator[] (uint32_t uIndex) const
|
||||
{
|
||||
assert(uIndex<m_pDimensions[0]);
|
||||
POLYVOX_ASSERT(uIndex < m_pDimensions[0], "Index out of range");
|
||||
return m_pElements[uIndex];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user