From 9f0ae602b88af8f2ca152c611980dbd2ec6fee75 Mon Sep 17 00:00:00 2001 From: David Williams Date: Tue, 19 Jul 2011 22:09:24 +0100 Subject: [PATCH 01/19] Increased warning level in Visual studio. --- examples/Basic/CMakeLists.txt | 3 +++ examples/OpenGL/CMakeLists.txt | 3 +++ examples/Paging/CMakeLists.txt | 3 +++ examples/SmoothLOD/CMakeLists.txt | 3 +++ library/PolyVoxCore/CMakeLists.txt | 7 +++++-- library/PolyVoxUtil/CMakeLists.txt | 4 ++-- 6 files changed, 19 insertions(+), 4 deletions(-) diff --git a/examples/Basic/CMakeLists.txt b/examples/Basic/CMakeLists.txt index 3e843543..20c97eb8 100644 --- a/examples/Basic/CMakeLists.txt +++ b/examples/Basic/CMakeLists.txt @@ -34,6 +34,9 @@ LINK_DIRECTORIES(${PolyVoxCore_BINARY_DIR}) #Build ADD_EXECUTABLE(BasicExample ${SRC_FILES}) +IF(MSVC) + SET_TARGET_PROPERTIES(BasicExample PROPERTIES COMPILE_FLAGS "/W4 /wd4127") +ENDIF(MSVC) TARGET_LINK_LIBRARIES(BasicExample ${QT_LIBRARIES} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} PolyVoxCore) #Install - Only install the example in Windows diff --git a/examples/OpenGL/CMakeLists.txt b/examples/OpenGL/CMakeLists.txt index ef0825c6..fe9a9139 100644 --- a/examples/OpenGL/CMakeLists.txt +++ b/examples/OpenGL/CMakeLists.txt @@ -40,6 +40,9 @@ LINK_DIRECTORIES(${PolyVoxCore_BINARY_DIR}) #Build ADD_EXECUTABLE(OpenGLExample ${SRC_FILES}) +IF(MSVC) + SET_TARGET_PROPERTIES(OpenGLExample PROPERTIES COMPILE_FLAGS "/W4 /wd4127") +ENDIF(MSVC) TARGET_LINK_LIBRARIES(OpenGLExample ${QT_LIBRARIES} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} PolyVoxCore) #Install - Only install the example in Windows diff --git a/examples/Paging/CMakeLists.txt b/examples/Paging/CMakeLists.txt index db5cc1de..1444eff6 100644 --- a/examples/Paging/CMakeLists.txt +++ b/examples/Paging/CMakeLists.txt @@ -36,6 +36,9 @@ LINK_DIRECTORIES(${PolyVoxCore_BINARY_DIR}) #Build ADD_EXECUTABLE(PagingExample ${SRC_FILES}) +IF(MSVC) + SET_TARGET_PROPERTIES(PagingExample PROPERTIES COMPILE_FLAGS "/W4 /wd4127") +ENDIF(MSVC) TARGET_LINK_LIBRARIES(PagingExample ${QT_LIBRARIES} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} PolyVoxCore) #Install - Only install the example in Windows diff --git a/examples/SmoothLOD/CMakeLists.txt b/examples/SmoothLOD/CMakeLists.txt index aaa677ff..e282fcf8 100644 --- a/examples/SmoothLOD/CMakeLists.txt +++ b/examples/SmoothLOD/CMakeLists.txt @@ -34,6 +34,9 @@ LINK_DIRECTORIES(${PolyVoxCore_BINARY_DIR}) #Build ADD_EXECUTABLE(SmoothLODExample ${SRC_FILES}) +IF(MSVC) + SET_TARGET_PROPERTIES(SmoothLODExample PROPERTIES COMPILE_FLAGS "/W4 /wd4127") #All warnings +ENDIF(MSVC) TARGET_LINK_LIBRARIES(SmoothLODExample ${QT_LIBRARIES} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} PolyVoxCore) #Install - Only install the example in Windows diff --git a/library/PolyVoxCore/CMakeLists.txt b/library/PolyVoxCore/CMakeLists.txt index 5d357ef2..a1bcf575 100644 --- a/library/PolyVoxCore/CMakeLists.txt +++ b/library/PolyVoxCore/CMakeLists.txt @@ -61,6 +61,9 @@ SET(CORE_INC_FILES include/PolyVoxCore/Vector.h include/PolyVoxCore/Vector.inl include/PolyVoxCore/VertexTypes.h + include/PolyVoxCore/Volume.h + include/PolyVoxCore/Volume.inl + include/PolyVoxCore/VolumeSampler.inl include/PolyVoxCore/VolumeResampler.h include/PolyVoxCore/VolumeResampler.inl include/PolyVoxCore/VoxelFilters.h @@ -108,7 +111,7 @@ IF(BUILD_STATIC_LIBRARIES) SET_TARGET_PROPERTIES(PolyVoxCoreStatic PROPERTIES OUTPUT_NAME "PolyVoxCore") SET_TARGET_PROPERTIES(PolyVoxCoreStatic PROPERTIES VERSION ${POLYVOX_VERSION} SOVERSION ${POLYVOX_VERSION_MAJOR}) IF(MSVC) - SET_TARGET_PROPERTIES(PolyVoxCoreStatic PROPERTIES COMPILE_FLAGS "/wd4251") #Disable warning on STL exports + SET_TARGET_PROPERTIES(PolyVoxCoreStatic PROPERTIES COMPILE_FLAGS "/W4 /wd4251 /wd4127") #Disable warning on STL exports ENDIF(MSVC) SET(PolyVoxCore_LIBRARY "PolyVoxCoreStatic") ENDIF() @@ -118,7 +121,7 @@ IF(BUILD_DYNAMIC_LIBRARIES) SET_TARGET_PROPERTIES(PolyVoxCoreDynamic PROPERTIES COMPILE_FLAGS "-DPOLYVOX_SHARED_EXPORTS") SET_TARGET_PROPERTIES(PolyVoxCoreDynamic PROPERTIES VERSION ${POLYVOX_VERSION} SOVERSION ${POLYVOX_VERSION_MAJOR}) IF(MSVC) - SET_TARGET_PROPERTIES(PolyVoxCoreDynamic PROPERTIES COMPILE_FLAGS "/wd4251") #Disable warning on STL exports + SET_TARGET_PROPERTIES(PolyVoxCoreDynamic PROPERTIES COMPILE_FLAGS "/W4 /wd4251 /wd4127") #Disable warning on STL exports ENDIF(MSVC) SET(PolyVoxCore_LIBRARY "PolyVoxCoreDynamic") ENDIF() diff --git a/library/PolyVoxUtil/CMakeLists.txt b/library/PolyVoxUtil/CMakeLists.txt index 52d1efc7..3c2a78a4 100644 --- a/library/PolyVoxUtil/CMakeLists.txt +++ b/library/PolyVoxUtil/CMakeLists.txt @@ -35,7 +35,7 @@ IF(BUILD_STATIC_LIBRARIES) SET_TARGET_PROPERTIES(PolyVoxUtilStatic PROPERTIES OUTPUT_NAME "PolyVoxUtil") SET_TARGET_PROPERTIES(PolyVoxUtilStatic PROPERTIES VERSION ${POLYVOX_VERSION} SOVERSION ${POLYVOX_VERSION_MAJOR}) IF(MSVC) - SET_TARGET_PROPERTIES(PolyVoxUtilStatic PROPERTIES COMPILE_FLAGS "/wd4251") #Disable warning on STL exports + SET_TARGET_PROPERTIES(PolyVoxUtilStatic PROPERTIES COMPILE_FLAGS "/W4 /wd4251 /wd4127") #Disable warning on STL exports ENDIF(MSVC) ADD_DEPENDENCIES(PolyVoxUtilStatic PolyVoxCoreStatic) ENDIF() @@ -46,7 +46,7 @@ IF(BUILD_DYNAMIC_LIBRARIES) SET_TARGET_PROPERTIES(PolyVoxUtilDynamic PROPERTIES COMPILE_FLAGS "-DPOLYVOX_SHARED_EXPORTS") SET_TARGET_PROPERTIES(PolyVoxUtilDynamic PROPERTIES VERSION ${POLYVOX_VERSION} SOVERSION ${POLYVOX_VERSION_MAJOR}) IF(MSVC) - SET_TARGET_PROPERTIES(PolyVoxUtilDynamic PROPERTIES COMPILE_FLAGS "/wd4251") #Disable warning on STL exports + SET_TARGET_PROPERTIES(PolyVoxUtilDynamic PROPERTIES COMPILE_FLAGS "/W4 /wd4251 /wd4127") #Disable warning on STL exports ENDIF(MSVC) ADD_DEPENDENCIES(PolyVoxUtilDynamic PolyVoxCoreDynamic) ENDIF() From 36e9b8af2a3fa76432f43cd5df4cb9fafb5293d0 Mon Sep 17 00:00:00 2001 From: David Williams Date: Tue, 19 Jul 2011 23:31:55 +0100 Subject: [PATCH 02/19] Fixed wrong include guards --- library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h index b9ba2909..0e611446 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h @@ -21,8 +21,8 @@ freely, subject to the following restrictions: distribution. *******************************************************************************/ -#ifndef __PolyVox_Volume_H__ -#define __PolyVox_Volume_H__ +#ifndef __PolyVox_LargeVolume_H__ +#define __PolyVox_LargeVolume_H__ #include "PolyVoxImpl/Block.h" #include "PolyVoxCore/Region.h" @@ -362,4 +362,4 @@ private: #include "PolyVoxCore/LargeVolume.inl" #include "PolyVoxCore/LargeVolumeSampler.inl" -#endif +#endif //__PolyVox_LargeVolume_H__ From ef30a13aef0729813fd181a4de070bc6c4337740 Mon Sep 17 00:00:00 2001 From: David Williams Date: Tue, 19 Jul 2011 23:37:37 +0100 Subject: [PATCH 03/19] Initial work adding base volume class. --- .../include/PolyVoxCore/RawVolume.h | 32 +-- .../include/PolyVoxCore/RawVolume.inl | 94 +------- .../PolyVoxCore/include/PolyVoxCore/Volume.h | 95 ++++++++ .../include/PolyVoxCore/Volume.inl | 202 ++++++++++++++++++ .../include/PolyVoxCore/VolumeSampler.inl | 0 5 files changed, 300 insertions(+), 123 deletions(-) create mode 100644 library/PolyVoxCore/include/PolyVoxCore/Volume.h create mode 100644 library/PolyVoxCore/include/PolyVoxCore/Volume.inl create mode 100644 library/PolyVoxCore/include/PolyVoxCore/VolumeSampler.inl diff --git a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h index 6a586174..1c417eb4 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h @@ -26,6 +26,7 @@ freely, subject to the following restrictions: #include "PolyVoxCore/Region.h" #include "PolyVoxCore/PolyVoxForwardDeclarations.h" +#include "PolyVoxCore/Volume.h" #include #include @@ -33,7 +34,7 @@ freely, subject to the following restrictions: namespace PolyVox { template - class RawVolume + class RawVolume : public Volume { public: #ifndef SWIG @@ -118,29 +119,11 @@ namespace PolyVox /// Destructor ~RawVolume(); - /// Gets the value used for voxels which are outside the volume - VoxelType getBorderValue(void) const; - /// Gets a Region representing the extents of the RawVolume. - Region getEnclosingRegion(void) const; - /// Gets the width of the volume in voxels. - int32_t getWidth(void) const; - /// Gets the height of the volume in voxels. - int32_t getHeight(void) const; - /// Gets the depth of the volume in voxels. - int32_t getDepth(void) const; - /// Gets the length of the longest side in voxels - int32_t getLongestSideLength(void) const; - /// Gets the length of the shortest side in voxels - int32_t getShortestSideLength(void) const; - /// Gets the length of the diagonal in voxels - float getDiagonalLength(void) const; /// Gets a voxel at the position given by x,y,z coordinates VoxelType getVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos) const; /// Gets a voxel at the position given by a 3D vector VoxelType getVoxelAt(const Vector3DInt32& v3dPos) const; - /// Sets the value used for voxels which are outside the volume - void setBorderValue(const VoxelType& tBorder); /// Sets the voxel at the position given by x,y,z coordinates bool setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue); /// Sets the voxel at the position given by a 3D vector @@ -155,17 +138,6 @@ namespace PolyVox private: //The block data VoxelType* m_pData; - - //The border value - VoxelType m_tBorderValue; - - //The size of the volume - Region m_regValidRegion; - - //Some useful sizes - int32_t m_uLongestSideLength; - int32_t m_uShortestSideLength; - float m_fDiagonalLength; }; } diff --git a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl index e174d9bc..08b8eeef 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl @@ -47,6 +47,7 @@ namespace PolyVox ( const Region& regValid ) + :Volume(regValid) { //Create a volume of the right size. resize(regValid); @@ -62,90 +63,6 @@ namespace PolyVox m_pData = 0; } - //////////////////////////////////////////////////////////////////////////////// - /// The border value is returned whenever an atempt is made to read a voxel which - /// is outside the extents of the volume. - /// \return The value used for voxels outside of the volume - //////////////////////////////////////////////////////////////////////////////// - template - VoxelType RawVolume::getBorderValue(void) const - { - return m_tBorderValue; - } - - //////////////////////////////////////////////////////////////////////////////// - /// \return A Region representing the extent of the volume. - //////////////////////////////////////////////////////////////////////////////// - template - Region RawVolume::getEnclosingRegion(void) const - { - return m_regValidRegion; - } - - //////////////////////////////////////////////////////////////////////////////// - /// \return The width of the volume in voxels. Note that this value is inclusive, so that if the valid range is e.g. 0 to 63 then the width is 64. - /// \sa getHeight(), getDepth() - //////////////////////////////////////////////////////////////////////////////// - template - int32_t RawVolume::getWidth(void) const - { - return m_regValidRegion.getUpperCorner().getX() - m_regValidRegion.getLowerCorner().getX() + 1; - } - - //////////////////////////////////////////////////////////////////////////////// - /// \return The height of the volume in voxels. Note that this value is inclusive, so that if the valid range is e.g. 0 to 63 then the height is 64. - /// \sa getWidth(), getDepth() - //////////////////////////////////////////////////////////////////////////////// - template - int32_t RawVolume::getHeight(void) const - { - return m_regValidRegion.getUpperCorner().getY() - m_regValidRegion.getLowerCorner().getY() + 1; - } - - //////////////////////////////////////////////////////////////////////////////// - /// \return The depth of the volume in voxels. Note that this value is inclusive, so that if the valid range is e.g. 0 to 63 then the depth is 64. - /// \sa getWidth(), getHeight() - //////////////////////////////////////////////////////////////////////////////// - template - int32_t RawVolume::getDepth(void) const - { - return m_regValidRegion.getUpperCorner().getZ() - m_regValidRegion.getLowerCorner().getZ() + 1; - } - - //////////////////////////////////////////////////////////////////////////////// - /// \return The length of the shortest side in voxels. For example, if a volume has - /// dimensions 256x512x1024 this function will return 256. - /// \sa getLongestSideLength(), getDiagonalLength() - //////////////////////////////////////////////////////////////////////////////// - template - int32_t RawVolume::getShortestSideLength(void) const - { - return m_uShortestSideLength; - } - - //////////////////////////////////////////////////////////////////////////////// - /// \return The length of the longest side in voxels. For example, if a volume has - /// dimensions 256x512x1024 this function will return 1024. - /// \sa getShortestSideLength(), getDiagonalLength() - //////////////////////////////////////////////////////////////////////////////// - template - int32_t RawVolume::getLongestSideLength(void) const - { - return m_uLongestSideLength; - } - - //////////////////////////////////////////////////////////////////////////////// - /// \return The length of the diagonal in voxels. For example, if a volume has - /// dimensions 256x512x1024 this function will return sqrt(256*256+512*512+1024*1024) - /// = 1173.139. This value is computed on volume creation so retrieving it is fast. - /// \sa getShortestSideLength(), getLongestSideLength() - //////////////////////////////////////////////////////////////////////////////// - template - float RawVolume::getDiagonalLength(void) const - { - return m_fDiagonalLength; - } - //////////////////////////////////////////////////////////////////////////////// /// \param uXPos The \c x position of the voxel /// \param uYPos The \c y position of the voxel @@ -180,15 +97,6 @@ namespace PolyVox return getVoxelAt(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ()); } - //////////////////////////////////////////////////////////////////////////////// - /// \param tBorder The value to use for voxels outside the volume. - //////////////////////////////////////////////////////////////////////////////// - template - void RawVolume::setBorderValue(const VoxelType& tBorder) - { - m_tBorderValue = tBorder; - } - //////////////////////////////////////////////////////////////////////////////// /// \param uXPos the \c x position of the voxel /// \param uYPos the \c y position of the voxel diff --git a/library/PolyVoxCore/include/PolyVoxCore/Volume.h b/library/PolyVoxCore/include/PolyVoxCore/Volume.h new file mode 100644 index 00000000..855d1173 --- /dev/null +++ b/library/PolyVoxCore/include/PolyVoxCore/Volume.h @@ -0,0 +1,95 @@ +/******************************************************************************* +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_Volume_H__ +#define __PolyVox_Volume_H__ + +#include "PolyVoxCore/Region.h" +#include "PolyVoxCore/PolyVoxForwardDeclarations.h" + +#include +#include + +namespace PolyVox +{ + template + class Volume + { + public: + /// Constructor for creating a fixed size volume. + Volume + ( + const Region& regValid + ); + /// Destructor + ~Volume(); + + /// Gets the value used for voxels which are outside the volume + VoxelType getBorderValue(void) const; + /// Gets a Region representing the extents of the RawVolume. + Region getEnclosingRegion(void) const; + /// Gets the width of the volume in voxels. + int32_t getWidth(void) const; + /// Gets the height of the volume in voxels. + int32_t getHeight(void) const; + /// Gets the depth of the volume in voxels. + int32_t getDepth(void) const; + /// Gets the length of the longest side in voxels + int32_t getLongestSideLength(void) const; + /// Gets the length of the shortest side in voxels + int32_t getShortestSideLength(void) const; + /// Gets the length of the diagonal in voxels + float getDiagonalLength(void) const; + /// Gets a voxel at the position given by x,y,z coordinates + VoxelType getVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos) const; + /// Gets a voxel at the position given by a 3D vector + VoxelType getVoxelAt(const Vector3DInt32& v3dPos) const; + + /// Sets the value used for voxels which are outside the volume + void setBorderValue(const VoxelType& tBorder); + /// Sets the voxel at the position given by x,y,z coordinates + bool setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue); + /// Sets the voxel at the position given by a 3D vector + bool setVoxelAt(const Vector3DInt32& v3dPos, VoxelType tValue); + + /// Calculates approximatly how many bytes of memory the volume is currently using. + uint32_t calculateSizeInBytes(void); + +protected: + //The border value + VoxelType m_tBorderValue; + + //The size of the volume + Region m_regValidRegion; + + //Some useful sizes + int32_t m_uLongestSideLength; + int32_t m_uShortestSideLength; + float m_fDiagonalLength; + }; +} + +#include "PolyVoxCore/Volume.inl" +#include "PolyVoxCore/VolumeSampler.inl" + +#endif //__PolyVox_Volume_H__ diff --git a/library/PolyVoxCore/include/PolyVoxCore/Volume.inl b/library/PolyVoxCore/include/PolyVoxCore/Volume.inl new file mode 100644 index 00000000..2b2251cc --- /dev/null +++ b/library/PolyVoxCore/include/PolyVoxCore/Volume.inl @@ -0,0 +1,202 @@ +/******************************************************************************* +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. +*******************************************************************************/ + +#include "PolyVoxCore/Log.h" +#include "PolyVoxCore/Region.h" +#include "PolyVoxCore/Vector.h" + +#include + +namespace PolyVox +{ + template + Volume::Volume + ( + const Region& regValid + ) + :m_regValidRegion(regValid) + { + } + + //////////////////////////////////////////////////////////////////////////////// + /// Destroys the volume + //////////////////////////////////////////////////////////////////////////////// + template + Volume::~Volume() + { + } + + //////////////////////////////////////////////////////////////////////////////// + /// The border value is returned whenever an attempt is made to read a voxel which + /// is outside the extents of the volume. + /// \return The value used for voxels outside of the volume + //////////////////////////////////////////////////////////////////////////////// + template + VoxelType Volume::getBorderValue(void) const + { + return m_tBorderValue; + } + + //////////////////////////////////////////////////////////////////////////////// + /// \return A Region representing the extent of the volume. + //////////////////////////////////////////////////////////////////////////////// + template + Region Volume::getEnclosingRegion(void) const + { + return m_regValidRegion; + } + + //////////////////////////////////////////////////////////////////////////////// + /// \return The width of the volume in voxels. Note that this value is inclusive, so that if the valid range is e.g. 0 to 63 then the width is 64. + /// \sa getHeight(), getDepth() + //////////////////////////////////////////////////////////////////////////////// + template + int32_t Volume::getWidth(void) const + { + return m_regValidRegion.getUpperCorner().getX() - m_regValidRegion.getLowerCorner().getX() + 1; + } + + //////////////////////////////////////////////////////////////////////////////// + /// \return The height of the volume in voxels. Note that this value is inclusive, so that if the valid range is e.g. 0 to 63 then the height is 64. + /// \sa getWidth(), getDepth() + //////////////////////////////////////////////////////////////////////////////// + template + int32_t Volume::getHeight(void) const + { + return m_regValidRegion.getUpperCorner().getY() - m_regValidRegion.getLowerCorner().getY() + 1; + } + + //////////////////////////////////////////////////////////////////////////////// + /// \return The depth of the volume in voxels. Note that this value is inclusive, so that if the valid range is e.g. 0 to 63 then the depth is 64. + /// \sa getWidth(), getHeight() + //////////////////////////////////////////////////////////////////////////////// + template + int32_t Volume::getDepth(void) const + { + return m_regValidRegion.getUpperCorner().getZ() - m_regValidRegion.getLowerCorner().getZ() + 1; + } + + //////////////////////////////////////////////////////////////////////////////// + /// \return The length of the shortest side in voxels. For example, if a volume has + /// dimensions 256x512x1024 this function will return 256. + /// \sa getLongestSideLength(), getDiagonalLength() + //////////////////////////////////////////////////////////////////////////////// + template + int32_t Volume::getShortestSideLength(void) const + { + return m_uShortestSideLength; + } + + //////////////////////////////////////////////////////////////////////////////// + /// \return The length of the longest side in voxels. For example, if a volume has + /// dimensions 256x512x1024 this function will return 1024. + /// \sa getShortestSideLength(), getDiagonalLength() + //////////////////////////////////////////////////////////////////////////////// + template + int32_t Volume::getLongestSideLength(void) const + { + return m_uLongestSideLength; + } + + //////////////////////////////////////////////////////////////////////////////// + /// \return The length of the diagonal in voxels. For example, if a volume has + /// dimensions 256x512x1024 this function will return sqrt(256*256+512*512+1024*1024) + /// = 1173.139. This value is computed on volume creation so retrieving it is fast. + /// \sa getShortestSideLength(), getLongestSideLength() + //////////////////////////////////////////////////////////////////////////////// + template + float Volume::getDiagonalLength(void) const + { + return m_fDiagonalLength; + } + + //////////////////////////////////////////////////////////////////////////////// + /// \param uXPos The \c x position of the voxel + /// \param uYPos The \c y position of the voxel + /// \param uZPos The \c z position of the voxel + /// \return The voxel value + //////////////////////////////////////////////////////////////////////////////// + template + VoxelType Volume::getVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos) const + { + assert(false); + return VoxelType; //Default constructor + } + + //////////////////////////////////////////////////////////////////////////////// + /// \param v3dPos The 3D position of the voxel + /// \return The voxel value + //////////////////////////////////////////////////////////////////////////////// + template + VoxelType Volume::getVoxelAt(const Vector3DInt32& v3dPos) const + { + assert(false); + return VoxelType; //Default constructor + } + + //////////////////////////////////////////////////////////////////////////////// + /// \param tBorder The value to use for voxels outside the volume. + //////////////////////////////////////////////////////////////////////////////// + template + void Volume::setBorderValue(const VoxelType& tBorder) + { + m_tBorderValue = tBorder; + } + + //////////////////////////////////////////////////////////////////////////////// + /// \param uXPos the \c x position of the voxel + /// \param uYPos the \c y position of the voxel + /// \param uZPos the \c z position of the voxel + /// \param tValue the value to which the voxel will be set + /// \return whether the requested position is inside the volume + //////////////////////////////////////////////////////////////////////////////// + template + bool Volume::setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue) + { + assert(false); + return false; + } + + //////////////////////////////////////////////////////////////////////////////// + /// \param v3dPos the 3D position of the voxel + /// \param tValue the value to which the voxel will be set + /// \return whether the requested position is inside the volume + //////////////////////////////////////////////////////////////////////////////// + template + bool Volume::setVoxelAt(const Vector3DInt32& v3dPos, VoxelType tValue) + { + assert(false); + return false; + } + + //////////////////////////////////////////////////////////////////////////////// + /// Note: This function needs reviewing for accuracy... + //////////////////////////////////////////////////////////////////////////////// + template + uint32_t Volume::calculateSizeInBytes(void) + { + return getWidth() * getHeight() * getDepth() * sizeof(VoxelType); + } + +} + diff --git a/library/PolyVoxCore/include/PolyVoxCore/VolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/VolumeSampler.inl new file mode 100644 index 00000000..e69de29b From d327b88c1741768748855cdb8101396a0bd49faa Mon Sep 17 00:00:00 2001 From: Matt Williams Date: Wed, 20 Jul 2011 18:50:12 +0200 Subject: [PATCH 04/19] Remove old Volume files from CMakeLists.txt --- library/PolyVoxCore/CMakeLists.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/library/PolyVoxCore/CMakeLists.txt b/library/PolyVoxCore/CMakeLists.txt index a1bcf575..3dce4314 100644 --- a/library/PolyVoxCore/CMakeLists.txt +++ b/library/PolyVoxCore/CMakeLists.txt @@ -61,9 +61,6 @@ SET(CORE_INC_FILES include/PolyVoxCore/Vector.h include/PolyVoxCore/Vector.inl include/PolyVoxCore/VertexTypes.h - include/PolyVoxCore/Volume.h - include/PolyVoxCore/Volume.inl - include/PolyVoxCore/VolumeSampler.inl include/PolyVoxCore/VolumeResampler.h include/PolyVoxCore/VolumeResampler.inl include/PolyVoxCore/VoxelFilters.h From ca8da0b0f3088476a2e58b51f0134966d0ab9011 Mon Sep 17 00:00:00 2001 From: David Williams Date: Wed, 20 Jul 2011 22:34:44 +0100 Subject: [PATCH 05/19] Initial commit of new Volume base class, which will be a base for the other volume classes. It's not working at this point... --- .../include/PolyVoxCore/RawVolume.h | 12 +- .../include/PolyVoxCore/RawVolumeSampler.inl | 34 +- .../PolyVoxCore/include/PolyVoxCore/Volume.h | 71 +++- .../include/PolyVoxCore/Volume.inl | 4 +- .../include/PolyVoxCore/VolumeSampler.inl | 304 ++++++++++++++++++ 5 files changed, 391 insertions(+), 34 deletions(-) diff --git a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h index 1c417eb4..d9bde4a7 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h @@ -38,14 +38,12 @@ namespace PolyVox { public: #ifndef SWIG - class Sampler + class Sampler : public Volume::Sampler { public: Sampler(RawVolume* volume); ~Sampler(); - Sampler& operator=(const Sampler& rhs) throw(); - int32_t getPosX(void) const; int32_t getPosY(void) const; int32_t getPosZ(void) const; @@ -95,18 +93,18 @@ namespace PolyVox private: //The current volume - RawVolume* mVolume; + RawVolume* mRawVolume; //The current position in the volume - int32_t mXPosInVolume; + /*int32_t mXPosInVolume; int32_t mYPosInVolume; - int32_t mZPosInVolume; + int32_t mZPosInVolume;*/ //Other current position information VoxelType* mCurrentVoxel; //Whether the current position is inside the volume - bool m_bIsCurrentPositionValid; + //bool m_bIsCurrentPositionValid; }; #endif diff --git a/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl index 570ea47a..b5f10b37 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl @@ -31,12 +31,13 @@ namespace PolyVox { template RawVolume::Sampler::Sampler(RawVolume* volume) - :mVolume(volume) - ,mXPosInVolume(0) - ,mYPosInVolume(0) - ,mZPosInVolume(0) + :Volume::Sampler(volume) + //,mXPosInVolume(0) + //,mYPosInVolume(0) + //,mZPosInVolume(0) + ,mRawVolume(volume) ,mCurrentVoxel(0) - ,m_bIsCurrentPositionValid(false) + //,m_bIsCurrentPositionValid(false) { } @@ -45,21 +46,6 @@ namespace PolyVox { } - template - typename RawVolume::Sampler& RawVolume::Sampler::operator=(const typename RawVolume::Sampler& rhs) throw() - { - if(this == &rhs) - { - return *this; - } - mVolume = rhs.mVolume; - mXPosInVolume = rhs.mXPosInVolume; - mYPosInVolume = rhs.mYPosInVolume; - mZPosInVolume = rhs.mZPosInVolume; - mCurrentVoxel = rhs.mCurrentVoxel; - return *this; - } - template int32_t RawVolume::Sampler::getPosX(void) const { @@ -87,7 +73,7 @@ namespace PolyVox template VoxelType RawVolume::Sampler::getVoxel(void) const { - return m_bIsCurrentPositionValid ? *mCurrentVoxel : mVolume->m_tBorderValue; + return m_bIsCurrentPositionValid ? *mCurrentVoxel : mVolume->getBorderValue(); } template @@ -107,9 +93,9 @@ namespace PolyVox yPos * mVolume->getWidth() + zPos * mVolume->getWidth() * mVolume->getHeight(); - mCurrentVoxel = mVolume->m_pData + uVoxelIndex; + mCurrentVoxel = mRawVolume->m_pData + uVoxelIndex; - m_bIsCurrentPositionValid = mVolume->m_regValidRegion.containsPoint(Vector3DInt32(xPos, yPos, zPos)); + m_bIsCurrentPositionValid = mVolume->getEnclosingRegion().containsPoint(Vector3DInt32(xPos, yPos, zPos)); } template @@ -131,7 +117,7 @@ namespace PolyVox template void RawVolume::Sampler::movePositiveZ(void) { - mZPosInVolume--; + mZPosInVolume++; mCurrentVoxel += mVolume->getWidth() * mVolume->getHeight(); m_bIsCurrentPositionValid = mZPosInVolume <= mVolume->getEnclosingRegion().getUpperCorner().getZ(); } diff --git a/library/PolyVoxCore/include/PolyVoxCore/Volume.h b/library/PolyVoxCore/include/PolyVoxCore/Volume.h index 855d1173..4ffe5046 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Volume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Volume.h @@ -35,6 +35,75 @@ namespace PolyVox template class Volume { + public: + #ifndef SWIG + class Sampler + { + public: + Sampler(Volume* volume); + ~Sampler(); + + int32_t getPosX(void) const; + int32_t getPosY(void) const; + int32_t getPosZ(void) 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; + + protected: + //The current volume + Volume* mVolume; + + //The current position in the volume + int32_t mXPosInVolume; + int32_t mYPosInVolume; + int32_t mZPosInVolume; + + //Whether the current position is inside the volume + bool m_bIsCurrentPositionValid; + }; + #endif + public: /// Constructor for creating a fixed size volume. Volume @@ -46,7 +115,7 @@ namespace PolyVox /// Gets the value used for voxels which are outside the volume VoxelType getBorderValue(void) const; - /// Gets a Region representing the extents of the RawVolume. + /// Gets a Region representing the extents of the Volume. Region getEnclosingRegion(void) const; /// Gets the width of the volume in voxels. int32_t getWidth(void) const; diff --git a/library/PolyVoxCore/include/PolyVoxCore/Volume.inl b/library/PolyVoxCore/include/PolyVoxCore/Volume.inl index 2b2251cc..5dd05be7 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Volume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/Volume.inl @@ -140,7 +140,7 @@ namespace PolyVox VoxelType Volume::getVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos) const { assert(false); - return VoxelType; //Default constructor + return VoxelType(); } //////////////////////////////////////////////////////////////////////////////// @@ -151,7 +151,7 @@ namespace PolyVox VoxelType Volume::getVoxelAt(const Vector3DInt32& v3dPos) const { assert(false); - return VoxelType; //Default constructor + return VoxelType(); } //////////////////////////////////////////////////////////////////////////////// diff --git a/library/PolyVoxCore/include/PolyVoxCore/VolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/VolumeSampler.inl index e69de29b..2638561a 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/VolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/VolumeSampler.inl @@ -0,0 +1,304 @@ +/******************************************************************************* +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. +*******************************************************************************/ + +#include "PolyVoxImpl/Block.h" +#include "PolyVoxCore/Volume.h" +#include "PolyVoxCore/Vector.h" +#include "PolyVoxCore/Region.h" + +#include +namespace PolyVox +{ + template + Volume::Sampler::Sampler(Volume* volume) + :mVolume(volume) + ,mXPosInVolume(0) + ,mYPosInVolume(0) + ,mZPosInVolume(0) + ,m_bIsCurrentPositionValid(false) + { + } + + template + Volume::Sampler::~Sampler() + { + } + + template + int32_t Volume::Sampler::getPosX(void) const + { + return mXPosInVolume; + } + + template + int32_t Volume::Sampler::getPosY(void) const + { + return mYPosInVolume; + } + + template + int32_t Volume::Sampler::getPosZ(void) const + { + return mZPosInVolume; + } + + template + const Volume* Volume::Sampler::getVolume(void) const + { + return mVolume; + } + + template + VoxelType Volume::Sampler::getVoxel(void) const + { + return m_bIsCurrentPositionValid ? mVolume->getVoxelAt(mXPosInVolume, mYPosInVolume, mZPosInVolume) : mVolume->m_tBorderValue; + } + + template + void Volume::Sampler::setPosition(const Vector3DInt32& v3dNewPos) + { + setPosition(v3dNewPos.getX(), v3dNewPos.getY(), v3dNewPos.getZ()); + } + + template + void Volume::Sampler::setPosition(int32_t xPos, int32_t yPos, int32_t zPos) + { + mXPosInVolume = xPos; + mYPosInVolume = yPos; + mZPosInVolume = zPos; + + const uint32_t uVoxelIndex = xPos + + yPos * mVolume->getWidth() + + zPos * mVolume->getWidth() * mVolume->getHeight(); + + m_bIsCurrentPositionValid = mVolume->m_regValidRegion.containsPoint(Vector3DInt32(xPos, yPos, zPos)); + } + + template + void Volume::Sampler::movePositiveX(void) + { + mXPosInVolume++; + m_bIsCurrentPositionValid = mXPosInVolume <= mVolume->getEnclosingRegion().getUpperCorner().getX(); + } + + template + void Volume::Sampler::movePositiveY(void) + { + mYPosInVolume++; + m_bIsCurrentPositionValid = mYPosInVolume <= mVolume->getEnclosingRegion().getUpperCorner().getY(); + } + + template + void Volume::Sampler::movePositiveZ(void) + { + mZPosInVolume++; + m_bIsCurrentPositionValid = mZPosInVolume <= mVolume->getEnclosingRegion().getUpperCorner().getZ(); + } + + template + void Volume::Sampler::moveNegativeX(void) + { + mXPosInVolume--; + m_bIsCurrentPositionValid = mXPosInVolume >= mVolume->getEnclosingRegion().getLowerCorner().getX(); + } + + template + void Volume::Sampler::moveNegativeY(void) + { + mYPosInVolume--; + m_bIsCurrentPositionValid = mYPosInVolume >= mVolume->getEnclosingRegion().getLowerCorner().getY(); + } + + template + void Volume::Sampler::moveNegativeZ(void) + { + mZPosInVolume--; + m_bIsCurrentPositionValid =mZPosInVolume >= mVolume->getEnclosingRegion().getLowerCorner().getZ(); + } + + template + VoxelType Volume::Sampler::peekVoxel1nx1ny1nz(void) const + { + return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume-1); + } + + template + VoxelType Volume::Sampler::peekVoxel1nx1ny0pz(void) const + { + return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume); + } + + template + VoxelType Volume::Sampler::peekVoxel1nx1ny1pz(void) const + { + return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume+1); + } + + template + VoxelType Volume::Sampler::peekVoxel1nx0py1nz(void) const + { + return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume-1); + } + + template + VoxelType Volume::Sampler::peekVoxel1nx0py0pz(void) const + { + return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume); + } + + template + VoxelType Volume::Sampler::peekVoxel1nx0py1pz(void) const + { + return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume+1); + } + + template + VoxelType Volume::Sampler::peekVoxel1nx1py1nz(void) const + { + return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume-1); + } + + template + VoxelType Volume::Sampler::peekVoxel1nx1py0pz(void) const + { + return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume); + } + + template + VoxelType Volume::Sampler::peekVoxel1nx1py1pz(void) const + { + return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume+1); + } + + ////////////////////////////////////////////////////////////////////////// + + template + VoxelType Volume::Sampler::peekVoxel0px1ny1nz(void) const + { + return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume-1); + } + + template + VoxelType Volume::Sampler::peekVoxel0px1ny0pz(void) const + { + return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume); + } + + template + VoxelType Volume::Sampler::peekVoxel0px1ny1pz(void) const + { + return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume+1); + } + + template + VoxelType Volume::Sampler::peekVoxel0px0py1nz(void) const + { + return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume,mZPosInVolume-1); + } + + template + VoxelType Volume::Sampler::peekVoxel0px0py0pz(void) const + { + return *mCurrentVoxel; + } + + template + VoxelType Volume::Sampler::peekVoxel0px0py1pz(void) const + { + return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume,mZPosInVolume+1); + } + + template + VoxelType Volume::Sampler::peekVoxel0px1py1nz(void) const + { + return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume-1); + } + + template + VoxelType Volume::Sampler::peekVoxel0px1py0pz(void) const + { + return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume); + } + + template + VoxelType Volume::Sampler::peekVoxel0px1py1pz(void) const + { + return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume+1); + } + + ////////////////////////////////////////////////////////////////////////// + + template + VoxelType Volume::Sampler::peekVoxel1px1ny1nz(void) const + { + return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume-1); + } + + template + VoxelType Volume::Sampler::peekVoxel1px1ny0pz(void) const + { + return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume); + } + + template + VoxelType Volume::Sampler::peekVoxel1px1ny1pz(void) const + { + return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume+1); + } + + template + VoxelType Volume::Sampler::peekVoxel1px0py1nz(void) const + { + return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume-1); + } + + template + VoxelType Volume::Sampler::peekVoxel1px0py0pz(void) const + { + return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume); + } + + template + VoxelType Volume::Sampler::peekVoxel1px0py1pz(void) const + { + return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume+1); + } + + template + VoxelType Volume::Sampler::peekVoxel1px1py1nz(void) const + { + return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume-1); + } + + template + VoxelType Volume::Sampler::peekVoxel1px1py0pz(void) const + { + return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume); + } + + template + VoxelType Volume::Sampler::peekVoxel1px1py1pz(void) const + { + return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume+1); + } +} From 6f428d2e18c34e5403d84e21ab508f450aa25375 Mon Sep 17 00:00:00 2001 From: David Williams Date: Wed, 20 Jul 2011 23:38:16 +0100 Subject: [PATCH 06/19] Base Volume class now compiles and works. --- library/PolyVoxCore/CMakeLists.txt | 3 + .../include/PolyVoxCore/RawVolume.h | 8 +- .../include/PolyVoxCore/RawVolumeSampler.inl | 13 +- .../PolyVoxCore/include/PolyVoxCore/Volume.h | 15 -- .../include/PolyVoxCore/VolumeSampler.inl | 141 +++++++++--------- 5 files changed, 85 insertions(+), 95 deletions(-) diff --git a/library/PolyVoxCore/CMakeLists.txt b/library/PolyVoxCore/CMakeLists.txt index 3dce4314..a1bcf575 100644 --- a/library/PolyVoxCore/CMakeLists.txt +++ b/library/PolyVoxCore/CMakeLists.txt @@ -61,6 +61,9 @@ SET(CORE_INC_FILES include/PolyVoxCore/Vector.h include/PolyVoxCore/Vector.inl include/PolyVoxCore/VertexTypes.h + include/PolyVoxCore/Volume.h + include/PolyVoxCore/Volume.inl + include/PolyVoxCore/VolumeSampler.inl include/PolyVoxCore/VolumeResampler.h include/PolyVoxCore/VolumeResampler.inl include/PolyVoxCore/VoxelFilters.h diff --git a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h index d9bde4a7..88ad1a18 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h @@ -93,18 +93,18 @@ namespace PolyVox private: //The current volume - RawVolume* mRawVolume; + RawVolume* mVolume; //The current position in the volume - /*int32_t mXPosInVolume; + int32_t mXPosInVolume; int32_t mYPosInVolume; - int32_t mZPosInVolume;*/ + int32_t mZPosInVolume; //Other current position information VoxelType* mCurrentVoxel; //Whether the current position is inside the volume - //bool m_bIsCurrentPositionValid; + bool m_bIsCurrentPositionValid; }; #endif diff --git a/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl index b5f10b37..63aa9827 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl @@ -31,13 +31,12 @@ namespace PolyVox { template RawVolume::Sampler::Sampler(RawVolume* volume) - :Volume::Sampler(volume) - //,mXPosInVolume(0) - //,mYPosInVolume(0) - //,mZPosInVolume(0) - ,mRawVolume(volume) + :mVolume(volume) + ,mXPosInVolume(0) + ,mYPosInVolume(0) + ,mZPosInVolume(0) ,mCurrentVoxel(0) - //,m_bIsCurrentPositionValid(false) + ,m_bIsCurrentPositionValid(false) { } @@ -93,7 +92,7 @@ namespace PolyVox yPos * mVolume->getWidth() + zPos * mVolume->getWidth() * mVolume->getHeight(); - mCurrentVoxel = mRawVolume->m_pData + uVoxelIndex; + mCurrentVoxel = mVolume->m_pData + uVoxelIndex; m_bIsCurrentPositionValid = mVolume->getEnclosingRegion().containsPoint(Vector3DInt32(xPos, yPos, zPos)); } diff --git a/library/PolyVoxCore/include/PolyVoxCore/Volume.h b/library/PolyVoxCore/include/PolyVoxCore/Volume.h index 4ffe5046..2e662836 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Volume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Volume.h @@ -40,9 +40,6 @@ namespace PolyVox class Sampler { public: - Sampler(Volume* volume); - ~Sampler(); - int32_t getPosX(void) const; int32_t getPosY(void) const; int32_t getPosZ(void) const; @@ -89,18 +86,6 @@ namespace PolyVox inline VoxelType peekVoxel1px1py1nz(void) const; inline VoxelType peekVoxel1px1py0pz(void) const; inline VoxelType peekVoxel1px1py1pz(void) const; - - protected: - //The current volume - Volume* mVolume; - - //The current position in the volume - int32_t mXPosInVolume; - int32_t mYPosInVolume; - int32_t mZPosInVolume; - - //Whether the current position is inside the volume - bool m_bIsCurrentPositionValid; }; #endif diff --git a/library/PolyVoxCore/include/PolyVoxCore/VolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/VolumeSampler.inl index 2638561a..8103fd9c 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/VolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/VolumeSampler.inl @@ -29,165 +29,150 @@ freely, subject to the following restrictions: #include namespace PolyVox { - template - Volume::Sampler::Sampler(Volume* volume) - :mVolume(volume) - ,mXPosInVolume(0) - ,mYPosInVolume(0) - ,mZPosInVolume(0) - ,m_bIsCurrentPositionValid(false) - { - } - - template - Volume::Sampler::~Sampler() - { - } - template int32_t Volume::Sampler::getPosX(void) const { - return mXPosInVolume; + assert(false); + return 0; } template int32_t Volume::Sampler::getPosY(void) const { - return mYPosInVolume; + assert(false); + return 0; } template int32_t Volume::Sampler::getPosZ(void) const { - return mZPosInVolume; + assert(false); + return 0; } template const Volume* Volume::Sampler::getVolume(void) const { - return mVolume; + assert(false); + return 0; } template VoxelType Volume::Sampler::getVoxel(void) const { - return m_bIsCurrentPositionValid ? mVolume->getVoxelAt(mXPosInVolume, mYPosInVolume, mZPosInVolume) : mVolume->m_tBorderValue; + assert(false); + return VoxelType(); } template void Volume::Sampler::setPosition(const Vector3DInt32& v3dNewPos) { - setPosition(v3dNewPos.getX(), v3dNewPos.getY(), v3dNewPos.getZ()); + assert(false); } template void Volume::Sampler::setPosition(int32_t xPos, int32_t yPos, int32_t zPos) { - mXPosInVolume = xPos; - mYPosInVolume = yPos; - mZPosInVolume = zPos; - - const uint32_t uVoxelIndex = xPos + - yPos * mVolume->getWidth() + - zPos * mVolume->getWidth() * mVolume->getHeight(); - - m_bIsCurrentPositionValid = mVolume->m_regValidRegion.containsPoint(Vector3DInt32(xPos, yPos, zPos)); + assert(false); } template void Volume::Sampler::movePositiveX(void) { - mXPosInVolume++; - m_bIsCurrentPositionValid = mXPosInVolume <= mVolume->getEnclosingRegion().getUpperCorner().getX(); + assert(false); } template void Volume::Sampler::movePositiveY(void) { - mYPosInVolume++; - m_bIsCurrentPositionValid = mYPosInVolume <= mVolume->getEnclosingRegion().getUpperCorner().getY(); + assert(false); } template void Volume::Sampler::movePositiveZ(void) { - mZPosInVolume++; - m_bIsCurrentPositionValid = mZPosInVolume <= mVolume->getEnclosingRegion().getUpperCorner().getZ(); + assert(false); } template void Volume::Sampler::moveNegativeX(void) { - mXPosInVolume--; - m_bIsCurrentPositionValid = mXPosInVolume >= mVolume->getEnclosingRegion().getLowerCorner().getX(); + assert(false); } template void Volume::Sampler::moveNegativeY(void) { - mYPosInVolume--; - m_bIsCurrentPositionValid = mYPosInVolume >= mVolume->getEnclosingRegion().getLowerCorner().getY(); + assert(false); } template void Volume::Sampler::moveNegativeZ(void) { - mZPosInVolume--; - m_bIsCurrentPositionValid =mZPosInVolume >= mVolume->getEnclosingRegion().getLowerCorner().getZ(); + assert(false); } template VoxelType Volume::Sampler::peekVoxel1nx1ny1nz(void) const { - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume-1); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel1nx1ny0pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel1nx1ny1pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume+1); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel1nx0py1nz(void) const { - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume-1); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel1nx0py0pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel1nx0py1pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume+1); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel1nx1py1nz(void) const { - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume-1); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel1nx1py0pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel1nx1py1pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume+1); + assert(false); + return VoxelType(); } ////////////////////////////////////////////////////////////////////////// @@ -195,55 +180,64 @@ namespace PolyVox template VoxelType Volume::Sampler::peekVoxel0px1ny1nz(void) const { - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume-1); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel0px1ny0pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel0px1ny1pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume+1); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel0px0py1nz(void) const { - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume,mZPosInVolume-1); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel0px0py0pz(void) const { - return *mCurrentVoxel; + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel0px0py1pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume,mZPosInVolume+1); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel0px1py1nz(void) const { - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume-1); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel0px1py0pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel0px1py1pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume+1); + assert(false); + return VoxelType(); } ////////////////////////////////////////////////////////////////////////// @@ -251,54 +245,63 @@ namespace PolyVox template VoxelType Volume::Sampler::peekVoxel1px1ny1nz(void) const { - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume-1); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel1px1ny0pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel1px1ny1pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume+1); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel1px0py1nz(void) const { - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume-1); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel1px0py0pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel1px0py1pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume+1); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel1px1py1nz(void) const { - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume-1); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel1px1py0pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume); + assert(false); + return VoxelType(); } template VoxelType Volume::Sampler::peekVoxel1px1py1pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume+1); + assert(false); + return VoxelType(); } } From 555ddc47a5964eb88599ba05b0e01ee6c3731418 Mon Sep 17 00:00:00 2001 From: David Williams Date: Sun, 24 Jul 2011 12:26:43 +0100 Subject: [PATCH 07/19] Compile fixes for G++. --- .../include/PolyVoxCore/RawVolume.inl | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl index 08b8eeef..ab0a95aa 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl @@ -47,7 +47,7 @@ namespace PolyVox ( const Region& regValid ) - :Volume(regValid) + :Volume(regValid) { //Create a volume of the right size. resize(regValid); @@ -72,18 +72,18 @@ namespace PolyVox template VoxelType RawVolume::getVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos) const { - if(m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos))) + if(Volume::m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos))) { return m_pData [ uXPos + - uYPos * getWidth() + - uZPos * getWidth() * getHeight() + uYPos * Volume::getWidth() + + uZPos * Volume::getWidth() * Volume::getHeight() ]; } else { - return getBorderValue(); + return Volume::getBorderValue(); } } @@ -107,13 +107,13 @@ namespace PolyVox template bool RawVolume::setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue) { - assert(m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos))); + assert(Volume::m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos))); m_pData [ uXPos + - uYPos * getWidth() + - uZPos * getWidth() * getHeight() + uYPos * Volume::getWidth() + + uZPos * Volume::getWidth() * Volume::getHeight() ] = tValue; //Return true to indicate that we modified a voxel. @@ -137,20 +137,20 @@ namespace PolyVox template void RawVolume::resize(const Region& regValidRegion) { - m_regValidRegion = regValidRegion; + Volume::m_regValidRegion = regValidRegion; //Ensure dimensions of the specified Region are valid - assert(getWidth() > 0); - assert(getHeight() > 0); - assert(getDepth() > 0); + assert(Volume::getWidth() > 0); + assert(Volume::getHeight() > 0); + assert(Volume::getDepth() > 0); //Create the data - m_pData = new VoxelType[getWidth() * getHeight()* getDepth()]; + m_pData = new VoxelType[Volume::getWidth() * Volume::getHeight()* Volume::getDepth()]; //Other properties we might find useful later - m_uLongestSideLength = (std::max)((std::max)(getWidth(),getHeight()),getDepth()); - m_uShortestSideLength = (std::min)((std::min)(getWidth(),getHeight()),getDepth()); - m_fDiagonalLength = sqrtf(static_cast(getWidth() * getWidth() + getHeight() * getHeight() + getDepth() * getDepth())); + Volume::m_uLongestSideLength = (std::max)((std::max)(Volume::getWidth(),Volume::getHeight()),Volume::getDepth()); + Volume::m_uShortestSideLength = (std::min)((std::min)(Volume::getWidth(),Volume::getHeight()),Volume::getDepth()); + Volume::m_fDiagonalLength = sqrtf(static_cast(Volume::getWidth() * Volume::getWidth() + Volume::getHeight() * Volume::getHeight() + Volume::getDepth() * Volume::getDepth())); } //////////////////////////////////////////////////////////////////////////////// @@ -159,7 +159,7 @@ namespace PolyVox template uint32_t RawVolume::calculateSizeInBytes(void) { - return getWidth() * getHeight() * getDepth() * sizeof(VoxelType); + return Volume::getWidth() * Volume::getHeight() * Volume::getDepth() * sizeof(VoxelType); } } From 8c7056d1a999b6f13c0d6e76624ca993f502c7fd Mon Sep 17 00:00:00 2001 From: David Williams Date: Sun, 24 Jul 2011 21:33:04 +0100 Subject: [PATCH 08/19] Made SimpleVolume and RawVolume derive from base Volume class. --- .../include/PolyVoxCore/LargeVolume.h | 25 +------ .../include/PolyVoxCore/LargeVolume.inl | 75 +------------------ .../include/PolyVoxCore/RawVolume.h | 7 ++ .../include/PolyVoxCore/RawVolume.inl | 20 +++++ .../include/PolyVoxCore/SimpleVolume.h | 27 +------ .../include/PolyVoxCore/SimpleVolume.inl | 74 +----------------- .../PolyVoxCore/include/PolyVoxCore/Volume.h | 3 - .../include/PolyVoxCore/Volume.inl | 5 +- 8 files changed, 40 insertions(+), 196 deletions(-) diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h index 0e611446..4c111ce9 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h @@ -27,6 +27,7 @@ freely, subject to the following restrictions: #include "PolyVoxImpl/Block.h" #include "PolyVoxCore/Region.h" #include "PolyVoxCore/PolyVoxForwardDeclarations.h" +#include "PolyVoxCore/Volume.h" #include #include @@ -141,10 +142,10 @@ namespace PolyVox /// of the block cache (amoung other problems). //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// template - class LargeVolume + class LargeVolume : public Volume { public: - class Sampler + class Sampler : public Volume::Sampler { public: Sampler(LargeVolume* volume); @@ -257,20 +258,6 @@ namespace PolyVox /// Gets the value used for voxels which are outside the volume VoxelType getBorderValue(void) const; - /// Gets a Region representing the extents of the LargeVolume. - Region getEnclosingRegion(void) const; - /// Gets the width of the volume in voxels. - int32_t getWidth(void) const; - /// Gets the height of the volume in voxels. - int32_t getHeight(void) const; - /// Gets the depth of the volume in voxels. - int32_t getDepth(void) const; - /// Gets the length of the longest side in voxels - int32_t getLongestSideLength(void) const; - /// Gets the length of the shortest side in voxels - int32_t getShortestSideLength(void) const; - /// Gets the length of the diagonal in voxels - float getDiagonalLength(void) const; /// Gets a voxel at the position given by x,y,z coordinates VoxelType getVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos) const; /// Gets a voxel at the position given by a 3D vector @@ -342,18 +329,12 @@ private: VoxelType* m_pUncompressedBorderData; //The size of the volume - Region m_regValidRegion; Region m_regValidRegionInBlocks; //The size of the blocks uint16_t m_uBlockSideLength; uint8_t m_uBlockSideLengthPower; - //Some useful sizes - int32_t m_uLongestSideLength; - int32_t m_uShortestSideLength; - float m_fDiagonalLength; - bool m_bCompressionEnabled; bool m_bPagingEnabled; }; diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl index f21153d2..a3d8c500 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl @@ -49,6 +49,7 @@ namespace PolyVox polyvox_function&, const Region&)> dataOverflowHandler, uint16_t uBlockSideLength ) + :Volume(Region::MaxRegion) { m_funcDataRequiredHandler = dataRequiredHandler; m_funcDataOverflowHandler = dataOverflowHandler; @@ -95,6 +96,7 @@ namespace PolyVox bool bPagingEnabled, uint16_t uBlockSideLength ) + :Volume(regValid) { m_funcDataRequiredHandler = dataRequiredHandler; m_funcDataOverflowHandler = dataOverflowHandler; @@ -124,79 +126,6 @@ namespace PolyVox return *m_pUncompressedBorderData; } - //////////////////////////////////////////////////////////////////////////////// - /// \return A Region representing the extent of the volume. - //////////////////////////////////////////////////////////////////////////////// - template - Region LargeVolume::getEnclosingRegion(void) const - { - return m_regValidRegion; - } - - //////////////////////////////////////////////////////////////////////////////// - /// \return The width of the volume in voxels. Note that this value is inclusive, so that if the valid range is e.g. 0 to 63 then the width is 64. - /// \sa getHeight(), getDepth() - //////////////////////////////////////////////////////////////////////////////// - template - int32_t LargeVolume::getWidth(void) const - { - return m_regValidRegion.getUpperCorner().getX() - m_regValidRegion.getLowerCorner().getX() + 1; - } - - //////////////////////////////////////////////////////////////////////////////// - /// \return The height of the volume in voxels. Note that this value is inclusive, so that if the valid range is e.g. 0 to 63 then the height is 64. - /// \sa getWidth(), getDepth() - //////////////////////////////////////////////////////////////////////////////// - template - int32_t LargeVolume::getHeight(void) const - { - return m_regValidRegion.getUpperCorner().getY() - m_regValidRegion.getLowerCorner().getY() + 1; - } - - //////////////////////////////////////////////////////////////////////////////// - /// \return The depth of the volume in voxels. Note that this value is inclusive, so that if the valid range is e.g. 0 to 63 then the depth is 64. - /// \sa getWidth(), getHeight() - //////////////////////////////////////////////////////////////////////////////// - template - int32_t LargeVolume::getDepth(void) const - { - return m_regValidRegion.getUpperCorner().getZ() - m_regValidRegion.getLowerCorner().getZ() + 1; - } - - //////////////////////////////////////////////////////////////////////////////// - /// \return The length of the shortest side in voxels. For example, if a volume has - /// dimensions 256x512x1024 this function will return 256. - /// \sa getLongestSideLength(), getDiagonalLength() - //////////////////////////////////////////////////////////////////////////////// - template - int32_t LargeVolume::getShortestSideLength(void) const - { - return m_uShortestSideLength; - } - - //////////////////////////////////////////////////////////////////////////////// - /// \return The length of the longest side in voxels. For example, if a volume has - /// dimensions 256x512x1024 this function will return 1024. - /// \sa getShortestSideLength(), getDiagonalLength() - //////////////////////////////////////////////////////////////////////////////// - template - int32_t LargeVolume::getLongestSideLength(void) const - { - return m_uLongestSideLength; - } - - //////////////////////////////////////////////////////////////////////////////// - /// \return The length of the diagonal in voxels. For example, if a volume has - /// dimensions 256x512x1024 this function will return sqrt(256*256+512*512+1024*1024) - /// = 1173.139. This value is computed on volume creation so retrieving it is fast. - /// \sa getShortestSideLength(), getLongestSideLength() - //////////////////////////////////////////////////////////////////////////////// - template - float LargeVolume::getDiagonalLength(void) const - { - return m_fDiagonalLength; - } - //////////////////////////////////////////////////////////////////////////////// /// \param uXPos The \c x position of the voxel /// \param uYPos The \c y position of the voxel diff --git a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h index 88ad1a18..877a519e 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h @@ -117,11 +117,15 @@ namespace PolyVox /// Destructor ~RawVolume(); + /// Gets the value used for voxels which are outside the volume + VoxelType getBorderValue(void) const; /// Gets a voxel at the position given by x,y,z coordinates VoxelType getVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos) const; /// Gets a voxel at the position given by a 3D vector VoxelType getVoxelAt(const Vector3DInt32& v3dPos) const; + /// Sets the value used for voxels which are outside the volume + void setBorderValue(const VoxelType& tBorder); /// Sets the voxel at the position given by x,y,z coordinates bool setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue); /// Sets the voxel at the position given by a 3D vector @@ -136,6 +140,9 @@ namespace PolyVox private: //The block data VoxelType* m_pData; + + //The border value + VoxelType m_tBorderValue; }; } diff --git a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl index ab0a95aa..51d0ee6f 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl @@ -63,6 +63,17 @@ namespace PolyVox m_pData = 0; } + //////////////////////////////////////////////////////////////////////////////// + /// The border value is returned whenever an attempt is made to read a voxel which + /// is outside the extents of the volume. + /// \return The value used for voxels outside of the volume + //////////////////////////////////////////////////////////////////////////////// + template + VoxelType RawVolume::getBorderValue(void) const + { + return m_tBorderValue; + } + //////////////////////////////////////////////////////////////////////////////// /// \param uXPos The \c x position of the voxel /// \param uYPos The \c y position of the voxel @@ -97,6 +108,15 @@ namespace PolyVox return getVoxelAt(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ()); } + //////////////////////////////////////////////////////////////////////////////// + /// \param tBorder The value to use for voxels outside the volume. + //////////////////////////////////////////////////////////////////////////////// + template + void RawVolume::setBorderValue(const VoxelType& tBorder) + { + m_tBorderValue = tBorder; + } + //////////////////////////////////////////////////////////////////////////////// /// \param uXPos the \c x position of the voxel /// \param uYPos the \c y position of the voxel diff --git a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h index d2c2edfc..788b98aa 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h @@ -26,6 +26,7 @@ freely, subject to the following restrictions: #include "PolyVoxCore/Region.h" #include "PolyVoxCore/PolyVoxForwardDeclarations.h" +#include "PolyVoxCore/Volume.h" #include #include @@ -33,7 +34,7 @@ freely, subject to the following restrictions: namespace PolyVox { template - class SimpleVolume + class SimpleVolume : public Volume { public: #ifndef SWIG @@ -61,7 +62,7 @@ namespace PolyVox uint8_t m_uSideLengthPower; }; - class Sampler + class Sampler : public Volume::Sampler { public: Sampler(SimpleVolume* volume); @@ -149,20 +150,6 @@ namespace PolyVox /// Gets the value used for voxels which are outside the volume VoxelType getBorderValue(void) const; - /// Gets a Region representing the extents of the SimpleVolume. - Region getEnclosingRegion(void) const; - /// Gets the width of the volume in voxels. - int32_t getWidth(void) const; - /// Gets the height of the volume in voxels. - int32_t getHeight(void) const; - /// Gets the depth of the volume in voxels. - int32_t getDepth(void) const; - /// Gets the length of the longest side in voxels - int32_t getLongestSideLength(void) const; - /// Gets the length of the shortest side in voxels - int32_t getShortestSideLength(void) const; - /// Gets the length of the diagonal in voxels - float getDiagonalLength(void) const; /// Gets a voxel at the position given by x,y,z coordinates VoxelType getVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos) const; /// Gets a voxel at the position given by a 3D vector @@ -193,8 +180,7 @@ private: //the VolumeIterator can do it's usual pointer arithmetic without needing to know it's gone outside the volume. VoxelType* m_pUncompressedBorderData; - //The size of the volume - Region m_regValidRegion; + //The size of the volume in vlocks Region m_regValidRegionInBlocks; //Volume size measured in blocks. @@ -206,11 +192,6 @@ private: //The size of the blocks uint16_t m_uBlockSideLength; uint8_t m_uBlockSideLengthPower; - - //Some useful sizes - int32_t m_uLongestSideLength; - int32_t m_uShortestSideLength; - float m_fDiagonalLength; }; } diff --git a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl index 3554c687..96466a58 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl @@ -69,6 +69,7 @@ namespace PolyVox const Region& regValid, uint16_t uBlockSideLength ) + :Volume(regValid) { //Create a volume of the right size. resize(regValid,uBlockSideLength); @@ -95,79 +96,6 @@ namespace PolyVox return *m_pUncompressedBorderData; } - //////////////////////////////////////////////////////////////////////////////// - /// \return A Region representing the extent of the volume. - //////////////////////////////////////////////////////////////////////////////// - template - Region SimpleVolume::getEnclosingRegion(void) const - { - return m_regValidRegion; - } - - //////////////////////////////////////////////////////////////////////////////// - /// \return The width of the volume in voxels. Note that this value is inclusive, so that if the valid range is e.g. 0 to 63 then the width is 64. - /// \sa getHeight(), getDepth() - //////////////////////////////////////////////////////////////////////////////// - template - int32_t SimpleVolume::getWidth(void) const - { - return m_regValidRegion.getUpperCorner().getX() - m_regValidRegion.getLowerCorner().getX() + 1; - } - - //////////////////////////////////////////////////////////////////////////////// - /// \return The height of the volume in voxels. Note that this value is inclusive, so that if the valid range is e.g. 0 to 63 then the height is 64. - /// \sa getWidth(), getDepth() - //////////////////////////////////////////////////////////////////////////////// - template - int32_t SimpleVolume::getHeight(void) const - { - return m_regValidRegion.getUpperCorner().getY() - m_regValidRegion.getLowerCorner().getY() + 1; - } - - //////////////////////////////////////////////////////////////////////////////// - /// \return The depth of the volume in voxels. Note that this value is inclusive, so that if the valid range is e.g. 0 to 63 then the depth is 64. - /// \sa getWidth(), getHeight() - //////////////////////////////////////////////////////////////////////////////// - template - int32_t SimpleVolume::getDepth(void) const - { - return m_regValidRegion.getUpperCorner().getZ() - m_regValidRegion.getLowerCorner().getZ() + 1; - } - - //////////////////////////////////////////////////////////////////////////////// - /// \return The length of the shortest side in voxels. For example, if a volume has - /// dimensions 256x512x1024 this function will return 256. - /// \sa getLongestSideLength(), getDiagonalLength() - //////////////////////////////////////////////////////////////////////////////// - template - int32_t SimpleVolume::getShortestSideLength(void) const - { - return m_uShortestSideLength; - } - - //////////////////////////////////////////////////////////////////////////////// - /// \return The length of the longest side in voxels. For example, if a volume has - /// dimensions 256x512x1024 this function will return 1024. - /// \sa getShortestSideLength(), getDiagonalLength() - //////////////////////////////////////////////////////////////////////////////// - template - int32_t SimpleVolume::getLongestSideLength(void) const - { - return m_uLongestSideLength; - } - - //////////////////////////////////////////////////////////////////////////////// - /// \return The length of the diagonal in voxels. For example, if a volume has - /// dimensions 256x512x1024 this function will return sqrt(256*256+512*512+1024*1024) - /// = 1173.139. This value is computed on volume creation so retrieving it is fast. - /// \sa getShortestSideLength(), getLongestSideLength() - //////////////////////////////////////////////////////////////////////////////// - template - float SimpleVolume::getDiagonalLength(void) const - { - return m_fDiagonalLength; - } - //////////////////////////////////////////////////////////////////////////////// /// \param uXPos The \c x position of the voxel /// \param uYPos The \c y position of the voxel diff --git a/library/PolyVoxCore/include/PolyVoxCore/Volume.h b/library/PolyVoxCore/include/PolyVoxCore/Volume.h index 2e662836..5b8f311b 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Volume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Volume.h @@ -130,9 +130,6 @@ namespace PolyVox uint32_t calculateSizeInBytes(void); protected: - //The border value - VoxelType m_tBorderValue; - //The size of the volume Region m_regValidRegion; diff --git a/library/PolyVoxCore/include/PolyVoxCore/Volume.inl b/library/PolyVoxCore/include/PolyVoxCore/Volume.inl index 5dd05be7..0a7f4cad 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Volume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/Volume.inl @@ -54,7 +54,8 @@ namespace PolyVox template VoxelType Volume::getBorderValue(void) const { - return m_tBorderValue; + assert(false); + return VoxelType(); } //////////////////////////////////////////////////////////////////////////////// @@ -160,7 +161,7 @@ namespace PolyVox template void Volume::setBorderValue(const VoxelType& tBorder) { - m_tBorderValue = tBorder; + assert(false); } //////////////////////////////////////////////////////////////////////////////// From 80832f49c0d5dc41ad2774602b3f79f607641706 Mon Sep 17 00:00:00 2001 From: David Williams Date: Sun, 24 Jul 2011 20:45:23 +0100 Subject: [PATCH 09/19] Compile fixes for G++ --- .../include/PolyVoxCore/LargeVolume.inl | 16 ++++++++-------- .../include/PolyVoxCore/SimpleVolume.inl | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl index a3d8c500..ea060ddb 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl @@ -135,7 +135,7 @@ namespace PolyVox template VoxelType LargeVolume::getVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos) const { - if(m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos))) + if(Volume::m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos))) { const int32_t blockX = uXPos >> m_uBlockSideLengthPower; const int32_t blockY = uYPos >> m_uBlockSideLengthPower; @@ -238,7 +238,7 @@ namespace PolyVox template bool LargeVolume::setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue) { - assert(m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos))); + assert(Volume::m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos))); const int32_t blockX = uXPos >> m_uBlockSideLengthPower; const int32_t blockY = uYPos >> m_uBlockSideLengthPower; @@ -424,10 +424,10 @@ namespace PolyVox m_pLastAccessedBlock = 0; m_bCompressionEnabled = true; - m_regValidRegion = regValidRegion; + Volume::m_regValidRegion = regValidRegion; - m_regValidRegionInBlocks.setLowerCorner(m_regValidRegion.getLowerCorner() / static_cast(uBlockSideLength)); - m_regValidRegionInBlocks.setUpperCorner(m_regValidRegion.getUpperCorner() / static_cast(uBlockSideLength)); + m_regValidRegionInBlocks.setLowerCorner(Volume::m_regValidRegion.getLowerCorner() / static_cast(uBlockSideLength)); + m_regValidRegionInBlocks.setUpperCorner(Volume::m_regValidRegion.getUpperCorner() / static_cast(uBlockSideLength)); setMaxNumberOfUncompressedBlocks(m_uMaxNumberOfUncompressedBlocks); @@ -446,9 +446,9 @@ namespace PolyVox std::fill(m_pUncompressedBorderData, m_pUncompressedBorderData + m_uBlockSideLength * m_uBlockSideLength * m_uBlockSideLength, VoxelType()); //Other properties we might find useful later - m_uLongestSideLength = (std::max)((std::max)(getWidth(),getHeight()),getDepth()); - m_uShortestSideLength = (std::min)((std::min)(getWidth(),getHeight()),getDepth()); - m_fDiagonalLength = sqrtf(static_cast(getWidth() * getWidth() + getHeight() * getHeight() + getDepth() * getDepth())); + Volume::m_uLongestSideLength = (std::max)((std::max)(Volume::getWidth(),Volume::getHeight()),Volume::getDepth()); + Volume::m_uShortestSideLength = (std::min)((std::min)(Volume::getWidth(),Volume::getHeight()),Volume::getDepth()); + Volume::m_fDiagonalLength = sqrtf(static_cast(Volume::getWidth() * Volume::getWidth() + Volume::getHeight() * Volume::getHeight() + Volume::getDepth() * Volume::getDepth())); } template diff --git a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl index 96466a58..0ba7d854 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl @@ -105,7 +105,7 @@ namespace PolyVox template VoxelType SimpleVolume::getVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos) const { - if(m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos))) + if(Volume::m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos))) { const int32_t blockX = uXPos >> m_uBlockSideLengthPower; const int32_t blockY = uYPos >> m_uBlockSideLengthPower; @@ -156,7 +156,7 @@ namespace PolyVox template bool SimpleVolume::setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue) { - assert(m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos))); + assert(Volume::m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos))); const int32_t blockX = uXPos >> m_uBlockSideLengthPower; const int32_t blockY = uYPos >> m_uBlockSideLengthPower; @@ -207,10 +207,10 @@ namespace PolyVox m_uBlockSideLength = uBlockSideLength; m_pUncompressedBorderData = 0; - m_regValidRegion = regValidRegion; + Volume::m_regValidRegion = regValidRegion; - m_regValidRegionInBlocks.setLowerCorner(m_regValidRegion.getLowerCorner() / static_cast(uBlockSideLength)); - m_regValidRegionInBlocks.setUpperCorner(m_regValidRegion.getUpperCorner() / static_cast(uBlockSideLength)); + m_regValidRegionInBlocks.setLowerCorner(Volume::m_regValidRegion.getLowerCorner() / static_cast(uBlockSideLength)); + m_regValidRegionInBlocks.setUpperCorner(Volume::m_regValidRegion.getUpperCorner() / static_cast(uBlockSideLength)); //Compute the block side length m_uBlockSideLength = uBlockSideLength; @@ -234,9 +234,9 @@ namespace PolyVox std::fill(m_pUncompressedBorderData, m_pUncompressedBorderData + m_uBlockSideLength * m_uBlockSideLength * m_uBlockSideLength, VoxelType()); //Other properties we might find useful later - m_uLongestSideLength = (std::max)((std::max)(getWidth(),getHeight()),getDepth()); - m_uShortestSideLength = (std::min)((std::min)(getWidth(),getHeight()),getDepth()); - m_fDiagonalLength = sqrtf(static_cast(getWidth() * getWidth() + getHeight() * getHeight() + getDepth() * getDepth())); + Volume::m_uLongestSideLength = (std::max)((std::max)(Volume::getWidth(),Volume::getHeight()),Volume::getDepth()); + Volume::m_uShortestSideLength = (std::min)((std::min)(Volume::getWidth(),Volume::getHeight()),Volume::getDepth()); + Volume::m_fDiagonalLength = sqrtf(static_cast(Volume::getWidth() * Volume::getWidth() + Volume::getHeight() * Volume::getHeight() + Volume::getDepth() * Volume::getDepth())); } template From 8dc1951a062e4a21b35924e75721646deac5ed69 Mon Sep 17 00:00:00 2001 From: David Williams Date: Tue, 26 Jul 2011 21:36:17 +0100 Subject: [PATCH 10/19] More work making volumes use a base class. --- .../include/PolyVoxCore/LargeVolume.h | 3 +- .../PolyVoxCore/LargeVolumeSampler.inl | 6 - .../include/PolyVoxCore/RawVolume.h | 3 +- .../include/PolyVoxCore/RawVolumeSampler.inl | 6 - .../include/PolyVoxCore/SimpleVolume.h | 5 +- .../PolyVoxCore/SimpleVolumeSampler.inl | 6 - .../PolyVoxCore/include/PolyVoxCore/Volume.h | 5 +- .../include/PolyVoxCore/VolumeSampler.inl | 124 +++++++++++------- library/PolyVoxCore/source/VoxelFilters.cpp | 7 - 9 files changed, 85 insertions(+), 80 deletions(-) diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h index 4c111ce9..382d1957 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h @@ -145,7 +145,7 @@ namespace PolyVox class LargeVolume : public Volume { public: - class Sampler : public Volume::Sampler + class Sampler : public Volume::Sampler< LargeVolume > { public: Sampler(LargeVolume* volume); @@ -157,7 +157,6 @@ namespace PolyVox int32_t getPosY(void) const; int32_t getPosZ(void) const; VoxelType getSubSampledVoxel(uint8_t uLevel) const; - const LargeVolume* getVolume(void) const; inline VoxelType getVoxel(void) const; void setPosition(const Vector3DInt32& v3dNewPos); diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl index 2b7e5371..9e667fa1 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl @@ -116,12 +116,6 @@ namespace PolyVox } } - template - const LargeVolume* LargeVolume::Sampler::getVolume(void) const - { - return mVolume; - } - template VoxelType LargeVolume::Sampler::getVoxel(void) const { diff --git a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h index 877a519e..02540249 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h @@ -38,7 +38,7 @@ namespace PolyVox { public: #ifndef SWIG - class Sampler : public Volume::Sampler + class Sampler : public Volume::Sampler< RawVolume > { public: Sampler(RawVolume* volume); @@ -47,7 +47,6 @@ namespace PolyVox int32_t getPosX(void) const; int32_t getPosY(void) const; int32_t getPosZ(void) const; - const RawVolume* getVolume(void) const; inline VoxelType getVoxel(void) const; void setPosition(const Vector3DInt32& v3dNewPos); diff --git a/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl index 63aa9827..e0f9bfff 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl @@ -63,12 +63,6 @@ namespace PolyVox return mZPosInVolume; } - template - const RawVolume* RawVolume::Sampler::getVolume(void) const - { - return mVolume; - } - template VoxelType RawVolume::Sampler::getVoxel(void) const { diff --git a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h index 788b98aa..48ea4f35 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h @@ -40,8 +40,6 @@ namespace PolyVox #ifndef SWIG class Block { - //Make Sampler a friend - friend class SimpleVolume::Sampler; public: Block(uint16_t uSideLength = 0); @@ -62,7 +60,7 @@ namespace PolyVox uint8_t m_uSideLengthPower; }; - class Sampler : public Volume::Sampler + class Sampler : public Volume::Sampler< SimpleVolume > { public: Sampler(SimpleVolume* volume); @@ -74,7 +72,6 @@ namespace PolyVox int32_t getPosY(void) const; int32_t getPosZ(void) const; VoxelType getSubSampledVoxel(uint8_t uLevel) const; - const SimpleVolume* getVolume(void) const; inline VoxelType getVoxel(void) const; void setPosition(const Vector3DInt32& v3dNewPos); diff --git a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl index bc7dcc7c..3190a8d2 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl @@ -116,12 +116,6 @@ namespace PolyVox } } - template - const SimpleVolume* SimpleVolume::Sampler::getVolume(void) const - { - return mVolume; - } - template VoxelType SimpleVolume::Sampler::getVoxel(void) const { diff --git a/library/PolyVoxCore/include/PolyVoxCore/Volume.h b/library/PolyVoxCore/include/PolyVoxCore/Volume.h index 5b8f311b..cc6a436d 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Volume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Volume.h @@ -37,13 +37,13 @@ namespace PolyVox { public: #ifndef SWIG + template class Sampler { public: int32_t getPosX(void) const; int32_t getPosY(void) const; int32_t getPosZ(void) const; - const Volume* getVolume(void) const; inline VoxelType getVoxel(void) const; void setPosition(const Vector3DInt32& v3dNewPos); @@ -86,6 +86,9 @@ namespace PolyVox inline VoxelType peekVoxel1px1py1nz(void) const; inline VoxelType peekVoxel1px1py0pz(void) const; inline VoxelType peekVoxel1px1py1pz(void) const; + + protected: + DerivedVolumeType* m_pDerivedVolume; }; #endif diff --git a/library/PolyVoxCore/include/PolyVoxCore/VolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/VolumeSampler.inl index 8103fd9c..6085d7a7 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/VolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/VolumeSampler.inl @@ -30,146 +30,160 @@ freely, subject to the following restrictions: namespace PolyVox { template - int32_t Volume::Sampler::getPosX(void) const + template + int32_t Volume::Sampler::getPosX(void) const { assert(false); return 0; } template - int32_t Volume::Sampler::getPosY(void) const + template + int32_t Volume::Sampler::getPosY(void) const { assert(false); return 0; } template - int32_t Volume::Sampler::getPosZ(void) const + template + int32_t Volume::Sampler::getPosZ(void) const { assert(false); return 0; } template - const Volume* Volume::Sampler::getVolume(void) const - { - assert(false); - return 0; - } - - template - VoxelType Volume::Sampler::getVoxel(void) const + template + VoxelType Volume::Sampler::getVoxel(void) const { assert(false); return VoxelType(); } template - void Volume::Sampler::setPosition(const Vector3DInt32& v3dNewPos) + template + void Volume::Sampler::setPosition(const Vector3DInt32& v3dNewPos) { assert(false); } template - void Volume::Sampler::setPosition(int32_t xPos, int32_t yPos, int32_t zPos) + template + void Volume::Sampler::setPosition(int32_t xPos, int32_t yPos, int32_t zPos) { assert(false); } template - void Volume::Sampler::movePositiveX(void) + template + void Volume::Sampler::movePositiveX(void) { assert(false); } template - void Volume::Sampler::movePositiveY(void) + template + void Volume::Sampler::movePositiveY(void) { assert(false); } template - void Volume::Sampler::movePositiveZ(void) + template + void Volume::Sampler::movePositiveZ(void) { assert(false); } template - void Volume::Sampler::moveNegativeX(void) + template + void Volume::Sampler::moveNegativeX(void) { assert(false); } template - void Volume::Sampler::moveNegativeY(void) + template + void Volume::Sampler::moveNegativeY(void) { assert(false); } template - void Volume::Sampler::moveNegativeZ(void) + template + void Volume::Sampler::moveNegativeZ(void) { assert(false); } template - VoxelType Volume::Sampler::peekVoxel1nx1ny1nz(void) const + template + VoxelType Volume::Sampler::peekVoxel1nx1ny1nz(void) const { assert(false); return VoxelType(); } template - VoxelType Volume::Sampler::peekVoxel1nx1ny0pz(void) const + template + VoxelType Volume::Sampler::peekVoxel1nx1ny0pz(void) const { assert(false); return VoxelType(); } template - VoxelType Volume::Sampler::peekVoxel1nx1ny1pz(void) const + template + VoxelType Volume::Sampler::peekVoxel1nx1ny1pz(void) const { assert(false); return VoxelType(); } template - VoxelType Volume::Sampler::peekVoxel1nx0py1nz(void) const + template + VoxelType Volume::Sampler::peekVoxel1nx0py1nz(void) const { assert(false); return VoxelType(); } template - VoxelType Volume::Sampler::peekVoxel1nx0py0pz(void) const + template + VoxelType Volume::Sampler::peekVoxel1nx0py0pz(void) const { assert(false); return VoxelType(); } template - VoxelType Volume::Sampler::peekVoxel1nx0py1pz(void) const + template + VoxelType Volume::Sampler::peekVoxel1nx0py1pz(void) const { assert(false); return VoxelType(); } template - VoxelType Volume::Sampler::peekVoxel1nx1py1nz(void) const + template + VoxelType Volume::Sampler::peekVoxel1nx1py1nz(void) const { assert(false); return VoxelType(); } template - VoxelType Volume::Sampler::peekVoxel1nx1py0pz(void) const + template + VoxelType Volume::Sampler::peekVoxel1nx1py0pz(void) const { assert(false); return VoxelType(); } template - VoxelType Volume::Sampler::peekVoxel1nx1py1pz(void) const + template + VoxelType Volume::Sampler::peekVoxel1nx1py1pz(void) const { assert(false); return VoxelType(); @@ -178,63 +192,72 @@ namespace PolyVox ////////////////////////////////////////////////////////////////////////// template - VoxelType Volume::Sampler::peekVoxel0px1ny1nz(void) const + template + VoxelType Volume::Sampler::peekVoxel0px1ny1nz(void) const { assert(false); return VoxelType(); } template - VoxelType Volume::Sampler::peekVoxel0px1ny0pz(void) const + template + VoxelType Volume::Sampler::peekVoxel0px1ny0pz(void) const { assert(false); return VoxelType(); } template - VoxelType Volume::Sampler::peekVoxel0px1ny1pz(void) const + template + VoxelType Volume::Sampler::peekVoxel0px1ny1pz(void) const { assert(false); return VoxelType(); } template - VoxelType Volume::Sampler::peekVoxel0px0py1nz(void) const + template + VoxelType Volume::Sampler::peekVoxel0px0py1nz(void) const { assert(false); return VoxelType(); } template - VoxelType Volume::Sampler::peekVoxel0px0py0pz(void) const + template + VoxelType Volume::Sampler::peekVoxel0px0py0pz(void) const { assert(false); return VoxelType(); } template - VoxelType Volume::Sampler::peekVoxel0px0py1pz(void) const + template + VoxelType Volume::Sampler::peekVoxel0px0py1pz(void) const { assert(false); return VoxelType(); } template - VoxelType Volume::Sampler::peekVoxel0px1py1nz(void) const + template + VoxelType Volume::Sampler::peekVoxel0px1py1nz(void) const { assert(false); return VoxelType(); } template - VoxelType Volume::Sampler::peekVoxel0px1py0pz(void) const + template + VoxelType Volume::Sampler::peekVoxel0px1py0pz(void) const { assert(false); return VoxelType(); } template - VoxelType Volume::Sampler::peekVoxel0px1py1pz(void) const + template + VoxelType Volume::Sampler::peekVoxel0px1py1pz(void) const { assert(false); return VoxelType(); @@ -243,63 +266,72 @@ namespace PolyVox ////////////////////////////////////////////////////////////////////////// template - VoxelType Volume::Sampler::peekVoxel1px1ny1nz(void) const + template + VoxelType Volume::Sampler::peekVoxel1px1ny1nz(void) const { assert(false); return VoxelType(); } template - VoxelType Volume::Sampler::peekVoxel1px1ny0pz(void) const + template + VoxelType Volume::Sampler::peekVoxel1px1ny0pz(void) const { assert(false); return VoxelType(); } template - VoxelType Volume::Sampler::peekVoxel1px1ny1pz(void) const + template + VoxelType Volume::Sampler::peekVoxel1px1ny1pz(void) const { assert(false); return VoxelType(); } template - VoxelType Volume::Sampler::peekVoxel1px0py1nz(void) const + template + VoxelType Volume::Sampler::peekVoxel1px0py1nz(void) const { assert(false); return VoxelType(); } template - VoxelType Volume::Sampler::peekVoxel1px0py0pz(void) const + template + VoxelType Volume::Sampler::peekVoxel1px0py0pz(void) const { assert(false); return VoxelType(); } template - VoxelType Volume::Sampler::peekVoxel1px0py1pz(void) const + template + VoxelType Volume::Sampler::peekVoxel1px0py1pz(void) const { assert(false); return VoxelType(); } template - VoxelType Volume::Sampler::peekVoxel1px1py1nz(void) const + template + VoxelType Volume::Sampler::peekVoxel1px1py1nz(void) const { assert(false); return VoxelType(); } template - VoxelType Volume::Sampler::peekVoxel1px1py0pz(void) const + template + VoxelType Volume::Sampler::peekVoxel1px1py0pz(void) const { assert(false); return VoxelType(); } template - VoxelType Volume::Sampler::peekVoxel1px1py1pz(void) const + template + VoxelType Volume::Sampler::peekVoxel1px1py1pz(void) const { assert(false); return VoxelType(); diff --git a/library/PolyVoxCore/source/VoxelFilters.cpp b/library/PolyVoxCore/source/VoxelFilters.cpp index e97f1fa6..45c5176c 100644 --- a/library/PolyVoxCore/source/VoxelFilters.cpp +++ b/library/PolyVoxCore/source/VoxelFilters.cpp @@ -28,13 +28,6 @@ namespace PolyVox template< template class VolumeType> float computeSmoothedVoxel(typename VolumeType::Sampler& volIter) { - assert(volIter.getPosX() >= 1); - assert(volIter.getPosY() >= 1); - assert(volIter.getPosZ() >= 1); - assert(volIter.getPosX() <= volIter.getVolume()->getWidth() - 2); - assert(volIter.getPosY() <= volIter.getVolume()->getHeight() - 2); - assert(volIter.getPosZ() <= volIter.getVolume()->getDepth() - 2); - float sum = 0.0; if(volIter.peekVoxel1nx1ny1nz() != 0) sum += 1.0f; From f847e6ad94ec0f7050eabca1d6d17a4fe9c36d63 Mon Sep 17 00:00:00 2001 From: David Williams Date: Tue, 26 Jul 2011 20:58:46 +0100 Subject: [PATCH 11/19] g++ compile fixes --- library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h | 2 +- library/PolyVoxCore/include/PolyVoxCore/RawVolume.h | 2 +- library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h index 382d1957..3452a1f0 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h @@ -145,7 +145,7 @@ namespace PolyVox class LargeVolume : public Volume { public: - class Sampler : public Volume::Sampler< LargeVolume > + class Sampler : public Volume::template Sampler< LargeVolume > { public: Sampler(LargeVolume* volume); diff --git a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h index 02540249..91c89e79 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h @@ -38,7 +38,7 @@ namespace PolyVox { public: #ifndef SWIG - class Sampler : public Volume::Sampler< RawVolume > + class Sampler : public Volume::template Sampler< RawVolume > { public: Sampler(RawVolume* volume); diff --git a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h index 48ea4f35..7391b61c 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h @@ -60,7 +60,7 @@ namespace PolyVox uint8_t m_uSideLengthPower; }; - class Sampler : public Volume::Sampler< SimpleVolume > + class Sampler : public Volume::template Sampler< SimpleVolume > { public: Sampler(SimpleVolume* volume); From f7c511b2c68da9d9509e82b17b15cd56da973fd0 Mon Sep 17 00:00:00 2001 From: David Williams Date: Wed, 27 Jul 2011 21:46:57 +0100 Subject: [PATCH 12/19] Moved volume pointer into base sampler class. --- library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h | 6 +++++- .../PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl | 4 +++- library/PolyVoxCore/include/PolyVoxCore/RawVolume.h | 6 +++++- .../PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl | 6 ++++-- library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h | 6 +++++- .../PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl | 4 +++- library/PolyVoxCore/include/PolyVoxCore/Volume.h | 2 +- 7 files changed, 26 insertions(+), 8 deletions(-) diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h index 3452a1f0..d48abdfe 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h @@ -145,7 +145,11 @@ namespace PolyVox class LargeVolume : public Volume { public: +#if defined(_MSC_VER) //DIRTY HACK!!! + class Sampler : public Volume::Sampler< LargeVolume > +#else class Sampler : public Volume::template Sampler< LargeVolume > +#endif { public: Sampler(LargeVolume* volume); @@ -203,7 +207,7 @@ namespace PolyVox private: //The current volume - LargeVolume* mVolume; + //LargeVolume* mVolume; //The current position in the volume int32_t mXPosInVolume; diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl index 9e667fa1..97798d80 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl @@ -36,8 +36,10 @@ namespace PolyVox { template LargeVolume::Sampler::Sampler(LargeVolume* volume) - :mVolume(volume) + //:mVolume(volume) { + //Dodgy doing this - need to find how to call base constructor + mVolume = volume; } template diff --git a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h index 91c89e79..0fa08c2c 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h @@ -38,7 +38,11 @@ namespace PolyVox { public: #ifndef SWIG +#if defined(_MSC_VER) //DIRTY HACK!!! + class Sampler : public Volume::Sampler< RawVolume > +#else class Sampler : public Volume::template Sampler< RawVolume > +#endif { public: Sampler(RawVolume* volume); @@ -92,7 +96,7 @@ namespace PolyVox private: //The current volume - RawVolume* mVolume; + //RawVolume* mVolume; //The current position in the volume int32_t mXPosInVolume; diff --git a/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl index e0f9bfff..99c4bc6a 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl @@ -31,13 +31,15 @@ namespace PolyVox { template RawVolume::Sampler::Sampler(RawVolume* volume) - :mVolume(volume) - ,mXPosInVolume(0) + //:mVolume(volume) + :mXPosInVolume(0) ,mYPosInVolume(0) ,mZPosInVolume(0) ,mCurrentVoxel(0) ,m_bIsCurrentPositionValid(false) { + //Dodgy doing this - need to find how to call base constructor + mVolume = volume; } template diff --git a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h index 7391b61c..eba5177a 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h @@ -60,7 +60,11 @@ namespace PolyVox uint8_t m_uSideLengthPower; }; +#if defined(_MSC_VER) //DIRTY HACK!!! + class Sampler : public Volume::Sampler< SimpleVolume > +#else class Sampler : public Volume::template Sampler< SimpleVolume > +#endif { public: Sampler(SimpleVolume* volume); @@ -118,7 +122,7 @@ namespace PolyVox private: //The current volume - SimpleVolume* mVolume; + //SimpleVolume* mVolume; //The current position in the volume int32_t mXPosInVolume; diff --git a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl index 3190a8d2..54161735 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl @@ -36,8 +36,10 @@ namespace PolyVox { template SimpleVolume::Sampler::Sampler(SimpleVolume* volume) - :mVolume(volume) + //:mVolume(volume) { + //Dodgy doing this - need to find how to call base constructor + mVolume = volume; } template diff --git a/library/PolyVoxCore/include/PolyVoxCore/Volume.h b/library/PolyVoxCore/include/PolyVoxCore/Volume.h index cc6a436d..b85eb701 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Volume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Volume.h @@ -88,7 +88,7 @@ namespace PolyVox inline VoxelType peekVoxel1px1py1pz(void) const; protected: - DerivedVolumeType* m_pDerivedVolume; + DerivedVolumeType* mVolume; }; #endif From 84c78f683986dfb76e04b2ad5eda4b8f9043a513 Mon Sep 17 00:00:00 2001 From: David Williams Date: Fri, 29 Jul 2011 22:00:22 +0100 Subject: [PATCH 13/19] More work adding base volume class. --- .../include/PolyVoxCore/LargeVolume.inl | 16 +-- .../PolyVoxCore/LargeVolumeSampler.inl | 2 +- .../include/PolyVoxCore/RawVolume.inl | 32 ++--- .../include/PolyVoxCore/RawVolumeSampler.inl | 2 +- .../include/PolyVoxCore/SimpleVolume.inl | 16 +-- .../PolyVoxCore/SimpleVolumeSampler.inl | 2 +- .../PolyVoxCore/include/PolyVoxCore/Volume.h | 4 + .../include/PolyVoxCore/VolumeSampler.inl | 113 +++++++----------- 8 files changed, 82 insertions(+), 105 deletions(-) diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl index ea060ddb..b041685c 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl @@ -135,7 +135,7 @@ namespace PolyVox template VoxelType LargeVolume::getVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos) const { - if(Volume::m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos))) + if(this->m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos))) { const int32_t blockX = uXPos >> m_uBlockSideLengthPower; const int32_t blockY = uYPos >> m_uBlockSideLengthPower; @@ -238,7 +238,7 @@ namespace PolyVox template bool LargeVolume::setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue) { - assert(Volume::m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos))); + assert(this->m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos))); const int32_t blockX = uXPos >> m_uBlockSideLengthPower; const int32_t blockY = uYPos >> m_uBlockSideLengthPower; @@ -424,10 +424,10 @@ namespace PolyVox m_pLastAccessedBlock = 0; m_bCompressionEnabled = true; - Volume::m_regValidRegion = regValidRegion; + this->m_regValidRegion = regValidRegion; - m_regValidRegionInBlocks.setLowerCorner(Volume::m_regValidRegion.getLowerCorner() / static_cast(uBlockSideLength)); - m_regValidRegionInBlocks.setUpperCorner(Volume::m_regValidRegion.getUpperCorner() / static_cast(uBlockSideLength)); + m_regValidRegionInBlocks.setLowerCorner(this->m_regValidRegion.getLowerCorner() / static_cast(uBlockSideLength)); + m_regValidRegionInBlocks.setUpperCorner(this->m_regValidRegion.getUpperCorner() / static_cast(uBlockSideLength)); setMaxNumberOfUncompressedBlocks(m_uMaxNumberOfUncompressedBlocks); @@ -446,9 +446,9 @@ namespace PolyVox std::fill(m_pUncompressedBorderData, m_pUncompressedBorderData + m_uBlockSideLength * m_uBlockSideLength * m_uBlockSideLength, VoxelType()); //Other properties we might find useful later - Volume::m_uLongestSideLength = (std::max)((std::max)(Volume::getWidth(),Volume::getHeight()),Volume::getDepth()); - Volume::m_uShortestSideLength = (std::min)((std::min)(Volume::getWidth(),Volume::getHeight()),Volume::getDepth()); - Volume::m_fDiagonalLength = sqrtf(static_cast(Volume::getWidth() * Volume::getWidth() + Volume::getHeight() * Volume::getHeight() + Volume::getDepth() * Volume::getDepth())); + this->m_uLongestSideLength = (std::max)((std::max)(this->getWidth(),this->getHeight()),this->getDepth()); + this->m_uShortestSideLength = (std::min)((std::min)(this->getWidth(),this->getHeight()),this->getDepth()); + this->m_fDiagonalLength = sqrtf(static_cast(this->getWidth() * this->getWidth() + this->getHeight() * this->getHeight() + this->getDepth() * this->getDepth())); } template diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl index 97798d80..a4db69d1 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl @@ -39,7 +39,7 @@ namespace PolyVox //:mVolume(volume) { //Dodgy doing this - need to find how to call base constructor - mVolume = volume; + this->mVolume = volume; } template diff --git a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl index 51d0ee6f..cbbdbec9 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl @@ -83,18 +83,18 @@ namespace PolyVox template VoxelType RawVolume::getVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos) const { - if(Volume::m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos))) + if(this->m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos))) { return m_pData [ uXPos + - uYPos * Volume::getWidth() + - uZPos * Volume::getWidth() * Volume::getHeight() + uYPos * this->getWidth() + + uZPos * this->getWidth() * this->getHeight() ]; } else { - return Volume::getBorderValue(); + return this->getBorderValue(); } } @@ -127,13 +127,13 @@ namespace PolyVox template bool RawVolume::setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue) { - assert(Volume::m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos))); + assert(this->m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos))); m_pData [ uXPos + - uYPos * Volume::getWidth() + - uZPos * Volume::getWidth() * Volume::getHeight() + uYPos * this->getWidth() + + uZPos * this->getWidth() * this->getHeight() ] = tValue; //Return true to indicate that we modified a voxel. @@ -157,20 +157,20 @@ namespace PolyVox template void RawVolume::resize(const Region& regValidRegion) { - Volume::m_regValidRegion = regValidRegion; + this->m_regValidRegion = regValidRegion; //Ensure dimensions of the specified Region are valid - assert(Volume::getWidth() > 0); - assert(Volume::getHeight() > 0); - assert(Volume::getDepth() > 0); + assert(this->getWidth() > 0); + assert(this->getHeight() > 0); + assert(this->getDepth() > 0); //Create the data - m_pData = new VoxelType[Volume::getWidth() * Volume::getHeight()* Volume::getDepth()]; + m_pData = new VoxelType[this->getWidth() * this->getHeight()* this->getDepth()]; //Other properties we might find useful later - Volume::m_uLongestSideLength = (std::max)((std::max)(Volume::getWidth(),Volume::getHeight()),Volume::getDepth()); - Volume::m_uShortestSideLength = (std::min)((std::min)(Volume::getWidth(),Volume::getHeight()),Volume::getDepth()); - Volume::m_fDiagonalLength = sqrtf(static_cast(Volume::getWidth() * Volume::getWidth() + Volume::getHeight() * Volume::getHeight() + Volume::getDepth() * Volume::getDepth())); + this->m_uLongestSideLength = (std::max)((std::max)(this->getWidth(),this->getHeight()),this->getDepth()); + this->m_uShortestSideLength = (std::min)((std::min)(this->getWidth(),this->getHeight()),this->getDepth()); + this->m_fDiagonalLength = sqrtf(static_cast(this->getWidth() * this->getWidth() + this->getHeight() * this->getHeight() + this->getDepth() * this->getDepth())); } //////////////////////////////////////////////////////////////////////////////// @@ -179,7 +179,7 @@ namespace PolyVox template uint32_t RawVolume::calculateSizeInBytes(void) { - return Volume::getWidth() * Volume::getHeight() * Volume::getDepth() * sizeof(VoxelType); + return this->getWidth() * this->getHeight() * this->getDepth() * sizeof(VoxelType); } } diff --git a/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl index 99c4bc6a..d1b9d736 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl @@ -39,7 +39,7 @@ namespace PolyVox ,m_bIsCurrentPositionValid(false) { //Dodgy doing this - need to find how to call base constructor - mVolume = volume; + this->mVolume = volume; } template diff --git a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl index 0ba7d854..a401ec95 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl @@ -105,7 +105,7 @@ namespace PolyVox template VoxelType SimpleVolume::getVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos) const { - if(Volume::m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos))) + if(this->m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos))) { const int32_t blockX = uXPos >> m_uBlockSideLengthPower; const int32_t blockY = uYPos >> m_uBlockSideLengthPower; @@ -156,7 +156,7 @@ namespace PolyVox template bool SimpleVolume::setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue) { - assert(Volume::m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos))); + assert(this->m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos))); const int32_t blockX = uXPos >> m_uBlockSideLengthPower; const int32_t blockY = uYPos >> m_uBlockSideLengthPower; @@ -207,10 +207,10 @@ namespace PolyVox m_uBlockSideLength = uBlockSideLength; m_pUncompressedBorderData = 0; - Volume::m_regValidRegion = regValidRegion; + this->m_regValidRegion = regValidRegion; - m_regValidRegionInBlocks.setLowerCorner(Volume::m_regValidRegion.getLowerCorner() / static_cast(uBlockSideLength)); - m_regValidRegionInBlocks.setUpperCorner(Volume::m_regValidRegion.getUpperCorner() / static_cast(uBlockSideLength)); + m_regValidRegionInBlocks.setLowerCorner(this->m_regValidRegion.getLowerCorner() / static_cast(uBlockSideLength)); + m_regValidRegionInBlocks.setUpperCorner(this->m_regValidRegion.getUpperCorner() / static_cast(uBlockSideLength)); //Compute the block side length m_uBlockSideLength = uBlockSideLength; @@ -234,9 +234,9 @@ namespace PolyVox std::fill(m_pUncompressedBorderData, m_pUncompressedBorderData + m_uBlockSideLength * m_uBlockSideLength * m_uBlockSideLength, VoxelType()); //Other properties we might find useful later - Volume::m_uLongestSideLength = (std::max)((std::max)(Volume::getWidth(),Volume::getHeight()),Volume::getDepth()); - Volume::m_uShortestSideLength = (std::min)((std::min)(Volume::getWidth(),Volume::getHeight()),Volume::getDepth()); - Volume::m_fDiagonalLength = sqrtf(static_cast(Volume::getWidth() * Volume::getWidth() + Volume::getHeight() * Volume::getHeight() + Volume::getDepth() * Volume::getDepth())); + this->m_uLongestSideLength = (std::max)((std::max)(this->getWidth(),this->getHeight()),this->getDepth()); + this->m_uShortestSideLength = (std::min)((std::min)(this->getWidth(),this->getHeight()),this->getDepth()); + this->m_fDiagonalLength = sqrtf(static_cast(this->getWidth() * this->getWidth() + this->getHeight() * this->getHeight() + this->getDepth() * this->getDepth())); } template diff --git a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl index 54161735..12d2366c 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl @@ -39,7 +39,7 @@ namespace PolyVox //:mVolume(volume) { //Dodgy doing this - need to find how to call base constructor - mVolume = volume; + this->mVolume = volume; } template diff --git a/library/PolyVoxCore/include/PolyVoxCore/Volume.h b/library/PolyVoxCore/include/PolyVoxCore/Volume.h index b85eb701..780db379 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Volume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Volume.h @@ -89,6 +89,10 @@ namespace PolyVox protected: DerivedVolumeType* mVolume; + + int32_t mXPos; + int32_t mYPos; + int32_t mZPos; }; #endif diff --git a/library/PolyVoxCore/include/PolyVoxCore/VolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/VolumeSampler.inl index 6085d7a7..25d6014d 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/VolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/VolumeSampler.inl @@ -33,160 +33,151 @@ namespace PolyVox template int32_t Volume::Sampler::getPosX(void) const { - assert(false); - return 0; + return mXPos; } template template int32_t Volume::Sampler::getPosY(void) const { - assert(false); - return 0; + return mYPos; } template template int32_t Volume::Sampler::getPosZ(void) const { - assert(false); - return 0; + return mZPos; } template template VoxelType Volume::Sampler::getVoxel(void) const { - assert(false); - return VoxelType(); + mVolume->getVoxelAt(mXPos, mYPos, mZPos); } template template void Volume::Sampler::setPosition(const Vector3DInt32& v3dNewPos) { - assert(false); + mXPos = v3dNewPos.getX(); + mYPos = v3dNewPos.getY(); + mZPos = v3dNewPos.getZ(); } template template void Volume::Sampler::setPosition(int32_t xPos, int32_t yPos, int32_t zPos) { - assert(false); + mXPos = xPos; + mYPos = yPos; + mZPos = zPos; } template template void Volume::Sampler::movePositiveX(void) { - assert(false); + mXPos++; } template template void Volume::Sampler::movePositiveY(void) { - assert(false); + mYPos++; } template template void Volume::Sampler::movePositiveZ(void) { - assert(false); + mZPos++; } template template void Volume::Sampler::moveNegativeX(void) { - assert(false); + mXPos--; } template template void Volume::Sampler::moveNegativeY(void) { - assert(false); + mYPos--; } template template void Volume::Sampler::moveNegativeZ(void) { - assert(false); + mZPos--; } template template VoxelType Volume::Sampler::peekVoxel1nx1ny1nz(void) const { - assert(false); - return VoxelType(); + mVolume->getVoxelAt(mXPos - 1, mYPos - 1, mZPos - 1); } template template VoxelType Volume::Sampler::peekVoxel1nx1ny0pz(void) const { - assert(false); - return VoxelType(); + mVolume->getVoxelAt(mXPos - 1, mYPos - 1, mZPos ); } template template VoxelType Volume::Sampler::peekVoxel1nx1ny1pz(void) const { - assert(false); - return VoxelType(); + mVolume->getVoxelAt(mXPos - 1, mYPos - 1, mZPos + 1); } template template VoxelType Volume::Sampler::peekVoxel1nx0py1nz(void) const { - assert(false); - return VoxelType(); + mVolume->getVoxelAt(mXPos - 1, mYPos , mZPos - 1); } template template VoxelType Volume::Sampler::peekVoxel1nx0py0pz(void) const { - assert(false); - return VoxelType(); + mVolume->getVoxelAt(mXPos - 1, mYPos , mZPos ); } template template VoxelType Volume::Sampler::peekVoxel1nx0py1pz(void) const { - assert(false); - return VoxelType(); + mVolume->getVoxelAt(mXPos - 1, mYPos , mZPos + 1); } template template VoxelType Volume::Sampler::peekVoxel1nx1py1nz(void) const { - assert(false); - return VoxelType(); + mVolume->getVoxelAt(mXPos - 1, mYPos + 1, mZPos - 1); } template template VoxelType Volume::Sampler::peekVoxel1nx1py0pz(void) const { - assert(false); - return VoxelType(); + mVolume->getVoxelAt(mXPos - 1, mYPos + 1, mZPos ); } template template VoxelType Volume::Sampler::peekVoxel1nx1py1pz(void) const { - assert(false); - return VoxelType(); + mVolume->getVoxelAt(mXPos - 1, mYPos + 1, mZPos + 1); } ////////////////////////////////////////////////////////////////////////// @@ -195,72 +186,63 @@ namespace PolyVox template VoxelType Volume::Sampler::peekVoxel0px1ny1nz(void) const { - assert(false); - return VoxelType(); + mVolume->getVoxelAt(mXPos , mYPos - 1, mZPos - 1); } template template VoxelType Volume::Sampler::peekVoxel0px1ny0pz(void) const { - assert(false); - return VoxelType(); + mVolume->getVoxelAt(mXPos , mYPos - 1, mZPos ); } template template VoxelType Volume::Sampler::peekVoxel0px1ny1pz(void) const { - assert(false); - return VoxelType(); + mVolume->getVoxelAt(mXPos , mYPos - 1, mZPos + 1); } template template VoxelType Volume::Sampler::peekVoxel0px0py1nz(void) const { - assert(false); - return VoxelType(); + mVolume->getVoxelAt(mXPos , mYPos , mZPos - 1); } template template VoxelType Volume::Sampler::peekVoxel0px0py0pz(void) const { - assert(false); - return VoxelType(); + mVolume->getVoxelAt(mXPos , mYPos , mZPos ); } template template VoxelType Volume::Sampler::peekVoxel0px0py1pz(void) const { - assert(false); - return VoxelType(); + mVolume->getVoxelAt(mXPos , mYPos , mZPos + 1); } template template VoxelType Volume::Sampler::peekVoxel0px1py1nz(void) const { - assert(false); - return VoxelType(); + mVolume->getVoxelAt(mXPos , mYPos + 1, mZPos - 1); } template template VoxelType Volume::Sampler::peekVoxel0px1py0pz(void) const { - assert(false); - return VoxelType(); + mVolume->getVoxelAt(mXPos , mYPos + 1, mZPos ); } template template VoxelType Volume::Sampler::peekVoxel0px1py1pz(void) const { - assert(false); - return VoxelType(); + mVolume->getVoxelAt(mXPos , mYPos + 1, mZPos + 1); } ////////////////////////////////////////////////////////////////////////// @@ -269,71 +251,62 @@ namespace PolyVox template VoxelType Volume::Sampler::peekVoxel1px1ny1nz(void) const { - assert(false); - return VoxelType(); + mVolume->getVoxelAt(mXPos + 1, mYPos - 1, mZPos - 1); } template template VoxelType Volume::Sampler::peekVoxel1px1ny0pz(void) const { - assert(false); - return VoxelType(); + mVolume->getVoxelAt(mXPos + 1, mYPos - 1, mZPos ); } template template VoxelType Volume::Sampler::peekVoxel1px1ny1pz(void) const { - assert(false); - return VoxelType(); + mVolume->getVoxelAt(mXPos + 1, mYPos - 1, mZPos + 1); } template template VoxelType Volume::Sampler::peekVoxel1px0py1nz(void) const { - assert(false); - return VoxelType(); + mVolume->getVoxelAt(mXPos + 1, mYPos , mZPos - 1); } template template VoxelType Volume::Sampler::peekVoxel1px0py0pz(void) const { - assert(false); - return VoxelType(); + mVolume->getVoxelAt(mXPos + 1, mYPos , mZPos ); } template template VoxelType Volume::Sampler::peekVoxel1px0py1pz(void) const { - assert(false); - return VoxelType(); + mVolume->getVoxelAt(mXPos + 1, mYPos , mZPos + 1); } template template VoxelType Volume::Sampler::peekVoxel1px1py1nz(void) const { - assert(false); - return VoxelType(); + mVolume->getVoxelAt(mXPos + 1, mYPos + 1, mZPos - 1); } template template VoxelType Volume::Sampler::peekVoxel1px1py0pz(void) const { - assert(false); - return VoxelType(); + mVolume->getVoxelAt(mXPos + 1, mYPos + 1, mZPos ); } template template VoxelType Volume::Sampler::peekVoxel1px1py1pz(void) const { - assert(false); - return VoxelType(); + mVolume->getVoxelAt(mXPos + 1, mYPos + 1, mZPos + 1); } } From 8b0eea1152a6053053ee13094c7fdf9cf0f4d3b9 Mon Sep 17 00:00:00 2001 From: David Williams Date: Sat, 30 Jul 2011 08:03:17 +0100 Subject: [PATCH 14/19] Added a bunch of 'this->' statements to fix compilation on g++. --- .../PolyVoxCore/LargeVolumeSampler.inl | 150 ++++++++--------- .../include/PolyVoxCore/RawVolumeSampler.inl | 84 +++++----- .../PolyVoxCore/SimpleVolumeSampler.inl | 156 +++++++++--------- 3 files changed, 195 insertions(+), 195 deletions(-) diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl index a4db69d1..d593dff0 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl @@ -26,8 +26,8 @@ freely, subject to the following restrictions: #include "PolyVoxCore/Vector.h" #include "PolyVoxCore/Region.h" -#define BORDER_LOW(x) ((( x >> mVolume->m_uBlockSideLengthPower) << mVolume->m_uBlockSideLengthPower) != x) -#define BORDER_HIGH(x) ((( (x+1) >> mVolume->m_uBlockSideLengthPower) << mVolume->m_uBlockSideLengthPower) != (x+1)) +#define BORDER_LOW(x) ((( x >> this->mVolume->m_uBlockSideLengthPower) << this->mVolume->m_uBlockSideLengthPower) != x) +#define BORDER_HIGH(x) ((( (x+1) >> this->mVolume->m_uBlockSideLengthPower) << this->mVolume->m_uBlockSideLengthPower) != (x+1)) //#define BORDER_LOW(x) (( x % mVolume->m_uBlockSideLength) != 0) //#define BORDER_HIGH(x) (( x % mVolume->m_uBlockSideLength) != mVolume->m_uBlockSideLength - 1) @@ -54,7 +54,7 @@ namespace PolyVox { return *this; } - mVolume = rhs.mVolume; + this->mVolume = rhs.mVolume; mXPosInVolume = rhs.mXPosInVolume; mYPosInVolume = rhs.mYPosInVolume; mZPosInVolume = rhs.mZPosInVolume; @@ -110,7 +110,7 @@ namespace PolyVox { for(uint8_t x = 0; x < uSize; ++x) { - tValue = (std::min)(tValue, mVolume->getVoxelAt(mXPosInVolume + x, mYPosInVolume + y, mZPosInVolume + z)); + tValue = (std::min)(tValue, this->mVolume->getVoxelAt(mXPosInVolume + x, mYPosInVolume + y, mZPosInVolume + z)); } } } @@ -137,27 +137,27 @@ namespace PolyVox mYPosInVolume = yPos; mZPosInVolume = zPos; - const int32_t uXBlock = mXPosInVolume >> mVolume->m_uBlockSideLengthPower; - const int32_t uYBlock = mYPosInVolume >> mVolume->m_uBlockSideLengthPower; - const int32_t uZBlock = mZPosInVolume >> mVolume->m_uBlockSideLengthPower; + const int32_t uXBlock = mXPosInVolume >> this->mVolume->m_uBlockSideLengthPower; + const int32_t uYBlock = mYPosInVolume >> this->mVolume->m_uBlockSideLengthPower; + const int32_t uZBlock = mZPosInVolume >> this->mVolume->m_uBlockSideLengthPower; - const uint16_t uXPosInBlock = mXPosInVolume - (uXBlock << mVolume->m_uBlockSideLengthPower); - const uint16_t uYPosInBlock = mYPosInVolume - (uYBlock << mVolume->m_uBlockSideLengthPower); - const uint16_t uZPosInBlock = mZPosInVolume - (uZBlock << mVolume->m_uBlockSideLengthPower); + const uint16_t uXPosInBlock = mXPosInVolume - (uXBlock << this->mVolume->m_uBlockSideLengthPower); + const uint16_t uYPosInBlock = mYPosInVolume - (uYBlock << this->mVolume->m_uBlockSideLengthPower); + const uint16_t uZPosInBlock = mZPosInVolume - (uZBlock << this->mVolume->m_uBlockSideLengthPower); const uint32_t uVoxelIndexInBlock = uXPosInBlock + - uYPosInBlock * mVolume->m_uBlockSideLength + - uZPosInBlock * mVolume->m_uBlockSideLength * mVolume->m_uBlockSideLength; + uYPosInBlock * this->mVolume->m_uBlockSideLength + + uZPosInBlock * this->mVolume->m_uBlockSideLength * this->mVolume->m_uBlockSideLength; - if(mVolume->m_regValidRegionInBlocks.containsPoint(Vector3DInt32(uXBlock, uYBlock, uZBlock))) + if(this->mVolume->m_regValidRegionInBlocks.containsPoint(Vector3DInt32(uXBlock, uYBlock, uZBlock))) { - Block* pUncompressedCurrentBlock = mVolume->getUncompressedBlock(uXBlock, uYBlock, uZBlock); + Block* pUncompressedCurrentBlock = this->mVolume->getUncompressedBlock(uXBlock, uYBlock, uZBlock); mCurrentVoxel = pUncompressedCurrentBlock->m_tUncompressedData + uVoxelIndexInBlock; } else { - mCurrentVoxel = mVolume->m_pUncompressedBorderData + uVoxelIndexInBlock; + mCurrentVoxel = this->mVolume->m_pUncompressedBorderData + uVoxelIndexInBlock; } } @@ -165,7 +165,7 @@ namespace PolyVox void LargeVolume::Sampler::movePositiveX(void) { //Note the *pre* increament here - if((++mXPosInVolume) % mVolume->m_uBlockSideLength != 0) + if((++mXPosInVolume) % this->mVolume->m_uBlockSideLength != 0) { //No need to compute new block. ++mCurrentVoxel; @@ -181,10 +181,10 @@ namespace PolyVox void LargeVolume::Sampler::movePositiveY(void) { //Note the *pre* increament here - if((++mYPosInVolume) % mVolume->m_uBlockSideLength != 0) + if((++mYPosInVolume) % this->mVolume->m_uBlockSideLength != 0) { //No need to compute new block. - mCurrentVoxel += mVolume->m_uBlockSideLength; + mCurrentVoxel += this->mVolume->m_uBlockSideLength; } else { @@ -197,10 +197,10 @@ namespace PolyVox void LargeVolume::Sampler::movePositiveZ(void) { //Note the *pre* increament here - if((++mZPosInVolume) % mVolume->m_uBlockSideLength != 0) + if((++mZPosInVolume) % this->mVolume->m_uBlockSideLength != 0) { //No need to compute new block. - mCurrentVoxel += mVolume->m_uBlockSideLength * mVolume->m_uBlockSideLength; + mCurrentVoxel += this->mVolume->m_uBlockSideLength * this->mVolume->m_uBlockSideLength; } else { @@ -213,7 +213,7 @@ namespace PolyVox void LargeVolume::Sampler::moveNegativeX(void) { //Note the *post* decreament here - if((mXPosInVolume--) % mVolume->m_uBlockSideLength != 0) + if((mXPosInVolume--) % this->mVolume->m_uBlockSideLength != 0) { //No need to compute new block. --mCurrentVoxel; @@ -229,10 +229,10 @@ namespace PolyVox void LargeVolume::Sampler::moveNegativeY(void) { //Note the *post* decreament here - if((mYPosInVolume--) % mVolume->m_uBlockSideLength != 0) + if((mYPosInVolume--) % this->mVolume->m_uBlockSideLength != 0) { //No need to compute new block. - mCurrentVoxel -= mVolume->m_uBlockSideLength; + mCurrentVoxel -= this->mVolume->m_uBlockSideLength; } else { @@ -245,10 +245,10 @@ namespace PolyVox void LargeVolume::Sampler::moveNegativeZ(void) { //Note the *post* decreament here - if((mZPosInVolume--) % mVolume->m_uBlockSideLength != 0) + if((mZPosInVolume--) % this->mVolume->m_uBlockSideLength != 0) { //No need to compute new block. - mCurrentVoxel -= mVolume->m_uBlockSideLength * mVolume->m_uBlockSideLength; + mCurrentVoxel -= this->mVolume->m_uBlockSideLength * this->mVolume->m_uBlockSideLength; } else { @@ -262,9 +262,9 @@ namespace PolyVox { if( BORDER_LOW(mXPosInVolume) && BORDER_LOW(mYPosInVolume) && BORDER_LOW(mZPosInVolume) ) { - return *(mCurrentVoxel - 1 - mVolume->m_uBlockSideLength - mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength); + return *(mCurrentVoxel - 1 - this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume-1); + return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume-1); } template @@ -272,9 +272,9 @@ namespace PolyVox { if( BORDER_LOW(mXPosInVolume) && BORDER_LOW(mYPosInVolume) ) { - return *(mCurrentVoxel - 1 - mVolume->m_uBlockSideLength); + return *(mCurrentVoxel - 1 - this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume); + return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume); } template @@ -282,9 +282,9 @@ namespace PolyVox { if( BORDER_LOW(mXPosInVolume) && BORDER_LOW(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) ) { - return *(mCurrentVoxel - 1 - mVolume->m_uBlockSideLength + mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength); + return *(mCurrentVoxel - 1 - this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume+1); + return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume+1); } template @@ -292,9 +292,9 @@ namespace PolyVox { if( BORDER_LOW(mXPosInVolume) && BORDER_LOW(mZPosInVolume) ) { - return *(mCurrentVoxel - 1 - mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength); + return *(mCurrentVoxel - 1 - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume-1); + return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume-1); } template @@ -304,7 +304,7 @@ namespace PolyVox { return *(mCurrentVoxel - 1); } - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume); + return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume); } template @@ -312,9 +312,9 @@ namespace PolyVox { if( BORDER_LOW(mXPosInVolume) && BORDER_HIGH(mZPosInVolume) ) { - return *(mCurrentVoxel - 1 + mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength); + return *(mCurrentVoxel - 1 + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume+1); + return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume+1); } template @@ -322,9 +322,9 @@ namespace PolyVox { if( BORDER_LOW(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) && BORDER_LOW(mYPosInVolume) ) { - return *(mCurrentVoxel - 1 + mVolume->m_uBlockSideLength - mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength); + return *(mCurrentVoxel - 1 + this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume-1); + return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume-1); } template @@ -332,9 +332,9 @@ namespace PolyVox { if( BORDER_LOW(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) ) { - return *(mCurrentVoxel - 1 + mVolume->m_uBlockSideLength); + return *(mCurrentVoxel - 1 + this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume); + return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume); } template @@ -342,9 +342,9 @@ namespace PolyVox { if( BORDER_LOW(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) ) { - return *(mCurrentVoxel - 1 + mVolume->m_uBlockSideLength + mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength); + return *(mCurrentVoxel - 1 + this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume+1); + return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume+1); } ////////////////////////////////////////////////////////////////////////// @@ -354,9 +354,9 @@ namespace PolyVox { if( BORDER_LOW(mYPosInVolume) && BORDER_LOW(mZPosInVolume) ) { - return *(mCurrentVoxel - mVolume->m_uBlockSideLength - mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength); + return *(mCurrentVoxel - this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume-1); + return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume-1); } template @@ -364,9 +364,9 @@ namespace PolyVox { if( BORDER_LOW(mYPosInVolume) ) { - return *(mCurrentVoxel - mVolume->m_uBlockSideLength); + return *(mCurrentVoxel - this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume); + return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume); } template @@ -374,9 +374,9 @@ namespace PolyVox { if( BORDER_LOW(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) ) { - return *(mCurrentVoxel - mVolume->m_uBlockSideLength + mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength); + return *(mCurrentVoxel - this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume+1); + return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume+1); } template @@ -384,9 +384,9 @@ namespace PolyVox { if( BORDER_LOW(mZPosInVolume) ) { - return *(mCurrentVoxel - mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength); + return *(mCurrentVoxel - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume,mZPosInVolume-1); + return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume,mZPosInVolume-1); } template @@ -400,9 +400,9 @@ namespace PolyVox { if( BORDER_HIGH(mZPosInVolume) ) { - return *(mCurrentVoxel + mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength); + return *(mCurrentVoxel + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume,mZPosInVolume+1); + return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume,mZPosInVolume+1); } template @@ -410,9 +410,9 @@ namespace PolyVox { if( BORDER_HIGH(mYPosInVolume) && BORDER_LOW(mZPosInVolume) ) { - return *(mCurrentVoxel + mVolume->m_uBlockSideLength - mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength); + return *(mCurrentVoxel + this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume-1); + return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume-1); } template @@ -420,9 +420,9 @@ namespace PolyVox { if( BORDER_HIGH(mYPosInVolume) ) { - return *(mCurrentVoxel + mVolume->m_uBlockSideLength); + return *(mCurrentVoxel + this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume); + return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume); } template @@ -430,9 +430,9 @@ namespace PolyVox { if( BORDER_HIGH(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) ) { - return *(mCurrentVoxel + mVolume->m_uBlockSideLength + mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength); + return *(mCurrentVoxel + this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume+1); + return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume+1); } ////////////////////////////////////////////////////////////////////////// @@ -442,9 +442,9 @@ namespace PolyVox { if( BORDER_HIGH(mXPosInVolume) && BORDER_LOW(mYPosInVolume) && BORDER_LOW(mZPosInVolume) ) { - return *(mCurrentVoxel + 1 - mVolume->m_uBlockSideLength - mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength); + return *(mCurrentVoxel + 1 - this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume-1); + return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume-1); } template @@ -452,9 +452,9 @@ namespace PolyVox { if( BORDER_HIGH(mXPosInVolume) && BORDER_LOW(mYPosInVolume) ) { - return *(mCurrentVoxel + 1 - mVolume->m_uBlockSideLength); + return *(mCurrentVoxel + 1 - this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume); + return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume); } template @@ -462,9 +462,9 @@ namespace PolyVox { if( BORDER_HIGH(mXPosInVolume) && BORDER_LOW(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) ) { - return *(mCurrentVoxel + 1 - mVolume->m_uBlockSideLength + mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength); + return *(mCurrentVoxel + 1 - this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume+1); + return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume+1); } template @@ -472,9 +472,9 @@ namespace PolyVox { if( BORDER_HIGH(mXPosInVolume) && BORDER_LOW(mZPosInVolume) ) { - return *(mCurrentVoxel + 1 - mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength); + return *(mCurrentVoxel + 1 - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume-1); + return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume-1); } template @@ -484,7 +484,7 @@ namespace PolyVox { return *(mCurrentVoxel + 1); } - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume); + return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume); } template @@ -492,9 +492,9 @@ namespace PolyVox { if( BORDER_HIGH(mXPosInVolume) && BORDER_HIGH(mZPosInVolume) ) { - return *(mCurrentVoxel + 1 + mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength); + return *(mCurrentVoxel + 1 + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume+1); + return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume+1); } template @@ -502,9 +502,9 @@ namespace PolyVox { if( BORDER_HIGH(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) && BORDER_LOW(mZPosInVolume) ) { - return *(mCurrentVoxel + 1 + mVolume->m_uBlockSideLength - mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength); + return *(mCurrentVoxel + 1 + this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume-1); + return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume-1); } template @@ -512,9 +512,9 @@ namespace PolyVox { if( BORDER_HIGH(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) ) { - return *(mCurrentVoxel + 1 + mVolume->m_uBlockSideLength); + return *(mCurrentVoxel + 1 + this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume); + return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume); } template @@ -522,8 +522,8 @@ namespace PolyVox { if( BORDER_HIGH(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) ) { - return *(mCurrentVoxel + 1 + mVolume->m_uBlockSideLength + mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength); + return *(mCurrentVoxel + 1 + this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume+1); + return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume+1); } } diff --git a/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl index d1b9d736..a123d099 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl @@ -31,7 +31,7 @@ namespace PolyVox { template RawVolume::Sampler::Sampler(RawVolume* volume) - //:mVolume(volume) + //:this->mVolume(volume) :mXPosInVolume(0) ,mYPosInVolume(0) ,mZPosInVolume(0) @@ -68,7 +68,7 @@ namespace PolyVox template VoxelType RawVolume::Sampler::getVoxel(void) const { - return m_bIsCurrentPositionValid ? *mCurrentVoxel : mVolume->getBorderValue(); + return m_bIsCurrentPositionValid ? *mCurrentVoxel : this->mVolume->getBorderValue(); } template @@ -85,12 +85,12 @@ namespace PolyVox mZPosInVolume = zPos; const uint32_t uVoxelIndex = xPos + - yPos * mVolume->getWidth() + - zPos * mVolume->getWidth() * mVolume->getHeight(); + yPos * this->mVolume->getWidth() + + zPos * this->mVolume->getWidth() * this->mVolume->getHeight(); - mCurrentVoxel = mVolume->m_pData + uVoxelIndex; + mCurrentVoxel = this->mVolume->m_pData + uVoxelIndex; - m_bIsCurrentPositionValid = mVolume->getEnclosingRegion().containsPoint(Vector3DInt32(xPos, yPos, zPos)); + m_bIsCurrentPositionValid = this->mVolume->getEnclosingRegion().containsPoint(Vector3DInt32(xPos, yPos, zPos)); } template @@ -98,23 +98,23 @@ namespace PolyVox { mXPosInVolume++; ++mCurrentVoxel; - m_bIsCurrentPositionValid = mXPosInVolume <= mVolume->getEnclosingRegion().getUpperCorner().getX(); + m_bIsCurrentPositionValid = mXPosInVolume <= this->mVolume->getEnclosingRegion().getUpperCorner().getX(); } template void RawVolume::Sampler::movePositiveY(void) { mYPosInVolume++; - mCurrentVoxel += mVolume->getWidth(); - m_bIsCurrentPositionValid = mYPosInVolume <= mVolume->getEnclosingRegion().getUpperCorner().getY(); + mCurrentVoxel += this->mVolume->getWidth(); + m_bIsCurrentPositionValid = mYPosInVolume <= this->mVolume->getEnclosingRegion().getUpperCorner().getY(); } template void RawVolume::Sampler::movePositiveZ(void) { mZPosInVolume++; - mCurrentVoxel += mVolume->getWidth() * mVolume->getHeight(); - m_bIsCurrentPositionValid = mZPosInVolume <= mVolume->getEnclosingRegion().getUpperCorner().getZ(); + mCurrentVoxel += this->mVolume->getWidth() * this->mVolume->getHeight(); + m_bIsCurrentPositionValid = mZPosInVolume <= this->mVolume->getEnclosingRegion().getUpperCorner().getZ(); } template @@ -122,77 +122,77 @@ namespace PolyVox { mXPosInVolume--; --mCurrentVoxel; - m_bIsCurrentPositionValid = mXPosInVolume >= mVolume->getEnclosingRegion().getLowerCorner().getX(); + m_bIsCurrentPositionValid = mXPosInVolume >= this->mVolume->getEnclosingRegion().getLowerCorner().getX(); } template void RawVolume::Sampler::moveNegativeY(void) { mYPosInVolume--; - mCurrentVoxel -= mVolume->getWidth(); - m_bIsCurrentPositionValid = mYPosInVolume >= mVolume->getEnclosingRegion().getLowerCorner().getY(); + mCurrentVoxel -= this->mVolume->getWidth(); + m_bIsCurrentPositionValid = mYPosInVolume >= this->mVolume->getEnclosingRegion().getLowerCorner().getY(); } template void RawVolume::Sampler::moveNegativeZ(void) { mZPosInVolume--; - mCurrentVoxel -= mVolume->getWidth() * mVolume->getHeight(); - m_bIsCurrentPositionValid =mZPosInVolume >= mVolume->getEnclosingRegion().getLowerCorner().getZ(); + mCurrentVoxel -= this->mVolume->getWidth() * this->mVolume->getHeight(); + m_bIsCurrentPositionValid =mZPosInVolume >= this->mVolume->getEnclosingRegion().getLowerCorner().getZ(); } template VoxelType RawVolume::Sampler::peekVoxel1nx1ny1nz(void) const { - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume-1); + return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume-1); } template VoxelType RawVolume::Sampler::peekVoxel1nx1ny0pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume); + return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume); } template VoxelType RawVolume::Sampler::peekVoxel1nx1ny1pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume+1); + return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume+1); } template VoxelType RawVolume::Sampler::peekVoxel1nx0py1nz(void) const { - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume-1); + return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume-1); } template VoxelType RawVolume::Sampler::peekVoxel1nx0py0pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume); + return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume); } template VoxelType RawVolume::Sampler::peekVoxel1nx0py1pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume+1); + return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume+1); } template VoxelType RawVolume::Sampler::peekVoxel1nx1py1nz(void) const { - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume-1); + return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume-1); } template VoxelType RawVolume::Sampler::peekVoxel1nx1py0pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume); + return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume); } template VoxelType RawVolume::Sampler::peekVoxel1nx1py1pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume+1); + return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume+1); } ////////////////////////////////////////////////////////////////////////// @@ -200,25 +200,25 @@ namespace PolyVox template VoxelType RawVolume::Sampler::peekVoxel0px1ny1nz(void) const { - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume-1); + return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume-1); } template VoxelType RawVolume::Sampler::peekVoxel0px1ny0pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume); + return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume); } template VoxelType RawVolume::Sampler::peekVoxel0px1ny1pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume+1); + return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume+1); } template VoxelType RawVolume::Sampler::peekVoxel0px0py1nz(void) const { - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume,mZPosInVolume-1); + return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume,mZPosInVolume-1); } template @@ -230,25 +230,25 @@ namespace PolyVox template VoxelType RawVolume::Sampler::peekVoxel0px0py1pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume,mZPosInVolume+1); + return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume,mZPosInVolume+1); } template VoxelType RawVolume::Sampler::peekVoxel0px1py1nz(void) const { - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume-1); + return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume-1); } template VoxelType RawVolume::Sampler::peekVoxel0px1py0pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume); + return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume); } template VoxelType RawVolume::Sampler::peekVoxel0px1py1pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume+1); + return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume+1); } ////////////////////////////////////////////////////////////////////////// @@ -256,54 +256,54 @@ namespace PolyVox template VoxelType RawVolume::Sampler::peekVoxel1px1ny1nz(void) const { - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume-1); + return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume-1); } template VoxelType RawVolume::Sampler::peekVoxel1px1ny0pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume); + return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume); } template VoxelType RawVolume::Sampler::peekVoxel1px1ny1pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume+1); + return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume+1); } template VoxelType RawVolume::Sampler::peekVoxel1px0py1nz(void) const { - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume-1); + return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume-1); } template VoxelType RawVolume::Sampler::peekVoxel1px0py0pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume); + return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume); } template VoxelType RawVolume::Sampler::peekVoxel1px0py1pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume+1); + return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume+1); } template VoxelType RawVolume::Sampler::peekVoxel1px1py1nz(void) const { - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume-1); + return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume-1); } template VoxelType RawVolume::Sampler::peekVoxel1px1py0pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume); + return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume); } template VoxelType RawVolume::Sampler::peekVoxel1px1py1pz(void) const { - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume+1); + return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume+1); } } diff --git a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl index 12d2366c..4b7edc24 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl @@ -26,17 +26,17 @@ freely, subject to the following restrictions: #include "PolyVoxCore/Vector.h" #include "PolyVoxCore/Region.h" -#define BORDER_LOW(x) ((( x >> mVolume->m_uBlockSideLengthPower) << mVolume->m_uBlockSideLengthPower) != x) -#define BORDER_HIGH(x) ((( (x+1) >> mVolume->m_uBlockSideLengthPower) << mVolume->m_uBlockSideLengthPower) != (x+1)) -//#define BORDER_LOW(x) (( x % mVolume->m_uBlockSideLength) != 0) -//#define BORDER_HIGH(x) (( x % mVolume->m_uBlockSideLength) != mVolume->m_uBlockSideLength - 1) +#define BORDER_LOW(x) ((( x >> this->mVolume->m_uBlockSideLengthPower) << this->mVolume->m_uBlockSideLengthPower) != x) +#define BORDER_HIGH(x) ((( (x+1) >> this->mVolume->m_uBlockSideLengthPower) << this->mVolume->m_uBlockSideLengthPower) != (x+1)) +//#define BORDER_LOW(x) (( x % this->mVolume->m_uBlockSideLength) != 0) +//#define BORDER_HIGH(x) (( x % this->mVolume->m_uBlockSideLength) != this->mVolume->m_uBlockSideLength - 1) #include namespace PolyVox { template SimpleVolume::Sampler::Sampler(SimpleVolume* volume) - //:mVolume(volume) + //:this->mVolume(volume) { //Dodgy doing this - need to find how to call base constructor this->mVolume = volume; @@ -54,7 +54,7 @@ namespace PolyVox { return *this; } - mVolume = rhs.mVolume; + this->mVolume = rhs.mVolume; mXPosInVolume = rhs.mXPosInVolume; mYPosInVolume = rhs.mYPosInVolume; mZPosInVolume = rhs.mZPosInVolume; @@ -110,7 +110,7 @@ namespace PolyVox { for(uint8_t x = 0; x < uSize; ++x) { - tValue = (std::min)(tValue, mVolume->getVoxelAt(mXPosInVolume + x, mYPosInVolume + y, mZPosInVolume + z)); + tValue = (std::min)(tValue, this->mVolume->getVoxelAt(mXPosInVolume + x, mYPosInVolume + y, mZPosInVolume + z)); } } } @@ -137,27 +137,27 @@ namespace PolyVox mYPosInVolume = yPos; mZPosInVolume = zPos; - const int32_t uXBlock = mXPosInVolume >> mVolume->m_uBlockSideLengthPower; - const int32_t uYBlock = mYPosInVolume >> mVolume->m_uBlockSideLengthPower; - const int32_t uZBlock = mZPosInVolume >> mVolume->m_uBlockSideLengthPower; + const int32_t uXBlock = mXPosInVolume >> this->mVolume->m_uBlockSideLengthPower; + const int32_t uYBlock = mYPosInVolume >> this->mVolume->m_uBlockSideLengthPower; + const int32_t uZBlock = mZPosInVolume >> this->mVolume->m_uBlockSideLengthPower; - const uint16_t uXPosInBlock = mXPosInVolume - (uXBlock << mVolume->m_uBlockSideLengthPower); - const uint16_t uYPosInBlock = mYPosInVolume - (uYBlock << mVolume->m_uBlockSideLengthPower); - const uint16_t uZPosInBlock = mZPosInVolume - (uZBlock << mVolume->m_uBlockSideLengthPower); + const uint16_t uXPosInBlock = mXPosInVolume - (uXBlock << this->mVolume->m_uBlockSideLengthPower); + const uint16_t uYPosInBlock = mYPosInVolume - (uYBlock << this->mVolume->m_uBlockSideLengthPower); + const uint16_t uZPosInBlock = mZPosInVolume - (uZBlock << this->mVolume->m_uBlockSideLengthPower); const uint32_t uVoxelIndexInBlock = uXPosInBlock + - uYPosInBlock * mVolume->m_uBlockSideLength + - uZPosInBlock * mVolume->m_uBlockSideLength * mVolume->m_uBlockSideLength; + uYPosInBlock * this->mVolume->m_uBlockSideLength + + uZPosInBlock * this->mVolume->m_uBlockSideLength * this->mVolume->m_uBlockSideLength; - if(mVolume->m_regValidRegionInBlocks.containsPoint(Vector3DInt32(uXBlock, uYBlock, uZBlock))) + if(this->mVolume->m_regValidRegionInBlocks.containsPoint(Vector3DInt32(uXBlock, uYBlock, uZBlock))) { - Block* pUncompressedCurrentBlock = mVolume->getUncompressedBlock(uXBlock, uYBlock, uZBlock); + Block* pUncompressedCurrentBlock = this->mVolume->getUncompressedBlock(uXBlock, uYBlock, uZBlock); mCurrentVoxel = pUncompressedCurrentBlock->m_tUncompressedData + uVoxelIndexInBlock; } else { - mCurrentVoxel = mVolume->m_pUncompressedBorderData + uVoxelIndexInBlock; + mCurrentVoxel = this->mVolume->m_pUncompressedBorderData + uVoxelIndexInBlock; } } @@ -165,7 +165,7 @@ namespace PolyVox void SimpleVolume::Sampler::movePositiveX(void) { //Note the *pre* increament here - if((++mXPosInVolume) % mVolume->m_uBlockSideLength != 0) + if((++mXPosInVolume) % this->mVolume->m_uBlockSideLength != 0) { //No need to compute new block. ++mCurrentVoxel; @@ -181,10 +181,10 @@ namespace PolyVox void SimpleVolume::Sampler::movePositiveY(void) { //Note the *pre* increament here - if((++mYPosInVolume) % mVolume->m_uBlockSideLength != 0) + if((++mYPosInVolume) % this->mVolume->m_uBlockSideLength != 0) { //No need to compute new block. - mCurrentVoxel += mVolume->m_uBlockSideLength; + mCurrentVoxel += this->mVolume->m_uBlockSideLength; } else { @@ -197,10 +197,10 @@ namespace PolyVox void SimpleVolume::Sampler::movePositiveZ(void) { //Note the *pre* increament here - if((++mZPosInVolume) % mVolume->m_uBlockSideLength != 0) + if((++mZPosInVolume) % this->mVolume->m_uBlockSideLength != 0) { //No need to compute new block. - mCurrentVoxel += mVolume->m_uBlockSideLength * mVolume->m_uBlockSideLength; + mCurrentVoxel += this->mVolume->m_uBlockSideLength * this->mVolume->m_uBlockSideLength; } else { @@ -213,7 +213,7 @@ namespace PolyVox void SimpleVolume::Sampler::moveNegativeX(void) { //Note the *post* decreament here - if((mXPosInVolume--) % mVolume->m_uBlockSideLength != 0) + if((mXPosInVolume--) % this->mVolume->m_uBlockSideLength != 0) { //No need to compute new block. --mCurrentVoxel; @@ -229,10 +229,10 @@ namespace PolyVox void SimpleVolume::Sampler::moveNegativeY(void) { //Note the *post* decreament here - if((mYPosInVolume--) % mVolume->m_uBlockSideLength != 0) + if((mYPosInVolume--) % this->mVolume->m_uBlockSideLength != 0) { //No need to compute new block. - mCurrentVoxel -= mVolume->m_uBlockSideLength; + mCurrentVoxel -= this->mVolume->m_uBlockSideLength; } else { @@ -245,10 +245,10 @@ namespace PolyVox void SimpleVolume::Sampler::moveNegativeZ(void) { //Note the *post* decreament here - if((mZPosInVolume--) % mVolume->m_uBlockSideLength != 0) + if((mZPosInVolume--) % this->mVolume->m_uBlockSideLength != 0) { //No need to compute new block. - mCurrentVoxel -= mVolume->m_uBlockSideLength * mVolume->m_uBlockSideLength; + mCurrentVoxel -= this->mVolume->m_uBlockSideLength * this->mVolume->m_uBlockSideLength; } else { @@ -262,9 +262,9 @@ namespace PolyVox { if( BORDER_LOW(mXPosInVolume) && BORDER_LOW(mYPosInVolume) && BORDER_LOW(mZPosInVolume) ) { - return *(mCurrentVoxel - 1 - mVolume->m_uBlockSideLength - mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength); + return *(mCurrentVoxel - 1 - this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume-1); + return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume-1); } template @@ -272,9 +272,9 @@ namespace PolyVox { if( BORDER_LOW(mXPosInVolume) && BORDER_LOW(mYPosInVolume) ) { - return *(mCurrentVoxel - 1 - mVolume->m_uBlockSideLength); + return *(mCurrentVoxel - 1 - this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume); + return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume); } template @@ -282,9 +282,9 @@ namespace PolyVox { if( BORDER_LOW(mXPosInVolume) && BORDER_LOW(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) ) { - return *(mCurrentVoxel - 1 - mVolume->m_uBlockSideLength + mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength); + return *(mCurrentVoxel - 1 - this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume+1); + return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume+1); } template @@ -292,9 +292,9 @@ namespace PolyVox { if( BORDER_LOW(mXPosInVolume) && BORDER_LOW(mZPosInVolume) ) { - return *(mCurrentVoxel - 1 - mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength); + return *(mCurrentVoxel - 1 - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume-1); + return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume-1); } template @@ -304,7 +304,7 @@ namespace PolyVox { return *(mCurrentVoxel - 1); } - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume); + return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume); } template @@ -312,9 +312,9 @@ namespace PolyVox { if( BORDER_LOW(mXPosInVolume) && BORDER_HIGH(mZPosInVolume) ) { - return *(mCurrentVoxel - 1 + mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength); + return *(mCurrentVoxel - 1 + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume+1); + return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume+1); } template @@ -322,9 +322,9 @@ namespace PolyVox { if( BORDER_LOW(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) && BORDER_LOW(mYPosInVolume) ) { - return *(mCurrentVoxel - 1 + mVolume->m_uBlockSideLength - mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength); + return *(mCurrentVoxel - 1 + this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume-1); + return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume-1); } template @@ -332,9 +332,9 @@ namespace PolyVox { if( BORDER_LOW(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) ) { - return *(mCurrentVoxel - 1 + mVolume->m_uBlockSideLength); + return *(mCurrentVoxel - 1 + this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume); + return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume); } template @@ -342,9 +342,9 @@ namespace PolyVox { if( BORDER_LOW(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) ) { - return *(mCurrentVoxel - 1 + mVolume->m_uBlockSideLength + mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength); + return *(mCurrentVoxel - 1 + this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume+1); + return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume+1); } ////////////////////////////////////////////////////////////////////////// @@ -354,9 +354,9 @@ namespace PolyVox { if( BORDER_LOW(mYPosInVolume) && BORDER_LOW(mZPosInVolume) ) { - return *(mCurrentVoxel - mVolume->m_uBlockSideLength - mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength); + return *(mCurrentVoxel - this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume-1); + return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume-1); } template @@ -364,9 +364,9 @@ namespace PolyVox { if( BORDER_LOW(mYPosInVolume) ) { - return *(mCurrentVoxel - mVolume->m_uBlockSideLength); + return *(mCurrentVoxel - this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume); + return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume); } template @@ -374,9 +374,9 @@ namespace PolyVox { if( BORDER_LOW(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) ) { - return *(mCurrentVoxel - mVolume->m_uBlockSideLength + mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength); + return *(mCurrentVoxel - this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume+1); + return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume+1); } template @@ -384,9 +384,9 @@ namespace PolyVox { if( BORDER_LOW(mZPosInVolume) ) { - return *(mCurrentVoxel - mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength); + return *(mCurrentVoxel - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume,mZPosInVolume-1); + return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume,mZPosInVolume-1); } template @@ -400,9 +400,9 @@ namespace PolyVox { if( BORDER_HIGH(mZPosInVolume) ) { - return *(mCurrentVoxel + mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength); + return *(mCurrentVoxel + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume,mZPosInVolume+1); + return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume,mZPosInVolume+1); } template @@ -410,9 +410,9 @@ namespace PolyVox { if( BORDER_HIGH(mYPosInVolume) && BORDER_LOW(mZPosInVolume) ) { - return *(mCurrentVoxel + mVolume->m_uBlockSideLength - mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength); + return *(mCurrentVoxel + this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume-1); + return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume-1); } template @@ -420,9 +420,9 @@ namespace PolyVox { if( BORDER_HIGH(mYPosInVolume) ) { - return *(mCurrentVoxel + mVolume->m_uBlockSideLength); + return *(mCurrentVoxel + this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume); + return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume); } template @@ -430,9 +430,9 @@ namespace PolyVox { if( BORDER_HIGH(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) ) { - return *(mCurrentVoxel + mVolume->m_uBlockSideLength + mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength); + return *(mCurrentVoxel + this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume+1); + return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume+1); } ////////////////////////////////////////////////////////////////////////// @@ -442,9 +442,9 @@ namespace PolyVox { if( BORDER_HIGH(mXPosInVolume) && BORDER_LOW(mYPosInVolume) && BORDER_LOW(mZPosInVolume) ) { - return *(mCurrentVoxel + 1 - mVolume->m_uBlockSideLength - mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength); + return *(mCurrentVoxel + 1 - this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume-1); + return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume-1); } template @@ -452,9 +452,9 @@ namespace PolyVox { if( BORDER_HIGH(mXPosInVolume) && BORDER_LOW(mYPosInVolume) ) { - return *(mCurrentVoxel + 1 - mVolume->m_uBlockSideLength); + return *(mCurrentVoxel + 1 - this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume); + return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume); } template @@ -462,9 +462,9 @@ namespace PolyVox { if( BORDER_HIGH(mXPosInVolume) && BORDER_LOW(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) ) { - return *(mCurrentVoxel + 1 - mVolume->m_uBlockSideLength + mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength); + return *(mCurrentVoxel + 1 - this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume+1); + return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume+1); } template @@ -472,9 +472,9 @@ namespace PolyVox { if( BORDER_HIGH(mXPosInVolume) && BORDER_LOW(mZPosInVolume) ) { - return *(mCurrentVoxel + 1 - mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength); + return *(mCurrentVoxel + 1 - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume-1); + return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume-1); } template @@ -484,7 +484,7 @@ namespace PolyVox { return *(mCurrentVoxel + 1); } - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume); + return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume); } template @@ -492,9 +492,9 @@ namespace PolyVox { if( BORDER_HIGH(mXPosInVolume) && BORDER_HIGH(mZPosInVolume) ) { - return *(mCurrentVoxel + 1 + mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength); + return *(mCurrentVoxel + 1 + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume+1); + return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume+1); } template @@ -502,9 +502,9 @@ namespace PolyVox { if( BORDER_HIGH(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) && BORDER_LOW(mZPosInVolume) ) { - return *(mCurrentVoxel + 1 + mVolume->m_uBlockSideLength - mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength); + return *(mCurrentVoxel + 1 + this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume-1); + return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume-1); } template @@ -512,9 +512,9 @@ namespace PolyVox { if( BORDER_HIGH(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) ) { - return *(mCurrentVoxel + 1 + mVolume->m_uBlockSideLength); + return *(mCurrentVoxel + 1 + this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume); + return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume); } template @@ -522,8 +522,8 @@ namespace PolyVox { if( BORDER_HIGH(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) ) { - return *(mCurrentVoxel + 1 + mVolume->m_uBlockSideLength + mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength); + return *(mCurrentVoxel + 1 + this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume+1); + return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume+1); } } From d1649c9323a95f25b0c6696da61a74abb2f03e67 Mon Sep 17 00:00:00 2001 From: David Williams Date: Sat, 30 Jul 2011 10:12:28 +0100 Subject: [PATCH 15/19] More work on base Volume class and sampler. Added new test case for creating a volume subclass. --- .../PolyVoxCore/LargeVolumeSampler.inl | 4 +- .../include/PolyVoxCore/RawVolumeSampler.inl | 6 +- .../PolyVoxCore/include/PolyVoxCore/Region.h | 1 + .../PolyVoxCore/SimpleVolumeSampler.inl | 4 +- .../PolyVoxCore/include/PolyVoxCore/Volume.h | 3 + .../include/PolyVoxCore/VolumeSampler.inl | 72 ++++++---- library/PolyVoxCore/source/Region.cpp | 10 ++ tests/CMakeLists.txt | 4 + tests/TestVolumeSubclass.cpp | 133 ++++++++++++++++++ tests/TestVolumeSubclass.h | 37 +++++ 10 files changed, 236 insertions(+), 38 deletions(-) create mode 100644 tests/TestVolumeSubclass.cpp create mode 100644 tests/TestVolumeSubclass.h diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl index a4db69d1..aa228dc7 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl @@ -36,10 +36,8 @@ namespace PolyVox { template LargeVolume::Sampler::Sampler(LargeVolume* volume) - //:mVolume(volume) + :Volume::Sampler< LargeVolume >(volume) { - //Dodgy doing this - need to find how to call base constructor - this->mVolume = volume; } template diff --git a/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl index d1b9d736..cd18672e 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl @@ -31,15 +31,13 @@ namespace PolyVox { template RawVolume::Sampler::Sampler(RawVolume* volume) - //:mVolume(volume) - :mXPosInVolume(0) + :Volume::Sampler< RawVolume >(volume) + ,mXPosInVolume(0) ,mYPosInVolume(0) ,mZPosInVolume(0) ,mCurrentVoxel(0) ,m_bIsCurrentPositionValid(false) { - //Dodgy doing this - need to find how to call base constructor - this->mVolume = volume; } template diff --git a/library/PolyVoxCore/include/PolyVoxCore/Region.h b/library/PolyVoxCore/include/PolyVoxCore/Region.h index 60ce2ba6..5888df0d 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Region.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Region.h @@ -41,6 +41,7 @@ namespace PolyVox Region(); Region(const Vector3DInt32& v3dLowerCorner, const Vector3DInt32& v3dUpperCorner); + Region(int32_t iLowerX, int32_t iLowerY, int32_t iLowerZ, int32_t iUpperX, int32_t iUpperY, int32_t iUpperZ); const Vector3DInt32& getLowerCorner(void) const; const Vector3DInt32& getUpperCorner(void) const; diff --git a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl index 12d2366c..dc4c74a4 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl @@ -36,10 +36,8 @@ namespace PolyVox { template SimpleVolume::Sampler::Sampler(SimpleVolume* volume) - //:mVolume(volume) + :Volume::Sampler< SimpleVolume >(volume) { - //Dodgy doing this - need to find how to call base constructor - this->mVolume = volume; } template diff --git a/library/PolyVoxCore/include/PolyVoxCore/Volume.h b/library/PolyVoxCore/include/PolyVoxCore/Volume.h index 780db379..b9d367aa 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Volume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Volume.h @@ -41,6 +41,9 @@ namespace PolyVox class Sampler { public: + Sampler(DerivedVolumeType* volume); + ~Sampler(); + int32_t getPosX(void) const; int32_t getPosY(void) const; int32_t getPosZ(void) const; diff --git a/library/PolyVoxCore/include/PolyVoxCore/VolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/VolumeSampler.inl index 25d6014d..4b7394dd 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/VolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/VolumeSampler.inl @@ -29,6 +29,22 @@ freely, subject to the following restrictions: #include namespace PolyVox { + template + template + Volume::Sampler::Sampler(DerivedVolumeType* volume) + :mVolume(volume) + ,mXPos(0) + ,mYPos(0) + ,mZPos(0) + { + } + + template + template + Volume::Sampler::~Sampler() + { + } + template template int32_t Volume::Sampler::getPosX(void) const @@ -54,7 +70,7 @@ namespace PolyVox template VoxelType Volume::Sampler::getVoxel(void) const { - mVolume->getVoxelAt(mXPos, mYPos, mZPos); + return mVolume->getVoxelAt(mXPos, mYPos, mZPos); } template @@ -121,63 +137,63 @@ namespace PolyVox template VoxelType Volume::Sampler::peekVoxel1nx1ny1nz(void) const { - mVolume->getVoxelAt(mXPos - 1, mYPos - 1, mZPos - 1); + return mVolume->getVoxelAt(mXPos - 1, mYPos - 1, mZPos - 1); } template template VoxelType Volume::Sampler::peekVoxel1nx1ny0pz(void) const { - mVolume->getVoxelAt(mXPos - 1, mYPos - 1, mZPos ); + return mVolume->getVoxelAt(mXPos - 1, mYPos - 1, mZPos ); } template template VoxelType Volume::Sampler::peekVoxel1nx1ny1pz(void) const { - mVolume->getVoxelAt(mXPos - 1, mYPos - 1, mZPos + 1); + return mVolume->getVoxelAt(mXPos - 1, mYPos - 1, mZPos + 1); } template template VoxelType Volume::Sampler::peekVoxel1nx0py1nz(void) const { - mVolume->getVoxelAt(mXPos - 1, mYPos , mZPos - 1); + return mVolume->getVoxelAt(mXPos - 1, mYPos , mZPos - 1); } template template VoxelType Volume::Sampler::peekVoxel1nx0py0pz(void) const { - mVolume->getVoxelAt(mXPos - 1, mYPos , mZPos ); + return mVolume->getVoxelAt(mXPos - 1, mYPos , mZPos ); } template template VoxelType Volume::Sampler::peekVoxel1nx0py1pz(void) const { - mVolume->getVoxelAt(mXPos - 1, mYPos , mZPos + 1); + return mVolume->getVoxelAt(mXPos - 1, mYPos , mZPos + 1); } template template VoxelType Volume::Sampler::peekVoxel1nx1py1nz(void) const { - mVolume->getVoxelAt(mXPos - 1, mYPos + 1, mZPos - 1); + return mVolume->getVoxelAt(mXPos - 1, mYPos + 1, mZPos - 1); } template template VoxelType Volume::Sampler::peekVoxel1nx1py0pz(void) const { - mVolume->getVoxelAt(mXPos - 1, mYPos + 1, mZPos ); + return mVolume->getVoxelAt(mXPos - 1, mYPos + 1, mZPos ); } template template VoxelType Volume::Sampler::peekVoxel1nx1py1pz(void) const { - mVolume->getVoxelAt(mXPos - 1, mYPos + 1, mZPos + 1); + return mVolume->getVoxelAt(mXPos - 1, mYPos + 1, mZPos + 1); } ////////////////////////////////////////////////////////////////////////// @@ -186,63 +202,63 @@ namespace PolyVox template VoxelType Volume::Sampler::peekVoxel0px1ny1nz(void) const { - mVolume->getVoxelAt(mXPos , mYPos - 1, mZPos - 1); + return mVolume->getVoxelAt(mXPos , mYPos - 1, mZPos - 1); } template template VoxelType Volume::Sampler::peekVoxel0px1ny0pz(void) const { - mVolume->getVoxelAt(mXPos , mYPos - 1, mZPos ); + return mVolume->getVoxelAt(mXPos , mYPos - 1, mZPos ); } template template VoxelType Volume::Sampler::peekVoxel0px1ny1pz(void) const { - mVolume->getVoxelAt(mXPos , mYPos - 1, mZPos + 1); + return mVolume->getVoxelAt(mXPos , mYPos - 1, mZPos + 1); } template template VoxelType Volume::Sampler::peekVoxel0px0py1nz(void) const { - mVolume->getVoxelAt(mXPos , mYPos , mZPos - 1); + return mVolume->getVoxelAt(mXPos , mYPos , mZPos - 1); } template template VoxelType Volume::Sampler::peekVoxel0px0py0pz(void) const { - mVolume->getVoxelAt(mXPos , mYPos , mZPos ); + return mVolume->getVoxelAt(mXPos , mYPos , mZPos ); } template template VoxelType Volume::Sampler::peekVoxel0px0py1pz(void) const { - mVolume->getVoxelAt(mXPos , mYPos , mZPos + 1); + return mVolume->getVoxelAt(mXPos , mYPos , mZPos + 1); } template template VoxelType Volume::Sampler::peekVoxel0px1py1nz(void) const { - mVolume->getVoxelAt(mXPos , mYPos + 1, mZPos - 1); + return mVolume->getVoxelAt(mXPos , mYPos + 1, mZPos - 1); } template template VoxelType Volume::Sampler::peekVoxel0px1py0pz(void) const { - mVolume->getVoxelAt(mXPos , mYPos + 1, mZPos ); + return mVolume->getVoxelAt(mXPos , mYPos + 1, mZPos ); } template template VoxelType Volume::Sampler::peekVoxel0px1py1pz(void) const { - mVolume->getVoxelAt(mXPos , mYPos + 1, mZPos + 1); + return mVolume->getVoxelAt(mXPos , mYPos + 1, mZPos + 1); } ////////////////////////////////////////////////////////////////////////// @@ -251,62 +267,62 @@ namespace PolyVox template VoxelType Volume::Sampler::peekVoxel1px1ny1nz(void) const { - mVolume->getVoxelAt(mXPos + 1, mYPos - 1, mZPos - 1); + return mVolume->getVoxelAt(mXPos + 1, mYPos - 1, mZPos - 1); } template template VoxelType Volume::Sampler::peekVoxel1px1ny0pz(void) const { - mVolume->getVoxelAt(mXPos + 1, mYPos - 1, mZPos ); + return mVolume->getVoxelAt(mXPos + 1, mYPos - 1, mZPos ); } template template VoxelType Volume::Sampler::peekVoxel1px1ny1pz(void) const { - mVolume->getVoxelAt(mXPos + 1, mYPos - 1, mZPos + 1); + return mVolume->getVoxelAt(mXPos + 1, mYPos - 1, mZPos + 1); } template template VoxelType Volume::Sampler::peekVoxel1px0py1nz(void) const { - mVolume->getVoxelAt(mXPos + 1, mYPos , mZPos - 1); + return mVolume->getVoxelAt(mXPos + 1, mYPos , mZPos - 1); } template template VoxelType Volume::Sampler::peekVoxel1px0py0pz(void) const { - mVolume->getVoxelAt(mXPos + 1, mYPos , mZPos ); + return mVolume->getVoxelAt(mXPos + 1, mYPos , mZPos ); } template template VoxelType Volume::Sampler::peekVoxel1px0py1pz(void) const { - mVolume->getVoxelAt(mXPos + 1, mYPos , mZPos + 1); + return mVolume->getVoxelAt(mXPos + 1, mYPos , mZPos + 1); } template template VoxelType Volume::Sampler::peekVoxel1px1py1nz(void) const { - mVolume->getVoxelAt(mXPos + 1, mYPos + 1, mZPos - 1); + return mVolume->getVoxelAt(mXPos + 1, mYPos + 1, mZPos - 1); } template template VoxelType Volume::Sampler::peekVoxel1px1py0pz(void) const { - mVolume->getVoxelAt(mXPos + 1, mYPos + 1, mZPos ); + return mVolume->getVoxelAt(mXPos + 1, mYPos + 1, mZPos ); } template template VoxelType Volume::Sampler::peekVoxel1px1py1pz(void) const { - mVolume->getVoxelAt(mXPos + 1, mYPos + 1, mZPos + 1); + return mVolume->getVoxelAt(mXPos + 1, mYPos + 1, mZPos + 1); } } diff --git a/library/PolyVoxCore/source/Region.cpp b/library/PolyVoxCore/source/Region.cpp index e0eaa1c1..8b6491d5 100644 --- a/library/PolyVoxCore/source/Region.cpp +++ b/library/PolyVoxCore/source/Region.cpp @@ -50,6 +50,16 @@ namespace PolyVox assert(m_v3dUpperCorner.getZ() >= m_v3dLowerCorner.getZ()); } + Region::Region(int32_t iLowerX, int32_t iLowerY, int32_t iLowerZ, int32_t iUpperX, int32_t iUpperY, int32_t iUpperZ) + :m_v3dLowerCorner(iLowerX, iLowerY, iLowerZ) + ,m_v3dUpperCorner(iUpperX, iUpperY, iUpperZ) + { + //Check the region is valid. + assert(m_v3dUpperCorner.getX() >= m_v3dLowerCorner.getX()); + assert(m_v3dUpperCorner.getY() >= m_v3dLowerCorner.getY()); + assert(m_v3dUpperCorner.getZ() >= m_v3dLowerCorner.getZ()); + } + const Vector3DInt32& Region::getLowerCorner(void) const { return m_v3dLowerCorner; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 877e7fe5..39a68d7b 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -59,3 +59,7 @@ ADD_TEST(MaterialTestCompile ${LATEST_TEST} testCompile) CREATE_TEST(testvector.h testvector.cpp testvector) ADD_TEST(VectorLengthTest ${LATEST_TEST} testLength) ADD_TEST(VectorDotProductTest ${LATEST_TEST} testDotProduct) + +# Volume subclass tests +CREATE_TEST(TestVolumeSubclass.h TestVolumeSubclass.cpp TestVolumeSubclass) +ADD_TEST(VolumeSubclassExtractSurfaceTest ${LATEST_TEST} testExtractSurface) diff --git a/tests/TestVolumeSubclass.cpp b/tests/TestVolumeSubclass.cpp new file mode 100644 index 00000000..2c42d954 --- /dev/null +++ b/tests/TestVolumeSubclass.cpp @@ -0,0 +1,133 @@ +/******************************************************************************* +Copyright (c) 2010 Matt 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. +*******************************************************************************/ + +#include "TestVolumeSubclass.h" + +#include "PolyVoxCore/Array.h" +#include "PolyVoxCore/CubicSurfaceExtractor.h" +#include "PolyVoxCore/Material.h" +#include "PolyVoxCore/Vector.h" +#include "PolyVoxCore/Volume.h" + +#include + +using namespace PolyVox; + +template +class VolumeSubclass : public Volume +{ +public: + +#if defined(_MSC_VER) //DIRTY HACK!!! + class Sampler : public Volume::Sampler< VolumeSubclass > +#else + class Sampler : public Volume::template Sampler< VolumeSubclass > +#endif + { + public: + Sampler(VolumeSubclass* volume) + :Volume::Sampler< VolumeSubclass >(volume) + { + this->mVolume = volume; + } + //~Sampler(); + }; + + /// Constructor for creating a fixed size volume. + VolumeSubclass(const Region& regValid) + :Volume(regValid) + { + mVolumeData.resize(ArraySizes(this->getWidth())(this->getHeight())(this->getDepth())); + } + /// Destructor + ~VolumeSubclass() {}; + + /// Gets the value used for voxels which are outside the volume + VoxelType getBorderValue(void) const { return 0; } + /// Gets a voxel at the position given by x,y,z coordinates + VoxelType getVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos) const + { + if(this->m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos))) + { + return mVolumeData[uXPos][uYPos][uZPos]; + } + else + { + return getBorderValue(); + } + } + /// Gets a voxel at the position given by a 3D vector + VoxelType getVoxelAt(const Vector3DInt32& v3dPos) const { return getVoxelAt(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ()); } + + /// Sets the value used for voxels which are outside the volume + void setBorderValue(const VoxelType& tBorder) { } + /// Sets the voxel at the position given by x,y,z coordinates + bool setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue) + { + if(this->m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos))) + { + mVolumeData[uXPos][uYPos][uZPos] = tValue; + return true; + } + else + { + return false; + } + } + /// Sets the voxel at the position given by a 3D vector + bool setVoxelAt(const Vector3DInt32& v3dPos, VoxelType tValue) { return setVoxelAt(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), tValue); } + + /// Calculates approximatly how many bytes of memory the volume is currently using. + uint32_t calculateSizeInBytes(void) { return 0; } + + /// Deprecated - I don't think we should expose this function? Let us know if you disagree... + //void resize(const Region& regValidRegion); + +private: + Array<3, VoxelType> mVolumeData; +}; + +void TestVolumeSubclass::testExtractSurface() +{ + VolumeSubclass volumeSubclass(Region(0,0,0,16,16,16)); + + for(int32_t z = 0; z < volumeSubclass.getDepth() / 2; z++) + { + for(int32_t y = 0; y < volumeSubclass.getHeight(); y++) + { + for(int32_t x = 0; x < volumeSubclass.getWidth(); x++) + { + Material8 mat(1); + volumeSubclass.setVoxelAt(Vector3DInt32(x,y,z),mat); + } + } + } + + SurfaceMesh result; + CubicSurfaceExtractor cubicSurfaceExtractor(&volumeSubclass, volumeSubclass.getEnclosingRegion(), &result); + cubicSurfaceExtractor.execute(); + + QCOMPARE(result.getNoOfVertices(), static_cast(8)); +} + +QTEST_MAIN(TestVolumeSubclass) diff --git a/tests/TestVolumeSubclass.h b/tests/TestVolumeSubclass.h new file mode 100644 index 00000000..46e86bd8 --- /dev/null +++ b/tests/TestVolumeSubclass.h @@ -0,0 +1,37 @@ +/******************************************************************************* +Copyright (c) 2010 Matt 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_TestVolumeSubclass_H__ +#define __PolyVox_TestVolumeSubclass_H__ + +#include + +class TestVolumeSubclass: public QObject +{ + Q_OBJECT + + private slots: + void testExtractSurface(); +}; + +#endif From 5e62d639fb9927256fb96863c279562526399bc9 Mon Sep 17 00:00:00 2001 From: David Williams Date: Sat, 30 Jul 2011 12:45:32 +0100 Subject: [PATCH 16/19] Compile fixes for g++. --- .../PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl | 2 +- library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl | 2 +- .../PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl | 4 ++-- tests/TestVolumeSubclass.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl index 052aa3e5..cd092055 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl @@ -36,7 +36,7 @@ namespace PolyVox { template LargeVolume::Sampler::Sampler(LargeVolume* volume) - :Volume::Sampler< LargeVolume >(volume) + :Volume::template Sampler< LargeVolume >(volume) { } diff --git a/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl index 431a2085..5a77a3c1 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl @@ -31,7 +31,7 @@ namespace PolyVox { template RawVolume::Sampler::Sampler(RawVolume* volume) - :Volume::Sampler< RawVolume >(volume) + :Volume::template Sampler< RawVolume >(volume) ,mXPosInVolume(0) ,mYPosInVolume(0) ,mZPosInVolume(0) diff --git a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl index 16ad76fc..855fbaf0 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl @@ -35,8 +35,8 @@ freely, subject to the following restrictions: namespace PolyVox { template - SimpleVolume::Sampler::Sampler(SimpleVolume* volume) - :Volume::Sampler< SimpleVolume >(volume) + SimpleVolume::Sampler::Sampler(SimpleVolume* volume) + :Volume::template Sampler< SimpleVolume >(volume) { } diff --git a/tests/TestVolumeSubclass.cpp b/tests/TestVolumeSubclass.cpp index 2c42d954..dc6af74d 100644 --- a/tests/TestVolumeSubclass.cpp +++ b/tests/TestVolumeSubclass.cpp @@ -46,7 +46,7 @@ public: { public: Sampler(VolumeSubclass* volume) - :Volume::Sampler< VolumeSubclass >(volume) + :Volume::template Sampler< VolumeSubclass >(volume) { this->mVolume = volume; } From b94b7e7baf52b8852e64f68565057e6d16b89406 Mon Sep 17 00:00:00 2001 From: David Williams Date: Sat, 30 Jul 2011 14:07:33 +0100 Subject: [PATCH 17/19] Moved sampler position into base class. --- .../include/PolyVoxCore/LargeVolume.h | 9 -- .../include/PolyVoxCore/RawVolume.h | 8 -- .../include/PolyVoxCore/RawVolumeSampler.inl | 3 - .../include/PolyVoxCore/SimpleVolume.h | 11 +-- .../PolyVoxCore/include/PolyVoxCore/Volume.h | 7 +- .../include/PolyVoxCore/VolumeSampler.inl | 92 +++++++++---------- 6 files changed, 51 insertions(+), 79 deletions(-) diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h index d48abdfe..884d46dd 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h @@ -205,15 +205,6 @@ namespace PolyVox inline VoxelType peekVoxel1px1py1pz(void) const; private: - - //The current volume - //LargeVolume* mVolume; - - //The current position in the volume - int32_t mXPosInVolume; - int32_t mYPosInVolume; - int32_t mZPosInVolume; - //Other current position information VoxelType* mCurrentVoxel; }; diff --git a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h index 0fa08c2c..b2bee28c 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h @@ -95,14 +95,6 @@ namespace PolyVox inline VoxelType peekVoxel1px1py1pz(void) const; private: - //The current volume - //RawVolume* mVolume; - - //The current position in the volume - int32_t mXPosInVolume; - int32_t mYPosInVolume; - int32_t mZPosInVolume; - //Other current position information VoxelType* mCurrentVoxel; diff --git a/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl index 431a2085..fb8e4f61 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl @@ -32,9 +32,6 @@ namespace PolyVox template RawVolume::Sampler::Sampler(RawVolume* volume) :Volume::Sampler< RawVolume >(volume) - ,mXPosInVolume(0) - ,mYPosInVolume(0) - ,mZPosInVolume(0) ,mCurrentVoxel(0) ,m_bIsCurrentPositionValid(false) { diff --git a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h index eba5177a..b9284e11 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h @@ -119,16 +119,7 @@ namespace PolyVox inline VoxelType peekVoxel1px1py0pz(void) const; inline VoxelType peekVoxel1px1py1pz(void) const; - private: - - //The current volume - //SimpleVolume* mVolume; - - //The current position in the volume - int32_t mXPosInVolume; - int32_t mYPosInVolume; - int32_t mZPosInVolume; - + private: //Other current position information VoxelType* mCurrentVoxel; }; diff --git a/library/PolyVoxCore/include/PolyVoxCore/Volume.h b/library/PolyVoxCore/include/PolyVoxCore/Volume.h index b9d367aa..51b7634a 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Volume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Volume.h @@ -93,9 +93,10 @@ namespace PolyVox protected: DerivedVolumeType* mVolume; - int32_t mXPos; - int32_t mYPos; - int32_t mZPos; + //The current position in the volume + int32_t mXPosInVolume; + int32_t mYPosInVolume; + int32_t mZPosInVolume; }; #endif diff --git a/library/PolyVoxCore/include/PolyVoxCore/VolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/VolumeSampler.inl index 4b7394dd..68b2e314 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/VolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/VolumeSampler.inl @@ -33,9 +33,9 @@ namespace PolyVox template Volume::Sampler::Sampler(DerivedVolumeType* volume) :mVolume(volume) - ,mXPos(0) - ,mYPos(0) - ,mZPos(0) + ,mXPosInVolume(0) + ,mYPosInVolume(0) + ,mZPosInVolume(0) { } @@ -49,151 +49,151 @@ namespace PolyVox template int32_t Volume::Sampler::getPosX(void) const { - return mXPos; + return mXPosInVolume; } template template int32_t Volume::Sampler::getPosY(void) const { - return mYPos; + return mYPosInVolume; } template template int32_t Volume::Sampler::getPosZ(void) const { - return mZPos; + return mZPosInVolume; } template template VoxelType Volume::Sampler::getVoxel(void) const { - return mVolume->getVoxelAt(mXPos, mYPos, mZPos); + return mVolume->getVoxelAt(mXPosInVolume, mYPosInVolume, mZPosInVolume); } template template void Volume::Sampler::setPosition(const Vector3DInt32& v3dNewPos) { - mXPos = v3dNewPos.getX(); - mYPos = v3dNewPos.getY(); - mZPos = v3dNewPos.getZ(); + mXPosInVolume = v3dNewPos.getX(); + mYPosInVolume = v3dNewPos.getY(); + mZPosInVolume = v3dNewPos.getZ(); } template template void Volume::Sampler::setPosition(int32_t xPos, int32_t yPos, int32_t zPos) { - mXPos = xPos; - mYPos = yPos; - mZPos = zPos; + mXPosInVolume = xPos; + mYPosInVolume = yPos; + mZPosInVolume = zPos; } template template void Volume::Sampler::movePositiveX(void) { - mXPos++; + mXPosInVolume++; } template template void Volume::Sampler::movePositiveY(void) { - mYPos++; + mYPosInVolume++; } template template void Volume::Sampler::movePositiveZ(void) { - mZPos++; + mZPosInVolume++; } template template void Volume::Sampler::moveNegativeX(void) { - mXPos--; + mXPosInVolume--; } template template void Volume::Sampler::moveNegativeY(void) { - mYPos--; + mYPosInVolume--; } template template void Volume::Sampler::moveNegativeZ(void) { - mZPos--; + mZPosInVolume--; } template template VoxelType Volume::Sampler::peekVoxel1nx1ny1nz(void) const { - return mVolume->getVoxelAt(mXPos - 1, mYPos - 1, mZPos - 1); + return mVolume->getVoxelAt(mXPosInVolume - 1, mYPosInVolume - 1, mZPosInVolume - 1); } template template VoxelType Volume::Sampler::peekVoxel1nx1ny0pz(void) const { - return mVolume->getVoxelAt(mXPos - 1, mYPos - 1, mZPos ); + return mVolume->getVoxelAt(mXPosInVolume - 1, mYPosInVolume - 1, mZPosInVolume ); } template template VoxelType Volume::Sampler::peekVoxel1nx1ny1pz(void) const { - return mVolume->getVoxelAt(mXPos - 1, mYPos - 1, mZPos + 1); + return mVolume->getVoxelAt(mXPosInVolume - 1, mYPosInVolume - 1, mZPosInVolume + 1); } template template VoxelType Volume::Sampler::peekVoxel1nx0py1nz(void) const { - return mVolume->getVoxelAt(mXPos - 1, mYPos , mZPos - 1); + return mVolume->getVoxelAt(mXPosInVolume - 1, mYPosInVolume , mZPosInVolume - 1); } template template VoxelType Volume::Sampler::peekVoxel1nx0py0pz(void) const { - return mVolume->getVoxelAt(mXPos - 1, mYPos , mZPos ); + return mVolume->getVoxelAt(mXPosInVolume - 1, mYPosInVolume , mZPosInVolume ); } template template VoxelType Volume::Sampler::peekVoxel1nx0py1pz(void) const { - return mVolume->getVoxelAt(mXPos - 1, mYPos , mZPos + 1); + return mVolume->getVoxelAt(mXPosInVolume - 1, mYPosInVolume , mZPosInVolume + 1); } template template VoxelType Volume::Sampler::peekVoxel1nx1py1nz(void) const { - return mVolume->getVoxelAt(mXPos - 1, mYPos + 1, mZPos - 1); + return mVolume->getVoxelAt(mXPosInVolume - 1, mYPosInVolume + 1, mZPosInVolume - 1); } template template VoxelType Volume::Sampler::peekVoxel1nx1py0pz(void) const { - return mVolume->getVoxelAt(mXPos - 1, mYPos + 1, mZPos ); + return mVolume->getVoxelAt(mXPosInVolume - 1, mYPosInVolume + 1, mZPosInVolume ); } template template VoxelType Volume::Sampler::peekVoxel1nx1py1pz(void) const { - return mVolume->getVoxelAt(mXPos - 1, mYPos + 1, mZPos + 1); + return mVolume->getVoxelAt(mXPosInVolume - 1, mYPosInVolume + 1, mZPosInVolume + 1); } ////////////////////////////////////////////////////////////////////////// @@ -202,63 +202,63 @@ namespace PolyVox template VoxelType Volume::Sampler::peekVoxel0px1ny1nz(void) const { - return mVolume->getVoxelAt(mXPos , mYPos - 1, mZPos - 1); + return mVolume->getVoxelAt(mXPosInVolume , mYPosInVolume - 1, mZPosInVolume - 1); } template template VoxelType Volume::Sampler::peekVoxel0px1ny0pz(void) const { - return mVolume->getVoxelAt(mXPos , mYPos - 1, mZPos ); + return mVolume->getVoxelAt(mXPosInVolume , mYPosInVolume - 1, mZPosInVolume ); } template template VoxelType Volume::Sampler::peekVoxel0px1ny1pz(void) const { - return mVolume->getVoxelAt(mXPos , mYPos - 1, mZPos + 1); + return mVolume->getVoxelAt(mXPosInVolume , mYPosInVolume - 1, mZPosInVolume + 1); } template template VoxelType Volume::Sampler::peekVoxel0px0py1nz(void) const { - return mVolume->getVoxelAt(mXPos , mYPos , mZPos - 1); + return mVolume->getVoxelAt(mXPosInVolume , mYPosInVolume , mZPosInVolume - 1); } template template VoxelType Volume::Sampler::peekVoxel0px0py0pz(void) const { - return mVolume->getVoxelAt(mXPos , mYPos , mZPos ); + return mVolume->getVoxelAt(mXPosInVolume , mYPosInVolume , mZPosInVolume ); } template template VoxelType Volume::Sampler::peekVoxel0px0py1pz(void) const { - return mVolume->getVoxelAt(mXPos , mYPos , mZPos + 1); + return mVolume->getVoxelAt(mXPosInVolume , mYPosInVolume , mZPosInVolume + 1); } template template VoxelType Volume::Sampler::peekVoxel0px1py1nz(void) const { - return mVolume->getVoxelAt(mXPos , mYPos + 1, mZPos - 1); + return mVolume->getVoxelAt(mXPosInVolume , mYPosInVolume + 1, mZPosInVolume - 1); } template template VoxelType Volume::Sampler::peekVoxel0px1py0pz(void) const { - return mVolume->getVoxelAt(mXPos , mYPos + 1, mZPos ); + return mVolume->getVoxelAt(mXPosInVolume , mYPosInVolume + 1, mZPosInVolume ); } template template VoxelType Volume::Sampler::peekVoxel0px1py1pz(void) const { - return mVolume->getVoxelAt(mXPos , mYPos + 1, mZPos + 1); + return mVolume->getVoxelAt(mXPosInVolume , mYPosInVolume + 1, mZPosInVolume + 1); } ////////////////////////////////////////////////////////////////////////// @@ -267,62 +267,62 @@ namespace PolyVox template VoxelType Volume::Sampler::peekVoxel1px1ny1nz(void) const { - return mVolume->getVoxelAt(mXPos + 1, mYPos - 1, mZPos - 1); + return mVolume->getVoxelAt(mXPosInVolume + 1, mYPosInVolume - 1, mZPosInVolume - 1); } template template VoxelType Volume::Sampler::peekVoxel1px1ny0pz(void) const { - return mVolume->getVoxelAt(mXPos + 1, mYPos - 1, mZPos ); + return mVolume->getVoxelAt(mXPosInVolume + 1, mYPosInVolume - 1, mZPosInVolume ); } template template VoxelType Volume::Sampler::peekVoxel1px1ny1pz(void) const { - return mVolume->getVoxelAt(mXPos + 1, mYPos - 1, mZPos + 1); + return mVolume->getVoxelAt(mXPosInVolume + 1, mYPosInVolume - 1, mZPosInVolume + 1); } template template VoxelType Volume::Sampler::peekVoxel1px0py1nz(void) const { - return mVolume->getVoxelAt(mXPos + 1, mYPos , mZPos - 1); + return mVolume->getVoxelAt(mXPosInVolume + 1, mYPosInVolume , mZPosInVolume - 1); } template template VoxelType Volume::Sampler::peekVoxel1px0py0pz(void) const { - return mVolume->getVoxelAt(mXPos + 1, mYPos , mZPos ); + return mVolume->getVoxelAt(mXPosInVolume + 1, mYPosInVolume , mZPosInVolume ); } template template VoxelType Volume::Sampler::peekVoxel1px0py1pz(void) const { - return mVolume->getVoxelAt(mXPos + 1, mYPos , mZPos + 1); + return mVolume->getVoxelAt(mXPosInVolume + 1, mYPosInVolume , mZPosInVolume + 1); } template template VoxelType Volume::Sampler::peekVoxel1px1py1nz(void) const { - return mVolume->getVoxelAt(mXPos + 1, mYPos + 1, mZPos - 1); + return mVolume->getVoxelAt(mXPosInVolume + 1, mYPosInVolume + 1, mZPosInVolume - 1); } template template VoxelType Volume::Sampler::peekVoxel1px1py0pz(void) const { - return mVolume->getVoxelAt(mXPos + 1, mYPos + 1, mZPos ); + return mVolume->getVoxelAt(mXPosInVolume + 1, mYPosInVolume + 1, mZPosInVolume ); } template template VoxelType Volume::Sampler::peekVoxel1px1py1pz(void) const { - return mVolume->getVoxelAt(mXPos + 1, mYPos + 1, mZPos + 1); + return mVolume->getVoxelAt(mXPosInVolume + 1, mYPosInVolume + 1, mZPosInVolume + 1); } } From 53ae3de4131a3c80b9d0b61584d491d388c9054f Mon Sep 17 00:00:00 2001 From: David Williams Date: Sun, 31 Jul 2011 08:58:52 +0100 Subject: [PATCH 18/19] Replaced GCC/VS2010 hacks with code that should compile on both platforms. --- .../include/PolyVoxCore/LargeVolume.h | 7 ++---- .../include/PolyVoxCore/RawVolume.h | 7 ++---- .../include/PolyVoxCore/SimpleVolume.h | 7 ++---- tests/TestVolumeSubclass.cpp | 24 ++++++++----------- 4 files changed, 16 insertions(+), 29 deletions(-) diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h index 884d46dd..2fb4fd0e 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h @@ -145,11 +145,8 @@ namespace PolyVox class LargeVolume : public Volume { public: -#if defined(_MSC_VER) //DIRTY HACK!!! - class Sampler : public Volume::Sampler< LargeVolume > -#else - class Sampler : public Volume::template Sampler< LargeVolume > -#endif + typedef Volume VolumeOfVoxelType; //Workaround for GCC/VS2010 differences. See http://goo.gl/qu1wn + class Sampler : public VolumeOfVoxelType::template Sampler< LargeVolume > { public: Sampler(LargeVolume* volume); diff --git a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h index b2bee28c..d7d2b1bf 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h @@ -38,11 +38,8 @@ namespace PolyVox { public: #ifndef SWIG -#if defined(_MSC_VER) //DIRTY HACK!!! - class Sampler : public Volume::Sampler< RawVolume > -#else - class Sampler : public Volume::template Sampler< RawVolume > -#endif + typedef Volume VolumeOfVoxelType; //Workaround for GCC/VS2010 differences. See http://goo.gl/qu1wn + class Sampler : public VolumeOfVoxelType::template Sampler< RawVolume > { public: Sampler(RawVolume* volume); diff --git a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h index b9284e11..b75cd367 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h @@ -60,11 +60,8 @@ namespace PolyVox uint8_t m_uSideLengthPower; }; -#if defined(_MSC_VER) //DIRTY HACK!!! - class Sampler : public Volume::Sampler< SimpleVolume > -#else - class Sampler : public Volume::template Sampler< SimpleVolume > -#endif + typedef Volume VolumeOfVoxelType; //Workaround for GCC/VS2010 differences. See http://goo.gl/qu1wn + class Sampler : public VolumeOfVoxelType::template Sampler< SimpleVolume > { public: Sampler(SimpleVolume* volume); diff --git a/tests/TestVolumeSubclass.cpp b/tests/TestVolumeSubclass.cpp index dc6af74d..4ed1e4aa 100644 --- a/tests/TestVolumeSubclass.cpp +++ b/tests/TestVolumeSubclass.cpp @@ -37,21 +37,17 @@ template class VolumeSubclass : public Volume { public: - -#if defined(_MSC_VER) //DIRTY HACK!!! - class Sampler : public Volume::Sampler< VolumeSubclass > -#else - class Sampler : public Volume::template Sampler< VolumeSubclass > -#endif + typedef Volume VolumeOfVoxelType; //Workaround for GCC/VS2010 differences. See http://goo.gl/qu1wn + class Sampler : public VolumeOfVoxelType::template Sampler< VolumeSubclass > + { + public: + Sampler(VolumeSubclass* volume) + :Volume::template Sampler< VolumeSubclass >(volume) { - public: - Sampler(VolumeSubclass* volume) - :Volume::template Sampler< VolumeSubclass >(volume) - { - this->mVolume = volume; - } - //~Sampler(); - }; + this->mVolume = volume; + } + //~Sampler(); + }; /// Constructor for creating a fixed size volume. VolumeSubclass(const Region& regValid) From fb0a2d0dac9fc752e0a307a381b465c0ab44977a Mon Sep 17 00:00:00 2001 From: David Williams Date: Sun, 31 Jul 2011 08:08:00 +0100 Subject: [PATCH 19/19] GCC compile fixes. --- .../PolyVoxCore/LargeVolumeSampler.inl | 160 +++++++++--------- .../include/PolyVoxCore/RawVolumeSampler.inl | 88 +++++----- .../PolyVoxCore/SimpleVolumeSampler.inl | 160 +++++++++--------- 3 files changed, 204 insertions(+), 204 deletions(-) diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl index cd092055..994a9ff3 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl @@ -53,9 +53,9 @@ namespace PolyVox return *this; } this->mVolume = rhs.mVolume; - mXPosInVolume = rhs.mXPosInVolume; - mYPosInVolume = rhs.mYPosInVolume; - mZPosInVolume = rhs.mZPosInVolume; + this->mXPosInVolume = rhs.mXPosInVolume; + this->mYPosInVolume = rhs.mYPosInVolume; + this->mZPosInVolume = rhs.mZPosInVolume; mCurrentVoxel = rhs.mCurrentVoxel; return *this; } @@ -63,19 +63,19 @@ namespace PolyVox template int32_t LargeVolume::Sampler::getPosX(void) const { - return mXPosInVolume; + return this->mXPosInVolume; } template int32_t LargeVolume::Sampler::getPosY(void) const { - return mYPosInVolume; + return this->mYPosInVolume; } template int32_t LargeVolume::Sampler::getPosZ(void) const { - return mZPosInVolume; + return this->mZPosInVolume; } template @@ -108,7 +108,7 @@ namespace PolyVox { for(uint8_t x = 0; x < uSize; ++x) { - tValue = (std::min)(tValue, this->mVolume->getVoxelAt(mXPosInVolume + x, mYPosInVolume + y, mZPosInVolume + z)); + tValue = (std::min)(tValue, this->mVolume->getVoxelAt(this->mXPosInVolume + x, this->mYPosInVolume + y, this->mZPosInVolume + z)); } } } @@ -131,17 +131,17 @@ namespace PolyVox template void LargeVolume::Sampler::setPosition(int32_t xPos, int32_t yPos, int32_t zPos) { - mXPosInVolume = xPos; - mYPosInVolume = yPos; - mZPosInVolume = zPos; + this->mXPosInVolume = xPos; + this->mYPosInVolume = yPos; + this->mZPosInVolume = zPos; - const int32_t uXBlock = mXPosInVolume >> this->mVolume->m_uBlockSideLengthPower; - const int32_t uYBlock = mYPosInVolume >> this->mVolume->m_uBlockSideLengthPower; - const int32_t uZBlock = mZPosInVolume >> this->mVolume->m_uBlockSideLengthPower; + const int32_t uXBlock = this->mXPosInVolume >> this->mVolume->m_uBlockSideLengthPower; + const int32_t uYBlock = this->mYPosInVolume >> this->mVolume->m_uBlockSideLengthPower; + const int32_t uZBlock = this->mZPosInVolume >> this->mVolume->m_uBlockSideLengthPower; - const uint16_t uXPosInBlock = mXPosInVolume - (uXBlock << this->mVolume->m_uBlockSideLengthPower); - const uint16_t uYPosInBlock = mYPosInVolume - (uYBlock << this->mVolume->m_uBlockSideLengthPower); - const uint16_t uZPosInBlock = mZPosInVolume - (uZBlock << this->mVolume->m_uBlockSideLengthPower); + const uint16_t uXPosInBlock = this->mXPosInVolume - (uXBlock << this->mVolume->m_uBlockSideLengthPower); + const uint16_t uYPosInBlock = this->mYPosInVolume - (uYBlock << this->mVolume->m_uBlockSideLengthPower); + const uint16_t uZPosInBlock = this->mZPosInVolume - (uZBlock << this->mVolume->m_uBlockSideLengthPower); const uint32_t uVoxelIndexInBlock = uXPosInBlock + uYPosInBlock * this->mVolume->m_uBlockSideLength + @@ -163,7 +163,7 @@ namespace PolyVox void LargeVolume::Sampler::movePositiveX(void) { //Note the *pre* increament here - if((++mXPosInVolume) % this->mVolume->m_uBlockSideLength != 0) + if((++this->mXPosInVolume) % this->mVolume->m_uBlockSideLength != 0) { //No need to compute new block. ++mCurrentVoxel; @@ -171,7 +171,7 @@ namespace PolyVox else { //We've hit the block boundary. Just calling setPosition() is the easiest way to resolve this. - setPosition(mXPosInVolume, mYPosInVolume, mZPosInVolume); + setPosition(this->mXPosInVolume, this->mYPosInVolume, this->mZPosInVolume); } } @@ -179,7 +179,7 @@ namespace PolyVox void LargeVolume::Sampler::movePositiveY(void) { //Note the *pre* increament here - if((++mYPosInVolume) % this->mVolume->m_uBlockSideLength != 0) + if((++this->mYPosInVolume) % this->mVolume->m_uBlockSideLength != 0) { //No need to compute new block. mCurrentVoxel += this->mVolume->m_uBlockSideLength; @@ -187,7 +187,7 @@ namespace PolyVox else { //We've hit the block boundary. Just calling setPosition() is the easiest way to resolve this. - setPosition(mXPosInVolume, mYPosInVolume, mZPosInVolume); + setPosition(this->mXPosInVolume, this->mYPosInVolume, this->mZPosInVolume); } } @@ -195,7 +195,7 @@ namespace PolyVox void LargeVolume::Sampler::movePositiveZ(void) { //Note the *pre* increament here - if((++mZPosInVolume) % this->mVolume->m_uBlockSideLength != 0) + if((++this->mZPosInVolume) % this->mVolume->m_uBlockSideLength != 0) { //No need to compute new block. mCurrentVoxel += this->mVolume->m_uBlockSideLength * this->mVolume->m_uBlockSideLength; @@ -203,7 +203,7 @@ namespace PolyVox else { //We've hit the block boundary. Just calling setPosition() is the easiest way to resolve this. - setPosition(mXPosInVolume, mYPosInVolume, mZPosInVolume); + setPosition(this->mXPosInVolume, this->mYPosInVolume, this->mZPosInVolume); } } @@ -211,7 +211,7 @@ namespace PolyVox void LargeVolume::Sampler::moveNegativeX(void) { //Note the *post* decreament here - if((mXPosInVolume--) % this->mVolume->m_uBlockSideLength != 0) + if((this->mXPosInVolume--) % this->mVolume->m_uBlockSideLength != 0) { //No need to compute new block. --mCurrentVoxel; @@ -219,7 +219,7 @@ namespace PolyVox else { //We've hit the block boundary. Just calling setPosition() is the easiest way to resolve this. - setPosition(mXPosInVolume, mYPosInVolume, mZPosInVolume); + setPosition(this->mXPosInVolume, this->mYPosInVolume, this->mZPosInVolume); } } @@ -227,7 +227,7 @@ namespace PolyVox void LargeVolume::Sampler::moveNegativeY(void) { //Note the *post* decreament here - if((mYPosInVolume--) % this->mVolume->m_uBlockSideLength != 0) + if((this->mYPosInVolume--) % this->mVolume->m_uBlockSideLength != 0) { //No need to compute new block. mCurrentVoxel -= this->mVolume->m_uBlockSideLength; @@ -235,7 +235,7 @@ namespace PolyVox else { //We've hit the block boundary. Just calling setPosition() is the easiest way to resolve this. - setPosition(mXPosInVolume, mYPosInVolume, mZPosInVolume); + setPosition(this->mXPosInVolume, this->mYPosInVolume, this->mZPosInVolume); } } @@ -243,7 +243,7 @@ namespace PolyVox void LargeVolume::Sampler::moveNegativeZ(void) { //Note the *post* decreament here - if((mZPosInVolume--) % this->mVolume->m_uBlockSideLength != 0) + if((this->mZPosInVolume--) % this->mVolume->m_uBlockSideLength != 0) { //No need to compute new block. mCurrentVoxel -= this->mVolume->m_uBlockSideLength * this->mVolume->m_uBlockSideLength; @@ -251,98 +251,98 @@ namespace PolyVox else { //We've hit the block boundary. Just calling setPosition() is the easiest way to resolve this. - setPosition(mXPosInVolume, mYPosInVolume, mZPosInVolume); + setPosition(this->mXPosInVolume, this->mYPosInVolume, this->mZPosInVolume); } } template VoxelType LargeVolume::Sampler::peekVoxel1nx1ny1nz(void) const { - if( BORDER_LOW(mXPosInVolume) && BORDER_LOW(mYPosInVolume) && BORDER_LOW(mZPosInVolume) ) + if( BORDER_LOW(this->mXPosInVolume) && BORDER_LOW(this->mYPosInVolume) && BORDER_LOW(this->mZPosInVolume) ) { return *(mCurrentVoxel - 1 - this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume-1); + return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume-1,this->mZPosInVolume-1); } template VoxelType LargeVolume::Sampler::peekVoxel1nx1ny0pz(void) const { - if( BORDER_LOW(mXPosInVolume) && BORDER_LOW(mYPosInVolume) ) + if( BORDER_LOW(this->mXPosInVolume) && BORDER_LOW(this->mYPosInVolume) ) { return *(mCurrentVoxel - 1 - this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume); + return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume-1,this->mZPosInVolume); } template VoxelType LargeVolume::Sampler::peekVoxel1nx1ny1pz(void) const { - if( BORDER_LOW(mXPosInVolume) && BORDER_LOW(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) ) + if( BORDER_LOW(this->mXPosInVolume) && BORDER_LOW(this->mYPosInVolume) && BORDER_HIGH(this->mZPosInVolume) ) { return *(mCurrentVoxel - 1 - this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume+1); + return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume-1,this->mZPosInVolume+1); } template VoxelType LargeVolume::Sampler::peekVoxel1nx0py1nz(void) const { - if( BORDER_LOW(mXPosInVolume) && BORDER_LOW(mZPosInVolume) ) + if( BORDER_LOW(this->mXPosInVolume) && BORDER_LOW(this->mZPosInVolume) ) { return *(mCurrentVoxel - 1 - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume-1); + return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume,this->mZPosInVolume-1); } template VoxelType LargeVolume::Sampler::peekVoxel1nx0py0pz(void) const { - if( BORDER_LOW(mXPosInVolume) ) + if( BORDER_LOW(this->mXPosInVolume) ) { return *(mCurrentVoxel - 1); } - return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume); + return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume,this->mZPosInVolume); } template VoxelType LargeVolume::Sampler::peekVoxel1nx0py1pz(void) const { - if( BORDER_LOW(mXPosInVolume) && BORDER_HIGH(mZPosInVolume) ) + if( BORDER_LOW(this->mXPosInVolume) && BORDER_HIGH(this->mZPosInVolume) ) { return *(mCurrentVoxel - 1 + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume+1); + return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume,this->mZPosInVolume+1); } template VoxelType LargeVolume::Sampler::peekVoxel1nx1py1nz(void) const { - if( BORDER_LOW(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) && BORDER_LOW(mYPosInVolume) ) + if( BORDER_LOW(this->mXPosInVolume) && BORDER_HIGH(this->mYPosInVolume) && BORDER_LOW(this->mYPosInVolume) ) { return *(mCurrentVoxel - 1 + this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume-1); + return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume+1,this->mZPosInVolume-1); } template VoxelType LargeVolume::Sampler::peekVoxel1nx1py0pz(void) const { - if( BORDER_LOW(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) ) + if( BORDER_LOW(this->mXPosInVolume) && BORDER_HIGH(this->mYPosInVolume) ) { return *(mCurrentVoxel - 1 + this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume); + return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume+1,this->mZPosInVolume); } template VoxelType LargeVolume::Sampler::peekVoxel1nx1py1pz(void) const { - if( BORDER_LOW(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) ) + if( BORDER_LOW(this->mXPosInVolume) && BORDER_HIGH(this->mYPosInVolume) && BORDER_HIGH(this->mZPosInVolume) ) { return *(mCurrentVoxel - 1 + this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume+1); + return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume+1,this->mZPosInVolume+1); } ////////////////////////////////////////////////////////////////////////// @@ -350,41 +350,41 @@ namespace PolyVox template VoxelType LargeVolume::Sampler::peekVoxel0px1ny1nz(void) const { - if( BORDER_LOW(mYPosInVolume) && BORDER_LOW(mZPosInVolume) ) + if( BORDER_LOW(this->mYPosInVolume) && BORDER_LOW(this->mZPosInVolume) ) { return *(mCurrentVoxel - this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume-1); + return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume-1,this->mZPosInVolume-1); } template VoxelType LargeVolume::Sampler::peekVoxel0px1ny0pz(void) const { - if( BORDER_LOW(mYPosInVolume) ) + if( BORDER_LOW(this->mYPosInVolume) ) { return *(mCurrentVoxel - this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume); + return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume-1,this->mZPosInVolume); } template VoxelType LargeVolume::Sampler::peekVoxel0px1ny1pz(void) const { - if( BORDER_LOW(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) ) + if( BORDER_LOW(this->mYPosInVolume) && BORDER_HIGH(this->mZPosInVolume) ) { return *(mCurrentVoxel - this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume+1); + return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume-1,this->mZPosInVolume+1); } template VoxelType LargeVolume::Sampler::peekVoxel0px0py1nz(void) const { - if( BORDER_LOW(mZPosInVolume) ) + if( BORDER_LOW(this->mZPosInVolume) ) { return *(mCurrentVoxel - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume,mZPosInVolume-1); + return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume,this->mZPosInVolume-1); } template @@ -396,41 +396,41 @@ namespace PolyVox template VoxelType LargeVolume::Sampler::peekVoxel0px0py1pz(void) const { - if( BORDER_HIGH(mZPosInVolume) ) + if( BORDER_HIGH(this->mZPosInVolume) ) { return *(mCurrentVoxel + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume,mZPosInVolume+1); + return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume,this->mZPosInVolume+1); } template VoxelType LargeVolume::Sampler::peekVoxel0px1py1nz(void) const { - if( BORDER_HIGH(mYPosInVolume) && BORDER_LOW(mZPosInVolume) ) + if( BORDER_HIGH(this->mYPosInVolume) && BORDER_LOW(this->mZPosInVolume) ) { return *(mCurrentVoxel + this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume-1); + return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume+1,this->mZPosInVolume-1); } template VoxelType LargeVolume::Sampler::peekVoxel0px1py0pz(void) const { - if( BORDER_HIGH(mYPosInVolume) ) + if( BORDER_HIGH(this->mYPosInVolume) ) { return *(mCurrentVoxel + this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume); + return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume+1,this->mZPosInVolume); } template VoxelType LargeVolume::Sampler::peekVoxel0px1py1pz(void) const { - if( BORDER_HIGH(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) ) + if( BORDER_HIGH(this->mYPosInVolume) && BORDER_HIGH(this->mZPosInVolume) ) { return *(mCurrentVoxel + this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume+1); + return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume+1,this->mZPosInVolume+1); } ////////////////////////////////////////////////////////////////////////// @@ -438,90 +438,90 @@ namespace PolyVox template VoxelType LargeVolume::Sampler::peekVoxel1px1ny1nz(void) const { - if( BORDER_HIGH(mXPosInVolume) && BORDER_LOW(mYPosInVolume) && BORDER_LOW(mZPosInVolume) ) + if( BORDER_HIGH(this->mXPosInVolume) && BORDER_LOW(this->mYPosInVolume) && BORDER_LOW(this->mZPosInVolume) ) { return *(mCurrentVoxel + 1 - this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume-1); + return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume-1,this->mZPosInVolume-1); } template VoxelType LargeVolume::Sampler::peekVoxel1px1ny0pz(void) const { - if( BORDER_HIGH(mXPosInVolume) && BORDER_LOW(mYPosInVolume) ) + if( BORDER_HIGH(this->mXPosInVolume) && BORDER_LOW(this->mYPosInVolume) ) { return *(mCurrentVoxel + 1 - this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume); + return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume-1,this->mZPosInVolume); } template VoxelType LargeVolume::Sampler::peekVoxel1px1ny1pz(void) const { - if( BORDER_HIGH(mXPosInVolume) && BORDER_LOW(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) ) + if( BORDER_HIGH(this->mXPosInVolume) && BORDER_LOW(this->mYPosInVolume) && BORDER_HIGH(this->mZPosInVolume) ) { return *(mCurrentVoxel + 1 - this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume+1); + return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume-1,this->mZPosInVolume+1); } template VoxelType LargeVolume::Sampler::peekVoxel1px0py1nz(void) const { - if( BORDER_HIGH(mXPosInVolume) && BORDER_LOW(mZPosInVolume) ) + if( BORDER_HIGH(this->mXPosInVolume) && BORDER_LOW(this->mZPosInVolume) ) { return *(mCurrentVoxel + 1 - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume-1); + return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume,this->mZPosInVolume-1); } template VoxelType LargeVolume::Sampler::peekVoxel1px0py0pz(void) const { - if( BORDER_HIGH(mXPosInVolume) ) + if( BORDER_HIGH(this->mXPosInVolume) ) { return *(mCurrentVoxel + 1); } - return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume); + return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume,this->mZPosInVolume); } template VoxelType LargeVolume::Sampler::peekVoxel1px0py1pz(void) const { - if( BORDER_HIGH(mXPosInVolume) && BORDER_HIGH(mZPosInVolume) ) + if( BORDER_HIGH(this->mXPosInVolume) && BORDER_HIGH(this->mZPosInVolume) ) { return *(mCurrentVoxel + 1 + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume+1); + return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume,this->mZPosInVolume+1); } template VoxelType LargeVolume::Sampler::peekVoxel1px1py1nz(void) const { - if( BORDER_HIGH(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) && BORDER_LOW(mZPosInVolume) ) + if( BORDER_HIGH(this->mXPosInVolume) && BORDER_HIGH(this->mYPosInVolume) && BORDER_LOW(this->mZPosInVolume) ) { return *(mCurrentVoxel + 1 + this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume-1); + return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume+1,this->mZPosInVolume-1); } template VoxelType LargeVolume::Sampler::peekVoxel1px1py0pz(void) const { - if( BORDER_HIGH(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) ) + if( BORDER_HIGH(this->mXPosInVolume) && BORDER_HIGH(this->mYPosInVolume) ) { return *(mCurrentVoxel + 1 + this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume); + return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume+1,this->mZPosInVolume); } template VoxelType LargeVolume::Sampler::peekVoxel1px1py1pz(void) const { - if( BORDER_HIGH(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) ) + if( BORDER_HIGH(this->mXPosInVolume) && BORDER_HIGH(this->mYPosInVolume) && BORDER_HIGH(this->mZPosInVolume) ) { return *(mCurrentVoxel + 1 + this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume+1); + return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume+1,this->mZPosInVolume+1); } } diff --git a/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl index 2fda578f..cff073fb 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl @@ -45,19 +45,19 @@ namespace PolyVox template int32_t RawVolume::Sampler::getPosX(void) const { - return mXPosInVolume; + return this->mXPosInVolume; } template int32_t RawVolume::Sampler::getPosY(void) const { - return mYPosInVolume; + return this->mYPosInVolume; } template int32_t RawVolume::Sampler::getPosZ(void) const { - return mZPosInVolume; + return this->mZPosInVolume; } template @@ -75,9 +75,9 @@ namespace PolyVox template void RawVolume::Sampler::setPosition(int32_t xPos, int32_t yPos, int32_t zPos) { - mXPosInVolume = xPos; - mYPosInVolume = yPos; - mZPosInVolume = zPos; + this->mXPosInVolume = xPos; + this->mYPosInVolume = yPos; + this->mZPosInVolume = zPos; const uint32_t uVoxelIndex = xPos + yPos * this->mVolume->getWidth() + @@ -91,103 +91,103 @@ namespace PolyVox template void RawVolume::Sampler::movePositiveX(void) { - mXPosInVolume++; + this->mXPosInVolume++; ++mCurrentVoxel; - m_bIsCurrentPositionValid = mXPosInVolume <= this->mVolume->getEnclosingRegion().getUpperCorner().getX(); + m_bIsCurrentPositionValid = this->mXPosInVolume <= this->mVolume->getEnclosingRegion().getUpperCorner().getX(); } template void RawVolume::Sampler::movePositiveY(void) { - mYPosInVolume++; + this->mYPosInVolume++; mCurrentVoxel += this->mVolume->getWidth(); - m_bIsCurrentPositionValid = mYPosInVolume <= this->mVolume->getEnclosingRegion().getUpperCorner().getY(); + m_bIsCurrentPositionValid = this->mYPosInVolume <= this->mVolume->getEnclosingRegion().getUpperCorner().getY(); } template void RawVolume::Sampler::movePositiveZ(void) { - mZPosInVolume++; + this->mZPosInVolume++; mCurrentVoxel += this->mVolume->getWidth() * this->mVolume->getHeight(); - m_bIsCurrentPositionValid = mZPosInVolume <= this->mVolume->getEnclosingRegion().getUpperCorner().getZ(); + m_bIsCurrentPositionValid = this->mZPosInVolume <= this->mVolume->getEnclosingRegion().getUpperCorner().getZ(); } template void RawVolume::Sampler::moveNegativeX(void) { - mXPosInVolume--; + this->mXPosInVolume--; --mCurrentVoxel; - m_bIsCurrentPositionValid = mXPosInVolume >= this->mVolume->getEnclosingRegion().getLowerCorner().getX(); + m_bIsCurrentPositionValid = this->mXPosInVolume >= this->mVolume->getEnclosingRegion().getLowerCorner().getX(); } template void RawVolume::Sampler::moveNegativeY(void) { - mYPosInVolume--; + this->mYPosInVolume--; mCurrentVoxel -= this->mVolume->getWidth(); - m_bIsCurrentPositionValid = mYPosInVolume >= this->mVolume->getEnclosingRegion().getLowerCorner().getY(); + m_bIsCurrentPositionValid = this->mYPosInVolume >= this->mVolume->getEnclosingRegion().getLowerCorner().getY(); } template void RawVolume::Sampler::moveNegativeZ(void) { - mZPosInVolume--; + this->mZPosInVolume--; mCurrentVoxel -= this->mVolume->getWidth() * this->mVolume->getHeight(); - m_bIsCurrentPositionValid =mZPosInVolume >= this->mVolume->getEnclosingRegion().getLowerCorner().getZ(); + m_bIsCurrentPositionValid =this->mZPosInVolume >= this->mVolume->getEnclosingRegion().getLowerCorner().getZ(); } template VoxelType RawVolume::Sampler::peekVoxel1nx1ny1nz(void) const { - return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume-1); + return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume-1,this->mZPosInVolume-1); } template VoxelType RawVolume::Sampler::peekVoxel1nx1ny0pz(void) const { - return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume); + return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume-1,this->mZPosInVolume); } template VoxelType RawVolume::Sampler::peekVoxel1nx1ny1pz(void) const { - return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume+1); + return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume-1,this->mZPosInVolume+1); } template VoxelType RawVolume::Sampler::peekVoxel1nx0py1nz(void) const { - return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume-1); + return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume,this->mZPosInVolume-1); } template VoxelType RawVolume::Sampler::peekVoxel1nx0py0pz(void) const { - return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume); + return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume,this->mZPosInVolume); } template VoxelType RawVolume::Sampler::peekVoxel1nx0py1pz(void) const { - return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume+1); + return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume,this->mZPosInVolume+1); } template VoxelType RawVolume::Sampler::peekVoxel1nx1py1nz(void) const { - return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume-1); + return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume+1,this->mZPosInVolume-1); } template VoxelType RawVolume::Sampler::peekVoxel1nx1py0pz(void) const { - return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume); + return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume+1,this->mZPosInVolume); } template VoxelType RawVolume::Sampler::peekVoxel1nx1py1pz(void) const { - return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume+1); + return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume+1,this->mZPosInVolume+1); } ////////////////////////////////////////////////////////////////////////// @@ -195,25 +195,25 @@ namespace PolyVox template VoxelType RawVolume::Sampler::peekVoxel0px1ny1nz(void) const { - return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume-1); + return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume-1,this->mZPosInVolume-1); } template VoxelType RawVolume::Sampler::peekVoxel0px1ny0pz(void) const { - return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume); + return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume-1,this->mZPosInVolume); } template VoxelType RawVolume::Sampler::peekVoxel0px1ny1pz(void) const { - return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume+1); + return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume-1,this->mZPosInVolume+1); } template VoxelType RawVolume::Sampler::peekVoxel0px0py1nz(void) const { - return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume,mZPosInVolume-1); + return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume,this->mZPosInVolume-1); } template @@ -225,25 +225,25 @@ namespace PolyVox template VoxelType RawVolume::Sampler::peekVoxel0px0py1pz(void) const { - return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume,mZPosInVolume+1); + return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume,this->mZPosInVolume+1); } template VoxelType RawVolume::Sampler::peekVoxel0px1py1nz(void) const { - return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume-1); + return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume+1,this->mZPosInVolume-1); } template VoxelType RawVolume::Sampler::peekVoxel0px1py0pz(void) const { - return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume); + return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume+1,this->mZPosInVolume); } template VoxelType RawVolume::Sampler::peekVoxel0px1py1pz(void) const { - return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume+1); + return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume+1,this->mZPosInVolume+1); } ////////////////////////////////////////////////////////////////////////// @@ -251,54 +251,54 @@ namespace PolyVox template VoxelType RawVolume::Sampler::peekVoxel1px1ny1nz(void) const { - return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume-1); + return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume-1,this->mZPosInVolume-1); } template VoxelType RawVolume::Sampler::peekVoxel1px1ny0pz(void) const { - return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume); + return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume-1,this->mZPosInVolume); } template VoxelType RawVolume::Sampler::peekVoxel1px1ny1pz(void) const { - return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume+1); + return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume-1,this->mZPosInVolume+1); } template VoxelType RawVolume::Sampler::peekVoxel1px0py1nz(void) const { - return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume-1); + return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume,this->mZPosInVolume-1); } template VoxelType RawVolume::Sampler::peekVoxel1px0py0pz(void) const { - return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume); + return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume,this->mZPosInVolume); } template VoxelType RawVolume::Sampler::peekVoxel1px0py1pz(void) const { - return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume+1); + return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume,this->mZPosInVolume+1); } template VoxelType RawVolume::Sampler::peekVoxel1px1py1nz(void) const { - return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume-1); + return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume+1,this->mZPosInVolume-1); } template VoxelType RawVolume::Sampler::peekVoxel1px1py0pz(void) const { - return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume); + return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume+1,this->mZPosInVolume); } template VoxelType RawVolume::Sampler::peekVoxel1px1py1pz(void) const { - return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume+1); + return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume+1,this->mZPosInVolume+1); } } diff --git a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl index 855fbaf0..ba8bdb1a 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl @@ -53,9 +53,9 @@ namespace PolyVox return *this; } this->mVolume = rhs.mVolume; - mXPosInVolume = rhs.mXPosInVolume; - mYPosInVolume = rhs.mYPosInVolume; - mZPosInVolume = rhs.mZPosInVolume; + this->mXPosInVolume = rhs.mXPosInVolume; + this->mYPosInVolume = rhs.mYPosInVolume; + this->mZPosInVolume = rhs.mZPosInVolume; mCurrentVoxel = rhs.mCurrentVoxel; return *this; } @@ -63,19 +63,19 @@ namespace PolyVox template int32_t SimpleVolume::Sampler::getPosX(void) const { - return mXPosInVolume; + return this->mXPosInVolume; } template int32_t SimpleVolume::Sampler::getPosY(void) const { - return mYPosInVolume; + return this->mYPosInVolume; } template int32_t SimpleVolume::Sampler::getPosZ(void) const { - return mZPosInVolume; + return this->mZPosInVolume; } template @@ -108,7 +108,7 @@ namespace PolyVox { for(uint8_t x = 0; x < uSize; ++x) { - tValue = (std::min)(tValue, this->mVolume->getVoxelAt(mXPosInVolume + x, mYPosInVolume + y, mZPosInVolume + z)); + tValue = (std::min)(tValue, this->mVolume->getVoxelAt(this->mXPosInVolume + x, this->mYPosInVolume + y, this->mZPosInVolume + z)); } } } @@ -131,17 +131,17 @@ namespace PolyVox template void SimpleVolume::Sampler::setPosition(int32_t xPos, int32_t yPos, int32_t zPos) { - mXPosInVolume = xPos; - mYPosInVolume = yPos; - mZPosInVolume = zPos; + this->mXPosInVolume = xPos; + this->mYPosInVolume = yPos; + this->mZPosInVolume = zPos; - const int32_t uXBlock = mXPosInVolume >> this->mVolume->m_uBlockSideLengthPower; - const int32_t uYBlock = mYPosInVolume >> this->mVolume->m_uBlockSideLengthPower; - const int32_t uZBlock = mZPosInVolume >> this->mVolume->m_uBlockSideLengthPower; + const int32_t uXBlock = this->mXPosInVolume >> this->mVolume->m_uBlockSideLengthPower; + const int32_t uYBlock = this->mYPosInVolume >> this->mVolume->m_uBlockSideLengthPower; + const int32_t uZBlock = this->mZPosInVolume >> this->mVolume->m_uBlockSideLengthPower; - const uint16_t uXPosInBlock = mXPosInVolume - (uXBlock << this->mVolume->m_uBlockSideLengthPower); - const uint16_t uYPosInBlock = mYPosInVolume - (uYBlock << this->mVolume->m_uBlockSideLengthPower); - const uint16_t uZPosInBlock = mZPosInVolume - (uZBlock << this->mVolume->m_uBlockSideLengthPower); + const uint16_t uXPosInBlock = this->mXPosInVolume - (uXBlock << this->mVolume->m_uBlockSideLengthPower); + const uint16_t uYPosInBlock = this->mYPosInVolume - (uYBlock << this->mVolume->m_uBlockSideLengthPower); + const uint16_t uZPosInBlock = this->mZPosInVolume - (uZBlock << this->mVolume->m_uBlockSideLengthPower); const uint32_t uVoxelIndexInBlock = uXPosInBlock + uYPosInBlock * this->mVolume->m_uBlockSideLength + @@ -163,7 +163,7 @@ namespace PolyVox void SimpleVolume::Sampler::movePositiveX(void) { //Note the *pre* increament here - if((++mXPosInVolume) % this->mVolume->m_uBlockSideLength != 0) + if((++this->mXPosInVolume) % this->mVolume->m_uBlockSideLength != 0) { //No need to compute new block. ++mCurrentVoxel; @@ -171,7 +171,7 @@ namespace PolyVox else { //We've hit the block boundary. Just calling setPosition() is the easiest way to resolve this. - setPosition(mXPosInVolume, mYPosInVolume, mZPosInVolume); + setPosition(this->mXPosInVolume, this->mYPosInVolume, this->mZPosInVolume); } } @@ -179,7 +179,7 @@ namespace PolyVox void SimpleVolume::Sampler::movePositiveY(void) { //Note the *pre* increament here - if((++mYPosInVolume) % this->mVolume->m_uBlockSideLength != 0) + if((++this->mYPosInVolume) % this->mVolume->m_uBlockSideLength != 0) { //No need to compute new block. mCurrentVoxel += this->mVolume->m_uBlockSideLength; @@ -187,7 +187,7 @@ namespace PolyVox else { //We've hit the block boundary. Just calling setPosition() is the easiest way to resolve this. - setPosition(mXPosInVolume, mYPosInVolume, mZPosInVolume); + setPosition(this->mXPosInVolume, this->mYPosInVolume, this->mZPosInVolume); } } @@ -195,7 +195,7 @@ namespace PolyVox void SimpleVolume::Sampler::movePositiveZ(void) { //Note the *pre* increament here - if((++mZPosInVolume) % this->mVolume->m_uBlockSideLength != 0) + if((++this->mZPosInVolume) % this->mVolume->m_uBlockSideLength != 0) { //No need to compute new block. mCurrentVoxel += this->mVolume->m_uBlockSideLength * this->mVolume->m_uBlockSideLength; @@ -203,7 +203,7 @@ namespace PolyVox else { //We've hit the block boundary. Just calling setPosition() is the easiest way to resolve this. - setPosition(mXPosInVolume, mYPosInVolume, mZPosInVolume); + setPosition(this->mXPosInVolume, this->mYPosInVolume, this->mZPosInVolume); } } @@ -211,7 +211,7 @@ namespace PolyVox void SimpleVolume::Sampler::moveNegativeX(void) { //Note the *post* decreament here - if((mXPosInVolume--) % this->mVolume->m_uBlockSideLength != 0) + if((this->mXPosInVolume--) % this->mVolume->m_uBlockSideLength != 0) { //No need to compute new block. --mCurrentVoxel; @@ -219,7 +219,7 @@ namespace PolyVox else { //We've hit the block boundary. Just calling setPosition() is the easiest way to resolve this. - setPosition(mXPosInVolume, mYPosInVolume, mZPosInVolume); + setPosition(this->mXPosInVolume, this->mYPosInVolume, this->mZPosInVolume); } } @@ -227,7 +227,7 @@ namespace PolyVox void SimpleVolume::Sampler::moveNegativeY(void) { //Note the *post* decreament here - if((mYPosInVolume--) % this->mVolume->m_uBlockSideLength != 0) + if((this->mYPosInVolume--) % this->mVolume->m_uBlockSideLength != 0) { //No need to compute new block. mCurrentVoxel -= this->mVolume->m_uBlockSideLength; @@ -235,7 +235,7 @@ namespace PolyVox else { //We've hit the block boundary. Just calling setPosition() is the easiest way to resolve this. - setPosition(mXPosInVolume, mYPosInVolume, mZPosInVolume); + setPosition(this->mXPosInVolume, this->mYPosInVolume, this->mZPosInVolume); } } @@ -243,7 +243,7 @@ namespace PolyVox void SimpleVolume::Sampler::moveNegativeZ(void) { //Note the *post* decreament here - if((mZPosInVolume--) % this->mVolume->m_uBlockSideLength != 0) + if((this->mZPosInVolume--) % this->mVolume->m_uBlockSideLength != 0) { //No need to compute new block. mCurrentVoxel -= this->mVolume->m_uBlockSideLength * this->mVolume->m_uBlockSideLength; @@ -251,98 +251,98 @@ namespace PolyVox else { //We've hit the block boundary. Just calling setPosition() is the easiest way to resolve this. - setPosition(mXPosInVolume, mYPosInVolume, mZPosInVolume); + setPosition(this->mXPosInVolume, this->mYPosInVolume, this->mZPosInVolume); } } template VoxelType SimpleVolume::Sampler::peekVoxel1nx1ny1nz(void) const { - if( BORDER_LOW(mXPosInVolume) && BORDER_LOW(mYPosInVolume) && BORDER_LOW(mZPosInVolume) ) + if( BORDER_LOW(this->mXPosInVolume) && BORDER_LOW(this->mYPosInVolume) && BORDER_LOW(this->mZPosInVolume) ) { return *(mCurrentVoxel - 1 - this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume-1); + return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume-1,this->mZPosInVolume-1); } template VoxelType SimpleVolume::Sampler::peekVoxel1nx1ny0pz(void) const { - if( BORDER_LOW(mXPosInVolume) && BORDER_LOW(mYPosInVolume) ) + if( BORDER_LOW(this->mXPosInVolume) && BORDER_LOW(this->mYPosInVolume) ) { return *(mCurrentVoxel - 1 - this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume); + return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume-1,this->mZPosInVolume); } template VoxelType SimpleVolume::Sampler::peekVoxel1nx1ny1pz(void) const { - if( BORDER_LOW(mXPosInVolume) && BORDER_LOW(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) ) + if( BORDER_LOW(this->mXPosInVolume) && BORDER_LOW(this->mYPosInVolume) && BORDER_HIGH(this->mZPosInVolume) ) { return *(mCurrentVoxel - 1 - this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume+1); + return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume-1,this->mZPosInVolume+1); } template VoxelType SimpleVolume::Sampler::peekVoxel1nx0py1nz(void) const { - if( BORDER_LOW(mXPosInVolume) && BORDER_LOW(mZPosInVolume) ) + if( BORDER_LOW(this->mXPosInVolume) && BORDER_LOW(this->mZPosInVolume) ) { return *(mCurrentVoxel - 1 - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume-1); + return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume,this->mZPosInVolume-1); } template VoxelType SimpleVolume::Sampler::peekVoxel1nx0py0pz(void) const { - if( BORDER_LOW(mXPosInVolume) ) + if( BORDER_LOW(this->mXPosInVolume) ) { return *(mCurrentVoxel - 1); } - return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume); + return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume,this->mZPosInVolume); } template VoxelType SimpleVolume::Sampler::peekVoxel1nx0py1pz(void) const { - if( BORDER_LOW(mXPosInVolume) && BORDER_HIGH(mZPosInVolume) ) + if( BORDER_LOW(this->mXPosInVolume) && BORDER_HIGH(this->mZPosInVolume) ) { return *(mCurrentVoxel - 1 + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume+1); + return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume,this->mZPosInVolume+1); } template VoxelType SimpleVolume::Sampler::peekVoxel1nx1py1nz(void) const { - if( BORDER_LOW(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) && BORDER_LOW(mYPosInVolume) ) + if( BORDER_LOW(this->mXPosInVolume) && BORDER_HIGH(this->mYPosInVolume) && BORDER_LOW(this->mYPosInVolume) ) { return *(mCurrentVoxel - 1 + this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume-1); + return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume+1,this->mZPosInVolume-1); } template VoxelType SimpleVolume::Sampler::peekVoxel1nx1py0pz(void) const { - if( BORDER_LOW(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) ) + if( BORDER_LOW(this->mXPosInVolume) && BORDER_HIGH(this->mYPosInVolume) ) { return *(mCurrentVoxel - 1 + this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume); + return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume+1,this->mZPosInVolume); } template VoxelType SimpleVolume::Sampler::peekVoxel1nx1py1pz(void) const { - if( BORDER_LOW(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) ) + if( BORDER_LOW(this->mXPosInVolume) && BORDER_HIGH(this->mYPosInVolume) && BORDER_HIGH(this->mZPosInVolume) ) { return *(mCurrentVoxel - 1 + this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume+1); + return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume+1,this->mZPosInVolume+1); } ////////////////////////////////////////////////////////////////////////// @@ -350,41 +350,41 @@ namespace PolyVox template VoxelType SimpleVolume::Sampler::peekVoxel0px1ny1nz(void) const { - if( BORDER_LOW(mYPosInVolume) && BORDER_LOW(mZPosInVolume) ) + if( BORDER_LOW(this->mYPosInVolume) && BORDER_LOW(this->mZPosInVolume) ) { return *(mCurrentVoxel - this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume-1); + return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume-1,this->mZPosInVolume-1); } template VoxelType SimpleVolume::Sampler::peekVoxel0px1ny0pz(void) const { - if( BORDER_LOW(mYPosInVolume) ) + if( BORDER_LOW(this->mYPosInVolume) ) { return *(mCurrentVoxel - this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume); + return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume-1,this->mZPosInVolume); } template VoxelType SimpleVolume::Sampler::peekVoxel0px1ny1pz(void) const { - if( BORDER_LOW(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) ) + if( BORDER_LOW(this->mYPosInVolume) && BORDER_HIGH(this->mZPosInVolume) ) { return *(mCurrentVoxel - this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume+1); + return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume-1,this->mZPosInVolume+1); } template VoxelType SimpleVolume::Sampler::peekVoxel0px0py1nz(void) const { - if( BORDER_LOW(mZPosInVolume) ) + if( BORDER_LOW(this->mZPosInVolume) ) { return *(mCurrentVoxel - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume,mZPosInVolume-1); + return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume,this->mZPosInVolume-1); } template @@ -396,41 +396,41 @@ namespace PolyVox template VoxelType SimpleVolume::Sampler::peekVoxel0px0py1pz(void) const { - if( BORDER_HIGH(mZPosInVolume) ) + if( BORDER_HIGH(this->mZPosInVolume) ) { return *(mCurrentVoxel + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume,mZPosInVolume+1); + return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume,this->mZPosInVolume+1); } template VoxelType SimpleVolume::Sampler::peekVoxel0px1py1nz(void) const { - if( BORDER_HIGH(mYPosInVolume) && BORDER_LOW(mZPosInVolume) ) + if( BORDER_HIGH(this->mYPosInVolume) && BORDER_LOW(this->mZPosInVolume) ) { return *(mCurrentVoxel + this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume-1); + return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume+1,this->mZPosInVolume-1); } template VoxelType SimpleVolume::Sampler::peekVoxel0px1py0pz(void) const { - if( BORDER_HIGH(mYPosInVolume) ) + if( BORDER_HIGH(this->mYPosInVolume) ) { return *(mCurrentVoxel + this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume); + return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume+1,this->mZPosInVolume); } template VoxelType SimpleVolume::Sampler::peekVoxel0px1py1pz(void) const { - if( BORDER_HIGH(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) ) + if( BORDER_HIGH(this->mYPosInVolume) && BORDER_HIGH(this->mZPosInVolume) ) { return *(mCurrentVoxel + this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume+1); + return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume+1,this->mZPosInVolume+1); } ////////////////////////////////////////////////////////////////////////// @@ -438,90 +438,90 @@ namespace PolyVox template VoxelType SimpleVolume::Sampler::peekVoxel1px1ny1nz(void) const { - if( BORDER_HIGH(mXPosInVolume) && BORDER_LOW(mYPosInVolume) && BORDER_LOW(mZPosInVolume) ) + if( BORDER_HIGH(this->mXPosInVolume) && BORDER_LOW(this->mYPosInVolume) && BORDER_LOW(this->mZPosInVolume) ) { return *(mCurrentVoxel + 1 - this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume-1); + return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume-1,this->mZPosInVolume-1); } template VoxelType SimpleVolume::Sampler::peekVoxel1px1ny0pz(void) const { - if( BORDER_HIGH(mXPosInVolume) && BORDER_LOW(mYPosInVolume) ) + if( BORDER_HIGH(this->mXPosInVolume) && BORDER_LOW(this->mYPosInVolume) ) { return *(mCurrentVoxel + 1 - this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume); + return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume-1,this->mZPosInVolume); } template VoxelType SimpleVolume::Sampler::peekVoxel1px1ny1pz(void) const { - if( BORDER_HIGH(mXPosInVolume) && BORDER_LOW(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) ) + if( BORDER_HIGH(this->mXPosInVolume) && BORDER_LOW(this->mYPosInVolume) && BORDER_HIGH(this->mZPosInVolume) ) { return *(mCurrentVoxel + 1 - this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume+1); + return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume-1,this->mZPosInVolume+1); } template VoxelType SimpleVolume::Sampler::peekVoxel1px0py1nz(void) const { - if( BORDER_HIGH(mXPosInVolume) && BORDER_LOW(mZPosInVolume) ) + if( BORDER_HIGH(this->mXPosInVolume) && BORDER_LOW(this->mZPosInVolume) ) { return *(mCurrentVoxel + 1 - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume-1); + return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume,this->mZPosInVolume-1); } template VoxelType SimpleVolume::Sampler::peekVoxel1px0py0pz(void) const { - if( BORDER_HIGH(mXPosInVolume) ) + if( BORDER_HIGH(this->mXPosInVolume) ) { return *(mCurrentVoxel + 1); } - return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume); + return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume,this->mZPosInVolume); } template VoxelType SimpleVolume::Sampler::peekVoxel1px0py1pz(void) const { - if( BORDER_HIGH(mXPosInVolume) && BORDER_HIGH(mZPosInVolume) ) + if( BORDER_HIGH(this->mXPosInVolume) && BORDER_HIGH(this->mZPosInVolume) ) { return *(mCurrentVoxel + 1 + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume+1); + return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume,this->mZPosInVolume+1); } template VoxelType SimpleVolume::Sampler::peekVoxel1px1py1nz(void) const { - if( BORDER_HIGH(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) && BORDER_LOW(mZPosInVolume) ) + if( BORDER_HIGH(this->mXPosInVolume) && BORDER_HIGH(this->mYPosInVolume) && BORDER_LOW(this->mZPosInVolume) ) { return *(mCurrentVoxel + 1 + this->mVolume->m_uBlockSideLength - this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume-1); + return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume+1,this->mZPosInVolume-1); } template VoxelType SimpleVolume::Sampler::peekVoxel1px1py0pz(void) const { - if( BORDER_HIGH(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) ) + if( BORDER_HIGH(this->mXPosInVolume) && BORDER_HIGH(this->mYPosInVolume) ) { return *(mCurrentVoxel + 1 + this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume); + return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume+1,this->mZPosInVolume); } template VoxelType SimpleVolume::Sampler::peekVoxel1px1py1pz(void) const { - if( BORDER_HIGH(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) ) + if( BORDER_HIGH(this->mXPosInVolume) && BORDER_HIGH(this->mYPosInVolume) && BORDER_HIGH(this->mZPosInVolume) ) { return *(mCurrentVoxel + 1 + this->mVolume->m_uBlockSideLength + this->mVolume->m_uBlockSideLength*this->mVolume->m_uBlockSideLength); } - return this->mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume+1); + return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume+1,this->mZPosInVolume+1); } }