Removed setCompressionEnabled() from LargeVolume.

This commit is contained in:
Daviw Williams 2013-02-07 15:55:10 +01:00
parent aef5373e8b
commit 50c1c7c64b
4 changed files with 18 additions and 39 deletions

View File

@ -279,8 +279,6 @@ namespace PolyVox
/// Gets a voxel at the position given by a 3D vector
VoxelType getVoxelWithWrapping(const Vector3DInt32& v3dPos, WrapMode eWrapMode = WrapModes::Border, VoxelType tBorder = VoxelType(0)) const;
//Sets whether or not blocks are compressed in memory
void setCompressionEnabled(bool bCompressionEnabled);
/// Sets the number of blocks for which uncompressed data is stored
void setMaxNumberOfUncompressedBlocks(uint32_t uMaxNumberOfUncompressedBlocks);
/// Sets the number of blocks which can be in memory before the paging system starts unloading them
@ -368,7 +366,6 @@ namespace PolyVox
//The compressor used by the Blocks to compress their data if required.
Compressor* m_pCompressor;
bool m_bCompressionEnabled;
bool m_bPagingEnabled;
};
}

View File

@ -53,6 +53,7 @@ namespace PolyVox
////////////////////////////////////////////////////////////////////////////////
/// This constructor creates a volume with a fixed size which is specified as a parameter. By default this constructor will not enable paging but you can override this if desired. If you do wish to enable paging then you are required to provide the call back function (see the other LargeVolume constructor).
/// \param regValid Specifies the minimum and maximum valid voxel positions.
/// \param pCompressor An implementation of the Compressor interface which is used to compress blocks in memory.
/// \param dataRequiredHandler The callback function which will be called when PolyVox tries to use data which is not currently in momory.
/// \param dataOverflowHandler The callback function which will be called when PolyVox has too much data and needs to remove some from memory.
/// \param bPagingEnabled Controls whether or not paging is enabled for this LargeVolume.
@ -82,7 +83,7 @@ namespace PolyVox
////////////////////////////////////////////////////////////////////////////////
/// This function should never be called. Copying volumes by value would be expensive, and we want to prevent users from doing
/// it by accident (such as when passing them as paramenters to functions). That said, there are times when you really do want to
/// make a copy of a volume and in this case you should look at the Volumeresampler.
/// make a copy of a volume and in this case you should look at the VolumeResampler.
///
/// \sa VolumeResampler
////////////////////////////////////////////////////////////////////////////////
@ -243,30 +244,6 @@ namespace PolyVox
return getVoxelWithWrapping(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), eWrapMode, tBorder);
}
////////////////////////////////////////////////////////////////////////////////
/// Enabling compression allows significantly more data to be stored in memory.
/// \param bCompressionEnabled Specifies whether compression is enabled.
////////////////////////////////////////////////////////////////////////////////
template <typename VoxelType>
void LargeVolume<VoxelType>::setCompressionEnabled(bool bCompressionEnabled)
{
//Early out - nothing to do
if(m_bCompressionEnabled == bCompressionEnabled)
{
return;
}
m_bCompressionEnabled = bCompressionEnabled;
if(m_bCompressionEnabled)
{
//If compression has been enabled then we need to start honouring the max number of
//uncompressed blocks. Because compression has been disabled for a while we might have
//gone above that limit. Easiest solution is just to clear the cache and start again.
clearBlockCache();
}
}
////////////////////////////////////////////////////////////////////////////////
/// Increasing the size of the block cache will increase memory but may improve performance.
/// You may want to set this to a large value (e.g. 1024) when you are first loading your
@ -472,6 +449,7 @@ namespace PolyVox
//Debug mode validation
POLYVOX_ASSERT(uBlockSideLength > 0, "Block side length cannot be zero.");
POLYVOX_ASSERT(isPowerOf2(uBlockSideLength), "Block side length must be a power of two.");
POLYVOX_ASSERT(m_pCompressor, "You must provide a compressor for the LargeVolume to use.");
//Release mode validation
if(uBlockSideLength == 0)
@ -482,6 +460,10 @@ namespace PolyVox
{
POLYVOX_THROW(std::invalid_argument, "Block side length must be a power of two.");
}
if(!m_pCompressor)
{
POLYVOX_THROW(std::invalid_argument, "You must provide a compressor for the LargeVolume to use.");
}
m_uTimestamper = 0;
m_uMaxNumberOfUncompressedBlocks = 16;
@ -489,7 +471,6 @@ namespace PolyVox
m_uMaxNumberOfBlocksInMemory = 1024;
m_v3dLastAccessedBlockPos = Vector3DInt32(0,0,0); //There are no invalid positions, but initially the m_pLastAccessedBlock pointer will be null;
m_pLastAccessedBlock = 0;
m_bCompressionEnabled = true;
this->m_regValidRegion = regValidRegion;
@ -532,7 +513,8 @@ namespace PolyVox
m_funcDataOverflowHandler(ConstVolumeProxy, reg);
}
if(m_bCompressionEnabled) {
if(m_pCompressor)
{
for(uint32_t ct = 0; ct < m_vecUncompressedBlockCache.size(); ct++)
{
// find the block in the uncompressed cache
@ -657,7 +639,7 @@ namespace PolyVox
}
//If we are allowed to compress then check whether we need to
if((m_bCompressionEnabled) && (m_vecUncompressedBlockCache.size() == m_uMaxNumberOfUncompressedBlocks))
if((m_pCompressor) && (m_vecUncompressedBlockCache.size() == m_uMaxNumberOfUncompressedBlocks))
{
int32_t leastRecentlyUsedBlockIndex = -1;
uint32_t uLeastRecentTimestamp = (std::numeric_limits<uint32_t>::max)();

View File

@ -271,8 +271,8 @@ TestVolume::TestVolume()
{
Region region(-57, -31, 12, 64, 96, 131); // Deliberatly awkward size
//m_pCompressor = new RLECompressor<int32_t, uint16_t>;
m_pCompressor = new MinizCompressor;
m_pCompressor = new RLECompressor<int32_t, uint16_t>;
//m_pCompressor = new MinizCompressor;
//Create the volumes
m_pRawVolume = new RawVolume<int32_t>(region);
@ -312,7 +312,7 @@ TestVolume::~TestVolume()
* RawVolume Tests
*/
/*void TestVolume::testRawVolumeDirectAccessAllInternalForwards()
void TestVolume::testRawVolumeDirectAccessAllInternalForwards()
{
int32_t result = 0;
@ -398,13 +398,13 @@ void TestVolume::testRawVolumeSamplersWithExternalBackwards()
result = testSamplersWithWrappingBackwards(m_pRawVolume, -1, -3, -2, 2, 5, 4);
}
QCOMPARE(result, static_cast<int32_t>(-769775893));
}*/
}
/*
* SimpleVolume Tests
*/
/*void TestVolume::testSimpleVolumeDirectAccessAllInternalForwards()
void TestVolume::testSimpleVolumeDirectAccessAllInternalForwards()
{
int32_t result = 0;
QBENCHMARK
@ -482,7 +482,7 @@ void TestVolume::testSimpleVolumeSamplersWithExternalBackwards()
result = testSamplersWithWrappingBackwards(m_pSimpleVolume, -1, -3, -2, 2, 5, 4);
}
QCOMPARE(result, static_cast<int32_t>(-769775893));
}*/
}
/*
* LargeVolume Tests

View File

@ -37,7 +37,7 @@ public:
~TestVolume();
private slots:
/*void testRawVolumeDirectAccessAllInternalForwards();
void testRawVolumeDirectAccessAllInternalForwards();
void testRawVolumeSamplersAllInternalForwards();
void testRawVolumeDirectAccessWithExternalForwards();
void testRawVolumeSamplersWithExternalForwards();
@ -53,7 +53,7 @@ private slots:
void testSimpleVolumeDirectAccessAllInternalBackwards();
void testSimpleVolumeSamplersAllInternalBackwards();
void testSimpleVolumeDirectAccessWithExternalBackwards();
void testSimpleVolumeSamplersWithExternalBackwards();*/
void testSimpleVolumeSamplersWithExternalBackwards();
void testLargeVolumeDirectAccessAllInternalForwards();
void testLargeVolumeSamplersAllInternalForwards();