From 1e0e8a8c167b6c786bd36cd616e6868319e7d476 Mon Sep 17 00:00:00 2001 From: David Williams Date: Mon, 13 Apr 2015 23:48:33 +0200 Subject: [PATCH] Fixed calculation of volume size in bytes. --- include/PolyVox/PagedVolume.inl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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; } }