From d98856b2761af5527f03182c2a5f763366f32425 Mon Sep 17 00:00:00 2001 From: Daviw Williams Date: Fri, 7 Jun 2013 16:49:06 +0200 Subject: [PATCH] setVoxel for RawVolume now takes WrapMode instead of bounds check. --- .../include/PolyVoxCore/RawVolume.h | 4 ++-- .../include/PolyVoxCore/RawVolume.inl | 24 ++++++++++--------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h index 2ad80cb5..04287b56 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h @@ -133,9 +133,9 @@ namespace PolyVox VoxelType getVoxelAt(const Vector3DInt32& v3dPos) const; /// Sets the voxel at the position given by x,y,z coordinates - void setVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue, BoundsCheck eBoundsCheck = BoundsChecks::Full); + void setVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue, WrapMode eWrapMode = WrapModes::None); /// Sets the voxel at the position given by a 3D vector - void setVoxel(const Vector3DInt32& v3dPos, VoxelType tValue, BoundsCheck eBoundsCheck = BoundsChecks::Full); + void setVoxel(const Vector3DInt32& v3dPos, VoxelType tValue, WrapMode eWrapMode = WrapModes::None); /// Sets the voxel at the position given by x,y,z coordinates bool setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue); /// Sets the 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 2dea1f15..21be2e4f 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl @@ -197,16 +197,19 @@ namespace PolyVox /// \param uYPos the \c y position of the voxel /// \param uZPos the \c z position of the voxel /// \param tValue the value to which the voxel will be set - /// \param eBoundsCheck Controls whether bounds checking is performed on voxel access. It's safest to - /// set this to BoundsChecks::Full (the default), but if you are certain that the voxel you are accessing - /// is inside the volume's enclosing region then you can skip this check to gain some performance. + /// \param eWrapMode Specifies the behaviour when the requested position is outside of the volume. + /// This must be set to 'None' or 'DontCheck'. Other wrap modes cannot be used when writing to volume data. //////////////////////////////////////////////////////////////////////////////// template - void RawVolume::setVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue, BoundsCheck eBoundsCheck) + void RawVolume::setVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue, WrapMode eWrapMode) { - // If bounds checking is enabled then we validate the - // bounds, and throw an exception if they are violated. - if(eBoundsCheck == BoundsChecks::Full) + if((eWrapMode != None) && (eWrapMode != DontCheck)) + { + POLYVOX_THROW(std::invalid_argument, "Invalid wrap mode in call to setVoxel(). It must be 'None' or 'DontCheck'."); + } + + // This validation is skipped if the wrap mode is 'DontCheck' + if(eWrapMode == WrapModes::None) { if(this->m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos)) == false) { @@ -230,12 +233,11 @@ namespace PolyVox //////////////////////////////////////////////////////////////////////////////// /// \param v3dPos the 3D position of the voxel /// \param tValue the value to which the voxel will be set - /// \param eBoundsCheck Controls whether bounds checking is performed on voxel access. It's safest to - /// set this to BoundsChecks::Full (the default), but if you are certain that the voxel you are accessing - /// is inside the volume's enclosing region then you can skip this check to gain some performance. + /// \param eWrapMode Specifies the behaviour when the requested position is outside of the volume. + /// This must be set to 'None' or 'DontCheck'. Other wrap modes cannot be used when writing to volume data. //////////////////////////////////////////////////////////////////////////////// template - void RawVolume::setVoxel(const Vector3DInt32& v3dPos, VoxelType tValue, BoundsCheck eBoundsCheck) + void RawVolume::setVoxel(const Vector3DInt32& v3dPos, VoxelType tValue, WrapMode eWrapMode) { setVoxel(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), tValue, eBoundsCheck); }