Renamed variable.

This commit is contained in:
David Williams 2014-09-13 23:14:07 +02:00
parent c0a22de2df
commit 5ff54c041f
2 changed files with 14 additions and 31 deletions

View File

@ -302,8 +302,6 @@ namespace PolyVox
typedef std::map<Vector3DInt32, UncompressedBlock<VoxelType>*, BlockPositionCompare> UncompressedBlockMap; typedef std::map<Vector3DInt32, UncompressedBlock<VoxelType>*, BlockPositionCompare> UncompressedBlockMap;
uint32_t calculateBlockMemoryUsage(void) const;
void ensureUncompressedBlockMapHasFreeSpace(void) const; void ensureUncompressedBlockMapHasFreeSpace(void) const;
void initialise(); void initialise();
@ -321,7 +319,7 @@ namespace PolyVox
void eraseBlock(typename UncompressedBlockMap::iterator itUncompressedBlock) const; void eraseBlock(typename UncompressedBlockMap::iterator itUncompressedBlock) const;
// The block data // The block data
mutable UncompressedBlockMap m_pUncompressedBlockCache; mutable UncompressedBlockMap m_pBlocks;
mutable uint32_t m_uTimestamper; mutable uint32_t m_uTimestamper;
mutable Vector3DInt32 m_v3dLastAccessedBlockPos; mutable Vector3DInt32 m_v3dLastAccessedBlockPos;

View File

@ -391,9 +391,9 @@ namespace PolyVox
//Replaced the for loop here as the call to //Replaced the for loop here as the call to
//eraseBlock was invalidating the iterator. //eraseBlock was invalidating the iterator.
while(m_pUncompressedBlockCache.size() > 0) while(m_pBlocks.size() > 0)
{ {
eraseBlock(m_pUncompressedBlockCache.begin()); eraseBlock(m_pBlocks.begin());
} }
} }
@ -422,8 +422,8 @@ namespace PolyVox
for(int32_t z = v3dStart.getZ(); z <= v3dEnd.getZ(); z++) for(int32_t z = v3dStart.getZ(); z <= v3dEnd.getZ(); z++)
{ {
Vector3DInt32 pos(x,y,z); Vector3DInt32 pos(x,y,z);
typename UncompressedBlockMap::iterator itBlock = m_pUncompressedBlockCache.find(pos); typename UncompressedBlockMap::iterator itBlock = m_pBlocks.find(pos);
if (itBlock == m_pUncompressedBlockCache.end()) if (itBlock == m_pBlocks.end())
{ {
// not loaded, not unloading // not loaded, not unloading
continue; continue;
@ -475,7 +475,7 @@ namespace PolyVox
//setMaxNumberOfUncompressedBlocks(m_uMaxNumberOfUncompressedBlocks); //setMaxNumberOfUncompressedBlocks(m_uMaxNumberOfUncompressedBlocks);
//Clear the previous data //Clear the previous data
m_pUncompressedBlockCache.clear(); m_pBlocks.clear();
//Other properties we might find useful later //Other properties we might find useful later
this->m_uLongestSideLength = (std::max)((std::max)(this->getWidth(),this->getHeight()),this->getDepth()); this->m_uLongestSideLength = (std::max)((std::max)(this->getWidth(),this->getHeight()),this->getDepth());
@ -514,7 +514,7 @@ namespace PolyVox
delete itUncompressedBlock->second; delete itUncompressedBlock->second;
// We can now remove the block data from memory. // We can now remove the block data from memory.
m_pUncompressedBlockCache.erase(itUncompressedBlock); m_pBlocks.erase(itUncompressedBlock);
} }
template <typename VoxelType> template <typename VoxelType>
@ -533,9 +533,9 @@ namespace PolyVox
UncompressedBlock<VoxelType>* pUncompressedBlock = 0; UncompressedBlock<VoxelType>* pUncompressedBlock = 0;
typename UncompressedBlockMap::iterator itUncompressedBlock = m_pUncompressedBlockCache.find(v3dBlockPos); typename UncompressedBlockMap::iterator itUncompressedBlock = m_pBlocks.find(v3dBlockPos);
// check whether the block is already loaded // check whether the block is already loaded
if(itUncompressedBlock != m_pUncompressedBlockCache.end()) if(itUncompressedBlock != m_pBlocks.end())
{ {
pUncompressedBlock = itUncompressedBlock->second; pUncompressedBlock = itUncompressedBlock->second;
} }
@ -565,7 +565,7 @@ namespace PolyVox
m_pPager->pageIn(reg, pUncompressedBlock); m_pPager->pageIn(reg, pUncompressedBlock);
// Add our new block to the map. // Add our new block to the map.
m_pUncompressedBlockCache.insert(std::make_pair(v3dBlockPos, pUncompressedBlock)); m_pBlocks.insert(std::make_pair(v3dBlockPos, pUncompressedBlock));
} }
pUncompressedBlock->m_uBlockLastAccessed = ++m_uTimestamper; pUncompressedBlock->m_uBlockLastAccessed = ++m_uTimestamper;
@ -585,7 +585,7 @@ namespace PolyVox
//Memory used by the blocks //Memory used by the blocks
typename UncompressedBlockMap::iterator i; typename UncompressedBlockMap::iterator i;
for (i = m_pUncompressedBlockCache.begin(); i != m_pUncompressedBlockCache.end(); i++) for (i = m_pBlocks.begin(); i != m_pBlocks.end(); i++)
{ {
//Inaccurate - account for rest of loaded block. //Inaccurate - account for rest of loaded block.
uSizeInBytes += i->second->calculateSizeInBytes(); uSizeInBytes += i->second->calculateSizeInBytes();
@ -598,31 +598,16 @@ namespace PolyVox
return uSizeInBytes; return uSizeInBytes;
} }
template <typename VoxelType>
uint32_t LargeVolume<VoxelType>::calculateBlockMemoryUsage(void) const
{
uint32_t uMemoryUsage = 0;
typename CompressedBlockMap::iterator i;
for(i = m_pBlocks.begin(); i != m_pBlocks.end(); i++)
{
//Inaccurate - account for rest of loaded block.
uMemoryUsage += i->second->calculateSizeInBytes();
}
return uMemoryUsage;
}
template <typename VoxelType> template <typename VoxelType>
void LargeVolume<VoxelType>::ensureUncompressedBlockMapHasFreeSpace(void) const void LargeVolume<VoxelType>::ensureUncompressedBlockMapHasFreeSpace(void) const
{ {
while(m_pUncompressedBlockCache.size() > m_uMaxNumberOfUncompressedBlocks) while(m_pBlocks.size() > m_uMaxNumberOfUncompressedBlocks)
{ {
// Find the least recently used block. The uncompressed block cache should be // Find the least recently used block. The uncompressed block cache should be
// much smaller than the total number of blocks, so hopefully this isn't too slow. // much smaller than the total number of blocks, so hopefully this isn't too slow.
typename UncompressedBlockMap::iterator i; typename UncompressedBlockMap::iterator i;
typename UncompressedBlockMap::iterator itUnloadBlock = m_pUncompressedBlockCache.begin(); typename UncompressedBlockMap::iterator itUnloadBlock = m_pBlocks.begin();
for(i = m_pUncompressedBlockCache.begin(); i != m_pUncompressedBlockCache.end(); i++) for(i = m_pBlocks.begin(); i != m_pBlocks.end(); i++)
{ {
if(i->second->m_uBlockLastAccessed < itUnloadBlock->second->m_uBlockLastAccessed) if(i->second->m_uBlockLastAccessed < itUnloadBlock->second->m_uBlockLastAccessed)
{ {