diff --git a/examples/Paging/main.cpp b/examples/Paging/main.cpp index f0248c14..f70de28f 100644 --- a/examples/Paging/main.cpp +++ b/examples/Paging/main.cpp @@ -27,9 +27,8 @@ freely, subject to the following restrictions: #include "PolyVoxCore/MaterialDensityPair.h" #include "PolyVoxCore/CubicSurfaceExtractor.h" #include "PolyVoxCore/MarchingCubesSurfaceExtractor.h" -#include "PolyVoxCore/Pager.h" #include "PolyVoxCore/Mesh.h" -#include "PolyVoxCore/LargeVolume.h" +#include "PolyVoxCore/PagedVolume.h" #include @@ -78,12 +77,12 @@ void createSphereInVolume(LargeVolume& volData, Vector3DF /** * Generates data using Perlin noise. */ -class PerlinNoisePager : public PolyVox::Pager +class PerlinNoisePager : public PolyVox::PagedVolume::Pager { public: /// Constructor PerlinNoisePager() - :Pager() + :PagedVolume::Pager() { } diff --git a/library/PolyVoxCore/CMakeLists.txt b/library/PolyVoxCore/CMakeLists.txt index 9704e593..42d8c752 100644 --- a/library/PolyVoxCore/CMakeLists.txt +++ b/library/PolyVoxCore/CMakeLists.txt @@ -62,7 +62,6 @@ SET(CORE_INC_FILES include/PolyVoxCore/PagedVolume.inl include/PolyVoxCore/PagedVolumeChunk.inl include/PolyVoxCore/PagedVolumeSampler.inl - include/PolyVoxCore/Pager.h include/PolyVoxCore/PolyVoxForwardDeclarations.h include/PolyVoxCore/Picking.h include/PolyVoxCore/Picking.inl diff --git a/library/PolyVoxCore/include/PolyVoxCore/FilePager.h b/library/PolyVoxCore/include/PolyVoxCore/FilePager.h index 269af29c..ed3b7a9a 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/FilePager.h +++ b/library/PolyVoxCore/include/PolyVoxCore/FilePager.h @@ -26,7 +26,7 @@ freely, subject to the following restrictions: #include "PolyVoxCore/Impl/TypeDef.h" -#include "PolyVoxCore/Pager.h" +#include "PolyVoxCore/PagedVolume.h" #include "PolyVoxCore/Region.h" #include @@ -42,12 +42,12 @@ namespace PolyVox * Provides an interface for performing paging of data. */ template - class FilePager : public Pager + class FilePager : public PagedVolume::Pager { public: /// Constructor FilePager(const std::string& strFolderName = ".") - :Pager() + :PagedVolume::Pager() ,m_strFolderName(strFolderName) { // Add the trailing slash, assuming the user dind't already do it. diff --git a/library/PolyVoxCore/include/PolyVoxCore/PagedVolume.h b/library/PolyVoxCore/include/PolyVoxCore/PagedVolume.h index 75acaaca..7ee41ec4 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/PagedVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/PagedVolume.h @@ -25,7 +25,6 @@ freely, subject to the following restrictions: #define __PolyVox_PagedVolume_H__ #include "PolyVoxCore/BaseVolume.h" -#include "PolyVoxCore/Pager.h" #include "PolyVoxCore/Region.h" #include "PolyVoxCore/Vector.h" @@ -156,11 +155,13 @@ namespace PolyVox class PagedVolume : public BaseVolume { public: + class Chunk; + class Pager; class Chunk { public: - Chunk(Vector3DInt32 v3dPosition, uint16_t uSideLength, Pager* pPager = nullptr); + Chunk(Vector3DInt32 v3dPosition, uint16_t uSideLength, typename PagedVolume::Pager* pPager = nullptr); ~Chunk(); VoxelType* getData(void) const; @@ -192,10 +193,25 @@ namespace PolyVox VoxelType* m_tData; uint16_t m_uSideLength; uint8_t m_uSideLengthPower; - Pager* m_pPager; + typename PagedVolume::Pager* m_pPager; Vector3DInt32 m_v3dChunkSpacePosition; }; + /** + * Provides an interface for performing paging of data. + */ + class Pager + { + public: + /// Constructor + Pager() {}; + /// Destructor + virtual ~Pager() {}; + + virtual void pageIn(const Region& region, typename PagedVolume::Chunk* pChunk) = 0; + virtual void pageOut(const Region& region, typename PagedVolume::Chunk* pChunk) = 0; + }; + //There seems to be some descrepency between Visual Studio and GCC about how the following class should be declared. //There is a work around (see also See http://goo.gl/qu1wn) given below which appears to work on VS2010 and GCC, but //which seems to cause internal compiler errors on VS2008 when building with the /Gm 'Enable Minimal Rebuild' compiler @@ -272,7 +288,7 @@ namespace PolyVox PagedVolume ( const Region& regValid, - Pager* pPager = nullptr, + typename PagedVolume::Pager* pPager = nullptr, uint16_t uChunkSideLength = 32 ); /// Destructor @@ -357,11 +373,11 @@ namespace PolyVox uint16_t m_uChunkSideLength; uint8_t m_uChunkSideLengthPower; - Pager* m_pPager; + typename PagedVolume::Pager* m_pPager; // Enough to make sure a chunks and it's neighbours can be loaded, with a few to spare. static const uint32_t uMinPracticalNoOfChunks = 32; - // Should preent multi-gigabyte volumes with reasonable chunk sizes. + // Should prevent multi-gigabyte volumes when chunk sizes are reasonable. static const uint32_t uMaxPracticalNoOfChunks = 32768; }; } diff --git a/library/PolyVoxCore/include/PolyVoxCore/PagedVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/PagedVolume.inl index ae5aeea3..7027bf68 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/PagedVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/PagedVolume.inl @@ -40,7 +40,7 @@ namespace PolyVox PagedVolume::PagedVolume ( const Region& regValid, - Pager* pPager, + typename PagedVolume::Pager* pPager, uint16_t uChunkSideLength ) :BaseVolume(regValid) diff --git a/library/PolyVoxCore/include/PolyVoxCore/PagedVolumeChunk.inl b/library/PolyVoxCore/include/PolyVoxCore/PagedVolumeChunk.inl index 05b713d2..7bb904a8 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/PagedVolumeChunk.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/PagedVolumeChunk.inl @@ -26,7 +26,7 @@ freely, subject to the following restrictions: namespace PolyVox { template - PagedVolume::Chunk::Chunk(Vector3DInt32 v3dPosition, uint16_t uSideLength, Pager* pPager) + PagedVolume::Chunk::Chunk(Vector3DInt32 v3dPosition, uint16_t uSideLength, typename PagedVolume::Pager* pPager) :m_uChunkLastAccessed(0) ,m_bDataModified(true) ,m_tData(0) diff --git a/library/PolyVoxCore/include/PolyVoxCore/Pager.h b/library/PolyVoxCore/include/PolyVoxCore/Pager.h deleted file mode 100644 index 0280883c..00000000 --- a/library/PolyVoxCore/include/PolyVoxCore/Pager.h +++ /dev/null @@ -1,51 +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_Pager_H__ -#define __PolyVox_Pager_H__ - -#include "PolyVoxCore/PagedVolume.h" -#include "PolyVoxCore/Impl/TypeDef.h" - -#include - -namespace PolyVox -{ - /** - * Provides an interface for performing paging of data. - */ - template - class Pager - { - public: - /// Constructor - Pager() {}; - /// Destructor - virtual ~Pager() {}; - - virtual void pageIn(const Region& region, typename PagedVolume::Chunk* pChunk) = 0; - virtual void pageOut(const Region& region, typename PagedVolume::Chunk* pChunk) = 0; - }; -} - -#endif //__PolyVox_Pager_H__