diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl index b4ee5feb..25588e69 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl @@ -614,13 +614,9 @@ namespace PolyVox // Purge null blocks so we know that all blocks are used. purgeNullPtrsFromAllBlocks(); - // We include the size of the LargeVolume class but it should be insignificant. - uint32_t uSizeInBytes = sizeof(LargeVolume); - - // Memory used by the blocks - uSizeInBytes += UncompressedBlock::calculateSizeInBytes(m_uBlockSideLength) * m_pAllBlocks.size(); - - return uSizeInBytes; + // Note: We disregard the size of the other class members as they are likely to be very small compared to the size of the + // allocated voxel data. This also keeps the reported size as a power of two, which makes other memory calculations easier. + return UncompressedBlock::calculateSizeInBytes(m_uBlockSideLength) * m_pAllBlocks.size(); } template diff --git a/library/PolyVoxCore/include/PolyVoxCore/UncompressedBlock.inl b/library/PolyVoxCore/include/PolyVoxCore/UncompressedBlock.inl index 6f73d2f1..083d763e 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/UncompressedBlock.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/UncompressedBlock.inl @@ -148,8 +148,9 @@ namespace PolyVox template uint32_t UncompressedBlock::calculateSizeInBytes(uint32_t uSideLength) { - // Returns the size of this class plus the size of the uncompressed data. - uint32_t uSizeInBytes = sizeof(UncompressedBlock) + (uSideLength * uSideLength * uSideLength * sizeof(VoxelType)); + // Note: We disregard the size of the other class members as they are likely to be very small compared to the size of the + // 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; } }