Renamed compress and uncompress functions.
This commit is contained in:
parent
6b92a5ab51
commit
a2210fc3f0
@ -52,13 +52,12 @@ namespace PolyVox
|
|||||||
void setVoxelAt(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos, VoxelType tValue);
|
void setVoxelAt(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos, VoxelType tValue);
|
||||||
void setVoxelAt(const Vector3DUint16& v3dPos, VoxelType tValue);
|
void setVoxelAt(const Vector3DUint16& v3dPos, VoxelType tValue);
|
||||||
|
|
||||||
void initialise(uint16_t uSideLength);
|
void createUncompressedData(void);
|
||||||
|
void destroyUncompressedData(void);
|
||||||
|
|
||||||
uint32_t calculateSizeInBytes(void);
|
uint32_t calculateSizeInBytes(void);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void compress();
|
|
||||||
void uncompress();
|
|
||||||
|
|
||||||
Compressor* m_pCompressor;
|
Compressor* m_pCompressor;
|
||||||
uint8_t* m_pCompressedData;
|
uint8_t* m_pCompressedData;
|
||||||
uint32_t m_uCompressedDataLength;
|
uint32_t m_uCompressedDataLength;
|
||||||
|
@ -161,15 +161,7 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
uint32_t Block<VoxelType>::calculateSizeInBytes(void)
|
void Block<VoxelType>::destroyUncompressedData()
|
||||||
{
|
|
||||||
//FIXME - This function is incomplete.
|
|
||||||
uint32_t uSizeInBytes = sizeof(Block<VoxelType>);
|
|
||||||
return uSizeInBytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename VoxelType>
|
|
||||||
void Block<VoxelType>::compress()
|
|
||||||
{
|
{
|
||||||
if(!hasUncompressedData())
|
if(!hasUncompressedData())
|
||||||
{
|
{
|
||||||
@ -244,7 +236,7 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
void Block<VoxelType>::uncompress()
|
void Block<VoxelType>::createUncompressedData()
|
||||||
{
|
{
|
||||||
if(hasUncompressedData())
|
if(hasUncompressedData())
|
||||||
{
|
{
|
||||||
@ -270,4 +262,12 @@ namespace PolyVox
|
|||||||
|
|
||||||
m_bIsUncompressedDataModified = false;
|
m_bIsUncompressedDataModified = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
uint32_t Block<VoxelType>::calculateSizeInBytes(void)
|
||||||
|
{
|
||||||
|
//FIXME - This function is incomplete.
|
||||||
|
uint32_t uSizeInBytes = sizeof(Block<VoxelType>);
|
||||||
|
return uSizeInBytes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -471,7 +471,7 @@ namespace PolyVox
|
|||||||
{
|
{
|
||||||
for(uint32_t ct = 0; ct < m_vecUncompressedBlockCache.size(); ct++)
|
for(uint32_t ct = 0; ct < m_vecUncompressedBlockCache.size(); ct++)
|
||||||
{
|
{
|
||||||
m_vecUncompressedBlockCache[ct]->block.compress();
|
m_vecUncompressedBlockCache[ct]->block.destroyUncompressedData();
|
||||||
}
|
}
|
||||||
m_vecUncompressedBlockCache.clear();
|
m_vecUncompressedBlockCache.clear();
|
||||||
}
|
}
|
||||||
@ -552,7 +552,7 @@ namespace PolyVox
|
|||||||
if(m_vecUncompressedBlockCache[ct] == &(itBlock->second))
|
if(m_vecUncompressedBlockCache[ct] == &(itBlock->second))
|
||||||
{
|
{
|
||||||
// TODO: compression is unneccessary? or will not compressing this cause a memleak?
|
// TODO: compression is unneccessary? or will not compressing this cause a memleak?
|
||||||
itBlock->second.block.compress();
|
itBlock->second.block.destroyUncompressedData();
|
||||||
// put last object in cache here
|
// put last object in cache here
|
||||||
m_vecUncompressedBlockCache[ct] = m_vecUncompressedBlockCache.back();
|
m_vecUncompressedBlockCache[ct] = m_vecUncompressedBlockCache.back();
|
||||||
// decrease cache size by one since last element is now in here twice
|
// decrease cache size by one since last element is now in here twice
|
||||||
@ -635,7 +635,7 @@ namespace PolyVox
|
|||||||
// Blocks start out compressed - should we change this?
|
// Blocks start out compressed - should we change this?
|
||||||
// Or maybe we should just 'seed' them with compressed data,
|
// Or maybe we should just 'seed' them with compressed data,
|
||||||
// rather than creating an empty block and then compressing?
|
// rather than creating an empty block and then compressing?
|
||||||
newBlock.block.compress();
|
newBlock.block.destroyUncompressedData();
|
||||||
|
|
||||||
itBlock = m_pBlocks.insert(std::make_pair(v3dBlockPos, newBlock)).first;
|
itBlock = m_pBlocks.insert(std::make_pair(v3dBlockPos, newBlock)).first;
|
||||||
|
|
||||||
@ -688,7 +688,7 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Compress the least recently used block.
|
//Compress the least recently used block.
|
||||||
m_vecUncompressedBlockCache[leastRecentlyUsedBlockIndex]->block.compress();
|
m_vecUncompressedBlockCache[leastRecentlyUsedBlockIndex]->block.destroyUncompressedData();
|
||||||
|
|
||||||
//We don't actually remove any elements from this vector, we
|
//We don't actually remove any elements from this vector, we
|
||||||
//simply change the pointer to point at the new uncompressed bloack.
|
//simply change the pointer to point at the new uncompressed bloack.
|
||||||
@ -699,7 +699,7 @@ namespace PolyVox
|
|||||||
m_vecUncompressedBlockCache.push_back(&loadedBlock);
|
m_vecUncompressedBlockCache.push_back(&loadedBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
loadedBlock.block.uncompress();
|
loadedBlock.block.createUncompressedData();
|
||||||
|
|
||||||
m_pLastAccessedBlock = &(loadedBlock.block);
|
m_pLastAccessedBlock = &(loadedBlock.block);
|
||||||
POLYVOX_ASSERT(m_pLastAccessedBlock->m_tUncompressedData, "Block has no uncompressed data");
|
POLYVOX_ASSERT(m_pLastAccessedBlock->m_tUncompressedData, "Block has no uncompressed data");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user