Work on tidying LargeVolume...

This commit is contained in:
David Williams 2013-06-26 22:01:44 +02:00
parent 44d525f591
commit 938eea7c8e
2 changed files with 6 additions and 3 deletions

View File

@ -82,7 +82,7 @@ int main(int argc, char *argv[])
//Create an empty volume and then place a sphere in it
RLECompressor<uint8_t, uint16_t>* pCompressor = new RLECompressor<uint8_t, uint16_t>();
FilePager<uint8_t>* pFilePager = new FilePager<uint8_t>("C:/temp/voldata/");
FilePager<uint8_t>* pFilePager = new FilePager<uint8_t>("D:/temp/voldata/");
LargeVolume<uint8_t> volData(PolyVox::Region(Vector3DInt32(0,0,0), Vector3DInt32(63, 63, 63)), pCompressor, pFilePager, 32);
volData.setMaxNumberOfUncompressedBlocks(2);

View File

@ -546,6 +546,11 @@ namespace PolyVox
template <typename VoxelType>
void LargeVolume<VoxelType>::eraseBlock(typename std::map<Vector3DInt32, Block<VoxelType>, 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