From 1064ea1c4777fcf10abcea778684ea8ba2a3352c Mon Sep 17 00:00:00 2001 From: David Williams Date: Wed, 26 Jun 2013 22:14:01 +0200 Subject: [PATCH] Stripped out unused code. --- examples/Paging/main.cpp | 65 --------------- library/PolyVoxCore/CMakeLists.txt | 1 - .../include/PolyVoxCore/ConstVolumeProxy.h | 83 ------------------- .../include/PolyVoxCore/FilePager.h | 8 -- .../include/PolyVoxCore/LargeVolume.h | 17 ---- .../include/PolyVoxCore/LargeVolume.inl | 32 ------- .../PolyVoxCore/include/PolyVoxCore/Pager.h | 12 --- 7 files changed, 218 deletions(-) delete mode 100644 library/PolyVoxCore/include/PolyVoxCore/ConstVolumeProxy.h diff --git a/examples/Paging/main.cpp b/examples/Paging/main.cpp index 9ddf456f..f10c2331 100644 --- a/examples/Paging/main.cpp +++ b/examples/Paging/main.cpp @@ -263,64 +263,8 @@ public: { std::cout << "warning unloading region: " << region.getLowerCorner() << " -> " << region.getUpperCorner() << std::endl; } - - virtual void dataRequiredHandler(const ConstVolumeProxy& volumeProxy, const Region& region) - { - POLYVOX_ASSERT(false, "NOT IMPLEMENTED"); - } - - virtual void dataOverflowHandler(const ConstVolumeProxy& /*volumeProxy*/, const Region& region) - { - std::cout << "warning unloading region: " << region.getLowerCorner() << " -> " << region.getUpperCorner() << std::endl; - } }; -void load(const ConstVolumeProxy& volume, const PolyVox::Region& reg) -{ - Perlin perlin(2,2,1,234); - - for(int x = reg.getLowerX(); x <= reg.getUpperX(); x++) - { - for(int y = reg.getLowerY(); y <= reg.getUpperY(); y++) - { - float perlinVal = perlin.Get(x / static_cast(255-1), y / static_cast(255-1)); - perlinVal += 1.0f; - perlinVal *= 0.5f; - perlinVal *= 255; - for(int z = reg.getLowerZ(); z <= reg.getUpperZ(); z++) - { - MaterialDensityPair44 voxel; - if(z < perlinVal) - { - const int xpos = 50; - const int zpos = 100; - if((x-xpos)*(x-xpos) + (z-zpos)*(z-zpos) < 200) { - // tunnel - voxel.setMaterial(0); - voxel.setDensity(MaterialDensityPair44::getMinDensity()); - } else { - // solid - voxel.setMaterial(245); - voxel.setDensity(MaterialDensityPair44::getMaxDensity()); - } - } - else - { - voxel.setMaterial(0); - voxel.setDensity(MaterialDensityPair44::getMinDensity()); - } - - volume.setVoxelAt(x, y, z, voxel); - } - } - } -} - -void unload(const ConstVolumeProxy& /*vol*/, const PolyVox::Region& reg) -{ - std::cout << "warning unloading region: " << reg.getLowerCorner() << " -> " << reg.getUpperCorner() << std::endl; -} - int main(int argc, char *argv[]) { //Create and show the Qt OpenGL window @@ -330,19 +274,10 @@ int main(int argc, char *argv[]) RLECompressor* compressor = new RLECompressor(); PerlinNoisePager* pager = new PerlinNoisePager(); - - //If these lines don't compile, please try commenting them out and using the two lines after - //(you will need Boost for this). If you have to do this then please let us know in the forums as - //we rely on community feedback to keep the Boost version running. LargeVolume volData(Region::MaxRegion, compressor, pager, 256); - //LargeVolume volData(polyvox_bind(&load, polyvox_placeholder_1, polyvox_placeholder_2), - // polyvox_bind(&unload, polyvox_placeholder_1, polyvox_placeholder_2), 256); volData.setMaxNumberOfBlocksInMemory(4096); volData.setMaxNumberOfUncompressedBlocks(64); - //volData.dataRequiredHandler = &load; - //volData.dataOverflowHandler = &unload; - //volData.setMaxNumberOfUncompressedBlocks(4096); //createSphereInVolume(volData, 30); //createPerlinTerrain(volData); diff --git a/library/PolyVoxCore/CMakeLists.txt b/library/PolyVoxCore/CMakeLists.txt index 8366d527..a8ce8a0c 100644 --- a/library/PolyVoxCore/CMakeLists.txt +++ b/library/PolyVoxCore/CMakeLists.txt @@ -49,7 +49,6 @@ SET(CORE_INC_FILES include/PolyVoxCore/BaseVolume.inl include/PolyVoxCore/BaseVolumeSampler.inl include/PolyVoxCore/Compressor.h - include/PolyVoxCore/ConstVolumeProxy.h include/PolyVoxCore/CubicSurfaceExtractor.h include/PolyVoxCore/CubicSurfaceExtractor.inl include/PolyVoxCore/CubicSurfaceExtractorWithNormals.h diff --git a/library/PolyVoxCore/include/PolyVoxCore/ConstVolumeProxy.h b/library/PolyVoxCore/include/PolyVoxCore/ConstVolumeProxy.h deleted file mode 100644 index 751377ec..00000000 --- a/library/PolyVoxCore/include/PolyVoxCore/ConstVolumeProxy.h +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* -Copyright (c) 2005-2009 David Williams - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. -*******************************************************************************/ - -#ifndef __PolyVox_ConstVolumeProxy_H__ -#define __PolyVox_ConstVolumeProxy_H__ - -#include "PolyVoxCore/Region.h" -#include "PolyVoxCore/Vector.h" - -namespace PolyVox -{ - template - class ConstVolumeProxy - { - //LargeVolume is a friend so it can call the constructor. - friend class LargeVolume; - public: - VoxelType getVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos) const - { - // PolyVox does not throw an exception when a voxel is out of range. Please see 'Error Handling' in the User Manual. - POLYVOX_ASSERT(m_regValid.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos)), "Position is outside valid region"); - return m_pVolume.getVoxel(uXPos, uYPos, uZPos); - } - - VoxelType getVoxelAt(const Vector3DInt32& v3dPos) const - { - // PolyVox does not throw an exception when a voxel is out of range. Please see 'Error Handling' in the User Manual. - POLYVOX_ASSERT(m_regValid.containsPoint(v3dPos), "Position is outside valid region"); - return getVoxelAt(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ()); - } - - void setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue) const - { - // PolyVox does not throw an exception when a voxel is out of range. Please see 'Error Handling' in the User Manual. - POLYVOX_ASSERT(m_regValid.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos)), "Position is outside valid region"); - m_pVolume.setVoxelAtConst(uXPos, uYPos, uZPos, tValue); - } - - void setVoxelAt(const Vector3DInt32& v3dPos, VoxelType tValue) const - { - // PolyVox does not throw an exception when a voxel is out of range. Please see 'Error Handling' in the User Manual. - POLYVOX_ASSERT(m_regValid.containsPoint(v3dPos), "Position is outside valid region"); - setVoxelAt(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), tValue); - } - private: - //Private constructor, so client code can't abuse this class. - ConstVolumeProxy(const LargeVolume& pVolume, const Region& regValid) - :m_pVolume(pVolume) - ,m_regValid(regValid) - { - } - - //Private assignment operator, so client code can't abuse this class. - ConstVolumeProxy& operator=(const ConstVolumeProxy& rhs) - { - } - - const LargeVolume& m_pVolume; - const Region& m_regValid; - }; -} - -#endif //__PolyVox_ConstVolumeProxy_H__ diff --git a/library/PolyVoxCore/include/PolyVoxCore/FilePager.h b/library/PolyVoxCore/include/PolyVoxCore/FilePager.h index 5d8d97ed..e5ab35b3 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/FilePager.h +++ b/library/PolyVoxCore/include/PolyVoxCore/FilePager.h @@ -124,14 +124,6 @@ namespace PolyVox fclose(pFile); } - virtual void dataRequiredHandler(const ConstVolumeProxy& volumeProxy, const Region& region) - { - } - - virtual void dataOverflowHandler(const ConstVolumeProxy& volumeProxy, const Region& region) - { - } - protected: std::string m_strFolderName; }; diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h index 581f1adf..103d7ca8 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h @@ -42,8 +42,6 @@ freely, subject to the following restrictions: namespace PolyVox { - template class ConstVolumeProxy; - /// The LargeVolume class provides a memory efficient method of storing voxel data while also allowing fast access and modification. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// A LargeVolume is essentially a 3D array in which each element (or voxel) is identified by a three dimensional (x,y,z) coordinate. @@ -228,9 +226,6 @@ namespace PolyVox VoxelType* mCurrentVoxel; }; - // Make the ConstVolumeProxy a friend - friend class ConstVolumeProxy; - #endif public: @@ -327,21 +322,9 @@ namespace PolyVox VoxelType getVoxelImpl(int32_t uXPos, int32_t uYPos, int32_t uZPos, WrapModeType, VoxelType tBorder) const; VoxelType getVoxelImpl(int32_t uXPos, int32_t uYPos, int32_t uZPos, WrapModeType, VoxelType tBorder) const; VoxelType getVoxelImpl(int32_t uXPos, int32_t uYPos, int32_t uZPos, WrapModeType, VoxelType tBorder) const; - - /// gets called when a new region is allocated and needs to be filled - /// NOTE: accessing ANY voxels outside this region during the process of this function - /// is absolutely unsafe - //polyvox_function&, const Region&)> m_funcDataRequiredHandler; - /// gets called when a Region needs to be stored by the user, because LargeVolume will erase it right after - /// this function returns - /// NOTE: accessing ANY voxels outside this region during the process of this function - /// is absolutely unsafe - //polyvox_function&, const Region&)> m_funcDataOverflowHandler; Block* getUncompressedBlock(int32_t uBlockX, int32_t uBlockY, int32_t uBlockZ) const; void eraseBlock(typename std::map, BlockPositionCompare>::iterator itBlock) const; - /// this function can be called by m_funcDataRequiredHandler without causing any weird effects - bool setVoxelAtConst(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue) const; // The block data mutable std::map, BlockPositionCompare> m_pBlocks; diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl index 4473e350..ef8dbb40 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl @@ -25,9 +25,6 @@ freely, subject to the following restrictions: #include "PolyVoxCore/MinizCompressor.h" -//Included here rather than in the .h because it refers to LargeVolume (avoids forward declaration) -#include "PolyVoxCore/ConstVolumeProxy.h" - namespace PolyVox { //////////////////////////////////////////////////////////////////////////////// @@ -558,9 +555,6 @@ namespace PolyVox Vector3DInt32 v3dUpper = v3dLower + Vector3DInt32(m_uBlockSideLength-1, m_uBlockSideLength-1, m_uBlockSideLength-1); Region reg(v3dLower, v3dUpper); - /*ConstVolumeProxy ConstVolumeProxy(*this, reg); - - m_pPager->dataOverflowHandler(ConstVolumeProxy, reg);*/ m_pPager->pageOut(reg, &(itBlock->second)); } @@ -581,30 +575,6 @@ namespace PolyVox m_pBlocks.erase(itBlock); } - template - bool LargeVolume::setVoxelAtConst(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue) const - { - //We don't have any range checks in this function because it - //is a private function only called by the ConstVolumeProxy. The - //ConstVolumeProxy takes care of ensuring the range is appropriate. - - const int32_t blockX = uXPos >> m_uBlockSideLengthPower; - const int32_t blockY = uYPos >> m_uBlockSideLengthPower; - const int32_t blockZ = uZPos >> m_uBlockSideLengthPower; - - const uint16_t xOffset = uXPos - (blockX << m_uBlockSideLengthPower); - const uint16_t yOffset = uYPos - (blockY << m_uBlockSideLengthPower); - const uint16_t zOffset = uZPos - (blockZ << m_uBlockSideLengthPower); - - Block* pUncompressedBlock = getUncompressedBlock(blockX, blockY, blockZ); - - pUncompressedBlock->setVoxelAt(xOffset,yOffset,zOffset, tValue); - - //Return true to indicate that we modified a voxel. - return true; - } - - template Block* LargeVolume::getUncompressedBlock(int32_t uBlockX, int32_t uBlockY, int32_t uBlockZ) const { @@ -665,8 +635,6 @@ namespace PolyVox Vector3DInt32 v3dLower(v3dBlockPos.getX() << m_uBlockSideLengthPower, v3dBlockPos.getY() << m_uBlockSideLengthPower, v3dBlockPos.getZ() << m_uBlockSideLengthPower); Vector3DInt32 v3dUpper = v3dLower + Vector3DInt32(m_uBlockSideLength-1, m_uBlockSideLength-1, m_uBlockSideLength-1); Region reg(v3dLower, v3dUpper); - /*ConstVolumeProxy ConstVolumeProxy(*this, reg); - m_pPager->dataRequiredHandler(ConstVolumeProxy, reg);*/ m_pPager->pageIn(reg, &(itBlock->second)); } diff --git a/library/PolyVoxCore/include/PolyVoxCore/Pager.h b/library/PolyVoxCore/include/PolyVoxCore/Pager.h index 13f4ad19..4cb95adc 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Pager.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Pager.h @@ -27,8 +27,6 @@ freely, subject to the following restrictions: #include "PolyVoxCore/Impl/Block.h" #include "PolyVoxCore/Impl/TypeDef.h" -#include "PolyVoxCore/ConstVolumeProxy.h" - namespace PolyVox { /** @@ -45,16 +43,6 @@ namespace PolyVox virtual void pageIn(const Region& region, Block* pBlockData) = 0; virtual void pageOut(const Region& region, Block* pBlockData) = 0; - - virtual void dataRequiredHandler(const ConstVolumeProxy& volumeProxy, const Region& region) - { - POLYVOX_ASSERT(false, "NOT IMPLEMENTED"); - } - - virtual void dataOverflowHandler(const ConstVolumeProxy& volumeProxy, const Region& region) - { - POLYVOX_ASSERT(false, "NOT IMPLEMENTED"); - } }; }