Simplifying code.

This commit is contained in:
David Williams 2014-09-18 16:54:14 +02:00
parent b08974c197
commit 2602b00103
2 changed files with 6 additions and 9 deletions

View File

@ -614,13 +614,9 @@ namespace PolyVox
// Purge null blocks so we know that all blocks are used. // Purge null blocks so we know that all blocks are used.
purgeNullPtrsFromAllBlocks(); purgeNullPtrsFromAllBlocks();
// We include the size of the LargeVolume class but it should be insignificant. // Note: We disregard the size of the other class members as they are likely to be very small compared to the size of the
uint32_t uSizeInBytes = sizeof(LargeVolume); // allocated voxel data. This also keeps the reported size as a power of two, which makes other memory calculations easier.
return UncompressedBlock<VoxelType>::calculateSizeInBytes(m_uBlockSideLength) * m_pAllBlocks.size();
// Memory used by the blocks
uSizeInBytes += UncompressedBlock<VoxelType>::calculateSizeInBytes(m_uBlockSideLength) * m_pAllBlocks.size();
return uSizeInBytes;
} }
template <typename VoxelType> template <typename VoxelType>

View File

@ -148,8 +148,9 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
uint32_t UncompressedBlock<VoxelType>::calculateSizeInBytes(uint32_t uSideLength) uint32_t UncompressedBlock<VoxelType>::calculateSizeInBytes(uint32_t uSideLength)
{ {
// Returns the size of this class plus the size of the uncompressed data. // Note: We disregard the size of the other class members as they are likely to be very small compared to the size of the
uint32_t uSizeInBytes = sizeof(UncompressedBlock<VoxelType>) + (uSideLength * uSideLength * uSideLength * sizeof(VoxelType)); // allocated voxel data. This also keeps the reported size as a power of two, which makes other memory calculations easier.
uint32_t uSizeInBytes = uSideLength * uSideLength * uSideLength * sizeof(VoxelType);
return uSizeInBytes; return uSizeInBytes;
} }
} }