Removed tracking of whether the PagedVolume::Sampler is currently valid.

This commit is contained in:
David Williams 2015-03-01 23:32:22 +01:00
parent 396d1cfc59
commit d3618ca688
2 changed files with 59 additions and 102 deletions

View File

@ -134,8 +134,6 @@ namespace PolyVox
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template <typename VoxelType> template <typename VoxelType>
VoxelType PagedVolume<VoxelType>::getVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos) const VoxelType PagedVolume<VoxelType>::getVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos) const
{
if (this->m_regValidRegion.containsPoint(uXPos, uYPos, uZPos))
{ {
const int32_t chunkX = uXPos >> m_uChunkSideLengthPower; const int32_t chunkX = uXPos >> m_uChunkSideLengthPower;
const int32_t chunkY = uYPos >> m_uChunkSideLengthPower; const int32_t chunkY = uYPos >> m_uChunkSideLengthPower;
@ -148,11 +146,6 @@ namespace PolyVox
auto pChunk = getChunk(chunkX, chunkY, chunkZ); auto pChunk = getChunk(chunkX, chunkY, chunkZ);
return pChunk->getVoxel(xOffset, yOffset, zOffset); return pChunk->getVoxel(xOffset, yOffset, zOffset);
} }
else
{
return VoxelType();
}
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// This version of the function is provided so that the wrap mode does not need /// This version of the function is provided so that the wrap mode does not need

View File

@ -21,12 +21,12 @@ freely, subject to the following restrictions:
distribution. distribution.
*******************************************************************************/ *******************************************************************************/
#define CAN_GO_NEG_X(val) ((val > this->mVolume->getEnclosingRegion().getLowerX()) && (val % this->mVolume->m_uChunkSideLength != 0)) #define CAN_GO_NEG_X(val) ((val % this->mVolume->m_uChunkSideLength != 0))
#define CAN_GO_POS_X(val) ((val < this->mVolume->getEnclosingRegion().getUpperX()) && ((val + 1) % this->mVolume->m_uChunkSideLength != 0)) #define CAN_GO_POS_X(val) (((val + 1) % this->mVolume->m_uChunkSideLength != 0))
#define CAN_GO_NEG_Y(val) ((val > this->mVolume->getEnclosingRegion().getLowerY()) && (val % this->mVolume->m_uChunkSideLength != 0)) #define CAN_GO_NEG_Y(val) ((val % this->mVolume->m_uChunkSideLength != 0))
#define CAN_GO_POS_Y(val) ((val < this->mVolume->getEnclosingRegion().getUpperY()) && ((val + 1) % this->mVolume->m_uChunkSideLength != 0)) #define CAN_GO_POS_Y(val) (((val + 1) % this->mVolume->m_uChunkSideLength != 0))
#define CAN_GO_NEG_Z(val) ((val > this->mVolume->getEnclosingRegion().getLowerZ()) && (val % this->mVolume->m_uChunkSideLength != 0)) #define CAN_GO_NEG_Z(val) ((val % this->mVolume->m_uChunkSideLength != 0))
#define CAN_GO_POS_Z(val) ((val < this->mVolume->getEnclosingRegion().getUpperZ()) && ((val + 1) % this->mVolume->m_uChunkSideLength != 0)) #define CAN_GO_POS_Z(val) (((val + 1) % this->mVolume->m_uChunkSideLength != 0))
namespace PolyVox namespace PolyVox
{ {
@ -81,16 +81,9 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
VoxelType PagedVolume<VoxelType>::Sampler::getVoxel(void) const VoxelType PagedVolume<VoxelType>::Sampler::getVoxel(void) const
{
if(this->isCurrentPositionValid())
{
return *mCurrentVoxel;
}
else
{ {
return this->getVoxelImpl(this->mXPosInVolume, this->mYPosInVolume, this->mZPosInVolume); return this->getVoxelImpl(this->mXPosInVolume, this->mYPosInVolume, this->mZPosInVolume);
} }
}
template <typename VoxelType> template <typename VoxelType>
void PagedVolume<VoxelType>::Sampler::setPosition(const Vector3DInt32& v3dNewPos) void PagedVolume<VoxelType>::Sampler::setPosition(const Vector3DInt32& v3dNewPos)
@ -105,8 +98,6 @@ namespace PolyVox
BaseVolume<VoxelType>::template Sampler< PagedVolume<VoxelType> >::setPosition(xPos, yPos, zPos); BaseVolume<VoxelType>::template Sampler< PagedVolume<VoxelType> >::setPosition(xPos, yPos, zPos);
// Then we update the voxel pointer // Then we update the voxel pointer
if(this->isCurrentPositionValid())
{
const int32_t uXChunk = this->mXPosInVolume >> this->mVolume->m_uChunkSideLengthPower; const int32_t uXChunk = this->mXPosInVolume >> this->mVolume->m_uChunkSideLengthPower;
const int32_t uYChunk = this->mYPosInVolume >> this->mVolume->m_uChunkSideLengthPower; const int32_t uYChunk = this->mYPosInVolume >> this->mVolume->m_uChunkSideLengthPower;
const int32_t uZChunk = this->mZPosInVolume >> this->mVolume->m_uChunkSideLengthPower; const int32_t uZChunk = this->mZPosInVolume >> this->mVolume->m_uChunkSideLengthPower;
@ -123,11 +114,6 @@ namespace PolyVox
mCurrentVoxel = pCurrentChunk->m_tData + uVoxelIndexInChunk; mCurrentVoxel = pCurrentChunk->m_tData + uVoxelIndexInChunk;
} }
else
{
mCurrentVoxel = 0;
}
}
template <typename VoxelType> template <typename VoxelType>
bool PagedVolume<VoxelType>::Sampler::setVoxel(VoxelType tValue) bool PagedVolume<VoxelType>::Sampler::setVoxel(VoxelType tValue)
@ -150,14 +136,11 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
void PagedVolume<VoxelType>::Sampler::movePositiveX(void) void PagedVolume<VoxelType>::Sampler::movePositiveX(void)
{ {
// We'll need this in a moment...
bool bIsOldPositionValid = this->isCurrentPositionValid();
// Base version updates position and validity flags. // Base version updates position and validity flags.
BaseVolume<VoxelType>::template Sampler< PagedVolume<VoxelType> >::movePositiveX(); BaseVolume<VoxelType>::template Sampler< PagedVolume<VoxelType> >::movePositiveX();
// Then we update the voxel pointer // Then we update the voxel pointer
if((this->isCurrentPositionValid()) && bIsOldPositionValid && ((this->mXPosInVolume) % this->mVolume->m_uChunkSideLength != 0)) if(((this->mXPosInVolume) % this->mVolume->m_uChunkSideLength != 0))
{ {
//No need to compute new chunk. //No need to compute new chunk.
++mCurrentVoxel; ++mCurrentVoxel;
@ -172,14 +155,11 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
void PagedVolume<VoxelType>::Sampler::movePositiveY(void) void PagedVolume<VoxelType>::Sampler::movePositiveY(void)
{ {
// We'll need this in a moment...
bool bIsOldPositionValid = this->isCurrentPositionValid();
// Base version updates position and validity flags. // Base version updates position and validity flags.
BaseVolume<VoxelType>::template Sampler< PagedVolume<VoxelType> >::movePositiveY(); BaseVolume<VoxelType>::template Sampler< PagedVolume<VoxelType> >::movePositiveY();
// Then we update the voxel pointer // Then we update the voxel pointer
if((this->isCurrentPositionValid()) && bIsOldPositionValid && ((this->mYPosInVolume) % this->mVolume->m_uChunkSideLength != 0)) if(((this->mYPosInVolume) % this->mVolume->m_uChunkSideLength != 0))
{ {
//No need to compute new chunk. //No need to compute new chunk.
mCurrentVoxel += this->mVolume->m_uChunkSideLength; mCurrentVoxel += this->mVolume->m_uChunkSideLength;
@ -194,14 +174,11 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
void PagedVolume<VoxelType>::Sampler::movePositiveZ(void) void PagedVolume<VoxelType>::Sampler::movePositiveZ(void)
{ {
// We'll need this in a moment...
bool bIsOldPositionValid = this->isCurrentPositionValid();
// Base version updates position and validity flags. // Base version updates position and validity flags.
BaseVolume<VoxelType>::template Sampler< PagedVolume<VoxelType> >::movePositiveZ(); BaseVolume<VoxelType>::template Sampler< PagedVolume<VoxelType> >::movePositiveZ();
// Then we update the voxel pointer // Then we update the voxel pointer
if((this->isCurrentPositionValid()) && bIsOldPositionValid && ((this->mZPosInVolume) % this->mVolume->m_uChunkSideLength != 0)) if(((this->mZPosInVolume) % this->mVolume->m_uChunkSideLength != 0))
{ {
//No need to compute new chunk. //No need to compute new chunk.
mCurrentVoxel += this->mVolume->m_uChunkSideLength * this->mVolume->m_uChunkSideLength; mCurrentVoxel += this->mVolume->m_uChunkSideLength * this->mVolume->m_uChunkSideLength;
@ -216,14 +193,11 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
void PagedVolume<VoxelType>::Sampler::moveNegativeX(void) void PagedVolume<VoxelType>::Sampler::moveNegativeX(void)
{ {
// We'll need this in a moment...
bool bIsOldPositionValid = this->isCurrentPositionValid();
// Base version updates position and validity flags. // Base version updates position and validity flags.
BaseVolume<VoxelType>::template Sampler< PagedVolume<VoxelType> >::moveNegativeX(); BaseVolume<VoxelType>::template Sampler< PagedVolume<VoxelType> >::moveNegativeX();
// Then we update the voxel pointer // Then we update the voxel pointer
if((this->isCurrentPositionValid()) && bIsOldPositionValid && ((this->mXPosInVolume + 1) % this->mVolume->m_uChunkSideLength != 0)) if(((this->mXPosInVolume + 1) % this->mVolume->m_uChunkSideLength != 0))
{ {
//No need to compute new chunk. //No need to compute new chunk.
--mCurrentVoxel; --mCurrentVoxel;
@ -238,14 +212,11 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
void PagedVolume<VoxelType>::Sampler::moveNegativeY(void) void PagedVolume<VoxelType>::Sampler::moveNegativeY(void)
{ {
// We'll need this in a moment...
bool bIsOldPositionValid = this->isCurrentPositionValid();
// Base version updates position and validity flags. // Base version updates position and validity flags.
BaseVolume<VoxelType>::template Sampler< PagedVolume<VoxelType> >::moveNegativeY(); BaseVolume<VoxelType>::template Sampler< PagedVolume<VoxelType> >::moveNegativeY();
// Then we update the voxel pointer // Then we update the voxel pointer
if((this->isCurrentPositionValid()) && bIsOldPositionValid && ((this->mYPosInVolume + 1) % this->mVolume->m_uChunkSideLength != 0)) if(((this->mYPosInVolume + 1) % this->mVolume->m_uChunkSideLength != 0))
{ {
//No need to compute new chunk. //No need to compute new chunk.
mCurrentVoxel -= this->mVolume->m_uChunkSideLength; mCurrentVoxel -= this->mVolume->m_uChunkSideLength;
@ -260,14 +231,11 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
void PagedVolume<VoxelType>::Sampler::moveNegativeZ(void) void PagedVolume<VoxelType>::Sampler::moveNegativeZ(void)
{ {
// We'll need this in a moment...
bool bIsOldPositionValid = this->isCurrentPositionValid();
// Base version updates position and validity flags. // Base version updates position and validity flags.
BaseVolume<VoxelType>::template Sampler< PagedVolume<VoxelType> >::moveNegativeZ(); BaseVolume<VoxelType>::template Sampler< PagedVolume<VoxelType> >::moveNegativeZ();
// Then we update the voxel pointer // Then we update the voxel pointer
if((this->isCurrentPositionValid()) && bIsOldPositionValid && ((this->mZPosInVolume + 1) % this->mVolume->m_uChunkSideLength != 0)) if(((this->mZPosInVolume + 1) % this->mVolume->m_uChunkSideLength != 0))
{ {
//No need to compute new chunk. //No need to compute new chunk.
mCurrentVoxel -= this->mVolume->m_uChunkSideLength * this->mVolume->m_uChunkSideLength; mCurrentVoxel -= this->mVolume->m_uChunkSideLength * this->mVolume->m_uChunkSideLength;
@ -282,7 +250,7 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1nx1ny1nz(void) const VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1nx1ny1nz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_NEG_Y(this->mYPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) ) if(CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_NEG_Y(this->mYPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) )
{ {
return *(mCurrentVoxel - 1 - this->mVolume->m_uChunkSideLength - this->mVolume->m_uChunkSideLength*this->mVolume->m_uChunkSideLength); return *(mCurrentVoxel - 1 - this->mVolume->m_uChunkSideLength - this->mVolume->m_uChunkSideLength*this->mVolume->m_uChunkSideLength);
} }
@ -292,7 +260,7 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1nx1ny0pz(void) const VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1nx1ny0pz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_NEG_Y(this->mYPosInVolume) ) if(CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_NEG_Y(this->mYPosInVolume) )
{ {
return *(mCurrentVoxel - 1 - this->mVolume->m_uChunkSideLength); return *(mCurrentVoxel - 1 - this->mVolume->m_uChunkSideLength);
} }
@ -302,7 +270,7 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1nx1ny1pz(void) const VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1nx1ny1pz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_NEG_Y(this->mYPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) ) if(CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_NEG_Y(this->mYPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) )
{ {
return *(mCurrentVoxel - 1 - this->mVolume->m_uChunkSideLength + this->mVolume->m_uChunkSideLength*this->mVolume->m_uChunkSideLength); return *(mCurrentVoxel - 1 - this->mVolume->m_uChunkSideLength + this->mVolume->m_uChunkSideLength*this->mVolume->m_uChunkSideLength);
} }
@ -312,7 +280,7 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1nx0py1nz(void) const VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1nx0py1nz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) ) if(CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) )
{ {
return *(mCurrentVoxel - 1 - this->mVolume->m_uChunkSideLength*this->mVolume->m_uChunkSideLength); return *(mCurrentVoxel - 1 - this->mVolume->m_uChunkSideLength*this->mVolume->m_uChunkSideLength);
} }
@ -322,7 +290,7 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1nx0py0pz(void) const VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1nx0py0pz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) ) if(CAN_GO_NEG_X(this->mXPosInVolume) )
{ {
return *(mCurrentVoxel - 1); return *(mCurrentVoxel - 1);
} }
@ -332,7 +300,7 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1nx0py1pz(void) const VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1nx0py1pz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) ) if(CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) )
{ {
return *(mCurrentVoxel - 1 + this->mVolume->m_uChunkSideLength*this->mVolume->m_uChunkSideLength); return *(mCurrentVoxel - 1 + this->mVolume->m_uChunkSideLength*this->mVolume->m_uChunkSideLength);
} }
@ -342,7 +310,7 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1nx1py1nz(void) const VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1nx1py1nz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_POS_Y(this->mYPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) ) if(CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_POS_Y(this->mYPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) )
{ {
return *(mCurrentVoxel - 1 + this->mVolume->m_uChunkSideLength - this->mVolume->m_uChunkSideLength*this->mVolume->m_uChunkSideLength); return *(mCurrentVoxel - 1 + this->mVolume->m_uChunkSideLength - this->mVolume->m_uChunkSideLength*this->mVolume->m_uChunkSideLength);
} }
@ -352,7 +320,7 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1nx1py0pz(void) const VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1nx1py0pz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_POS_Y(this->mYPosInVolume) ) if(CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_POS_Y(this->mYPosInVolume) )
{ {
return *(mCurrentVoxel - 1 + this->mVolume->m_uChunkSideLength); return *(mCurrentVoxel - 1 + this->mVolume->m_uChunkSideLength);
} }
@ -362,7 +330,7 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1nx1py1pz(void) const VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1nx1py1pz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_POS_Y(this->mYPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) ) if(CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_POS_Y(this->mYPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) )
{ {
return *(mCurrentVoxel - 1 + this->mVolume->m_uChunkSideLength + this->mVolume->m_uChunkSideLength*this->mVolume->m_uChunkSideLength); return *(mCurrentVoxel - 1 + this->mVolume->m_uChunkSideLength + this->mVolume->m_uChunkSideLength*this->mVolume->m_uChunkSideLength);
} }
@ -374,7 +342,7 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel0px1ny1nz(void) const VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel0px1ny1nz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_NEG_Y(this->mYPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) ) if(CAN_GO_NEG_Y(this->mYPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) )
{ {
return *(mCurrentVoxel - this->mVolume->m_uChunkSideLength - this->mVolume->m_uChunkSideLength*this->mVolume->m_uChunkSideLength); return *(mCurrentVoxel - this->mVolume->m_uChunkSideLength - this->mVolume->m_uChunkSideLength*this->mVolume->m_uChunkSideLength);
} }
@ -384,7 +352,7 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel0px1ny0pz(void) const VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel0px1ny0pz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_NEG_Y(this->mYPosInVolume) ) if(CAN_GO_NEG_Y(this->mYPosInVolume) )
{ {
return *(mCurrentVoxel - this->mVolume->m_uChunkSideLength); return *(mCurrentVoxel - this->mVolume->m_uChunkSideLength);
} }
@ -394,7 +362,7 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel0px1ny1pz(void) const VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel0px1ny1pz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_NEG_Y(this->mYPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) ) if(CAN_GO_NEG_Y(this->mYPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) )
{ {
return *(mCurrentVoxel - this->mVolume->m_uChunkSideLength + this->mVolume->m_uChunkSideLength*this->mVolume->m_uChunkSideLength); return *(mCurrentVoxel - this->mVolume->m_uChunkSideLength + this->mVolume->m_uChunkSideLength*this->mVolume->m_uChunkSideLength);
} }
@ -404,7 +372,7 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel0px0py1nz(void) const VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel0px0py1nz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_NEG_Z(this->mZPosInVolume) ) if(CAN_GO_NEG_Z(this->mZPosInVolume) )
{ {
return *(mCurrentVoxel - this->mVolume->m_uChunkSideLength*this->mVolume->m_uChunkSideLength); return *(mCurrentVoxel - this->mVolume->m_uChunkSideLength*this->mVolume->m_uChunkSideLength);
} }
@ -413,18 +381,14 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel0px0py0pz(void) const VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel0px0py0pz(void) const
{
if((this->isCurrentPositionValid()))
{ {
return *mCurrentVoxel; return *mCurrentVoxel;
} }
return this->mVolume->getVoxel(this->mXPosInVolume, this->mYPosInVolume, this->mZPosInVolume);
}
template <typename VoxelType> template <typename VoxelType>
VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel0px0py1pz(void) const VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel0px0py1pz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_POS_Z(this->mZPosInVolume) ) if(CAN_GO_POS_Z(this->mZPosInVolume) )
{ {
return *(mCurrentVoxel + this->mVolume->m_uChunkSideLength*this->mVolume->m_uChunkSideLength); return *(mCurrentVoxel + this->mVolume->m_uChunkSideLength*this->mVolume->m_uChunkSideLength);
} }
@ -434,7 +398,7 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel0px1py1nz(void) const VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel0px1py1nz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_POS_Y(this->mYPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) ) if(CAN_GO_POS_Y(this->mYPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) )
{ {
return *(mCurrentVoxel + this->mVolume->m_uChunkSideLength - this->mVolume->m_uChunkSideLength*this->mVolume->m_uChunkSideLength); return *(mCurrentVoxel + this->mVolume->m_uChunkSideLength - this->mVolume->m_uChunkSideLength*this->mVolume->m_uChunkSideLength);
} }
@ -444,7 +408,7 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel0px1py0pz(void) const VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel0px1py0pz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_POS_Y(this->mYPosInVolume) ) if(CAN_GO_POS_Y(this->mYPosInVolume) )
{ {
return *(mCurrentVoxel + this->mVolume->m_uChunkSideLength); return *(mCurrentVoxel + this->mVolume->m_uChunkSideLength);
} }
@ -454,7 +418,7 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel0px1py1pz(void) const VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel0px1py1pz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_POS_Y(this->mYPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) ) if(CAN_GO_POS_Y(this->mYPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) )
{ {
return *(mCurrentVoxel + this->mVolume->m_uChunkSideLength + this->mVolume->m_uChunkSideLength*this->mVolume->m_uChunkSideLength); return *(mCurrentVoxel + this->mVolume->m_uChunkSideLength + this->mVolume->m_uChunkSideLength*this->mVolume->m_uChunkSideLength);
} }
@ -466,7 +430,7 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1px1ny1nz(void) const VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1px1ny1nz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_NEG_Y(this->mYPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) ) if(CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_NEG_Y(this->mYPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) )
{ {
return *(mCurrentVoxel + 1 - this->mVolume->m_uChunkSideLength - this->mVolume->m_uChunkSideLength*this->mVolume->m_uChunkSideLength); return *(mCurrentVoxel + 1 - this->mVolume->m_uChunkSideLength - this->mVolume->m_uChunkSideLength*this->mVolume->m_uChunkSideLength);
} }
@ -476,7 +440,7 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1px1ny0pz(void) const VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1px1ny0pz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_NEG_Y(this->mYPosInVolume) ) if(CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_NEG_Y(this->mYPosInVolume) )
{ {
return *(mCurrentVoxel + 1 - this->mVolume->m_uChunkSideLength); return *(mCurrentVoxel + 1 - this->mVolume->m_uChunkSideLength);
} }
@ -486,7 +450,7 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1px1ny1pz(void) const VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1px1ny1pz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_NEG_Y(this->mYPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) ) if(CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_NEG_Y(this->mYPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) )
{ {
return *(mCurrentVoxel + 1 - this->mVolume->m_uChunkSideLength + this->mVolume->m_uChunkSideLength*this->mVolume->m_uChunkSideLength); return *(mCurrentVoxel + 1 - this->mVolume->m_uChunkSideLength + this->mVolume->m_uChunkSideLength*this->mVolume->m_uChunkSideLength);
} }
@ -496,7 +460,7 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1px0py1nz(void) const VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1px0py1nz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) ) if(CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) )
{ {
return *(mCurrentVoxel + 1 - this->mVolume->m_uChunkSideLength*this->mVolume->m_uChunkSideLength); return *(mCurrentVoxel + 1 - this->mVolume->m_uChunkSideLength*this->mVolume->m_uChunkSideLength);
} }
@ -506,7 +470,7 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1px0py0pz(void) const VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1px0py0pz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) ) if(CAN_GO_POS_X(this->mXPosInVolume) )
{ {
return *(mCurrentVoxel + 1); return *(mCurrentVoxel + 1);
} }
@ -516,7 +480,7 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1px0py1pz(void) const VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1px0py1pz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) ) if(CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) )
{ {
return *(mCurrentVoxel + 1 + this->mVolume->m_uChunkSideLength*this->mVolume->m_uChunkSideLength); return *(mCurrentVoxel + 1 + this->mVolume->m_uChunkSideLength*this->mVolume->m_uChunkSideLength);
} }
@ -526,7 +490,7 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1px1py1nz(void) const VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1px1py1nz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_POS_Y(this->mYPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) ) if(CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_POS_Y(this->mYPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) )
{ {
return *(mCurrentVoxel + 1 + this->mVolume->m_uChunkSideLength - this->mVolume->m_uChunkSideLength*this->mVolume->m_uChunkSideLength); return *(mCurrentVoxel + 1 + this->mVolume->m_uChunkSideLength - this->mVolume->m_uChunkSideLength*this->mVolume->m_uChunkSideLength);
} }
@ -536,7 +500,7 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1px1py0pz(void) const VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1px1py0pz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_POS_Y(this->mYPosInVolume) ) if(CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_POS_Y(this->mYPosInVolume) )
{ {
return *(mCurrentVoxel + 1 + this->mVolume->m_uChunkSideLength); return *(mCurrentVoxel + 1 + this->mVolume->m_uChunkSideLength);
} }
@ -546,7 +510,7 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1px1py1pz(void) const VoxelType PagedVolume<VoxelType>::Sampler::peekVoxel1px1py1pz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_POS_Y(this->mYPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) ) if(CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_POS_Y(this->mYPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) )
{ {
return *(mCurrentVoxel + 1 + this->mVolume->m_uChunkSideLength + this->mVolume->m_uChunkSideLength*this->mVolume->m_uChunkSideLength); return *(mCurrentVoxel + 1 + this->mVolume->m_uChunkSideLength + this->mVolume->m_uChunkSideLength*this->mVolume->m_uChunkSideLength);
} }