Base Volume class now compiles and works.

This commit is contained in:
David Williams 2011-07-20 23:38:16 +01:00
parent 9e8be282f1
commit 6f428d2e18
5 changed files with 85 additions and 95 deletions

View File

@ -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

View File

@ -93,18 +93,18 @@ namespace PolyVox
private:
//The current volume
RawVolume<VoxelType>* mRawVolume;
RawVolume<VoxelType>* 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

View File

@ -31,13 +31,12 @@ namespace PolyVox
{
template <typename VoxelType>
RawVolume<VoxelType>::Sampler::Sampler(RawVolume<VoxelType>* volume)
:Volume<VoxelType>::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));
}

View File

@ -40,9 +40,6 @@ namespace PolyVox
class Sampler
{
public:
Sampler(Volume<VoxelType>* 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<VoxelType>* 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

View File

@ -29,165 +29,150 @@ freely, subject to the following restrictions:
#include <limits>
namespace PolyVox
{
template <typename VoxelType>
Volume<VoxelType>::Sampler::Sampler(Volume<VoxelType>* volume)
:mVolume(volume)
,mXPosInVolume(0)
,mYPosInVolume(0)
,mZPosInVolume(0)
,m_bIsCurrentPositionValid(false)
{
}
template <typename VoxelType>
Volume<VoxelType>::Sampler::~Sampler()
{
}
template <typename VoxelType>
int32_t Volume<VoxelType>::Sampler::getPosX(void) const
{
return mXPosInVolume;
assert(false);
return 0;
}
template <typename VoxelType>
int32_t Volume<VoxelType>::Sampler::getPosY(void) const
{
return mYPosInVolume;
assert(false);
return 0;
}
template <typename VoxelType>
int32_t Volume<VoxelType>::Sampler::getPosZ(void) const
{
return mZPosInVolume;
assert(false);
return 0;
}
template <typename VoxelType>
const Volume<VoxelType>* Volume<VoxelType>::Sampler::getVolume(void) const
{
return mVolume;
assert(false);
return 0;
}
template <typename VoxelType>
VoxelType Volume<VoxelType>::Sampler::getVoxel(void) const
{
return m_bIsCurrentPositionValid ? mVolume->getVoxelAt(mXPosInVolume, mYPosInVolume, mZPosInVolume) : mVolume->m_tBorderValue;
assert(false);
return VoxelType();
}
template <typename VoxelType>
void Volume<VoxelType>::Sampler::setPosition(const Vector3DInt32& v3dNewPos)
{
setPosition(v3dNewPos.getX(), v3dNewPos.getY(), v3dNewPos.getZ());
assert(false);
}
template <typename VoxelType>
void Volume<VoxelType>::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 <typename VoxelType>
void Volume<VoxelType>::Sampler::movePositiveX(void)
{
mXPosInVolume++;
m_bIsCurrentPositionValid = mXPosInVolume <= mVolume->getEnclosingRegion().getUpperCorner().getX();
assert(false);
}
template <typename VoxelType>
void Volume<VoxelType>::Sampler::movePositiveY(void)
{
mYPosInVolume++;
m_bIsCurrentPositionValid = mYPosInVolume <= mVolume->getEnclosingRegion().getUpperCorner().getY();
assert(false);
}
template <typename VoxelType>
void Volume<VoxelType>::Sampler::movePositiveZ(void)
{
mZPosInVolume++;
m_bIsCurrentPositionValid = mZPosInVolume <= mVolume->getEnclosingRegion().getUpperCorner().getZ();
assert(false);
}
template <typename VoxelType>
void Volume<VoxelType>::Sampler::moveNegativeX(void)
{
mXPosInVolume--;
m_bIsCurrentPositionValid = mXPosInVolume >= mVolume->getEnclosingRegion().getLowerCorner().getX();
assert(false);
}
template <typename VoxelType>
void Volume<VoxelType>::Sampler::moveNegativeY(void)
{
mYPosInVolume--;
m_bIsCurrentPositionValid = mYPosInVolume >= mVolume->getEnclosingRegion().getLowerCorner().getY();
assert(false);
}
template <typename VoxelType>
void Volume<VoxelType>::Sampler::moveNegativeZ(void)
{
mZPosInVolume--;
m_bIsCurrentPositionValid =mZPosInVolume >= mVolume->getEnclosingRegion().getLowerCorner().getZ();
assert(false);
}
template <typename VoxelType>
VoxelType Volume<VoxelType>::Sampler::peekVoxel1nx1ny1nz(void) const
{
return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume-1);
assert(false);
return VoxelType();
}
template <typename VoxelType>
VoxelType Volume<VoxelType>::Sampler::peekVoxel1nx1ny0pz(void) const
{
return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume);
assert(false);
return VoxelType();
}
template <typename VoxelType>
VoxelType Volume<VoxelType>::Sampler::peekVoxel1nx1ny1pz(void) const
{
return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume+1);
assert(false);
return VoxelType();
}
template <typename VoxelType>
VoxelType Volume<VoxelType>::Sampler::peekVoxel1nx0py1nz(void) const
{
return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume-1);
assert(false);
return VoxelType();
}
template <typename VoxelType>
VoxelType Volume<VoxelType>::Sampler::peekVoxel1nx0py0pz(void) const
{
return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume);
assert(false);
return VoxelType();
}
template <typename VoxelType>
VoxelType Volume<VoxelType>::Sampler::peekVoxel1nx0py1pz(void) const
{
return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume+1);
assert(false);
return VoxelType();
}
template <typename VoxelType>
VoxelType Volume<VoxelType>::Sampler::peekVoxel1nx1py1nz(void) const
{
return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume-1);
assert(false);
return VoxelType();
}
template <typename VoxelType>
VoxelType Volume<VoxelType>::Sampler::peekVoxel1nx1py0pz(void) const
{
return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume);
assert(false);
return VoxelType();
}
template <typename VoxelType>
VoxelType Volume<VoxelType>::Sampler::peekVoxel1nx1py1pz(void) const
{
return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume+1);
assert(false);
return VoxelType();
}
//////////////////////////////////////////////////////////////////////////
@ -195,55 +180,64 @@ namespace PolyVox
template <typename VoxelType>
VoxelType Volume<VoxelType>::Sampler::peekVoxel0px1ny1nz(void) const
{
return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume-1);
assert(false);
return VoxelType();
}
template <typename VoxelType>
VoxelType Volume<VoxelType>::Sampler::peekVoxel0px1ny0pz(void) const
{
return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume);
assert(false);
return VoxelType();
}
template <typename VoxelType>
VoxelType Volume<VoxelType>::Sampler::peekVoxel0px1ny1pz(void) const
{
return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume+1);
assert(false);
return VoxelType();
}
template <typename VoxelType>
VoxelType Volume<VoxelType>::Sampler::peekVoxel0px0py1nz(void) const
{
return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume,mZPosInVolume-1);
assert(false);
return VoxelType();
}
template <typename VoxelType>
VoxelType Volume<VoxelType>::Sampler::peekVoxel0px0py0pz(void) const
{
return *mCurrentVoxel;
assert(false);
return VoxelType();
}
template <typename VoxelType>
VoxelType Volume<VoxelType>::Sampler::peekVoxel0px0py1pz(void) const
{
return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume,mZPosInVolume+1);
assert(false);
return VoxelType();
}
template <typename VoxelType>
VoxelType Volume<VoxelType>::Sampler::peekVoxel0px1py1nz(void) const
{
return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume-1);
assert(false);
return VoxelType();
}
template <typename VoxelType>
VoxelType Volume<VoxelType>::Sampler::peekVoxel0px1py0pz(void) const
{
return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume);
assert(false);
return VoxelType();
}
template <typename VoxelType>
VoxelType Volume<VoxelType>::Sampler::peekVoxel0px1py1pz(void) const
{
return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume+1);
assert(false);
return VoxelType();
}
//////////////////////////////////////////////////////////////////////////
@ -251,54 +245,63 @@ namespace PolyVox
template <typename VoxelType>
VoxelType Volume<VoxelType>::Sampler::peekVoxel1px1ny1nz(void) const
{
return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume-1);
assert(false);
return VoxelType();
}
template <typename VoxelType>
VoxelType Volume<VoxelType>::Sampler::peekVoxel1px1ny0pz(void) const
{
return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume);
assert(false);
return VoxelType();
}
template <typename VoxelType>
VoxelType Volume<VoxelType>::Sampler::peekVoxel1px1ny1pz(void) const
{
return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume+1);
assert(false);
return VoxelType();
}
template <typename VoxelType>
VoxelType Volume<VoxelType>::Sampler::peekVoxel1px0py1nz(void) const
{
return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume-1);
assert(false);
return VoxelType();
}
template <typename VoxelType>
VoxelType Volume<VoxelType>::Sampler::peekVoxel1px0py0pz(void) const
{
return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume);
assert(false);
return VoxelType();
}
template <typename VoxelType>
VoxelType Volume<VoxelType>::Sampler::peekVoxel1px0py1pz(void) const
{
return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume+1);
assert(false);
return VoxelType();
}
template <typename VoxelType>
VoxelType Volume<VoxelType>::Sampler::peekVoxel1px1py1nz(void) const
{
return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume-1);
assert(false);
return VoxelType();
}
template <typename VoxelType>
VoxelType Volume<VoxelType>::Sampler::peekVoxel1px1py0pz(void) const
{
return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume);
assert(false);
return VoxelType();
}
template <typename VoxelType>
VoxelType Volume<VoxelType>::Sampler::peekVoxel1px1py1pz(void) const
{
return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume+1);
assert(false);
return VoxelType();
}
}