From 938eea7c8e2a28eb85575e8ebf99b61935873373 Mon Sep 17 00:00:00 2001 From: David Williams Date: Wed, 26 Jun 2013 22:01:44 +0200 Subject: [PATCH] Work on tidying LargeVolume... --- examples/Basic/main.cpp | 2 +- library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/Basic/main.cpp b/examples/Basic/main.cpp index 407d4e8e..b3ba51b7 100644 --- a/examples/Basic/main.cpp +++ b/examples/Basic/main.cpp @@ -82,7 +82,7 @@ int main(int argc, char *argv[]) //Create an empty volume and then place a sphere in it RLECompressor* pCompressor = new RLECompressor(); - FilePager* pFilePager = new FilePager("C:/temp/voldata/"); + FilePager* pFilePager = new FilePager("D:/temp/voldata/"); LargeVolume volData(PolyVox::Region(Vector3DInt32(0,0,0), Vector3DInt32(63, 63, 63)), pCompressor, pFilePager, 32); volData.setMaxNumberOfUncompressedBlocks(2); diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl index 640ddc3e..4473e350 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl @@ -546,6 +546,11 @@ namespace PolyVox template void LargeVolume::eraseBlock(typename std::map, BlockPositionCompare>::iterator itBlock) const { + if(itBlock->second.hasUncompressedData()) + { + itBlock->second.destroyUncompressedData(); + } + if(m_pPager) { Vector3DInt32 v3dPos = itBlock->first; @@ -565,8 +570,6 @@ namespace PolyVox // find the block in the uncompressed cache if(m_vecBlocksWithUncompressedData[ct] == &(itBlock->second)) { - // TODO: compression is unneccessary? or will not compressing this cause a memleak? - itBlock->second.destroyUncompressedData(); // put last object in cache here m_vecBlocksWithUncompressedData[ct] = m_vecBlocksWithUncompressedData.back(); // decrease cache size by one since last element is now in here twice