Added extra tests to move functions.

This commit is contained in:
Daviw Williams 2012-12-07 13:38:39 +01:00
parent fea429a79a
commit d0c9b7ba3d
4 changed files with 64 additions and 22 deletions

View File

@ -145,7 +145,7 @@ namespace PolyVox
BaseVolume<VoxelType>::template Sampler< LargeVolume<VoxelType> >::movePositiveX(); BaseVolume<VoxelType>::template Sampler< LargeVolume<VoxelType> >::movePositiveX();
// Then we update the voxel pointer // Then we update the voxel pointer
if((this->mXPosInVolume) % this->mVolume->m_uBlockSideLength != 0) if((this->isCurrentPositionValid()) && ((this->mXPosInVolume) % this->mVolume->m_uBlockSideLength != 0))
{ {
//No need to compute new block. //No need to compute new block.
++mCurrentVoxel; ++mCurrentVoxel;
@ -164,7 +164,7 @@ namespace PolyVox
BaseVolume<VoxelType>::template Sampler< LargeVolume<VoxelType> >::movePositiveY(); BaseVolume<VoxelType>::template Sampler< LargeVolume<VoxelType> >::movePositiveY();
// Then we update the voxel pointer // Then we update the voxel pointer
if((this->mYPosInVolume) % this->mVolume->m_uBlockSideLength != 0) if((this->isCurrentPositionValid()) && ((this->mYPosInVolume) % this->mVolume->m_uBlockSideLength != 0))
{ {
//No need to compute new block. //No need to compute new block.
mCurrentVoxel += this->mVolume->m_uBlockSideLength; mCurrentVoxel += this->mVolume->m_uBlockSideLength;
@ -183,7 +183,7 @@ namespace PolyVox
BaseVolume<VoxelType>::template Sampler< LargeVolume<VoxelType> >::movePositiveZ(); BaseVolume<VoxelType>::template Sampler< LargeVolume<VoxelType> >::movePositiveZ();
// Then we update the voxel pointer // Then we update the voxel pointer
if((this->mZPosInVolume) % this->mVolume->m_uBlockSideLength != 0) if((this->isCurrentPositionValid()) && ((this->mZPosInVolume) % this->mVolume->m_uBlockSideLength != 0))
{ {
//No need to compute new block. //No need to compute new block.
mCurrentVoxel += this->mVolume->m_uBlockSideLength * this->mVolume->m_uBlockSideLength; mCurrentVoxel += this->mVolume->m_uBlockSideLength * this->mVolume->m_uBlockSideLength;
@ -202,7 +202,7 @@ namespace PolyVox
BaseVolume<VoxelType>::template Sampler< LargeVolume<VoxelType> >::moveNegativeX(); BaseVolume<VoxelType>::template Sampler< LargeVolume<VoxelType> >::moveNegativeX();
// Then we update the voxel pointer // Then we update the voxel pointer
if((this->mXPosInVolume + 1) % this->mVolume->m_uBlockSideLength != 0) if((this->isCurrentPositionValid()) && ((this->mXPosInVolume + 1) % this->mVolume->m_uBlockSideLength != 0))
{ {
//No need to compute new block. //No need to compute new block.
--mCurrentVoxel; --mCurrentVoxel;
@ -221,7 +221,7 @@ namespace PolyVox
BaseVolume<VoxelType>::template Sampler< LargeVolume<VoxelType> >::moveNegativeY(); BaseVolume<VoxelType>::template Sampler< LargeVolume<VoxelType> >::moveNegativeY();
// Then we update the voxel pointer // Then we update the voxel pointer
if((this->mYPosInVolume + 1) % this->mVolume->m_uBlockSideLength != 0) if((this->isCurrentPositionValid()) && ((this->mYPosInVolume + 1) % this->mVolume->m_uBlockSideLength != 0))
{ {
//No need to compute new block. //No need to compute new block.
mCurrentVoxel -= this->mVolume->m_uBlockSideLength; mCurrentVoxel -= this->mVolume->m_uBlockSideLength;
@ -240,7 +240,7 @@ namespace PolyVox
BaseVolume<VoxelType>::template Sampler< LargeVolume<VoxelType> >::moveNegativeZ(); BaseVolume<VoxelType>::template Sampler< LargeVolume<VoxelType> >::moveNegativeZ();
// Then we update the voxel pointer // Then we update the voxel pointer
if((this->mZPosInVolume + 1) % this->mVolume->m_uBlockSideLength != 0) if((this->isCurrentPositionValid()) && ((this->mZPosInVolume + 1) % this->mVolume->m_uBlockSideLength != 0))
{ {
//No need to compute new block. //No need to compute new block.
mCurrentVoxel -= this->mVolume->m_uBlockSideLength * this->mVolume->m_uBlockSideLength; mCurrentVoxel -= this->mVolume->m_uBlockSideLength * this->mVolume->m_uBlockSideLength;

View File

@ -102,8 +102,15 @@ namespace PolyVox
BaseVolume<VoxelType>::template Sampler< RawVolume<VoxelType> >::movePositiveX(); BaseVolume<VoxelType>::template Sampler< RawVolume<VoxelType> >::movePositiveX();
// Then we update the voxel pointer // Then we update the voxel pointer
if(this->isCurrentPositionValid())
{
++mCurrentVoxel; ++mCurrentVoxel;
} }
else
{
setPosition(this->mXPosInVolume, this->mYPosInVolume, this->mZPosInVolume);
}
}
template <typename VoxelType> template <typename VoxelType>
void RawVolume<VoxelType>::Sampler::movePositiveY(void) void RawVolume<VoxelType>::Sampler::movePositiveY(void)
@ -112,8 +119,15 @@ namespace PolyVox
BaseVolume<VoxelType>::template Sampler< RawVolume<VoxelType> >::movePositiveY(); BaseVolume<VoxelType>::template Sampler< RawVolume<VoxelType> >::movePositiveY();
// Then we update the voxel pointer // Then we update the voxel pointer
if(this->isCurrentPositionValid())
{
mCurrentVoxel += this->mVolume->getWidth(); mCurrentVoxel += this->mVolume->getWidth();
} }
else
{
setPosition(this->mXPosInVolume, this->mYPosInVolume, this->mZPosInVolume);
}
}
template <typename VoxelType> template <typename VoxelType>
void RawVolume<VoxelType>::Sampler::movePositiveZ(void) void RawVolume<VoxelType>::Sampler::movePositiveZ(void)
@ -122,8 +136,15 @@ namespace PolyVox
BaseVolume<VoxelType>::template Sampler< RawVolume<VoxelType> >::movePositiveZ(); BaseVolume<VoxelType>::template Sampler< RawVolume<VoxelType> >::movePositiveZ();
// Then we update the voxel pointer // Then we update the voxel pointer
if(this->isCurrentPositionValid())
{
mCurrentVoxel += this->mVolume->getWidth() * this->mVolume->getHeight(); mCurrentVoxel += this->mVolume->getWidth() * this->mVolume->getHeight();
} }
else
{
setPosition(this->mXPosInVolume, this->mYPosInVolume, this->mZPosInVolume);
}
}
template <typename VoxelType> template <typename VoxelType>
void RawVolume<VoxelType>::Sampler::moveNegativeX(void) void RawVolume<VoxelType>::Sampler::moveNegativeX(void)
@ -132,8 +153,15 @@ namespace PolyVox
BaseVolume<VoxelType>::template Sampler< RawVolume<VoxelType> >::moveNegativeX(); BaseVolume<VoxelType>::template Sampler< RawVolume<VoxelType> >::moveNegativeX();
// Then we update the voxel pointer // Then we update the voxel pointer
if(this->isCurrentPositionValid())
{
--mCurrentVoxel; --mCurrentVoxel;
} }
else
{
setPosition(this->mXPosInVolume, this->mYPosInVolume, this->mZPosInVolume);
}
}
template <typename VoxelType> template <typename VoxelType>
void RawVolume<VoxelType>::Sampler::moveNegativeY(void) void RawVolume<VoxelType>::Sampler::moveNegativeY(void)
@ -142,8 +170,15 @@ namespace PolyVox
BaseVolume<VoxelType>::template Sampler< RawVolume<VoxelType> >::moveNegativeY(); BaseVolume<VoxelType>::template Sampler< RawVolume<VoxelType> >::moveNegativeY();
// Then we update the voxel pointer // Then we update the voxel pointer
if(this->isCurrentPositionValid())
{
mCurrentVoxel -= this->mVolume->getWidth(); mCurrentVoxel -= this->mVolume->getWidth();
} }
else
{
setPosition(this->mXPosInVolume, this->mYPosInVolume, this->mZPosInVolume);
}
}
template <typename VoxelType> template <typename VoxelType>
void RawVolume<VoxelType>::Sampler::moveNegativeZ(void) void RawVolume<VoxelType>::Sampler::moveNegativeZ(void)
@ -152,8 +187,15 @@ namespace PolyVox
BaseVolume<VoxelType>::template Sampler< RawVolume<VoxelType> >::moveNegativeZ(); BaseVolume<VoxelType>::template Sampler< RawVolume<VoxelType> >::moveNegativeZ();
// Then we update the voxel pointer // Then we update the voxel pointer
if(this->isCurrentPositionValid())
{
mCurrentVoxel -= this->mVolume->getWidth() * this->mVolume->getHeight(); mCurrentVoxel -= this->mVolume->getWidth() * this->mVolume->getHeight();
} }
else
{
setPosition(this->mXPosInVolume, this->mYPosInVolume, this->mZPosInVolume);
}
}
template <typename VoxelType> template <typename VoxelType>
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1nx1ny1nz(void) const VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1nx1ny1nz(void) const

View File

@ -164,7 +164,7 @@ namespace PolyVox
BaseVolume<VoxelType>::template Sampler< SimpleVolume<VoxelType> >::movePositiveX(); BaseVolume<VoxelType>::template Sampler< SimpleVolume<VoxelType> >::movePositiveX();
// Then we update the voxel pointer // Then we update the voxel pointer
if((this->mXPosInVolume) % this->mVolume->m_uBlockSideLength != 0) if((this->isCurrentPositionValid()) && ((this->mXPosInVolume) % this->mVolume->m_uBlockSideLength != 0))
{ {
//No need to compute new block. //No need to compute new block.
++mCurrentVoxel; ++mCurrentVoxel;
@ -183,7 +183,7 @@ namespace PolyVox
BaseVolume<VoxelType>::template Sampler< SimpleVolume<VoxelType> >::movePositiveY(); BaseVolume<VoxelType>::template Sampler< SimpleVolume<VoxelType> >::movePositiveY();
// Then we update the voxel pointer // Then we update the voxel pointer
if((this->mYPosInVolume) % this->mVolume->m_uBlockSideLength != 0) if((this->isCurrentPositionValid()) && ((this->mYPosInVolume) % this->mVolume->m_uBlockSideLength != 0))
{ {
//No need to compute new block. //No need to compute new block.
mCurrentVoxel += this->mVolume->m_uBlockSideLength; mCurrentVoxel += this->mVolume->m_uBlockSideLength;
@ -202,7 +202,7 @@ namespace PolyVox
BaseVolume<VoxelType>::template Sampler< SimpleVolume<VoxelType> >::movePositiveZ(); BaseVolume<VoxelType>::template Sampler< SimpleVolume<VoxelType> >::movePositiveZ();
// Then we update the voxel pointer // Then we update the voxel pointer
if((this->mZPosInVolume) % this->mVolume->m_uBlockSideLength != 0) if((this->isCurrentPositionValid()) && ((this->mZPosInVolume) % this->mVolume->m_uBlockSideLength != 0))
{ {
//No need to compute new block. //No need to compute new block.
mCurrentVoxel += this->mVolume->m_uBlockSideLength * this->mVolume->m_uBlockSideLength; mCurrentVoxel += this->mVolume->m_uBlockSideLength * this->mVolume->m_uBlockSideLength;
@ -221,7 +221,7 @@ namespace PolyVox
BaseVolume<VoxelType>::template Sampler< SimpleVolume<VoxelType> >::moveNegativeX(); BaseVolume<VoxelType>::template Sampler< SimpleVolume<VoxelType> >::moveNegativeX();
// Then we update the voxel pointer // Then we update the voxel pointer
if((this->mXPosInVolume + 1) % this->mVolume->m_uBlockSideLength != 0) if((this->isCurrentPositionValid()) && ((this->mXPosInVolume + 1) % this->mVolume->m_uBlockSideLength != 0))
{ {
//No need to compute new block. //No need to compute new block.
--mCurrentVoxel; --mCurrentVoxel;
@ -240,7 +240,7 @@ namespace PolyVox
BaseVolume<VoxelType>::template Sampler< SimpleVolume<VoxelType> >::moveNegativeY(); BaseVolume<VoxelType>::template Sampler< SimpleVolume<VoxelType> >::moveNegativeY();
// Then we update the voxel pointer // Then we update the voxel pointer
if((this->mYPosInVolume + 1) % this->mVolume->m_uBlockSideLength != 0) if((this->isCurrentPositionValid()) && ((this->mYPosInVolume + 1) % this->mVolume->m_uBlockSideLength != 0))
{ {
//No need to compute new block. //No need to compute new block.
mCurrentVoxel -= this->mVolume->m_uBlockSideLength; mCurrentVoxel -= this->mVolume->m_uBlockSideLength;
@ -259,7 +259,7 @@ namespace PolyVox
BaseVolume<VoxelType>::template Sampler< SimpleVolume<VoxelType> >::moveNegativeZ(); BaseVolume<VoxelType>::template Sampler< SimpleVolume<VoxelType> >::moveNegativeZ();
// Then we update the voxel pointer // Then we update the voxel pointer
if((this->mZPosInVolume + 1) % this->mVolume->m_uBlockSideLength != 0) if((this->isCurrentPositionValid()) && ((this->mZPosInVolume + 1) % this->mVolume->m_uBlockSideLength != 0))
{ {
//No need to compute new block. //No need to compute new block.
mCurrentVoxel -= this->mVolume->m_uBlockSideLength * this->mVolume->m_uBlockSideLength; mCurrentVoxel -= this->mVolume->m_uBlockSideLength * this->mVolume->m_uBlockSideLength;

View File

@ -116,11 +116,11 @@ int32_t complexVolumeTest(void)
zSampler.setWrapMode(WrapModes::Border, 1); zSampler.setWrapMode(WrapModes::Border, 1);
sampler.setWrapMode(WrapModes::Border, 1); sampler.setWrapMode(WrapModes::Border, 1);
//zSampler.setPosition(testVolume.getEnclosingRegion().getLowerX() - 4, testVolume.getEnclosingRegion().getLowerY() - 1, testVolume.getEnclosingRegion().getLowerZ() - 2); zSampler.setPosition(testVolume.getEnclosingRegion().getLowerX() - 4, testVolume.getEnclosingRegion().getLowerY() - 1, testVolume.getEnclosingRegion().getLowerZ() - 2);
for(int z = testVolume.getEnclosingRegion().getLowerZ() - 2; z <= testVolume.getEnclosingRegion().getUpperZ() + 1; z++) for(int z = testVolume.getEnclosingRegion().getLowerZ() - 2; z <= testVolume.getEnclosingRegion().getUpperZ() + 1; z++)
{ {
//ySampler = zSampler; ySampler = zSampler;
ySampler.setPosition(testVolume.getEnclosingRegion().getLowerX() - 4, testVolume.getEnclosingRegion().getLowerY() - 1, z); //ySampler.setPosition(testVolume.getEnclosingRegion().getLowerX() - 4, testVolume.getEnclosingRegion().getLowerY() - 1, z);
for(int y = testVolume.getEnclosingRegion().getLowerY() - 1; y <= testVolume.getEnclosingRegion().getUpperY() + 3; y++) for(int y = testVolume.getEnclosingRegion().getLowerY() - 1; y <= testVolume.getEnclosingRegion().getUpperY() + 3; y++)
{ {
xSampler = ySampler; xSampler = ySampler;
@ -137,7 +137,7 @@ int32_t complexVolumeTest(void)
} }
ySampler.movePositiveY(); ySampler.movePositiveY();
} }
//zSampler.movePositiveZ(); zSampler.movePositiveZ();
} }
return result; return result;