Improved the logic of a few tests.

This commit is contained in:
David Williams
2012-12-08 10:42:59 +01:00
parent c49caa1511
commit b93ceca542
3 changed files with 72 additions and 18 deletions

View File

@ -148,11 +148,14 @@ namespace PolyVox
template <typename VoxelType>
void LargeVolume<VoxelType>::Sampler::movePositiveX(void)
{
// We'll need this in a moment...
bool bIsOldPositionValid = this->isCurrentPositionValid();
// Base version updates position and validity flags.
BaseVolume<VoxelType>::template Sampler< LargeVolume<VoxelType> >::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 <typename VoxelType>
void LargeVolume<VoxelType>::Sampler::movePositiveY(void)
{
// We'll need this in a moment...
bool bIsOldPositionValid = this->isCurrentPositionValid();
// Base version updates position and validity flags.
BaseVolume<VoxelType>::template Sampler< LargeVolume<VoxelType> >::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 <typename VoxelType>
void LargeVolume<VoxelType>::Sampler::movePositiveZ(void)
{
// We'll need this in a moment...
bool bIsOldPositionValid = this->isCurrentPositionValid();
// Base version updates position and validity flags.
BaseVolume<VoxelType>::template Sampler< LargeVolume<VoxelType> >::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 <typename VoxelType>
void LargeVolume<VoxelType>::Sampler::moveNegativeX(void)
{
// We'll need this in a moment...
bool bIsOldPositionValid = this->isCurrentPositionValid();
// Base version updates position and validity flags.
BaseVolume<VoxelType>::template Sampler< LargeVolume<VoxelType> >::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 <typename VoxelType>
void LargeVolume<VoxelType>::Sampler::moveNegativeY(void)
{
// We'll need this in a moment...
bool bIsOldPositionValid = this->isCurrentPositionValid();
// Base version updates position and validity flags.
BaseVolume<VoxelType>::template Sampler< LargeVolume<VoxelType> >::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 <typename VoxelType>
void LargeVolume<VoxelType>::Sampler::moveNegativeZ(void)
{
// We'll need this in a moment...
bool bIsOldPositionValid = this->isCurrentPositionValid();
// Base version updates position and validity flags.
BaseVolume<VoxelType>::template Sampler< LargeVolume<VoxelType> >::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;

View File

@ -105,11 +105,14 @@ namespace PolyVox
template <typename VoxelType>
void RawVolume<VoxelType>::Sampler::movePositiveX(void)
{
// We'll need this in a moment...
bool bIsOldPositionValid = this->isCurrentPositionValid();
// Base version updates position and validity flags.
BaseVolume<VoxelType>::template Sampler< RawVolume<VoxelType> >::movePositiveX();
// Then we update the voxel pointer
if(this->isCurrentPositionValid() && mCurrentVoxel )
if(this->isCurrentPositionValid() && bIsOldPositionValid )
{
++mCurrentVoxel;
}
@ -122,11 +125,14 @@ namespace PolyVox
template <typename VoxelType>
void RawVolume<VoxelType>::Sampler::movePositiveY(void)
{
// We'll need this in a moment...
bool bIsOldPositionValid = this->isCurrentPositionValid();
// Base version updates position and validity flags.
BaseVolume<VoxelType>::template Sampler< RawVolume<VoxelType> >::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 <typename VoxelType>
void RawVolume<VoxelType>::Sampler::movePositiveZ(void)
{
// We'll need this in a moment...
bool bIsOldPositionValid = this->isCurrentPositionValid();
// Base version updates position and validity flags.
BaseVolume<VoxelType>::template Sampler< RawVolume<VoxelType> >::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 <typename VoxelType>
void RawVolume<VoxelType>::Sampler::moveNegativeX(void)
{
// We'll need this in a moment...
bool bIsOldPositionValid = this->isCurrentPositionValid();
// Base version updates position and validity flags.
BaseVolume<VoxelType>::template Sampler< RawVolume<VoxelType> >::moveNegativeX();
// Then we update the voxel pointer
if(this->isCurrentPositionValid() && mCurrentVoxel )
if(this->isCurrentPositionValid() && bIsOldPositionValid )
{
--mCurrentVoxel;
}
@ -173,11 +185,14 @@ namespace PolyVox
template <typename VoxelType>
void RawVolume<VoxelType>::Sampler::moveNegativeY(void)
{
// We'll need this in a moment...
bool bIsOldPositionValid = this->isCurrentPositionValid();
// Base version updates position and validity flags.
BaseVolume<VoxelType>::template Sampler< RawVolume<VoxelType> >::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 <typename VoxelType>
void RawVolume<VoxelType>::Sampler::moveNegativeZ(void)
{
// We'll need this in a moment...
bool bIsOldPositionValid = this->isCurrentPositionValid();
// Base version updates position and validity flags.
BaseVolume<VoxelType>::template Sampler< RawVolume<VoxelType> >::moveNegativeZ();
// Then we update the voxel pointer
if(this->isCurrentPositionValid() && mCurrentVoxel )
if(this->isCurrentPositionValid() && bIsOldPositionValid )
{
mCurrentVoxel -= this->mVolume->getWidth() * this->mVolume->getHeight();
}

View File

@ -167,11 +167,14 @@ namespace PolyVox
template <typename VoxelType>
void SimpleVolume<VoxelType>::Sampler::movePositiveX(void)
{
// We'll need this in a moment...
bool bIsOldPositionValid = this->isCurrentPositionValid();
// Base version updates position and validity flags.
BaseVolume<VoxelType>::template Sampler< SimpleVolume<VoxelType> >::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 <typename VoxelType>
void SimpleVolume<VoxelType>::Sampler::movePositiveY(void)
{
// We'll need this in a moment...
bool bIsOldPositionValid = this->isCurrentPositionValid();
// Base version updates position and validity flags.
BaseVolume<VoxelType>::template Sampler< SimpleVolume<VoxelType> >::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 <typename VoxelType>
void SimpleVolume<VoxelType>::Sampler::movePositiveZ(void)
{
// We'll need this in a moment...
bool bIsOldPositionValid = this->isCurrentPositionValid();
// Base version updates position and validity flags.
BaseVolume<VoxelType>::template Sampler< SimpleVolume<VoxelType> >::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 <typename VoxelType>
void SimpleVolume<VoxelType>::Sampler::moveNegativeX(void)
{
// We'll need this in a moment...
bool bIsOldPositionValid = this->isCurrentPositionValid();
// Base version updates position and validity flags.
BaseVolume<VoxelType>::template Sampler< SimpleVolume<VoxelType> >::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 <typename VoxelType>
void SimpleVolume<VoxelType>::Sampler::moveNegativeY(void)
{
// We'll need this in a moment...
bool bIsOldPositionValid = this->isCurrentPositionValid();
// Base version updates position and validity flags.
BaseVolume<VoxelType>::template Sampler< SimpleVolume<VoxelType> >::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 <typename VoxelType>
void SimpleVolume<VoxelType>::Sampler::moveNegativeZ(void)
{
// We'll need this in a moment...
bool bIsOldPositionValid = this->isCurrentPositionValid();
// Base version updates position and validity flags.
BaseVolume<VoxelType>::template Sampler< SimpleVolume<VoxelType> >::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;