From 056cae39b5f234e090b1c242022ca9dea3abeaf4 Mon Sep 17 00:00:00 2001 From: David Williams Date: Wed, 1 Apr 2015 22:57:22 +0200 Subject: [PATCH] Fixed sampler move...() functions to work with Morton ordering. --- include/PolyVox/PagedVolumeSampler.inl | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/include/PolyVox/PagedVolumeSampler.inl b/include/PolyVox/PagedVolumeSampler.inl index aaccf535..db540f54 100644 --- a/include/PolyVox/PagedVolumeSampler.inl +++ b/include/PolyVox/PagedVolumeSampler.inl @@ -145,12 +145,14 @@ namespace PolyVox { // Base version updates position and validity flags. BaseVolume::template Sampler< PagedVolume >::movePositiveX(); + + this->m_uXPosInChunk++; // Then we update the voxel pointer if(((this->mXPosInVolume) % this->mVolume->m_uChunkSideLength != 0)) { //No need to compute new chunk. - ++mCurrentVoxel; + mCurrentVoxel += POS_X_DELTA; } else { @@ -165,11 +167,13 @@ namespace PolyVox // Base version updates position and validity flags. BaseVolume::template Sampler< PagedVolume >::movePositiveY(); + this->m_uYPosInChunk++; + // Then we update the voxel pointer if(((this->mYPosInVolume) % this->mVolume->m_uChunkSideLength != 0)) { //No need to compute new chunk. - mCurrentVoxel += this->mVolume->m_uChunkSideLength; + mCurrentVoxel += POS_Y_DELTA; } else { @@ -184,11 +188,13 @@ namespace PolyVox // Base version updates position and validity flags. BaseVolume::template Sampler< PagedVolume >::movePositiveZ(); + this->m_uZPosInChunk++; + // Then we update the voxel pointer if(((this->mZPosInVolume) % this->mVolume->m_uChunkSideLength != 0)) { //No need to compute new chunk. - mCurrentVoxel += this->mVolume->m_uChunkSideLength * this->mVolume->m_uChunkSideLength; + mCurrentVoxel += POS_Z_DELTA; } else { @@ -203,11 +209,13 @@ namespace PolyVox // Base version updates position and validity flags. BaseVolume::template Sampler< PagedVolume >::moveNegativeX(); + this->m_uXPosInChunk--; + // Then we update the voxel pointer if(((this->mXPosInVolume + 1) % this->mVolume->m_uChunkSideLength != 0)) { //No need to compute new chunk. - --mCurrentVoxel; + mCurrentVoxel += NEG_X_DELTA; } else { @@ -222,11 +230,13 @@ namespace PolyVox // Base version updates position and validity flags. BaseVolume::template Sampler< PagedVolume >::moveNegativeY(); + this->m_uYPosInChunk--; + // Then we update the voxel pointer if(((this->mYPosInVolume + 1) % this->mVolume->m_uChunkSideLength != 0)) { //No need to compute new chunk. - mCurrentVoxel -= this->mVolume->m_uChunkSideLength; + mCurrentVoxel += NEG_Y_DELTA; } else { @@ -241,11 +251,13 @@ namespace PolyVox // Base version updates position and validity flags. BaseVolume::template Sampler< PagedVolume >::moveNegativeZ(); + this->m_uZPosInChunk--; + // Then we update the voxel pointer if(((this->mZPosInVolume + 1) % this->mVolume->m_uChunkSideLength != 0)) { //No need to compute new chunk. - mCurrentVoxel -= this->mVolume->m_uChunkSideLength * this->mVolume->m_uChunkSideLength; + mCurrentVoxel += NEG_Z_DELTA; } else {