Yep, that sounds possible. It also explains why the CubicSurfaceExtractor is not affected as it doesn't use the VolumeSampler (though it should). But the use of % is just in the optimisations - you can comment out the 'if' part and make it always call the 'else' part which calls setVoxel().
That is replace
Code:
template <typename VoxelType>
void VolumeSampler<VoxelType>::moveNegativeZ(void)
{
//Note the *post* decreament here
if((mZPosInVolume--) % mVolume->m_uBlockSideLength != 0)
{
//No need to compute new block.
mCurrentVoxel -= mVolume->m_uBlockSideLength * mVolume->m_uBlockSideLength;
}
else
{
//We've hit the block boundary. Just calling setPosition() is the easiest way to resolve this.
setPosition(mXPosInVolume, mYPosInVolume, mZPosInVolume);
}
}
With
Code:
template <typename VoxelType>
void VolumeSampler<VoxelType>::moveNegativeZ(void)
{
//Note the *post* decreament here
/*if((mZPosInVolume--) % mVolume->m_uBlockSideLength != 0)
{
//No need to compute new block.
mCurrentVoxel -= mVolume->m_uBlockSideLength * mVolume->m_uBlockSideLength;
}
else*/
{
//We've hit the block boundary. Just calling setPosition() is the easiest way to resolve this.
setPosition(mXPosInVolume, mYPosInVolume, mZPosInVolume);
}
}
for all the moveXXX functions and replace
Code:
template <typename VoxelType>
VoxelType VolumeSampler<VoxelType>::peekVoxel1nx1ny1nz(void) const
{
if((mXPosInVolume%mVolume->m_uBlockSideLength != 0) && (mYPosInVolume%mVolume->m_uBlockSideLength != 0) && (mZPosInVolume%mVolume->m_uBlockSideLength != 0))
{
return *(mCurrentVoxel - 1 - mVolume->m_uBlockSideLength - mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength);
}
return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume-1);
}
with:
Code:
template <typename VoxelType>
VoxelType VolumeSampler<VoxelType>::peekVoxel1nx1ny1nz(void) const
{
/*if((mXPosInVolume%mVolume->m_uBlockSideLength != 0) && (mYPosInVolume%mVolume->m_uBlockSideLength != 0) && (mZPosInVolume%mVolume->m_uBlockSideLength != 0))
{
return *(mCurrentVoxel - 1 - mVolume->m_uBlockSideLength - mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength);
}*/
return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume-1);
}
for all the peekXXX() functions. This will let you test whether that really is the problem, then we can worry about fixing the logic