From 6f1ddb7d5f06a246334b238c43a2d7e1500de97d Mon Sep 17 00:00:00 2001 From: David Williams Date: Thu, 28 Apr 2011 20:30:16 +0100 Subject: [PATCH] Moved VolumeSampler into Volume class. --- library/PolyVoxCore/CMakeLists.txt | 2 +- library/PolyVoxCore/include/AStarPathfinder.h | 1 - .../include/AmbientOcclusionCalculator.h | 2 +- .../include/AmbientOcclusionCalculator.inl | 1 - .../include/CubicSurfaceExtractor.h | 3 +- .../CubicSurfaceExtractorWithNormals.h | 4 +- .../PolyVoxCore/include/GradientEstimators.h | 12 +- .../include/GradientEstimators.inl | 12 +- .../include/PolyVoxForwardDeclarations.h | 2 +- .../PolyVoxCore/include/PolyVoxImpl/Block.h | 2 +- library/PolyVoxCore/include/Raycast.h | 2 +- .../PolyVoxCore/include/RaycastWithCallback.h | 2 +- .../PolyVoxCore/include/SurfaceExtractor.h | 8 +- .../PolyVoxCore/include/SurfaceExtractor.inl | 4 +- library/PolyVoxCore/include/Volume.h | 76 ++++++++++++- library/PolyVoxCore/include/Volume.inl | 1 - library/PolyVoxCore/include/VolumeSampler.h | 105 ------------------ library/PolyVoxCore/include/VolumeSampler.inl | 88 +++++++-------- library/PolyVoxCore/include/VoxelFilters.h | 4 +- .../PolyVoxCore/source/GradientEstimators.cpp | 22 ++-- library/PolyVoxCore/source/VoxelFilters.cpp | 4 +- library/PolyVoxUtil/include/Serialization.inl | 7 +- .../include/VolumeChangeTracker.inl | 1 - 23 files changed, 164 insertions(+), 201 deletions(-) delete mode 100644 library/PolyVoxCore/include/VolumeSampler.h diff --git a/library/PolyVoxCore/CMakeLists.txt b/library/PolyVoxCore/CMakeLists.txt index 8d76ccf3..0051b069 100644 --- a/library/PolyVoxCore/CMakeLists.txt +++ b/library/PolyVoxCore/CMakeLists.txt @@ -31,6 +31,7 @@ SET(CORE_INC_FILES include/Density.h include/Filters.h include/Filters.inl + include/GradientEstimators.h include/GradientEstimators.inl include/Log.h include/Material.h @@ -52,7 +53,6 @@ SET(CORE_INC_FILES include/VertexTypes.h include/Volume.h include/Volume.inl - include/VolumeSampler.h include/VolumeSampler.inl include/VoxelFilters.h ) diff --git a/library/PolyVoxCore/include/AStarPathfinder.h b/library/PolyVoxCore/include/AStarPathfinder.h index ae2e4c02..8a04b5f2 100644 --- a/library/PolyVoxCore/include/AStarPathfinder.h +++ b/library/PolyVoxCore/include/AStarPathfinder.h @@ -28,7 +28,6 @@ freely, subject to the following restrictions: #include "PolyVoxImpl/AStarPathfinderImpl.h" #include "PolyVoxForwardDeclarations.h" #include "Volume.h" -#include "VolumeSampler.h" #include "PolyVoxImpl/TypeDef.h" diff --git a/library/PolyVoxCore/include/AmbientOcclusionCalculator.h b/library/PolyVoxCore/include/AmbientOcclusionCalculator.h index f6fec428..97120601 100644 --- a/library/PolyVoxCore/include/AmbientOcclusionCalculator.h +++ b/library/PolyVoxCore/include/AmbientOcclusionCalculator.h @@ -39,7 +39,7 @@ namespace PolyVox private: Region m_region; - VolumeSampler m_sampVolume; + Volume::VolumeSampler m_sampVolume; Volume* m_volInput; Array<3, uint8_t>* m_arrayResult; float m_fRayLength; diff --git a/library/PolyVoxCore/include/AmbientOcclusionCalculator.inl b/library/PolyVoxCore/include/AmbientOcclusionCalculator.inl index a579cf4d..7ac59d56 100644 --- a/library/PolyVoxCore/include/AmbientOcclusionCalculator.inl +++ b/library/PolyVoxCore/include/AmbientOcclusionCalculator.inl @@ -24,7 +24,6 @@ freely, subject to the following restrictions: #include "Array.h" #include "Raycast.h" #include "Volume.h" -#include "VolumeSampler.h" #include "PolyVoxImpl/RandomUnitVectors.h" #include "PolyVoxImpl/RandomVectors.h" diff --git a/library/PolyVoxCore/include/CubicSurfaceExtractor.h b/library/PolyVoxCore/include/CubicSurfaceExtractor.h index 3178c4a0..b3963dcf 100644 --- a/library/PolyVoxCore/include/CubicSurfaceExtractor.h +++ b/library/PolyVoxCore/include/CubicSurfaceExtractor.h @@ -26,7 +26,6 @@ freely, subject to the following restrictions: #include "Array.h" #include "PolyVoxForwardDeclarations.h" -#include "VolumeSampler.h" #include "PolyVoxImpl/TypeDef.h" @@ -51,7 +50,7 @@ namespace PolyVox private: //The volume data and a sampler to access it. Volume* m_volData; - VolumeSampler m_sampVolume; + Volume::VolumeSampler m_sampVolume; //Information about the region we are currently processing Region m_regSizeInVoxels; diff --git a/library/PolyVoxCore/include/CubicSurfaceExtractorWithNormals.h b/library/PolyVoxCore/include/CubicSurfaceExtractorWithNormals.h index dfb5ae2b..67d6f466 100644 --- a/library/PolyVoxCore/include/CubicSurfaceExtractorWithNormals.h +++ b/library/PolyVoxCore/include/CubicSurfaceExtractorWithNormals.h @@ -25,7 +25,7 @@ freely, subject to the following restrictions: #define __PolyVox_CubicSurfaceExtractorWithNormals_H__ #include "PolyVoxForwardDeclarations.h" -#include "VolumeSampler.h" +#include "Volume.h" #include "PolyVoxImpl/TypeDef.h" @@ -42,7 +42,7 @@ namespace PolyVox private: //The volume data and a sampler to access it. Volume* m_volData; - VolumeSampler m_sampVolume; + typename Volume::VolumeSampler m_sampVolume; //The surface patch we are currently filling. SurfaceMesh* m_meshCurrent; diff --git a/library/PolyVoxCore/include/GradientEstimators.h b/library/PolyVoxCore/include/GradientEstimators.h index 26029f97..0b5c8784 100644 --- a/library/PolyVoxCore/include/GradientEstimators.h +++ b/library/PolyVoxCore/include/GradientEstimators.h @@ -26,7 +26,7 @@ freely, subject to the following restrictions: #ifndef __PolyVox_GradientEstimators_H__ #define __PolyVox_GradientEstimators_H__ -#include "VolumeSampler.h" +#include "Volume.h" #include @@ -42,18 +42,18 @@ namespace PolyVox }; template - Vector3DFloat computeCentralDifferenceGradient(const VolumeSampler& volIter); + Vector3DFloat computeCentralDifferenceGradient(const typename Volume::VolumeSampler& volIter); template - Vector3DFloat computeSmoothCentralDifferenceGradient(VolumeSampler& volIter); + Vector3DFloat computeSmoothCentralDifferenceGradient(typename Volume::VolumeSampler& volIter); template - Vector3DFloat computeDecimatedCentralDifferenceGradient(VolumeSampler& volIter); + Vector3DFloat computeDecimatedCentralDifferenceGradient(typename Volume::VolumeSampler& volIter); template - Vector3DFloat computeSobelGradient(const VolumeSampler& volIter); + Vector3DFloat computeSobelGradient(const typename Volume::VolumeSampler& volIter); template - Vector3DFloat computeSmoothSobelGradient(VolumeSampler& volIter); + Vector3DFloat computeSmoothSobelGradient(typename Volume::VolumeSampler& volIter); POLYVOX_API void computeNormalsForVertices(Volume* volumeData, SurfaceMesh& mesh, NormalGenerationMethod normalGenerationMethod); POLYVOX_API Vector3DFloat computeNormal(Volume* volumeData, const Vector3DFloat& v3dPos, NormalGenerationMethod normalGenerationMethod); diff --git a/library/PolyVoxCore/include/GradientEstimators.inl b/library/PolyVoxCore/include/GradientEstimators.inl index 94609020..cbc019f7 100644 --- a/library/PolyVoxCore/include/GradientEstimators.inl +++ b/library/PolyVoxCore/include/GradientEstimators.inl @@ -23,10 +23,12 @@ freely, subject to the following restrictions: #include "VoxelFilters.h" +#include "Volume.h" + namespace PolyVox { template - Vector3DFloat computeCentralDifferenceGradient(const VolumeSampler& volIter) + Vector3DFloat computeCentralDifferenceGradient(const typename Volume::VolumeSampler& volIter) { //FIXME - bitwise way of doing this? VoxelType voxel1nx = volIter.peekVoxel1nx0py0pz() > 0 ? 1: 0; @@ -47,7 +49,7 @@ namespace PolyVox } template - Vector3DFloat computeDecimatedCentralDifferenceGradient(const VolumeSampler& volIter) + Vector3DFloat computeDecimatedCentralDifferenceGradient(const typename Volume::VolumeSampler& volIter) { const int32_t x = volIter.getPosX(); const int32_t y = volIter.getPosY(); @@ -72,7 +74,7 @@ namespace PolyVox } template - Vector3DFloat computeSmoothCentralDifferenceGradient(VolumeSampler& volIter) + Vector3DFloat computeSmoothCentralDifferenceGradient(typename Volume::VolumeSampler& volIter) { int32_t initialX = volIter.getPosX(); int32_t initialY = volIter.getPosY(); @@ -103,7 +105,7 @@ namespace PolyVox } template - Vector3DFloat computeSobelGradient(const VolumeSampler& volIter) + Vector3DFloat computeSobelGradient(const typename Volume::VolumeSampler& volIter) { static const int weights[3][3][3] = { { {2,3,2}, {3,6,3}, {2,3,2} }, { {3,6,3}, {6,0,6}, {3,6,3} }, { {2,3,2}, {3,6,3}, {2,3,2} } }; @@ -186,7 +188,7 @@ namespace PolyVox } template - Vector3DFloat computeSmoothSobelGradient(VolumeSampler& volIter) + Vector3DFloat computeSmoothSobelGradient(typename Volume::VolumeSampler& volIter) { static const int weights[3][3][3] = { { {2,3,2}, {3,6,3}, {2,3,2} }, { {3,6,3}, {6,0,6}, {3,6,3} }, { {2,3,2}, {3,6,3}, {2,3,2} } }; diff --git a/library/PolyVoxCore/include/PolyVoxForwardDeclarations.h b/library/PolyVoxCore/include/PolyVoxForwardDeclarations.h index a97af60b..40b7a9bf 100644 --- a/library/PolyVoxCore/include/PolyVoxForwardDeclarations.h +++ b/library/PolyVoxCore/include/PolyVoxForwardDeclarations.h @@ -99,7 +99,7 @@ namespace PolyVox typedef Vector<3,uint32_t> Vector3DUint32; //---------------------------- - template class VolumeSampler; + //template class VolumeSampler; } #endif diff --git a/library/PolyVoxCore/include/PolyVoxImpl/Block.h b/library/PolyVoxCore/include/PolyVoxImpl/Block.h index 4f8b6e84..aea98952 100644 --- a/library/PolyVoxCore/include/PolyVoxImpl/Block.h +++ b/library/PolyVoxCore/include/PolyVoxImpl/Block.h @@ -45,7 +45,7 @@ namespace PolyVox }; //Make VolumeSampler a friend - friend class VolumeSampler; + friend class Volume::VolumeSampler; public: Block(uint16_t uSideLength = 0); diff --git a/library/PolyVoxCore/include/Raycast.h b/library/PolyVoxCore/include/Raycast.h index 4c7d0a6d..6465a38f 100644 --- a/library/PolyVoxCore/include/Raycast.h +++ b/library/PolyVoxCore/include/Raycast.h @@ -101,7 +101,7 @@ namespace PolyVox void doRaycast(float x1, float y1, float z1, float x2, float y2, float z2); Volume* m_volData; - VolumeSampler m_sampVolume; + Volume::VolumeSampler m_sampVolume; Vector3DFloat m_v3dStart; Vector3DFloat m_v3dDirection; diff --git a/library/PolyVoxCore/include/RaycastWithCallback.h b/library/PolyVoxCore/include/RaycastWithCallback.h index ced2cdbd..522e001f 100644 --- a/library/PolyVoxCore/include/RaycastWithCallback.h +++ b/library/PolyVoxCore/include/RaycastWithCallback.h @@ -47,7 +47,7 @@ namespace PolyVox void doRaycast(float x1, float y1, float z1, float x2, float y2, float z2); Volume* m_volData; - VolumeSampler m_sampVolume; + Volume::VolumeSampler m_sampVolume; Vector3DFloat m_v3dStart; Vector3DFloat m_v3dDirection; diff --git a/library/PolyVoxCore/include/SurfaceExtractor.h b/library/PolyVoxCore/include/SurfaceExtractor.h index d3a8a953..8efff6c4 100644 --- a/library/PolyVoxCore/include/SurfaceExtractor.h +++ b/library/PolyVoxCore/include/SurfaceExtractor.h @@ -25,7 +25,7 @@ freely, subject to the following restrictions: #define __PolyVox_SurfaceExtractor_H__ #include "PolyVoxForwardDeclarations.h" -#include "VolumeSampler.h" +#include "Volume.h" #include "PolyVoxImpl/TypeDef.h" @@ -54,8 +54,8 @@ namespace PolyVox Array2DInt32& m_pCurrentVertexIndicesY, Array2DInt32& m_pCurrentVertexIndicesZ); - Vector3DFloat computeCentralDifferenceGradient(const VolumeSampler& volIter); - Vector3DFloat computeSobelGradient(const VolumeSampler& volIter); + Vector3DFloat computeCentralDifferenceGradient(const typename Volume::VolumeSampler& volIter); + Vector3DFloat computeSobelGradient(const typename Volume::VolumeSampler& volIter); //Use the cell bitmasks to generate all the indices needed for that slice void generateIndicesForSlice(const Array2DUint8& pPreviousBitmask, @@ -68,7 +68,7 @@ namespace PolyVox //The volume data and a sampler to access it. Volume* m_volData; - VolumeSampler m_sampVolume; + typename Volume::VolumeSampler m_sampVolume; //Holds a position in volume space. int32_t iXVolSpace; diff --git a/library/PolyVoxCore/include/SurfaceExtractor.inl b/library/PolyVoxCore/include/SurfaceExtractor.inl index be721bea..bd26c57a 100644 --- a/library/PolyVoxCore/include/SurfaceExtractor.inl +++ b/library/PolyVoxCore/include/SurfaceExtractor.inl @@ -507,7 +507,7 @@ namespace PolyVox } template - Vector3DFloat SurfaceExtractor::computeCentralDifferenceGradient(const VolumeSampler& volIter) + Vector3DFloat SurfaceExtractor::computeCentralDifferenceGradient(const typename Volume::VolumeSampler& volIter) { uint8_t voxel1nx = volIter.peekVoxel1nx0py0pz().getDensity(); uint8_t voxel1px = volIter.peekVoxel1px0py0pz().getDensity(); @@ -527,7 +527,7 @@ namespace PolyVox } template - Vector3DFloat SurfaceExtractor::computeSobelGradient(const VolumeSampler& volIter) + Vector3DFloat SurfaceExtractor::computeSobelGradient(const typename Volume::VolumeSampler& volIter) { static const int weights[3][3][3] = { { {2,3,2}, {3,6,3}, {2,3,2} }, { {3,6,3}, {6,0,6}, {3,6,3} }, { {2,3,2}, {3,6,3}, {2,3,2} } }; diff --git a/library/PolyVoxCore/include/Volume.h b/library/PolyVoxCore/include/Volume.h index 826ee24b..148cbb94 100644 --- a/library/PolyVoxCore/include/Volume.h +++ b/library/PolyVoxCore/include/Volume.h @@ -143,8 +143,77 @@ namespace PolyVox template class Volume { - // Make VolumeSampler a friend - friend class VolumeSampler; + public: + class VolumeSampler + { + public: + VolumeSampler(Volume* volume); + ~VolumeSampler(); + + typename VolumeSampler& operator=(const typename VolumeSampler& rhs) throw(); + + int32_t getPosX(void) const; + int32_t getPosY(void) const; + int32_t getPosZ(void) const; + VoxelType getSubSampledVoxel(uint8_t uLevel) const; + const Volume* getVolume(void) const; + inline VoxelType getVoxel(void) const; + + void setPosition(const Vector3DInt32& v3dNewPos); + void setPosition(int32_t xPos, int32_t yPos, int32_t zPos); + + void movePositiveX(void); + void movePositiveY(void); + void movePositiveZ(void); + + void moveNegativeX(void); + void moveNegativeY(void); + void moveNegativeZ(void); + + inline VoxelType peekVoxel1nx1ny1nz(void) const; + inline VoxelType peekVoxel1nx1ny0pz(void) const; + inline VoxelType peekVoxel1nx1ny1pz(void) const; + inline VoxelType peekVoxel1nx0py1nz(void) const; + inline VoxelType peekVoxel1nx0py0pz(void) const; + inline VoxelType peekVoxel1nx0py1pz(void) const; + inline VoxelType peekVoxel1nx1py1nz(void) const; + inline VoxelType peekVoxel1nx1py0pz(void) const; + inline VoxelType peekVoxel1nx1py1pz(void) const; + + inline VoxelType peekVoxel0px1ny1nz(void) const; + inline VoxelType peekVoxel0px1ny0pz(void) const; + inline VoxelType peekVoxel0px1ny1pz(void) const; + inline VoxelType peekVoxel0px0py1nz(void) const; + inline VoxelType peekVoxel0px0py0pz(void) const; + inline VoxelType peekVoxel0px0py1pz(void) const; + inline VoxelType peekVoxel0px1py1nz(void) const; + inline VoxelType peekVoxel0px1py0pz(void) const; + inline VoxelType peekVoxel0px1py1pz(void) const; + + inline VoxelType peekVoxel1px1ny1nz(void) const; + inline VoxelType peekVoxel1px1ny0pz(void) const; + inline VoxelType peekVoxel1px1ny1pz(void) const; + inline VoxelType peekVoxel1px0py1nz(void) const; + inline VoxelType peekVoxel1px0py0pz(void) const; + inline VoxelType peekVoxel1px0py1pz(void) const; + inline VoxelType peekVoxel1px1py1nz(void) const; + inline VoxelType peekVoxel1px1py0pz(void) const; + inline VoxelType peekVoxel1px1py1pz(void) const; + + private: + + //The current volume + Volume* mVolume; + + //The current position in the volume + int32_t mXPosInVolume; + int32_t mYPosInVolume; + int32_t mZPosInVolume; + + //Other current position information + VoxelType* mCurrentVoxel; + }; + // Make the ConstVolumeProxy a friend friend class ConstVolumeProxy; @@ -162,7 +231,7 @@ namespace PolyVox }; public: - /// Constructor for creting a very large paging volume. + /// Constructor for creating a very large paging volume. Volume ( polyvox_function&, const Region&)> dataRequiredHandler, @@ -291,5 +360,6 @@ private: } #include "Volume.inl" +#include "VolumeSampler.inl" #endif diff --git a/library/PolyVoxCore/include/Volume.inl b/library/PolyVoxCore/include/Volume.inl index d9939691..bf35634a 100644 --- a/library/PolyVoxCore/include/Volume.inl +++ b/library/PolyVoxCore/include/Volume.inl @@ -24,7 +24,6 @@ freely, subject to the following restrictions: #include "ConstVolumeProxy.h" #include "PolyVoxImpl/Block.h" #include "Log.h" -#include "VolumeSampler.h" #include "Region.h" #include "Vector.h" diff --git a/library/PolyVoxCore/include/VolumeSampler.h b/library/PolyVoxCore/include/VolumeSampler.h deleted file mode 100644 index b2d1a550..00000000 --- a/library/PolyVoxCore/include/VolumeSampler.h +++ /dev/null @@ -1,105 +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 __VolumeSampler_H__ -#define __VolumeSampler_H__ - -#include "PolyVoxForwardDeclarations.h" - -namespace PolyVox -{ - template - class VolumeSampler - { - public: - VolumeSampler(Volume* volume); - ~VolumeSampler(); - - VolumeSampler& operator=(const VolumeSampler& rhs) throw(); - - int32_t getPosX(void) const; - int32_t getPosY(void) const; - int32_t getPosZ(void) const; - VoxelType getSubSampledVoxel(uint8_t uLevel) const; - const Volume* getVolume(void) const; - inline VoxelType getVoxel(void) const; - - void setPosition(const Vector3DInt32& v3dNewPos); - void setPosition(int32_t xPos, int32_t yPos, int32_t zPos); - - void movePositiveX(void); - void movePositiveY(void); - void movePositiveZ(void); - - void moveNegativeX(void); - void moveNegativeY(void); - void moveNegativeZ(void); - - inline VoxelType peekVoxel1nx1ny1nz(void) const; - inline VoxelType peekVoxel1nx1ny0pz(void) const; - inline VoxelType peekVoxel1nx1ny1pz(void) const; - inline VoxelType peekVoxel1nx0py1nz(void) const; - inline VoxelType peekVoxel1nx0py0pz(void) const; - inline VoxelType peekVoxel1nx0py1pz(void) const; - inline VoxelType peekVoxel1nx1py1nz(void) const; - inline VoxelType peekVoxel1nx1py0pz(void) const; - inline VoxelType peekVoxel1nx1py1pz(void) const; - - inline VoxelType peekVoxel0px1ny1nz(void) const; - inline VoxelType peekVoxel0px1ny0pz(void) const; - inline VoxelType peekVoxel0px1ny1pz(void) const; - inline VoxelType peekVoxel0px0py1nz(void) const; - inline VoxelType peekVoxel0px0py0pz(void) const; - inline VoxelType peekVoxel0px0py1pz(void) const; - inline VoxelType peekVoxel0px1py1nz(void) const; - inline VoxelType peekVoxel0px1py0pz(void) const; - inline VoxelType peekVoxel0px1py1pz(void) const; - - inline VoxelType peekVoxel1px1ny1nz(void) const; - inline VoxelType peekVoxel1px1ny0pz(void) const; - inline VoxelType peekVoxel1px1ny1pz(void) const; - inline VoxelType peekVoxel1px0py1nz(void) const; - inline VoxelType peekVoxel1px0py0pz(void) const; - inline VoxelType peekVoxel1px0py1pz(void) const; - inline VoxelType peekVoxel1px1py1nz(void) const; - inline VoxelType peekVoxel1px1py0pz(void) const; - inline VoxelType peekVoxel1px1py1pz(void) const; - - private: - - //The current volume - Volume* mVolume; - - //The current position in the volume - int32_t mXPosInVolume; - int32_t mYPosInVolume; - int32_t mZPosInVolume; - - //Other current position information - VoxelType* mCurrentVoxel; - }; -} - -#include "VolumeSampler.inl" - -#endif diff --git a/library/PolyVoxCore/include/VolumeSampler.inl b/library/PolyVoxCore/include/VolumeSampler.inl index 92591a56..dcd9d069 100644 --- a/library/PolyVoxCore/include/VolumeSampler.inl +++ b/library/PolyVoxCore/include/VolumeSampler.inl @@ -35,18 +35,18 @@ freely, subject to the following restrictions: namespace PolyVox { template - VolumeSampler::VolumeSampler(Volume* volume) + Volume::VolumeSampler::VolumeSampler(Volume* volume) :mVolume(volume) { } template - VolumeSampler::~VolumeSampler() + Volume::VolumeSampler::~VolumeSampler() { } template - VolumeSampler& VolumeSampler::operator=(const VolumeSampler& rhs) throw() + typename Volume::VolumeSampler& Volume::VolumeSampler::operator=(const typename Volume::VolumeSampler& rhs) throw() { if(this == &rhs) { @@ -61,25 +61,25 @@ namespace PolyVox } template - int32_t VolumeSampler::getPosX(void) const + int32_t Volume::VolumeSampler::getPosX(void) const { return mXPosInVolume; } template - int32_t VolumeSampler::getPosY(void) const + int32_t Volume::VolumeSampler::getPosY(void) const { return mYPosInVolume; } template - int32_t VolumeSampler::getPosZ(void) const + int32_t Volume::VolumeSampler::getPosZ(void) const { return mZPosInVolume; } template - VoxelType VolumeSampler::getSubSampledVoxel(uint8_t uLevel) const + VoxelType Volume::VolumeSampler::getSubSampledVoxel(uint8_t uLevel) const { if(uLevel == 0) { @@ -117,25 +117,25 @@ namespace PolyVox } template - const Volume* VolumeSampler::getVolume(void) const + const Volume* Volume::VolumeSampler::getVolume(void) const { return mVolume; } template - VoxelType VolumeSampler::getVoxel(void) const + VoxelType Volume::VolumeSampler::getVoxel(void) const { return *mCurrentVoxel; } template - void VolumeSampler::setPosition(const Vector3DInt32& v3dNewPos) + void Volume::VolumeSampler::setPosition(const Vector3DInt32& v3dNewPos) { setPosition(v3dNewPos.getX(), v3dNewPos.getY(), v3dNewPos.getZ()); } template - void VolumeSampler::setPosition(int32_t xPos, int32_t yPos, int32_t zPos) + void Volume::VolumeSampler::setPosition(int32_t xPos, int32_t yPos, int32_t zPos) { mXPosInVolume = xPos; mYPosInVolume = yPos; @@ -166,7 +166,7 @@ namespace PolyVox } template - void VolumeSampler::movePositiveX(void) + void Volume::VolumeSampler::movePositiveX(void) { //Note the *pre* increament here if((++mXPosInVolume) % mVolume->m_uBlockSideLength != 0) @@ -182,7 +182,7 @@ namespace PolyVox } template - void VolumeSampler::movePositiveY(void) + void Volume::VolumeSampler::movePositiveY(void) { //Note the *pre* increament here if((++mYPosInVolume) % mVolume->m_uBlockSideLength != 0) @@ -198,7 +198,7 @@ namespace PolyVox } template - void VolumeSampler::movePositiveZ(void) + void Volume::VolumeSampler::movePositiveZ(void) { //Note the *pre* increament here if((++mZPosInVolume) % mVolume->m_uBlockSideLength != 0) @@ -214,7 +214,7 @@ namespace PolyVox } template - void VolumeSampler::moveNegativeX(void) + void Volume::VolumeSampler::moveNegativeX(void) { //Note the *post* decreament here if((mXPosInVolume--) % mVolume->m_uBlockSideLength != 0) @@ -230,7 +230,7 @@ namespace PolyVox } template - void VolumeSampler::moveNegativeY(void) + void Volume::VolumeSampler::moveNegativeY(void) { //Note the *post* decreament here if((mYPosInVolume--) % mVolume->m_uBlockSideLength != 0) @@ -246,7 +246,7 @@ namespace PolyVox } template - void VolumeSampler::moveNegativeZ(void) + void Volume::VolumeSampler::moveNegativeZ(void) { //Note the *post* decreament here if((mZPosInVolume--) % mVolume->m_uBlockSideLength != 0) @@ -262,7 +262,7 @@ namespace PolyVox } template - VoxelType VolumeSampler::peekVoxel1nx1ny1nz(void) const + VoxelType Volume::VolumeSampler::peekVoxel1nx1ny1nz(void) const { if( BORDER_LOW(mXPosInVolume) && BORDER_LOW(mYPosInVolume) && BORDER_LOW(mZPosInVolume) ) { @@ -272,7 +272,7 @@ namespace PolyVox } template - VoxelType VolumeSampler::peekVoxel1nx1ny0pz(void) const + VoxelType Volume::VolumeSampler::peekVoxel1nx1ny0pz(void) const { if( BORDER_LOW(mXPosInVolume) && BORDER_LOW(mYPosInVolume) ) { @@ -282,7 +282,7 @@ namespace PolyVox } template - VoxelType VolumeSampler::peekVoxel1nx1ny1pz(void) const + VoxelType Volume::VolumeSampler::peekVoxel1nx1ny1pz(void) const { if( BORDER_LOW(mXPosInVolume) && BORDER_LOW(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) ) { @@ -292,7 +292,7 @@ namespace PolyVox } template - VoxelType VolumeSampler::peekVoxel1nx0py1nz(void) const + VoxelType Volume::VolumeSampler::peekVoxel1nx0py1nz(void) const { if( BORDER_LOW(mXPosInVolume) && BORDER_LOW(mZPosInVolume) ) { @@ -302,7 +302,7 @@ namespace PolyVox } template - VoxelType VolumeSampler::peekVoxel1nx0py0pz(void) const + VoxelType Volume::VolumeSampler::peekVoxel1nx0py0pz(void) const { if( BORDER_LOW(mXPosInVolume) ) { @@ -312,7 +312,7 @@ namespace PolyVox } template - VoxelType VolumeSampler::peekVoxel1nx0py1pz(void) const + VoxelType Volume::VolumeSampler::peekVoxel1nx0py1pz(void) const { if( BORDER_LOW(mXPosInVolume) && BORDER_HIGH(mZPosInVolume) ) { @@ -322,7 +322,7 @@ namespace PolyVox } template - VoxelType VolumeSampler::peekVoxel1nx1py1nz(void) const + VoxelType Volume::VolumeSampler::peekVoxel1nx1py1nz(void) const { if( BORDER_LOW(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) && BORDER_LOW(mYPosInVolume) ) { @@ -332,7 +332,7 @@ namespace PolyVox } template - VoxelType VolumeSampler::peekVoxel1nx1py0pz(void) const + VoxelType Volume::VolumeSampler::peekVoxel1nx1py0pz(void) const { if( BORDER_LOW(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) ) { @@ -342,7 +342,7 @@ namespace PolyVox } template - VoxelType VolumeSampler::peekVoxel1nx1py1pz(void) const + VoxelType Volume::VolumeSampler::peekVoxel1nx1py1pz(void) const { if( BORDER_LOW(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) ) { @@ -354,7 +354,7 @@ namespace PolyVox ////////////////////////////////////////////////////////////////////////// template - VoxelType VolumeSampler::peekVoxel0px1ny1nz(void) const + VoxelType Volume::VolumeSampler::peekVoxel0px1ny1nz(void) const { if( BORDER_LOW(mYPosInVolume) && BORDER_LOW(mZPosInVolume) ) { @@ -364,7 +364,7 @@ namespace PolyVox } template - VoxelType VolumeSampler::peekVoxel0px1ny0pz(void) const + VoxelType Volume::VolumeSampler::peekVoxel0px1ny0pz(void) const { if( BORDER_LOW(mYPosInVolume) ) { @@ -374,7 +374,7 @@ namespace PolyVox } template - VoxelType VolumeSampler::peekVoxel0px1ny1pz(void) const + VoxelType Volume::VolumeSampler::peekVoxel0px1ny1pz(void) const { if( BORDER_LOW(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) ) { @@ -384,7 +384,7 @@ namespace PolyVox } template - VoxelType VolumeSampler::peekVoxel0px0py1nz(void) const + VoxelType Volume::VolumeSampler::peekVoxel0px0py1nz(void) const { if( BORDER_LOW(mZPosInVolume) ) { @@ -394,13 +394,13 @@ namespace PolyVox } template - VoxelType VolumeSampler::peekVoxel0px0py0pz(void) const + VoxelType Volume::VolumeSampler::peekVoxel0px0py0pz(void) const { return *mCurrentVoxel; } template - VoxelType VolumeSampler::peekVoxel0px0py1pz(void) const + VoxelType Volume::VolumeSampler::peekVoxel0px0py1pz(void) const { if( BORDER_HIGH(mZPosInVolume) ) { @@ -410,7 +410,7 @@ namespace PolyVox } template - VoxelType VolumeSampler::peekVoxel0px1py1nz(void) const + VoxelType Volume::VolumeSampler::peekVoxel0px1py1nz(void) const { if( BORDER_HIGH(mYPosInVolume) && BORDER_LOW(mZPosInVolume) ) { @@ -420,7 +420,7 @@ namespace PolyVox } template - VoxelType VolumeSampler::peekVoxel0px1py0pz(void) const + VoxelType Volume::VolumeSampler::peekVoxel0px1py0pz(void) const { if( BORDER_HIGH(mYPosInVolume) ) { @@ -430,7 +430,7 @@ namespace PolyVox } template - VoxelType VolumeSampler::peekVoxel0px1py1pz(void) const + VoxelType Volume::VolumeSampler::peekVoxel0px1py1pz(void) const { if( BORDER_HIGH(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) ) { @@ -442,7 +442,7 @@ namespace PolyVox ////////////////////////////////////////////////////////////////////////// template - VoxelType VolumeSampler::peekVoxel1px1ny1nz(void) const + VoxelType Volume::VolumeSampler::peekVoxel1px1ny1nz(void) const { if( BORDER_HIGH(mXPosInVolume) && BORDER_LOW(mYPosInVolume) && BORDER_LOW(mZPosInVolume) ) { @@ -452,7 +452,7 @@ namespace PolyVox } template - VoxelType VolumeSampler::peekVoxel1px1ny0pz(void) const + VoxelType Volume::VolumeSampler::peekVoxel1px1ny0pz(void) const { if( BORDER_HIGH(mXPosInVolume) && BORDER_LOW(mYPosInVolume) ) { @@ -462,7 +462,7 @@ namespace PolyVox } template - VoxelType VolumeSampler::peekVoxel1px1ny1pz(void) const + VoxelType Volume::VolumeSampler::peekVoxel1px1ny1pz(void) const { if( BORDER_HIGH(mXPosInVolume) && BORDER_LOW(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) ) { @@ -472,7 +472,7 @@ namespace PolyVox } template - VoxelType VolumeSampler::peekVoxel1px0py1nz(void) const + VoxelType Volume::VolumeSampler::peekVoxel1px0py1nz(void) const { if( BORDER_HIGH(mXPosInVolume) && BORDER_LOW(mZPosInVolume) ) { @@ -482,7 +482,7 @@ namespace PolyVox } template - VoxelType VolumeSampler::peekVoxel1px0py0pz(void) const + VoxelType Volume::VolumeSampler::peekVoxel1px0py0pz(void) const { if( BORDER_HIGH(mXPosInVolume) ) { @@ -492,7 +492,7 @@ namespace PolyVox } template - VoxelType VolumeSampler::peekVoxel1px0py1pz(void) const + VoxelType Volume::VolumeSampler::peekVoxel1px0py1pz(void) const { if( BORDER_HIGH(mXPosInVolume) && BORDER_HIGH(mZPosInVolume) ) { @@ -502,7 +502,7 @@ namespace PolyVox } template - VoxelType VolumeSampler::peekVoxel1px1py1nz(void) const + VoxelType Volume::VolumeSampler::peekVoxel1px1py1nz(void) const { if( BORDER_HIGH(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) && BORDER_LOW(mZPosInVolume) ) { @@ -512,7 +512,7 @@ namespace PolyVox } template - VoxelType VolumeSampler::peekVoxel1px1py0pz(void) const + VoxelType Volume::VolumeSampler::peekVoxel1px1py0pz(void) const { if( BORDER_HIGH(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) ) { @@ -522,7 +522,7 @@ namespace PolyVox } template - VoxelType VolumeSampler::peekVoxel1px1py1pz(void) const + VoxelType Volume::VolumeSampler::peekVoxel1px1py1pz(void) const { if( BORDER_HIGH(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) ) { diff --git a/library/PolyVoxCore/include/VoxelFilters.h b/library/PolyVoxCore/include/VoxelFilters.h index ce6b3c2c..cb1f884a 100644 --- a/library/PolyVoxCore/include/VoxelFilters.h +++ b/library/PolyVoxCore/include/VoxelFilters.h @@ -27,9 +27,11 @@ freely, subject to the following restrictions: #include "PolyVoxForwardDeclarations.h" #include "PolyVoxImpl/TypeDef.h" +#include "Volume.h" + namespace PolyVox { - float computeSmoothedVoxel(VolumeSampler& volIter); + float computeSmoothedVoxel(Volume::VolumeSampler& volIter); } #endif \ No newline at end of file diff --git a/library/PolyVoxCore/source/GradientEstimators.cpp b/library/PolyVoxCore/source/GradientEstimators.cpp index ea94da05..53c3497b 100644 --- a/library/PolyVoxCore/source/GradientEstimators.cpp +++ b/library/PolyVoxCore/source/GradientEstimators.cpp @@ -26,6 +26,8 @@ freely, subject to the following restrictions: #include "VertexTypes.h" #include "PolyVoxImpl/TypeDef.h" +#include "Volume.h" + using namespace std; namespace PolyVox @@ -39,7 +41,7 @@ namespace PolyVox const Vector3DFloat& v3dPos = iterSurfaceVertex->getPosition() + static_cast(mesh.m_Region.getLowerCorner()); const Vector3DInt32 v3dFloor = static_cast(v3dPos); - VolumeSampler volIter(volumeData); + Volume::VolumeSampler volIter(volumeData); //Check all corners are within the volume, allowing a boundary for gradient estimation bool lowerCornerInside = volumeData->getEnclosingRegion().containsPoint(v3dFloor,2); @@ -65,7 +67,7 @@ namespace PolyVox { Vector3DFloat v3dGradient; //To store the result - VolumeSampler volIter(volumeData); + Volume::VolumeSampler volIter(volumeData); const Vector3DInt32 v3dFloor = static_cast(v3dPos); @@ -74,16 +76,16 @@ namespace PolyVox switch(normalGenerationMethod) { case SOBEL_SMOOTHED: - gradFloor = computeSmoothSobelGradient(volIter); + gradFloor = computeSmoothSobelGradient(volIter); break; case CENTRAL_DIFFERENCE_SMOOTHED: - gradFloor = computeSmoothCentralDifferenceGradient(volIter); + gradFloor = computeSmoothCentralDifferenceGradient(volIter); break; case SOBEL: - gradFloor = computeSobelGradient(volIter); + gradFloor = computeSobelGradient(volIter); break; case CENTRAL_DIFFERENCE: - gradFloor = computeCentralDifferenceGradient(volIter); + gradFloor = computeCentralDifferenceGradient(volIter); break; } @@ -104,16 +106,16 @@ namespace PolyVox switch(normalGenerationMethod) { case SOBEL_SMOOTHED: - gradCeil = computeSmoothSobelGradient(volIter); + gradCeil = computeSmoothSobelGradient(volIter); break; case CENTRAL_DIFFERENCE_SMOOTHED: - gradCeil = computeSmoothCentralDifferenceGradient(volIter); + gradCeil = computeSmoothCentralDifferenceGradient(volIter); break; case SOBEL: - gradCeil = computeSobelGradient(volIter); + gradCeil = computeSobelGradient(volIter); break; case CENTRAL_DIFFERENCE: - gradCeil = computeCentralDifferenceGradient(volIter); + gradCeil = computeCentralDifferenceGradient(volIter); break; } diff --git a/library/PolyVoxCore/source/VoxelFilters.cpp b/library/PolyVoxCore/source/VoxelFilters.cpp index 572ab666..720ff950 100644 --- a/library/PolyVoxCore/source/VoxelFilters.cpp +++ b/library/PolyVoxCore/source/VoxelFilters.cpp @@ -23,11 +23,9 @@ freely, subject to the following restrictions: #include "VoxelFilters.h" -#include "VolumeSampler.h" - namespace PolyVox { - float computeSmoothedVoxel(VolumeSampler& volIter) + float computeSmoothedVoxel(Volume::VolumeSampler& volIter) { assert(volIter.getPosX() >= 1); assert(volIter.getPosY() >= 1); diff --git a/library/PolyVoxUtil/include/Serialization.inl b/library/PolyVoxUtil/include/Serialization.inl index 4ac8e923..13a4a361 100644 --- a/library/PolyVoxUtil/include/Serialization.inl +++ b/library/PolyVoxUtil/include/Serialization.inl @@ -22,7 +22,6 @@ freely, subject to the following restrictions: *******************************************************************************/ #include "Volume.h" -#include "VolumeSampler.h" #include "PolyVoxImpl/Utility.h" namespace PolyVox @@ -99,7 +98,7 @@ namespace PolyVox stream.write(reinterpret_cast(&volumeDepthPower), sizeof(volumeDepthPower)); //Write data - VolumeSampler volIter(&volume); + Volume::VolumeSampler volIter(&volume); for(uint16_t z = 0; z < volumeDepth; ++z) { //Update progress once per slice. @@ -213,7 +212,7 @@ namespace PolyVox stream.write(reinterpret_cast(&volumeDepthPower), sizeof(volumeDepthPower)); //Write data - VolumeSampler volIter(&volume); + Volume::VolumeSampler volIter(&volume); VoxelType current; uint32_t runLength = 0; bool firstTime = true; @@ -381,7 +380,7 @@ namespace PolyVox stream.write(reinterpret_cast(&volumeDepth), sizeof(volumeDepth)); //Write data - VolumeSampler volIter(&volume); + Volume::VolumeSampler volIter(&volume); VoxelType current; uint32_t runLength = 0; bool firstTime = true; diff --git a/library/PolyVoxUtil/include/VolumeChangeTracker.inl b/library/PolyVoxUtil/include/VolumeChangeTracker.inl index 15a4c649..fb48d627 100644 --- a/library/PolyVoxUtil/include/VolumeChangeTracker.inl +++ b/library/PolyVoxUtil/include/VolumeChangeTracker.inl @@ -30,7 +30,6 @@ freely, subject to the following restrictions: #include "PolyVoxImpl/Utility.h" #include "Vector.h" #include "Volume.h" -#include "VolumeSampler.h" namespace PolyVox {