diff --git a/examples/Basic/main.cpp b/examples/Basic/main.cpp index 8315d3be..55619d24 100644 --- a/examples/Basic/main.cpp +++ b/examples/Basic/main.cpp @@ -511,11 +511,12 @@ int main(int argc, char *argv[]) //Create an empty volume and then place a sphere in it Volume volData(256, 256, 256); + volData.useCompatibilityMode(); //createSphereInVolume(volData, 30); createPerlinTerrain(volData); //createPerlinVolumeSlow(volData); std::cout << "Memory usage: " << volData.calculateSizeInBytes() << std::endl; - volData.setBlockCacheSize(8); + //volData.setBlockCacheSize(8); std::cout << "Memory usage: " << volData.calculateSizeInBytes() << std::endl; std::cout << "Compression ratio: " << volData.calculateCompressionRatio() << std::endl; diff --git a/library/PolyVoxCore/include/Volume.h b/library/PolyVoxCore/include/Volume.h index 0532d87c..abe48009 100644 --- a/library/PolyVoxCore/include/Volume.h +++ b/library/PolyVoxCore/include/Volume.h @@ -159,6 +159,7 @@ namespace PolyVox void clearBlockCache(void); float calculateCompressionRatio(void); uint32_t calculateSizeInBytes(void); + void useCompatibilityMode(void); /// Resizes the volume to the specified dimensions void resize(uint16_t uWidth, uint16_t uHeight, uint16_t uDepth, uint16_t uBlockSideLength = 32); diff --git a/library/PolyVoxCore/include/Volume.inl b/library/PolyVoxCore/include/Volume.inl index fd48aab6..423825a5 100644 --- a/library/PolyVoxCore/include/Volume.inl +++ b/library/PolyVoxCore/include/Volume.inl @@ -463,4 +463,21 @@ namespace PolyVox return uSizeInBytes; } + + template + void Volume::useCompatibilityMode(void) + { + setBlockCacheSize(m_uNoOfBlocksInVolume * 2); //Times two gives space to spare + + for(uint32_t z = 0; z < m_uDepthInBlocks; z++) + { + for(uint32_t y = 0; y < m_uHeightInBlocks; y++) + { + for(uint32_t x = 0; x < m_uWidthInBlocks; x++) + { + getUncompressedBlock(x,y,z); + } + } + } + } }