From 4765390ef6e9715327eb3c2d1030c1957c1b162d Mon Sep 17 00:00:00 2001 From: Daviw Williams Date: Fri, 17 May 2013 14:51:14 +0200 Subject: [PATCH] Replaced bool parameter with 'BoundsCheck' parameter for a nicer API. --- .../PolyVoxCore/include/PolyVoxCore/BaseVolume.h | 14 ++++++++++++-- .../PolyVoxCore/include/PolyVoxCore/BaseVolume.inl | 4 ++-- .../PolyVoxCore/include/PolyVoxCore/LargeVolume.h | 4 ++-- .../include/PolyVoxCore/LargeVolume.inl | 8 ++++---- .../PolyVoxCore/include/PolyVoxCore/RawVolume.h | 4 ++-- .../PolyVoxCore/include/PolyVoxCore/RawVolume.inl | 8 ++++---- .../PolyVoxCore/include/PolyVoxCore/SimpleVolume.h | 4 ++-- .../include/PolyVoxCore/SimpleVolume.inl | 8 ++++---- 8 files changed, 32 insertions(+), 22 deletions(-) diff --git a/library/PolyVoxCore/include/PolyVoxCore/BaseVolume.h b/library/PolyVoxCore/include/PolyVoxCore/BaseVolume.h index 4eeb5c62..6965fb0e 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/BaseVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/BaseVolume.h @@ -36,6 +36,16 @@ namespace PolyVox //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// More details to come... //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + namespace BoundsChecks + { + enum BoundsCheck + { + None = 0, + Full = 1 + }; + } + typedef BoundsChecks::BoundsCheck BoundsCheck; + namespace WrapModes { enum WrapMode @@ -147,9 +157,9 @@ namespace PolyVox /// Gets the length of the diagonal in voxels float getDiagonalLength(void) const; /// Gets a voxel at the position given by x,y,z coordinates - VoxelType getVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, bool bPerformBoundsChecks = true) const; + VoxelType getVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, BoundsCheck eBoundsCheck = BoundsChecks::Full) const; /// Gets a voxel at the position given by a 3D vector - VoxelType getVoxel(const Vector3DInt32& v3dPos, bool bPerformBoundsChecks = true) const; + VoxelType getVoxel(const Vector3DInt32& v3dPos, BoundsCheck eBoundsCheck = BoundsChecks::Full) const; /// Gets a voxel at the position given by x,y,z coordinates VoxelType getVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos) const; /// Gets a voxel at the position given by a 3D vector diff --git a/library/PolyVoxCore/include/PolyVoxCore/BaseVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/BaseVolume.inl index b4237b18..0b24643a 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/BaseVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/BaseVolume.inl @@ -160,7 +160,7 @@ namespace PolyVox /// \return The voxel value //////////////////////////////////////////////////////////////////////////////// template - VoxelType BaseVolume::getVoxel(int32_t /*uXPos*/, int32_t /*uYPos*/, int32_t /*uZPos*/, bool /*bPerformBoundsChecks*/) const + VoxelType BaseVolume::getVoxel(int32_t /*uXPos*/, int32_t /*uYPos*/, int32_t /*uZPos*/, BoundsCheck /*eBoundsCheck*/) const { POLYVOX_THROW(not_implemented, "You should never call the base class version of this function."); return VoxelType(); @@ -171,7 +171,7 @@ namespace PolyVox /// \return The voxel value //////////////////////////////////////////////////////////////////////////////// template - VoxelType BaseVolume::getVoxel(const Vector3DInt32& /*v3dPos*/, bool /*bPerformBoundsChecks*/) const + VoxelType BaseVolume::getVoxel(const Vector3DInt32& /*v3dPos*/, BoundsCheck /*eBoundsCheck*/) const { POLYVOX_THROW(not_implemented, "You should never call the base class version of this function."); return VoxelType(); diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h index ca4a8bb4..6dd7afab 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h @@ -266,9 +266,9 @@ namespace PolyVox ~LargeVolume(); /// Gets a voxel at the position given by x,y,z coordinates - VoxelType getVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, bool bPerformBoundsChecks = true) const; + VoxelType getVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, BoundsCheck eBoundsCheck = BoundsChecks::Full) const; /// Gets a voxel at the position given by a 3D vector - VoxelType getVoxel(const Vector3DInt32& v3dPos, bool bPerformBoundsChecks = true) const; + VoxelType getVoxel(const Vector3DInt32& v3dPos, BoundsCheck eBoundsCheck = BoundsChecks::Full) const; /// Gets a voxel at the position given by x,y,z coordinates VoxelType getVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos) const; /// Gets a voxel at the position given by a 3D vector diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl index 0f2826b6..178218b7 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl @@ -122,11 +122,11 @@ namespace PolyVox /// \return The voxel value //////////////////////////////////////////////////////////////////////////////// template - VoxelType LargeVolume::getVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, bool bPerformBoundsChecks) const + VoxelType LargeVolume::getVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, BoundsCheck eBoundsCheck) const { // If bounds checking is enabled then we validate the // bounds, and throw an exception if they are violated. - if(bPerformBoundsChecks) + if(eBoundsCheck == BoundsChecks::Full) { if(this->m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos)) == false) { @@ -152,9 +152,9 @@ namespace PolyVox /// \return The voxel value //////////////////////////////////////////////////////////////////////////////// template - VoxelType LargeVolume::getVoxel(const Vector3DInt32& v3dPos, bool bPerformBoundsChecks) const + VoxelType LargeVolume::getVoxel(const Vector3DInt32& v3dPos, BoundsCheck eBoundsCheck) const { - return getVoxel(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), bPerformBoundsChecks); + return getVoxel(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), eBoundsCheck); } //////////////////////////////////////////////////////////////////////////////// diff --git a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h index f50087a7..2a85248a 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h @@ -116,9 +116,9 @@ namespace PolyVox ~RawVolume(); /// Gets a voxel at the position given by x,y,z coordinates - VoxelType getVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, bool bPerformBoundsChecks = true) const; + VoxelType getVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, BoundsCheck eBoundsCheck = BoundsChecks::Full) const; /// Gets a voxel at the position given by a 3D vector - VoxelType getVoxel(const Vector3DInt32& v3dPos, bool bPerformBoundsChecks = true) const; + VoxelType getVoxel(const Vector3DInt32& v3dPos, BoundsCheck eBoundsCheck = BoundsChecks::Full) const; /// Gets a voxel at the position given by x,y,z coordinates VoxelType getVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos) const; /// Gets a voxel at the position given by a 3D vector diff --git a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl index 668ad929..2867ca92 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl @@ -80,11 +80,11 @@ namespace PolyVox /// \return The voxel value //////////////////////////////////////////////////////////////////////////////// template - VoxelType RawVolume::getVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, bool bPerformBoundsChecks) const + VoxelType RawVolume::getVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, BoundsCheck eBoundsCheck) const { // If bounds checking is enabled then we validate the // bounds, and throw an exception if they are violated. - if(bPerformBoundsChecks) + if(eBoundsCheck == BoundsChecks::Full) { if(this->m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos)) == false) { @@ -110,9 +110,9 @@ namespace PolyVox /// \return The voxel value //////////////////////////////////////////////////////////////////////////////// template - VoxelType RawVolume::getVoxel(const Vector3DInt32& v3dPos, bool bPerformBoundsChecks) const + VoxelType RawVolume::getVoxel(const Vector3DInt32& v3dPos, BoundsCheck eBoundsCheck) const { - return getVoxel(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), bPerformBoundsChecks); + return getVoxel(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), eBoundsCheck); } //////////////////////////////////////////////////////////////////////////////// diff --git a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h index 7b4b11b0..3ddd628a 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h @@ -155,9 +155,9 @@ namespace PolyVox ~SimpleVolume(); /// Gets a voxel at the position given by x,y,z coordinates - VoxelType getVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, bool bPerformBoundsChecks = true) const; + VoxelType getVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, BoundsCheck eBoundsCheck = BoundsChecks::Full) const; /// Gets a voxel at the position given by a 3D vector - VoxelType getVoxel(const Vector3DInt32& v3dPos, bool bPerformBoundsChecks = true) const; + VoxelType getVoxel(const Vector3DInt32& v3dPos, BoundsCheck eBoundsCheck = BoundsChecks::Full) const; /// Gets a voxel at the position given by x,y,z coordinates VoxelType getVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos) const; /// Gets a voxel at the position given by a 3D vector diff --git a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl index 13fdfae9..256b26b9 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl @@ -80,11 +80,11 @@ namespace PolyVox /// \return The voxel value //////////////////////////////////////////////////////////////////////////////// template - VoxelType SimpleVolume::getVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, bool bPerformBoundsChecks) const + VoxelType SimpleVolume::getVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, BoundsCheck eBoundsCheck) const { // If bounds checking is enabled then we validate the // bounds, and throw an exception if they are violated. - if(bPerformBoundsChecks) + if(eBoundsCheck == BoundsChecks::Full) { if(this->m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos)) == false) { @@ -110,9 +110,9 @@ namespace PolyVox /// \return The voxel value //////////////////////////////////////////////////////////////////////////////// template - VoxelType SimpleVolume::getVoxel(const Vector3DInt32& v3dPos, bool bPerformBoundsChecks) const + VoxelType SimpleVolume::getVoxel(const Vector3DInt32& v3dPos, BoundsCheck eBoundsCheck) const { - return getVoxel(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), bPerformBoundsChecks); + return getVoxel(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), eBoundsCheck); } ////////////////////////////////////////////////////////////////////////////////