diff --git a/library/PolyVoxCore/include/PolyVoxCore/Impl/Block.inl b/library/PolyVoxCore/include/PolyVoxCore/Impl/Block.inl index 3f0829dd..b4abf7d6 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Impl/Block.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/Impl/Block.inl @@ -129,9 +129,6 @@ namespace PolyVox const uint32_t uNoOfVoxels = m_uSideLength * m_uSideLength * m_uSideLength; std::fill(m_tUncompressedData, m_tUncompressedData + uNoOfVoxels, VoxelType()); m_bIsUncompressedDataModified = true; - - //For some reason blocks start out compressed. We should probably change this. - compress(0); } template @@ -159,8 +156,8 @@ namespace PolyVox uint32_t uDstLength = 1000000; //MinizCompressor compressor; - RLECompressor compressor; - uint32_t uCompressedLength = compressor.compress(pSrcData, uSrcLength, pDstData, uDstLength); + //RLECompressor compressor; + uint32_t uCompressedLength = pCompressor->compress(pSrcData, uSrcLength, pDstData, uDstLength); m_pCompressedData = reinterpret_cast( new uint8_t[uCompressedLength] ); memcpy(m_pCompressedData, pDstData, uCompressedLength); @@ -178,7 +175,7 @@ namespace PolyVox template void Block::uncompress(Compressor* pCompressor) { - //POLYVOX_ASSERT(pCompressor, "Compressor is not valid"); + POLYVOX_ASSERT(pCompressor, "Compressor is not valid"); POLYVOX_ASSERT(m_bIsCompressed == true, "Attempted to uncompress block which is not flagged as compressed."); POLYVOX_ASSERT(m_tUncompressedData == 0, "Uncompressed data already exists."); @@ -190,8 +187,8 @@ namespace PolyVox uint32_t uDstLength = m_uSideLength * m_uSideLength * m_uSideLength * sizeof(VoxelType); //MinizCompressor compressor; - RLECompressor compressor; - uint32_t uUncompressedLength = compressor.decompress(pSrcData, uSrcLength, pDstData, uDstLength); + //RLECompressor compressor; + uint32_t uUncompressedLength = pCompressor->decompress(pSrcData, uSrcLength, pDstData, uDstLength); POLYVOX_ASSERT(uUncompressedLength == m_uSideLength * m_uSideLength * m_uSideLength * sizeof(VoxelType), "Destination length has changed."); diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl index a048d03c..c3f53407 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl @@ -618,6 +618,10 @@ namespace PolyVox // create the new block LoadedBlock newBlock(m_uBlockSideLength); + + //Blocks start out compressed - should we change this? + newBlock.block.compress(m_pCompressor); + itBlock = m_pBlocks.insert(std::make_pair(v3dBlockPos, newBlock)).first; //We have created the new block. If paging is enabled it should be used to diff --git a/library/PolyVoxCore/include/PolyVoxCore/PolyVoxForwardDeclarations.h b/library/PolyVoxCore/include/PolyVoxCore/PolyVoxForwardDeclarations.h index addaa962..d618bb6e 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/PolyVoxForwardDeclarations.h +++ b/library/PolyVoxCore/include/PolyVoxCore/PolyVoxForwardDeclarations.h @@ -60,6 +60,11 @@ namespace PolyVox typedef Array<3,int32_t> Array3DInt32; typedef Array<3,uint32_t> Array3DUint32; + //////////////////////////////////////////////////////////////////////////////// + // Compressor + //////////////////////////////////////////////////////////////////////////////// + class Compressor; + //////////////////////////////////////////////////////////////////////////////// // CubicSurfaceExtractor //////////////////////////////////////////////////////////////////////////////// diff --git a/tests/testvolume.cpp b/tests/testvolume.cpp index cdb9fbf5..5d704760 100644 --- a/tests/testvolume.cpp +++ b/tests/testvolume.cpp @@ -25,6 +25,7 @@ freely, subject to the following restrictions: #include "PolyVoxCore/LargeVolume.h" #include "PolyVoxCore/RawVolume.h" +#include "PolyVoxCore/RLECompressor.h" #include "PolyVoxCore/SimpleVolume.h" #include @@ -269,10 +270,12 @@ TestVolume::TestVolume() { Region region(-57, -31, 12, 64, 96, 131); // Deliberatly awkward size + m_pCompressor = new RLECompressor; + //Create the volumes m_pRawVolume = new RawVolume(region); m_pSimpleVolume = new SimpleVolume(region); - m_pLargeVolume = new LargeVolume(region); + m_pLargeVolume = new LargeVolume(region, m_pCompressor); // LargeVolume currently fails a test if compression is enabled. It // may be related to accessing the data through more than one sampler? @@ -299,6 +302,8 @@ TestVolume::~TestVolume() delete m_pRawVolume; delete m_pSimpleVolume; delete m_pLargeVolume; + + delete m_pCompressor; } /* diff --git a/tests/testvolume.h b/tests/testvolume.h index 7917f577..59a63ec8 100644 --- a/tests/testvolume.h +++ b/tests/testvolume.h @@ -65,6 +65,7 @@ private slots: void testLargeVolumeSamplersWithExternalBackwards(); private: + PolyVox::Compressor* m_pCompressor; PolyVox::RawVolume* m_pRawVolume; PolyVox::SimpleVolume* m_pSimpleVolume; PolyVox::LargeVolume* m_pLargeVolume;