Documentation and tidying.

This commit is contained in:
David Williams
2011-02-13 00:07:12 +00:00
parent 29e2e14c3a
commit ad0e923413
5 changed files with 124 additions and 114 deletions

View File

@ -198,6 +198,20 @@ namespace PolyVox
return getVoxelAt(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ());
}
////////////////////////////////////////////////////////////////////////////////
/// Increasing the size of the block cache will increase memory but may improve performance.
/// You may want to set this to a large value (e.g. 1024) when you are first loading your
/// volume data and then set it to a smaller value (e.g.64) for general processing.
/// \param uBlockCacheSize The number of blocks for which uncompressed data can be cached.
////////////////////////////////////////////////////////////////////////////////
template <typename VoxelType>
void Volume<VoxelType>::setBlockCacheSize(uint16_t uBlockCacheSize)
{
clearBlockCache();
m_uMaxUncompressedBlockCacheSize = uBlockCacheSize;
}
////////////////////////////////////////////////////////////////////////////////
/// \param tBorder The value to use for voxels outside the volume.
////////////////////////////////////////////////////////////////////////////////
@ -352,14 +366,6 @@ namespace PolyVox
m_fDiagonalLength = sqrtf(static_cast<float>(m_uWidth * m_uWidth + m_uHeight * m_uHeight + m_uDepth * m_uDepth));
}
template <typename VoxelType>
void Volume<VoxelType>::setBlockCacheSize(uint16_t uBlockCacheSize)
{
clearBlockCache();
m_uMaxUncompressedBlockCacheSize = uBlockCacheSize;
}
template <typename VoxelType>
Block<VoxelType>* Volume<VoxelType>::getUncompressedBlock(uint16_t uBlockX, uint16_t uBlockY, uint16_t uBlockZ) const
{
@ -424,14 +430,22 @@ namespace PolyVox
}
template <typename VoxelType>
uint32_t Volume<VoxelType>::sizeInBytes(void)
float Volume<VoxelType>::calculateCompressionRatio(void)
{
float fRawSize = m_uWidth * m_uHeight * m_uDepth * sizeof(VoxelType);
float fCompressedSize = calculateSizeInBytes();
return fCompressedSize/fRawSize;
}
template <typename VoxelType>
uint32_t Volume<VoxelType>::calculateSizeInBytes(void)
{
uint32_t uSizeInBytes = sizeof(Volume);
//Memory used by the blocks
for(uint32_t i = 0; i < m_uNoOfBlocksInVolume; ++i)
{
uSizeInBytes += m_pBlocks[i].sizeInBytes();
uSizeInBytes += m_pBlocks[i].calculateSizeInBytes();
}
//Memory used by the block cache.