diff --git a/include/PolyVox/PagedVolume.inl b/include/PolyVox/PagedVolume.inl index 736c76e0..93e4e51f 100644 --- a/include/PolyVox/PagedVolume.inl +++ b/include/PolyVox/PagedVolume.inl @@ -371,9 +371,18 @@ namespace PolyVox template uint32_t PagedVolume::calculateSizeInBytes(void) { + uint32_t uChunkCount = 0; + for (uint32_t uIndex = 0; uIndex < uChunkArraySize; uIndex++) + { + if (m_arrayChunks[uIndex]) + { + uChunkCount++; + } + } + // 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 PagedVolume::Chunk::calculateSizeInBytes(m_uChunkSideLength) * m_mapChunks.size(); + return PagedVolume::Chunk::calculateSizeInBytes(m_uChunkSideLength) * uChunkCount; } }