diff --git a/examples/Paging/main.cpp b/examples/Paging/main.cpp index 55e08b75..6d183033 100644 --- a/examples/Paging/main.cpp +++ b/examples/Paging/main.cpp @@ -84,14 +84,14 @@ class PerlinNoisePager : public PolyVox::Pager public: /// Constructor PerlinNoisePager() - :Pager() + :Pager() { } /// Destructor virtual ~PerlinNoisePager() {}; - virtual void pageIn(const Region& region, Block* pBlockData) + virtual void pageIn(const PolyVox::Region& region, Block* pBlockData) { pBlockData->createUncompressedData(); @@ -137,7 +137,7 @@ public: } } - virtual void pageOut(const Region& region, Block* pBlockData) + virtual void pageOut(const PolyVox::Region& region, Block* pBlockData) { std::cout << "warning unloading region: " << region.getLowerCorner() << " -> " << region.getUpperCorner() << std::endl; } @@ -152,7 +152,7 @@ int main(int argc, char *argv[]) RLECompressor* compressor = new RLECompressor(); PerlinNoisePager* pager = new PerlinNoisePager(); - LargeVolume volData(Region::MaxRegion, compressor, pager, 256); + LargeVolume volData(PolyVox::Region::MaxRegion, compressor, pager, 256); volData.setMaxNumberOfBlocksInMemory(4096); volData.setMaxNumberOfUncompressedBlocks(64); diff --git a/library/PolyVoxCore/include/PolyVoxCore/FilePager.h b/library/PolyVoxCore/include/PolyVoxCore/FilePager.h index e5ab35b3..1f3115ab 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/FilePager.h +++ b/library/PolyVoxCore/include/PolyVoxCore/FilePager.h @@ -27,6 +27,7 @@ freely, subject to the following restrictions: #include "PolyVoxCore/Impl/TypeDef.h" #include "PolyVoxCore/Pager.h" +#include "PolyVoxCore/Region.h" #include #include @@ -38,12 +39,12 @@ namespace PolyVox * Provides an interface for performing paging of data. */ template - class FilePager : public Pager + class FilePager : public Pager { public: /// Constructor FilePager(const std::string& strFolderName) - :Pager() + :Pager() ,m_strFolderName(strFolderName) { } diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl index ab6f4b46..19b7d114 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl @@ -619,9 +619,7 @@ namespace PolyVox // create the new block Block newBlock(m_uBlockSideLength, m_pCompressor); - auto retVal = m_pBlocks.insert(std::make_pair(v3dBlockPos, newBlock)); - itBlock = retVal.first; - POLYVOX_ASSERT(retVal.second == true, "Element was not supposed to exist!"); + 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 //fill in the required data. Otherwise it is just left in the default state. diff --git a/library/PolyVoxCore/include/PolyVoxCore/PolyVoxForwardDeclarations.h b/library/PolyVoxCore/include/PolyVoxCore/PolyVoxForwardDeclarations.h index d0c5c1ab..8f8ded69 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/PolyVoxForwardDeclarations.h +++ b/library/PolyVoxCore/include/PolyVoxCore/PolyVoxForwardDeclarations.h @@ -86,6 +86,11 @@ namespace PolyVox typedef DensityU8 Density8; //Backwards compatibility typedef DensityU16 Density16; //Backwards compatibility + //////////////////////////////////////////////////////////////////////////////// + // FilePager + //////////////////////////////////////////////////////////////////////////////// + template class FilePager; + //////////////////////////////////////////////////////////////////////////////// // LargeVolume //////////////////////////////////////////////////////////////////////////////// @@ -112,6 +117,11 @@ namespace PolyVox typedef MaterialDensityPair MaterialDensityPair44; typedef MaterialDensityPair MaterialDensityPair88; + //////////////////////////////////////////////////////////////////////////////// + // Pager + //////////////////////////////////////////////////////////////////////////////// + template class Pager; + //////////////////////////////////////////////////////////////////////////////// // PositionMaterial //////////////////////////////////////////////////////////////////////////////// diff --git a/library/bindings/FilePager.i b/library/bindings/FilePager.i new file mode 100644 index 00000000..c6ec6c74 --- /dev/null +++ b/library/bindings/FilePager.i @@ -0,0 +1,6 @@ +%module FilePager +%{ +#include "FilePager.h" +%} + +%include "FilePager.h" diff --git a/library/bindings/Pager.i b/library/bindings/Pager.i new file mode 100644 index 00000000..b586f9ef --- /dev/null +++ b/library/bindings/Pager.i @@ -0,0 +1,6 @@ +%module Pager +%{ +#include "Pager.h" +%} + +%include "Pager.h" diff --git a/library/bindings/PolyVoxCore.i b/library/bindings/PolyVoxCore.i index bb693c47..30a71407 100644 --- a/library/bindings/PolyVoxCore.i +++ b/library/bindings/PolyVoxCore.i @@ -76,6 +76,8 @@ EXTRACTOR(shortname, LargeVolume) %include "DefaultMarchingCubesController.i" %include "Region.i" %include "Compressor.i" +%include "Pager.i" +%include "FilePager.i" %include "MinizCompressor.i" %include "RLECompressor.i" %include "BaseVolume.i" diff --git a/tests/testvolume.cpp b/tests/testvolume.cpp index 4a4d638d..77ad1063 100644 --- a/tests/testvolume.cpp +++ b/tests/testvolume.cpp @@ -23,6 +23,7 @@ freely, subject to the following restrictions: #include "testvolume.h" +#include "PolyVoxCore/FilePager.h" #include "PolyVoxCore/LargeVolume.h" #include "PolyVoxCore/MinizCompressor.h" #include "PolyVoxCore/RawVolume.h" @@ -273,15 +274,15 @@ TestVolume::TestVolume() //m_pCompressor = new RLECompressor; m_pCompressor = new MinizCompressor; + m_pFilePager = new FilePager("./"); //Create the volumes m_pRawVolume = new RawVolume(region); m_pSimpleVolume = new SimpleVolume(region); - m_pLargeVolume = new LargeVolume(region, m_pCompressor, 0, 32); + m_pLargeVolume = new LargeVolume(region, m_pCompressor, m_pFilePager, 32); - // LargeVolume currently fails a test if compression is enabled. It - // may be related to accessing the data through more than one sampler? - //m_pLargeVolume->setCompressionEnabled(false); + m_pLargeVolume->setMaxNumberOfBlocksInMemory(32); + m_pLargeVolume->setMaxNumberOfUncompressedBlocks(16); //Fill the volume with some data for(int z = region.getLowerZ(); z <= region.getUpperZ(); z++) @@ -305,6 +306,7 @@ TestVolume::~TestVolume() delete m_pSimpleVolume; delete m_pLargeVolume; + delete m_pFilePager; delete m_pCompressor; } diff --git a/tests/testvolume.h b/tests/testvolume.h index 0c363109..8a3e46d7 100644 --- a/tests/testvolume.h +++ b/tests/testvolume.h @@ -66,6 +66,8 @@ private slots: private: PolyVox::Compressor* m_pCompressor; + PolyVox::FilePager* m_pFilePager; + PolyVox::RawVolume* m_pRawVolume; PolyVox::SimpleVolume* m_pSimpleVolume; PolyVox::LargeVolume* m_pLargeVolume;