diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl index 3434d099..530fafc0 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl @@ -148,11 +148,14 @@ namespace PolyVox template void LargeVolume::Sampler::movePositiveX(void) { + // We'll need this in a moment... + bool bIsOldPositionValid = this->isCurrentPositionValid(); + // Base version updates position and validity flags. BaseVolume::template Sampler< LargeVolume >::movePositiveX(); // Then we update the voxel pointer - if((this->isCurrentPositionValid()) && mCurrentVoxel && ((this->mXPosInVolume) % this->mVolume->m_uBlockSideLength != 0)) + if((this->isCurrentPositionValid()) && bIsOldPositionValid && ((this->mXPosInVolume) % this->mVolume->m_uBlockSideLength != 0)) { //No need to compute new block. ++mCurrentVoxel; @@ -167,11 +170,14 @@ namespace PolyVox template void LargeVolume::Sampler::movePositiveY(void) { + // We'll need this in a moment... + bool bIsOldPositionValid = this->isCurrentPositionValid(); + // Base version updates position and validity flags. BaseVolume::template Sampler< LargeVolume >::movePositiveY(); // Then we update the voxel pointer - if((this->isCurrentPositionValid()) && mCurrentVoxel && ((this->mYPosInVolume) % this->mVolume->m_uBlockSideLength != 0)) + if((this->isCurrentPositionValid()) && bIsOldPositionValid && ((this->mYPosInVolume) % this->mVolume->m_uBlockSideLength != 0)) { //No need to compute new block. mCurrentVoxel += this->mVolume->m_uBlockSideLength; @@ -186,11 +192,14 @@ namespace PolyVox template void LargeVolume::Sampler::movePositiveZ(void) { + // We'll need this in a moment... + bool bIsOldPositionValid = this->isCurrentPositionValid(); + // Base version updates position and validity flags. BaseVolume::template Sampler< LargeVolume >::movePositiveZ(); // Then we update the voxel pointer - if((this->isCurrentPositionValid()) && mCurrentVoxel && ((this->mZPosInVolume) % this->mVolume->m_uBlockSideLength != 0)) + if((this->isCurrentPositionValid()) && bIsOldPositionValid && ((this->mZPosInVolume) % this->mVolume->m_uBlockSideLength != 0)) { //No need to compute new block. mCurrentVoxel += this->mVolume->m_uBlockSideLength * this->mVolume->m_uBlockSideLength; @@ -205,11 +214,14 @@ namespace PolyVox template void LargeVolume::Sampler::moveNegativeX(void) { + // We'll need this in a moment... + bool bIsOldPositionValid = this->isCurrentPositionValid(); + // Base version updates position and validity flags. BaseVolume::template Sampler< LargeVolume >::moveNegativeX(); // Then we update the voxel pointer - if((this->isCurrentPositionValid()) && mCurrentVoxel && ((this->mXPosInVolume + 1) % this->mVolume->m_uBlockSideLength != 0)) + if((this->isCurrentPositionValid()) && bIsOldPositionValid && ((this->mXPosInVolume + 1) % this->mVolume->m_uBlockSideLength != 0)) { //No need to compute new block. --mCurrentVoxel; @@ -224,11 +236,14 @@ namespace PolyVox template void LargeVolume::Sampler::moveNegativeY(void) { + // We'll need this in a moment... + bool bIsOldPositionValid = this->isCurrentPositionValid(); + // Base version updates position and validity flags. BaseVolume::template Sampler< LargeVolume >::moveNegativeY(); // Then we update the voxel pointer - if((this->isCurrentPositionValid()) && mCurrentVoxel && ((this->mYPosInVolume + 1) % this->mVolume->m_uBlockSideLength != 0)) + if((this->isCurrentPositionValid()) && bIsOldPositionValid && ((this->mYPosInVolume + 1) % this->mVolume->m_uBlockSideLength != 0)) { //No need to compute new block. mCurrentVoxel -= this->mVolume->m_uBlockSideLength; @@ -243,11 +258,14 @@ namespace PolyVox template void LargeVolume::Sampler::moveNegativeZ(void) { + // We'll need this in a moment... + bool bIsOldPositionValid = this->isCurrentPositionValid(); + // Base version updates position and validity flags. BaseVolume::template Sampler< LargeVolume >::moveNegativeZ(); // Then we update the voxel pointer - if((this->isCurrentPositionValid()) && mCurrentVoxel && ((this->mZPosInVolume + 1) % this->mVolume->m_uBlockSideLength != 0)) + if((this->isCurrentPositionValid()) && bIsOldPositionValid && ((this->mZPosInVolume + 1) % this->mVolume->m_uBlockSideLength != 0)) { //No need to compute new block. mCurrentVoxel -= this->mVolume->m_uBlockSideLength * this->mVolume->m_uBlockSideLength; diff --git a/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl index a2dfb9dc..866a2f64 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl @@ -105,11 +105,14 @@ namespace PolyVox template void RawVolume::Sampler::movePositiveX(void) { + // We'll need this in a moment... + bool bIsOldPositionValid = this->isCurrentPositionValid(); + // Base version updates position and validity flags. BaseVolume::template Sampler< RawVolume >::movePositiveX(); // Then we update the voxel pointer - if(this->isCurrentPositionValid() && mCurrentVoxel ) + if(this->isCurrentPositionValid() && bIsOldPositionValid ) { ++mCurrentVoxel; } @@ -122,11 +125,14 @@ namespace PolyVox template void RawVolume::Sampler::movePositiveY(void) { + // We'll need this in a moment... + bool bIsOldPositionValid = this->isCurrentPositionValid(); + // Base version updates position and validity flags. BaseVolume::template Sampler< RawVolume >::movePositiveY(); // Then we update the voxel pointer - if(this->isCurrentPositionValid() && mCurrentVoxel ) + if(this->isCurrentPositionValid() && bIsOldPositionValid ) { mCurrentVoxel += this->mVolume->getWidth(); } @@ -139,11 +145,14 @@ namespace PolyVox template void RawVolume::Sampler::movePositiveZ(void) { + // We'll need this in a moment... + bool bIsOldPositionValid = this->isCurrentPositionValid(); + // Base version updates position and validity flags. BaseVolume::template Sampler< RawVolume >::movePositiveZ(); // Then we update the voxel pointer - if(this->isCurrentPositionValid() && mCurrentVoxel ) + if(this->isCurrentPositionValid() && bIsOldPositionValid ) { mCurrentVoxel += this->mVolume->getWidth() * this->mVolume->getHeight(); } @@ -156,11 +165,14 @@ namespace PolyVox template void RawVolume::Sampler::moveNegativeX(void) { + // We'll need this in a moment... + bool bIsOldPositionValid = this->isCurrentPositionValid(); + // Base version updates position and validity flags. BaseVolume::template Sampler< RawVolume >::moveNegativeX(); // Then we update the voxel pointer - if(this->isCurrentPositionValid() && mCurrentVoxel ) + if(this->isCurrentPositionValid() && bIsOldPositionValid ) { --mCurrentVoxel; } @@ -173,11 +185,14 @@ namespace PolyVox template void RawVolume::Sampler::moveNegativeY(void) { + // We'll need this in a moment... + bool bIsOldPositionValid = this->isCurrentPositionValid(); + // Base version updates position and validity flags. BaseVolume::template Sampler< RawVolume >::moveNegativeY(); // Then we update the voxel pointer - if(this->isCurrentPositionValid() && mCurrentVoxel ) + if(this->isCurrentPositionValid() && bIsOldPositionValid ) { mCurrentVoxel -= this->mVolume->getWidth(); } @@ -190,11 +205,14 @@ namespace PolyVox template void RawVolume::Sampler::moveNegativeZ(void) { + // We'll need this in a moment... + bool bIsOldPositionValid = this->isCurrentPositionValid(); + // Base version updates position and validity flags. BaseVolume::template Sampler< RawVolume >::moveNegativeZ(); // Then we update the voxel pointer - if(this->isCurrentPositionValid() && mCurrentVoxel ) + if(this->isCurrentPositionValid() && bIsOldPositionValid ) { mCurrentVoxel -= this->mVolume->getWidth() * this->mVolume->getHeight(); } diff --git a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl index 3893df22..7920fc6b 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl @@ -167,11 +167,14 @@ namespace PolyVox template void SimpleVolume::Sampler::movePositiveX(void) { + // We'll need this in a moment... + bool bIsOldPositionValid = this->isCurrentPositionValid(); + // Base version updates position and validity flags. BaseVolume::template Sampler< SimpleVolume >::movePositiveX(); // Then we update the voxel pointer - if((this->isCurrentPositionValid()) && mCurrentVoxel && ((this->mXPosInVolume) % this->mVolume->m_uBlockSideLength != 0)) + if((this->isCurrentPositionValid()) && bIsOldPositionValid && ((this->mXPosInVolume) % this->mVolume->m_uBlockSideLength != 0)) { //No need to compute new block. ++mCurrentVoxel; @@ -186,11 +189,14 @@ namespace PolyVox template void SimpleVolume::Sampler::movePositiveY(void) { + // We'll need this in a moment... + bool bIsOldPositionValid = this->isCurrentPositionValid(); + // Base version updates position and validity flags. BaseVolume::template Sampler< SimpleVolume >::movePositiveY(); // Then we update the voxel pointer - if((this->isCurrentPositionValid()) && mCurrentVoxel && ((this->mYPosInVolume) % this->mVolume->m_uBlockSideLength != 0)) + if((this->isCurrentPositionValid()) && bIsOldPositionValid && ((this->mYPosInVolume) % this->mVolume->m_uBlockSideLength != 0)) { //No need to compute new block. mCurrentVoxel += this->mVolume->m_uBlockSideLength; @@ -205,11 +211,14 @@ namespace PolyVox template void SimpleVolume::Sampler::movePositiveZ(void) { + // We'll need this in a moment... + bool bIsOldPositionValid = this->isCurrentPositionValid(); + // Base version updates position and validity flags. BaseVolume::template Sampler< SimpleVolume >::movePositiveZ(); // Then we update the voxel pointer - if((this->isCurrentPositionValid()) && mCurrentVoxel && ((this->mZPosInVolume) % this->mVolume->m_uBlockSideLength != 0)) + if((this->isCurrentPositionValid()) && bIsOldPositionValid && ((this->mZPosInVolume) % this->mVolume->m_uBlockSideLength != 0)) { //No need to compute new block. mCurrentVoxel += this->mVolume->m_uBlockSideLength * this->mVolume->m_uBlockSideLength; @@ -224,11 +233,14 @@ namespace PolyVox template void SimpleVolume::Sampler::moveNegativeX(void) { + // We'll need this in a moment... + bool bIsOldPositionValid = this->isCurrentPositionValid(); + // Base version updates position and validity flags. BaseVolume::template Sampler< SimpleVolume >::moveNegativeX(); // Then we update the voxel pointer - if((this->isCurrentPositionValid()) && mCurrentVoxel && ((this->mXPosInVolume + 1) % this->mVolume->m_uBlockSideLength != 0)) + if((this->isCurrentPositionValid()) && bIsOldPositionValid && ((this->mXPosInVolume + 1) % this->mVolume->m_uBlockSideLength != 0)) { //No need to compute new block. --mCurrentVoxel; @@ -243,11 +255,14 @@ namespace PolyVox template void SimpleVolume::Sampler::moveNegativeY(void) { + // We'll need this in a moment... + bool bIsOldPositionValid = this->isCurrentPositionValid(); + // Base version updates position and validity flags. BaseVolume::template Sampler< SimpleVolume >::moveNegativeY(); // Then we update the voxel pointer - if((this->isCurrentPositionValid()) && mCurrentVoxel && ((this->mYPosInVolume + 1) % this->mVolume->m_uBlockSideLength != 0)) + if((this->isCurrentPositionValid()) && bIsOldPositionValid && ((this->mYPosInVolume + 1) % this->mVolume->m_uBlockSideLength != 0)) { //No need to compute new block. mCurrentVoxel -= this->mVolume->m_uBlockSideLength; @@ -262,11 +277,14 @@ namespace PolyVox template void SimpleVolume::Sampler::moveNegativeZ(void) { + // We'll need this in a moment... + bool bIsOldPositionValid = this->isCurrentPositionValid(); + // Base version updates position and validity flags. BaseVolume::template Sampler< SimpleVolume >::moveNegativeZ(); // Then we update the voxel pointer - if((this->isCurrentPositionValid()) && mCurrentVoxel && ((this->mZPosInVolume + 1) % this->mVolume->m_uBlockSideLength != 0)) + if((this->isCurrentPositionValid()) && bIsOldPositionValid && ((this->mZPosInVolume + 1) % this->mVolume->m_uBlockSideLength != 0)) { //No need to compute new block. mCurrentVoxel -= this->mVolume->m_uBlockSideLength * this->mVolume->m_uBlockSideLength;