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