From 6f428d2e18c34e5403d84e21ab508f450aa25375 Mon Sep 17 00:00:00 2001 From: David Williams Date: Wed, 20 Jul 2011 23:38:16 +0100 Subject: [PATCH] Base Volume class now compiles and works. --- library/PolyVoxCore/CMakeLists.txt | 3 + .../include/PolyVoxCore/RawVolume.h | 8 +- .../include/PolyVoxCore/RawVolumeSampler.inl | 13 +- .../PolyVoxCore/include/PolyVoxCore/Volume.h | 15 -- .../include/PolyVoxCore/VolumeSampler.inl | 141 +++++++++--------- 5 files changed, 85 insertions(+), 95 deletions(-) diff --git a/library/PolyVoxCore/CMakeLists.txt b/library/PolyVoxCore/CMakeLists.txt index 3dce4314..a1bcf575 100644 --- a/library/PolyVoxCore/CMakeLists.txt +++ b/library/PolyVoxCore/CMakeLists.txt @@ -61,6 +61,9 @@ SET(CORE_INC_FILES include/PolyVoxCore/Vector.h include/PolyVoxCore/Vector.inl include/PolyVoxCore/VertexTypes.h + include/PolyVoxCore/Volume.h + include/PolyVoxCore/Volume.inl + include/PolyVoxCore/VolumeSampler.inl include/PolyVoxCore/VolumeResampler.h include/PolyVoxCore/VolumeResampler.inl include/PolyVoxCore/VoxelFilters.h diff --git a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h index d9bde4a7..88ad1a18 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h @@ -93,18 +93,18 @@ namespace PolyVox private: //The current volume - RawVolume* mRawVolume; + RawVolume* mVolume; //The current position in the volume - /*int32_t mXPosInVolume; + int32_t mXPosInVolume; int32_t mYPosInVolume; - int32_t mZPosInVolume;*/ + int32_t mZPosInVolume; //Other current position information VoxelType* mCurrentVoxel; //Whether the current position is inside the volume - //bool m_bIsCurrentPositionValid; + bool m_bIsCurrentPositionValid; }; #endif diff --git a/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl index b5f10b37..63aa9827 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl @@ -31,13 +31,12 @@ namespace PolyVox { template RawVolume::Sampler::Sampler(RawVolume* volume) - :Volume::Sampler(volume) - //,mXPosInVolume(0) - //,mYPosInVolume(0) - //,mZPosInVolume(0) - ,mRawVolume(volume) + :mVolume(volume) + ,mXPosInVolume(0) + ,mYPosInVolume(0) + ,mZPosInVolume(0) ,mCurrentVoxel(0) - //,m_bIsCurrentPositionValid(false) + ,m_bIsCurrentPositionValid(false) { } @@ -93,7 +92,7 @@ namespace PolyVox yPos * mVolume->getWidth() + zPos * mVolume->getWidth() * mVolume->getHeight(); - mCurrentVoxel = mRawVolume->m_pData + uVoxelIndex; + mCurrentVoxel = mVolume->m_pData + uVoxelIndex; m_bIsCurrentPositionValid = mVolume->getEnclosingRegion().containsPoint(Vector3DInt32(xPos, yPos, zPos)); } diff --git a/library/PolyVoxCore/include/PolyVoxCore/Volume.h b/library/PolyVoxCore/include/PolyVoxCore/Volume.h index 4ffe5046..2e662836 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Volume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Volume.h @@ -40,9 +40,6 @@ namespace PolyVox class Sampler { public: - Sampler(Volume* volume); - ~Sampler(); - int32_t getPosX(void) const; int32_t getPosY(void) const; int32_t getPosZ(void) const; @@ -89,18 +86,6 @@ namespace PolyVox inline VoxelType peekVoxel1px1py1nz(void) const; inline VoxelType peekVoxel1px1py0pz(void) const; inline VoxelType peekVoxel1px1py1pz(void) const; - - protected: - //The current volume - Volume* mVolume; - - //The current position in the volume - int32_t mXPosInVolume; - int32_t mYPosInVolume; - int32_t mZPosInVolume; - - //Whether the current position is inside the volume - bool m_bIsCurrentPositionValid; }; #endif diff --git a/library/PolyVoxCore/include/PolyVoxCore/VolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/VolumeSampler.inl index 2638561a..8103fd9c 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/VolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/VolumeSampler.inl @@ -29,165 +29,150 @@ freely, subject to the following restrictions: #include namespace PolyVox { - template - Volume::Sampler::Sampler(Volume* volume) - :mVolume(volume) - ,mXPosInVolume(0) - ,mYPosInVolume(0) - ,mZPosInVolume(0) - ,m_bIsCurrentPositionValid(false) - { - } - - template - Volume::Sampler::~Sampler() - { - } - template int32_t Volume::Sampler::getPosX(void) const { - return mXPosInVolume; + assert(false); + return 0; } template int32_t Volume::Sampler::getPosY(void) const { - return mYPosInVolume; + assert(false); + return 0; } template int32_t Volume::Sampler::getPosZ(void) const { - return mZPosInVolume; + assert(false); + return 0; } template const Volume* Volume::Sampler::getVolume(void) const { - return mVolume; + assert(false); + return 0; } template VoxelType Volume::Sampler::getVoxel(void) const { - return m_bIsCurrentPositionValid ? mVolume->getVoxelAt(mXPosInVolume, mYPosInVolume, mZPosInVolume) : mVolume->m_tBorderValue; + assert(false); + return VoxelType(); } template void Volume::Sampler::setPosition(const Vector3DInt32& v3dNewPos) { - setPosition(v3dNewPos.getX(), v3dNewPos.getY(), v3dNewPos.getZ()); + assert(false); } template void Volume::Sampler::setPosition(int32_t xPos, int32_t yPos, int32_t zPos) { - mXPosInVolume = xPos; - mYPosInVolume = yPos; - mZPosInVolume = zPos; - - const uint32_t uVoxelIndex = xPos + - yPos * mVolume->getWidth() + - zPos * mVolume->getWidth() * mVolume->getHeight(); - - m_bIsCurrentPositionValid = mVolume->m_regValidRegion.containsPoint(Vector3DInt32(xPos, yPos, zPos)); + assert(false); } template void Volume::Sampler::movePositiveX(void) { - mXPosInVolume++; - m_bIsCurrentPositionValid = mXPosInVolume <= mVolume->getEnclosingRegion().getUpperCorner().getX(); + assert(false); } template void Volume::Sampler::movePositiveY(void) { - mYPosInVolume++; - m_bIsCurrentPositionValid = mYPosInVolume <= mVolume->getEnclosingRegion().getUpperCorner().getY(); + assert(false); } template void Volume::Sampler::movePositiveZ(void) { - mZPosInVolume++; - m_bIsCurrentPositionValid = mZPosInVolume <= mVolume->getEnclosingRegion().getUpperCorner().getZ(); + assert(false); } template void Volume::Sampler::moveNegativeX(void) { - mXPosInVolume--; - m_bIsCurrentPositionValid = mXPosInVolume >= mVolume->getEnclosingRegion().getLowerCorner().getX(); + assert(false); } template void Volume::Sampler::moveNegativeY(void) { - mYPosInVolume--; - m_bIsCurrentPositionValid = mYPosInVolume >= mVolume->getEnclosingRegion().getLowerCorner().getY(); + assert(false); } template void Volume::Sampler::moveNegativeZ(void) { - mZPosInVolume--; - m_bIsCurrentPositionValid =mZPosInVolume >= mVolume->getEnclosingRegion().getLowerCorner().getZ(); + assert(false); } template VoxelType Volume::Sampler::peekVoxel1nx1ny1nz(void) const { - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume-1); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel1nx1ny0pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel1nx1ny1pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume+1); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel1nx0py1nz(void) const { - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume-1); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel1nx0py0pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel1nx0py1pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume+1); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel1nx1py1nz(void) const { - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume-1); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel1nx1py0pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel1nx1py1pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume+1); + assert(false); + return VoxelType(); } ////////////////////////////////////////////////////////////////////////// @@ -195,55 +180,64 @@ namespace PolyVox template VoxelType Volume::Sampler::peekVoxel0px1ny1nz(void) const { - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume-1); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel0px1ny0pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel0px1ny1pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume+1); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel0px0py1nz(void) const { - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume,mZPosInVolume-1); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel0px0py0pz(void) const { - return *mCurrentVoxel; + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel0px0py1pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume,mZPosInVolume+1); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel0px1py1nz(void) const { - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume-1); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel0px1py0pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel0px1py1pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume+1); + assert(false); + return VoxelType(); } ////////////////////////////////////////////////////////////////////////// @@ -251,54 +245,63 @@ namespace PolyVox template VoxelType Volume::Sampler::peekVoxel1px1ny1nz(void) const { - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume-1); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel1px1ny0pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel1px1ny1pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume+1); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel1px0py1nz(void) const { - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume-1); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel1px0py0pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel1px0py1pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume+1); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel1px1py1nz(void) const { - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume-1); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel1px1py0pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel1px1py1pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume+1); + assert(false); + return VoxelType(); } }