Renamed Block to CompressedBlock
This commit is contained in:
parent
00eb281990
commit
a00574351f
@ -91,7 +91,7 @@ public:
|
||||
/// Destructor
|
||||
virtual ~PerlinNoisePager() {};
|
||||
|
||||
virtual void pageIn(const PolyVox::Region& region, Block<MaterialDensityPair44>* pBlockData)
|
||||
virtual void pageIn(const PolyVox::Region& region, CompressedBlock<MaterialDensityPair44>* pBlockData)
|
||||
{
|
||||
/*pBlockData->createUncompressedData();
|
||||
|
||||
@ -137,7 +137,7 @@ public:
|
||||
}*/
|
||||
}
|
||||
|
||||
virtual void pageOut(const PolyVox::Region& region, Block<MaterialDensityPair44>* /*pBlockData*/)
|
||||
virtual void pageOut(const PolyVox::Region& region, CompressedBlock<MaterialDensityPair44>* /*pBlockData*/)
|
||||
{
|
||||
std::cout << "warning unloading region: " << region.getLowerCorner() << " -> " << region.getUpperCorner() << std::endl;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ namespace PolyVox
|
||||
/// Destructor
|
||||
virtual ~FilePager() {};
|
||||
|
||||
virtual void pageIn(const Region& region, Block<VoxelType>* pBlockData)
|
||||
virtual void pageIn(const Region& region, CompressedBlock<VoxelType>* pBlockData)
|
||||
{
|
||||
POLYVOX_ASSERT(pBlockData, "Attempting to page in NULL block");
|
||||
//POLYVOX_ASSERT(pBlockData->hasUncompressedData() == false, "Block should not have uncompressed data");
|
||||
@ -93,7 +93,7 @@ namespace PolyVox
|
||||
}
|
||||
}
|
||||
|
||||
virtual void pageOut(const Region& region, Block<VoxelType>* pBlockData)
|
||||
virtual void pageOut(const Region& region, CompressedBlock<VoxelType>* pBlockData)
|
||||
{
|
||||
POLYVOX_ASSERT(pBlockData, "Attempting to page out NULL block");
|
||||
//POLYVOX_ASSERT(pBlockData->hasUncompressedData() == false, "Block should not have uncompressed data");
|
||||
|
@ -35,10 +35,10 @@ freely, subject to the following restrictions:
|
||||
namespace PolyVox
|
||||
{
|
||||
template <typename VoxelType>
|
||||
class Block
|
||||
class CompressedBlock
|
||||
{
|
||||
public:
|
||||
Block(uint16_t uSideLength, Compressor* pCompressor);
|
||||
CompressedBlock(uint16_t uSideLength, Compressor* pCompressor);
|
||||
|
||||
const uint8_t* getCompressedData(void) const;
|
||||
uint32_t getCompressedDataLength(void) const;
|
||||
|
@ -36,7 +36,7 @@ freely, subject to the following restrictions:
|
||||
namespace PolyVox
|
||||
{
|
||||
template <typename VoxelType>
|
||||
Block<VoxelType>::Block(uint16_t uSideLength, Compressor* pCompressor)
|
||||
CompressedBlock<VoxelType>::CompressedBlock(uint16_t uSideLength, Compressor* pCompressor)
|
||||
:m_pCompressedData(0)
|
||||
,m_uCompressedDataLength(0)
|
||||
{
|
||||
@ -58,21 +58,21 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
const uint8_t* Block<VoxelType>::getCompressedData(void) const
|
||||
const uint8_t* CompressedBlock<VoxelType>::getCompressedData(void) const
|
||||
{
|
||||
POLYVOX_ASSERT(m_pCompressedData, "Compressed data is NULL");
|
||||
return m_pCompressedData;
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
uint32_t Block<VoxelType>::getCompressedDataLength(void) const
|
||||
uint32_t CompressedBlock<VoxelType>::getCompressedDataLength(void) const
|
||||
{
|
||||
POLYVOX_ASSERT(m_pCompressedData, "Compressed data is NULL");
|
||||
return m_uCompressedDataLength;
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
void Block<VoxelType>::setCompressedData(const uint8_t* const data, uint32_t dataLength)
|
||||
void CompressedBlock<VoxelType>::setCompressedData(const uint8_t* const data, uint32_t dataLength)
|
||||
{
|
||||
//POLYVOX_ASSERT(m_pCompressedData, "Compressed data is NULL");
|
||||
POLYVOX_ASSERT(m_pCompressedData != data, "Attempting to copy data onto itself");
|
||||
@ -85,11 +85,11 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
uint32_t Block<VoxelType>::calculateSizeInBytes(void)
|
||||
uint32_t CompressedBlock<VoxelType>::calculateSizeInBytes(void)
|
||||
{
|
||||
// Returns the size of this class plus the size of the compressed data. It
|
||||
// doesn't include the uncompressed data cache as that is owned by the volume.
|
||||
uint32_t uSizeInBytes = sizeof(Block<VoxelType>) + m_uCompressedDataLength;
|
||||
uint32_t uSizeInBytes = sizeof(CompressedBlock<VoxelType>) + m_uCompressedDataLength;
|
||||
return uSizeInBytes;
|
||||
}
|
||||
}
|
||||
|
@ -329,13 +329,13 @@ namespace PolyVox
|
||||
VoxelType getVoxelImpl(int32_t uXPos, int32_t uYPos, int32_t uZPos, WrapModeType<WrapModes::Border>, VoxelType tBorder) const;
|
||||
VoxelType getVoxelImpl(int32_t uXPos, int32_t uYPos, int32_t uZPos, WrapModeType<WrapModes::AssumeValid>, VoxelType tBorder) const;
|
||||
|
||||
Block<VoxelType>* getCompressedBlock(int32_t uBlockX, int32_t uBlockY, int32_t uBlockZ) const;
|
||||
CompressedBlock<VoxelType>* getCompressedBlock(int32_t uBlockX, int32_t uBlockY, int32_t uBlockZ) const;
|
||||
VoxelType* getUncompressedBlock(int32_t uBlockX, int32_t uBlockY, int32_t uBlockZ) const;
|
||||
void eraseBlock(typename std::map<Vector3DInt32, Block<VoxelType>, BlockPositionCompare>::iterator itBlock) const;
|
||||
void eraseBlock(typename std::map<Vector3DInt32, CompressedBlock<VoxelType>, BlockPositionCompare>::iterator itBlock) const;
|
||||
|
||||
// The block data
|
||||
mutable std::map<Vector3DInt32, VoxelType*, BlockPositionCompare> m_pUncompressedBlockCache;
|
||||
mutable std::map<Vector3DInt32, Block<VoxelType>, BlockPositionCompare> m_pBlocks;
|
||||
mutable std::map<Vector3DInt32, CompressedBlock<VoxelType>, BlockPositionCompare> m_pBlocks;
|
||||
|
||||
mutable uint32_t m_uTimestamper;
|
||||
mutable Vector3DInt32 m_v3dLastAccessedBlockPos;
|
||||
|
@ -421,7 +421,7 @@ namespace PolyVox
|
||||
for(int32_t z = v3dStart.getZ(); z <= v3dEnd.getZ(); z++)
|
||||
{
|
||||
Vector3DInt32 pos(x,y,z);
|
||||
typename std::map<Vector3DInt32, Block<VoxelType>, BlockPositionCompare>::iterator itBlock = m_pBlocks.find(pos);
|
||||
typename std::map<Vector3DInt32, CompressedBlock<VoxelType>, BlockPositionCompare>::iterator itBlock = m_pBlocks.find(pos);
|
||||
|
||||
if(itBlock != m_pBlocks.end())
|
||||
{
|
||||
@ -452,7 +452,7 @@ namespace PolyVox
|
||||
template <typename VoxelType>
|
||||
void LargeVolume<VoxelType>::flushAll()
|
||||
{
|
||||
typename std::map<Vector3DInt32, Block<VoxelType>, BlockPositionCompare>::iterator i;
|
||||
typename std::map<Vector3DInt32, CompressedBlock<VoxelType>, BlockPositionCompare>::iterator i;
|
||||
//Replaced the for loop here as the call to
|
||||
//eraseBlock was invalidating the iterator.
|
||||
while(m_pBlocks.size() > 0)
|
||||
@ -486,7 +486,7 @@ namespace PolyVox
|
||||
for(int32_t z = v3dStart.getZ(); z <= v3dEnd.getZ(); z++)
|
||||
{
|
||||
Vector3DInt32 pos(x,y,z);
|
||||
typename std::map<Vector3DInt32, Block<VoxelType>, BlockPositionCompare>::iterator itBlock = m_pBlocks.find(pos);
|
||||
typename std::map<Vector3DInt32, CompressedBlock<VoxelType>, BlockPositionCompare>::iterator itBlock = m_pBlocks.find(pos);
|
||||
if(itBlock == m_pBlocks.end())
|
||||
{
|
||||
// not loaded, not unloading
|
||||
@ -564,7 +564,7 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
void LargeVolume<VoxelType>::eraseBlock(typename std::map<Vector3DInt32, Block<VoxelType>, BlockPositionCompare>::iterator itBlock) const
|
||||
void LargeVolume<VoxelType>::eraseBlock(typename std::map<Vector3DInt32, CompressedBlock<VoxelType>, BlockPositionCompare>::iterator itBlock) const
|
||||
{
|
||||
POLYVOX_ASSERT(false, "This function has not been implemented properly");
|
||||
|
||||
@ -603,16 +603,16 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
Block<VoxelType>* LargeVolume<VoxelType>::getCompressedBlock(int32_t uBlockX, int32_t uBlockY, int32_t uBlockZ) const
|
||||
CompressedBlock<VoxelType>* LargeVolume<VoxelType>::getCompressedBlock(int32_t uBlockX, int32_t uBlockY, int32_t uBlockZ) const
|
||||
{
|
||||
Vector3DInt32 v3dBlockPos(uBlockX, uBlockY, uBlockZ);
|
||||
|
||||
typename std::map<Vector3DInt32, Block<VoxelType>, BlockPositionCompare>::iterator itBlock = m_pBlocks.find(v3dBlockPos);
|
||||
typename std::map<Vector3DInt32, CompressedBlock<VoxelType>, BlockPositionCompare>::iterator itBlock = m_pBlocks.find(v3dBlockPos);
|
||||
// check whether the block is already loaded
|
||||
if(itBlock == m_pBlocks.end())
|
||||
{
|
||||
//The block is not in the map, so we will have to create a new block and add it.
|
||||
Block<VoxelType> newBlock(m_uBlockSideLength, m_pCompressor);
|
||||
CompressedBlock<VoxelType> newBlock(m_uBlockSideLength, m_pCompressor);
|
||||
itBlock = m_pBlocks.insert(std::make_pair(v3dBlockPos, newBlock)).first;
|
||||
|
||||
// Now use the pager to fill the block with it's initial data.
|
||||
@ -626,7 +626,7 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
//Get the block and mark that we accessed it
|
||||
Block<VoxelType>& block = itBlock->second;
|
||||
CompressedBlock<VoxelType>& block = itBlock->second;
|
||||
block.timestamp = ++m_uTimestamper;
|
||||
//m_v3dLastAccessedBlockPos = v3dBlockPos;
|
||||
|
||||
@ -648,7 +648,7 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
//Get the block and mark that we accessed it
|
||||
Block<VoxelType>* block = getCompressedBlock(uBlockX, uBlockY, uBlockZ);
|
||||
CompressedBlock<VoxelType>* block = getCompressedBlock(uBlockX, uBlockY, uBlockZ);
|
||||
|
||||
|
||||
typename std::map<Vector3DInt32, VoxelType*, BlockPositionCompare>::iterator itUncompressedBlock = m_pUncompressedBlockCache.find(v3dBlockPos);
|
||||
@ -697,7 +697,7 @@ namespace PolyVox
|
||||
uint32_t uSizeInBytes = sizeof(LargeVolume);
|
||||
|
||||
//Memory used by the blocks
|
||||
typename std::map<Vector3DInt32, Block<VoxelType>, BlockPositionCompare>::iterator i;
|
||||
typename std::map<Vector3DInt32, CompressedBlock<VoxelType>, BlockPositionCompare>::iterator i;
|
||||
for(i = m_pBlocks.begin(); i != m_pBlocks.end(); i++)
|
||||
{
|
||||
//Inaccurate - account for rest of loaded block.
|
||||
@ -716,7 +716,7 @@ namespace PolyVox
|
||||
{
|
||||
uint32_t uMemoryUsage = 0;
|
||||
|
||||
typename std::map<Vector3DInt32, Block<VoxelType>, BlockPositionCompare>::iterator i;
|
||||
typename std::map<Vector3DInt32, CompressedBlock<VoxelType>, BlockPositionCompare>::iterator i;
|
||||
for(i = m_pBlocks.begin(); i != m_pBlocks.end(); i++)
|
||||
{
|
||||
//Inaccurate - account for rest of loaded block.
|
||||
@ -736,8 +736,8 @@ namespace PolyVox
|
||||
while(calculateBlockMemoryUsage() > m_uCompressedBlockMemoryLimitInBytes) //FIXME - This calculation of size is slow and should be outside the loop.
|
||||
{
|
||||
// find the least recently used block
|
||||
typename std::map<Vector3DInt32, Block<VoxelType>, BlockPositionCompare>::iterator i;
|
||||
typename std::map<Vector3DInt32, Block<VoxelType>, BlockPositionCompare>::iterator itUnloadBlock = m_pBlocks.begin();
|
||||
typename std::map<Vector3DInt32, CompressedBlock<VoxelType>, BlockPositionCompare>::iterator i;
|
||||
typename std::map<Vector3DInt32, CompressedBlock<VoxelType>, BlockPositionCompare>::iterator itUnloadBlock = m_pBlocks.begin();
|
||||
for(i = m_pBlocks.begin(); i != m_pBlocks.end(); i++)
|
||||
{
|
||||
if(i->second.timestamp < itUnloadBlock->second.timestamp)
|
||||
|
@ -41,8 +41,8 @@ namespace PolyVox
|
||||
/// Destructor
|
||||
virtual ~Pager() {};
|
||||
|
||||
virtual void pageIn(const Region& region, Block<VoxelType>* pBlockData) = 0;
|
||||
virtual void pageOut(const Region& region, Block<VoxelType>* pBlockData) = 0;
|
||||
virtual void pageIn(const Region& region, CompressedBlock<VoxelType>* pBlockData) = 0;
|
||||
virtual void pageOut(const Region& region, CompressedBlock<VoxelType>* pBlockData) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user