Stuff related to valid regions is being moved from BaseVolum to RawVolume, as PagedVolume is now infinite.
This commit is contained in:
@ -29,7 +29,9 @@ namespace PolyVox
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
template <typename VoxelType>
|
||||
RawVolume<VoxelType>::RawVolume(const Region& regValid)
|
||||
:BaseVolume<VoxelType>(regValid)
|
||||
:BaseVolume<VoxelType>()
|
||||
, m_regValidRegion(regValid)
|
||||
, m_tBorderValue()
|
||||
{
|
||||
this->setBorderValue(VoxelType());
|
||||
|
||||
@ -73,6 +75,90 @@ namespace PolyVox
|
||||
POLYVOX_THROW(not_implemented, "Volume assignment operator not implemented for performance reasons.");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// The border value is returned whenever an attempt is made to read a voxel which
|
||||
/// is outside the extents of the volume.
|
||||
/// \return The value used for voxels outside of the volume
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
template <typename VoxelType>
|
||||
VoxelType RawVolume<VoxelType>::getBorderValue(void) const
|
||||
{
|
||||
return m_tBorderValue;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// \return A Region representing the extent of the volume.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
template <typename VoxelType>
|
||||
const Region& RawVolume<VoxelType>::getEnclosingRegion(void) const
|
||||
{
|
||||
return m_regValidRegion;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// \return The width of the volume in voxels. Note that this value is inclusive, so that if the valid range is e.g. 0 to 63 then the width is 64.
|
||||
/// \sa getHeight(), getDepth()
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
template <typename VoxelType>
|
||||
int32_t RawVolume<VoxelType>::getWidth(void) const
|
||||
{
|
||||
return m_regValidRegion.getUpperX() - m_regValidRegion.getLowerX() + 1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// \return The height of the volume in voxels. Note that this value is inclusive, so that if the valid range is e.g. 0 to 63 then the height is 64.
|
||||
/// \sa getWidth(), getDepth()
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
template <typename VoxelType>
|
||||
int32_t RawVolume<VoxelType>::getHeight(void) const
|
||||
{
|
||||
return m_regValidRegion.getUpperY() - m_regValidRegion.getLowerY() + 1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// \return The depth of the volume in voxels. Note that this value is inclusive, so that if the valid range is e.g. 0 to 63 then the depth is 64.
|
||||
/// \sa getWidth(), getHeight()
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
template <typename VoxelType>
|
||||
int32_t RawVolume<VoxelType>::getDepth(void) const
|
||||
{
|
||||
return m_regValidRegion.getUpperZ() - m_regValidRegion.getLowerZ() + 1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// \return The length of the shortest side in voxels. For example, if a volume has
|
||||
/// dimensions 256x512x1024 this function will return 256.
|
||||
/// \sa getLongestSideLength(), getDiagonalLength()
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
template <typename VoxelType>
|
||||
int32_t RawVolume<VoxelType>::getShortestSideLength(void) const
|
||||
{
|
||||
return m_uShortestSideLength;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// \return The length of the longest side in voxels. For example, if a volume has
|
||||
/// dimensions 256x512x1024 this function will return 1024.
|
||||
/// \sa getShortestSideLength(), getDiagonalLength()
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
template <typename VoxelType>
|
||||
int32_t RawVolume<VoxelType>::getLongestSideLength(void) const
|
||||
{
|
||||
return m_uLongestSideLength;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// \return The length of the diagonal in voxels. For example, if a volume has
|
||||
/// dimensions 256x512x1024 this function will return sqrt(256*256+512*512+1024*1024)
|
||||
/// = 1173.139. This value is computed on volume creation so retrieving it is fast.
|
||||
/// \sa getShortestSideLength(), getLongestSideLength()
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
template <typename VoxelType>
|
||||
float RawVolume<VoxelType>::getDiagonalLength(void) const
|
||||
{
|
||||
return m_fDiagonalLength;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// This version of the function is provided so that the wrap mode does not need
|
||||
/// to be specified as a template parameter, as it may be confusing to some users.
|
||||
@ -120,6 +206,15 @@ namespace PolyVox
|
||||
return getVoxel(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// \param tBorder The value to use for voxels outside the volume.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
template <typename VoxelType>
|
||||
void RawVolume<VoxelType>::setBorderValue(const VoxelType& tBorder)
|
||||
{
|
||||
m_tBorderValue = tBorder;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// \param uXPos the \c x position of the voxel
|
||||
/// \param uYPos the \c y position of the voxel
|
||||
@ -185,6 +280,9 @@ namespace PolyVox
|
||||
//Create the data
|
||||
m_pData = new VoxelType[this->getWidth() * this->getHeight()* this->getDepth()];
|
||||
|
||||
// Clear to zeros
|
||||
std::fill(m_pData, m_pData + this->getWidth() * this->getHeight()* this->getDepth(), VoxelType());
|
||||
|
||||
//Other properties we might find useful later
|
||||
this->m_uLongestSideLength = (std::max)((std::max)(this->getWidth(),this->getHeight()),this->getDepth());
|
||||
this->m_uShortestSideLength = (std::min)((std::min)(this->getWidth(),this->getHeight()),this->getDepth());
|
||||
|
Reference in New Issue
Block a user