From 64d010527bda0fd885993974d409d840090062c4 Mon Sep 17 00:00:00 2001 From: David Williams Date: Fri, 27 Feb 2015 11:07:15 +0100 Subject: [PATCH] Removed old getVoxelAt()/setVoxelAt() functions. they've been flagged as deprecated for a while now, and are replaced by just getVoxel()/setVoxel(). --- examples/Basic/main.cpp | 2 +- examples/DecodeOnGPU/main.cpp | 2 +- examples/OpenGL/Shapes.cpp | 4 +- examples/Paging/main.cpp | 4 +- examples/SmoothLOD/main.cpp | 4 +- include/PolyVox/BaseVolume.h | 9 --- include/PolyVox/BaseVolume.inl | 50 --------------- include/PolyVox/BaseVolumeSampler.inl | 2 +- include/PolyVox/Impl/Config.h | 4 +- include/PolyVox/LowPassFilter.inl | 16 ++--- include/PolyVox/PagedVolume.h | 14 +---- include/PolyVox/PagedVolume.inl | 82 +----------------------- include/PolyVox/PagedVolumeChunk.inl | 6 +- include/PolyVox/PagedVolumeSampler.inl | 2 +- include/PolyVox/RawVolume.h | 9 --- include/PolyVox/RawVolume.inl | 83 ------------------------- include/PolyVox/VolumeResampler.inl | 4 +- tests/TestAStarPathfinder.cpp | 4 +- tests/TestAmbientOcclusionGenerator.cpp | 2 +- tests/TestCubicSurfaceExtractor.cpp | 8 +-- tests/TestLowPassFilter.cpp | 2 +- tests/TestPicking.cpp | 4 +- tests/TestRaycast.cpp | 4 +- tests/TestSurfaceExtractor.cpp | 4 +- tests/TestVolumeSubclass.cpp | 6 +- tests/testvolume.cpp | 4 +- 26 files changed, 48 insertions(+), 287 deletions(-) diff --git a/examples/Basic/main.cpp b/examples/Basic/main.cpp index 2627cd7b..cfa415ef 100644 --- a/examples/Basic/main.cpp +++ b/examples/Basic/main.cpp @@ -60,7 +60,7 @@ void createSphereInVolume(PagedVolume& volData, float fRadius) } //Wrte the voxel value into the volume - volData.setVoxelAt(x, y, z, uVoxelValue); + volData.setVoxel(x, y, z, uVoxelValue); } } } diff --git a/examples/DecodeOnGPU/main.cpp b/examples/DecodeOnGPU/main.cpp index 158bcfec..f36989f4 100644 --- a/examples/DecodeOnGPU/main.cpp +++ b/examples/DecodeOnGPU/main.cpp @@ -60,7 +60,7 @@ void createSphereInVolume(PagedVolume& volData, float fRadius) } //Wrte the voxel value into the volume - volData.setVoxelAt(x, y, z, uVoxelValue); + volData.setVoxel(x, y, z, uVoxelValue); } } } diff --git a/examples/OpenGL/Shapes.cpp b/examples/OpenGL/Shapes.cpp index 1ebe6e58..48cd350b 100644 --- a/examples/OpenGL/Shapes.cpp +++ b/examples/OpenGL/Shapes.cpp @@ -48,7 +48,7 @@ void createSphereInVolume(PagedVolume& volData, float fRa //then we make it solid, otherwise we make it empty space. if(fDistToCenter <= fRadius) { - volData.setVoxelAt(x,y,z, MaterialDensityPair88(uValue, uValue > 0 ? MaterialDensityPair88::getMaxDensity() : MaterialDensityPair88::getMinDensity())); + volData.setVoxel(x,y,z, MaterialDensityPair88(uValue, uValue > 0 ? MaterialDensityPair88::getMaxDensity() : MaterialDensityPair88::getMinDensity())); } } } @@ -66,7 +66,7 @@ void createCubeInVolume(PagedVolume& volData, Vector3DInt { for (int x = lowerCorner.getX() ; x <= upperCorner.getX(); x++) { - volData.setVoxelAt(x,y,z, MaterialDensityPair88(uValue, uValue > 0 ? maxDen : minDen)); + volData.setVoxel(x,y,z, MaterialDensityPair88(uValue, uValue > 0 ? maxDen : minDen)); } } } diff --git a/examples/Paging/main.cpp b/examples/Paging/main.cpp index 415a466d..39a43d0e 100644 --- a/examples/Paging/main.cpp +++ b/examples/Paging/main.cpp @@ -67,7 +67,7 @@ void createSphereInVolume(PagedVolume& volData, Vector3DF voxel.setDensity(uDensity); //Wrte the voxel value into the volume - volData.setVoxelAt(x, y, z, voxel); + volData.setVoxel(x, y, z, voxel); } } } @@ -127,7 +127,7 @@ public: // Voxel position within a chunk always start from zero. So if a chunk represents region (4, 8, 12) to (11, 19, 15) // then the valid chunk voxels are from (0, 0, 0) to (7, 11, 3). Hence we subtract the lower corner position of the // region from the volume space position in order to get the chunk space position. - pChunk->setVoxelAt(x - region.getLowerX(), y - region.getLowerY(), z - region.getLowerZ(), voxel); + pChunk->setVoxel(x - region.getLowerX(), y - region.getLowerY(), z - region.getLowerZ(), voxel); } } } diff --git a/examples/SmoothLOD/main.cpp b/examples/SmoothLOD/main.cpp index 57cfcd90..73be1ca5 100644 --- a/examples/SmoothLOD/main.cpp +++ b/examples/SmoothLOD/main.cpp @@ -58,11 +58,11 @@ void createSphereInVolume(PagedVolume& volData, float fRadius) uint8_t uDensity = std::numeric_limits::max(); //Wrte the voxel value into the volume - volData.setVoxelAt(x, y, z, uDensity); + volData.setVoxel(x, y, z, uDensity); } //144 in the middle, (144 - 32) at the edges. Threshold of 128 is between these - //volData.setVoxelAt(x, y, z, 144 - fDistToCenter); + //volData.setVoxel(x, y, z, 144 - fDistToCenter); } } } diff --git a/include/PolyVox/BaseVolume.h b/include/PolyVox/BaseVolume.h index 57898ffb..f566e92f 100644 --- a/include/PolyVox/BaseVolume.h +++ b/include/PolyVox/BaseVolume.h @@ -165,11 +165,6 @@ namespace PolyVox VoxelType getVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, WrapMode eWrapMode = WrapModes::Validate, VoxelType tBorder = VoxelType()) const; /// Gets a voxel at the position given by a 3D vector VoxelType getVoxel(const Vector3DInt32& v3dPos, WrapMode eWrapMode = WrapModes::Validate, VoxelType tBorder = VoxelType()) const; - - /// Gets a voxel at the position given by x,y,z coordinates - POLYVOX_DEPRECATED VoxelType getVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos) const; - /// Gets a voxel at the position given by a 3D vector - POLYVOX_DEPRECATED VoxelType getVoxelAt(const Vector3DInt32& v3dPos) const; /// Sets the value used for voxels which are outside the volume void setBorderValue(const VoxelType& tBorder); @@ -177,10 +172,6 @@ namespace PolyVox void setVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue, WrapMode eWrapMode = WrapModes::Validate); /// Sets the voxel at the position given by a 3D vector void setVoxel(const Vector3DInt32& v3dPos, VoxelType tValue, WrapMode eWrapMode = WrapModes::Validate); - /// 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); diff --git a/include/PolyVox/BaseVolume.inl b/include/PolyVox/BaseVolume.inl index 4f2d8121..16d3a761 100644 --- a/include/PolyVox/BaseVolume.inl +++ b/include/PolyVox/BaseVolume.inl @@ -221,30 +221,6 @@ namespace PolyVox return VoxelType(); } - //////////////////////////////////////////////////////////////////////////////// - /// \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 BaseVolume::getVoxelAt(int32_t /*uXPos*/, int32_t /*uYPos*/, int32_t /*uZPos*/) const - { - POLYVOX_THROW(not_implemented, "You should never call the base class version of this function."); - return VoxelType(); - } - - //////////////////////////////////////////////////////////////////////////////// - /// \param v3dPos The 3D position of the voxel - /// \return The voxel value - //////////////////////////////////////////////////////////////////////////////// - template - VoxelType BaseVolume::getVoxelAt(const Vector3DInt32& /*v3dPos*/) const - { - POLYVOX_THROW(not_implemented, "You should never call the base class version of this function."); - return VoxelType(); - } - //////////////////////////////////////////////////////////////////////////////// /// \param tBorder The value to use for voxels outside the volume. //////////////////////////////////////////////////////////////////////////////// @@ -276,32 +252,6 @@ namespace PolyVox POLYVOX_THROW(not_implemented, "You should never call the base class version of this function."); } - //////////////////////////////////////////////////////////////////////////////// - /// \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 BaseVolume::setVoxelAt(int32_t /*uXPos*/, int32_t /*uYPos*/, int32_t /*uZPos*/, VoxelType /*tValue*/) - { - POLYVOX_THROW(not_implemented, "You should never call the base class version of this function."); - 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 BaseVolume::setVoxelAt(const Vector3DInt32& /*v3dPos*/, VoxelType /*tValue*/) - { - POLYVOX_THROW(not_implemented, "You should never call the base class version of this function."); - return false; - } - //////////////////////////////////////////////////////////////////////////////// /// Note: This function needs reviewing for accuracy... //////////////////////////////////////////////////////////////////////////////// diff --git a/include/PolyVox/BaseVolumeSampler.inl b/include/PolyVox/BaseVolumeSampler.inl index 993113a3..b4690db3 100644 --- a/include/PolyVox/BaseVolumeSampler.inl +++ b/include/PolyVox/BaseVolumeSampler.inl @@ -91,7 +91,7 @@ namespace PolyVox template bool BaseVolume::Sampler::setVoxel(VoxelType tValue) { - return mVolume->setVoxelAt(mXPosInVolume, mYPosInVolume, mZPosInVolume, tValue); + return mVolume->setVoxel(mXPosInVolume, mYPosInVolume, mZPosInVolume, tValue); } template diff --git a/include/PolyVox/Impl/Config.h b/include/PolyVox/Impl/Config.h index 4a39a615..1959a6d2 100644 --- a/include/PolyVox/Impl/Config.h +++ b/include/PolyVox/Impl/Config.h @@ -25,13 +25,13 @@ freely, subject to the following restrictions: #define __PolyVox_Config_H__ //#define POLYVOX_LOG_TRACE_ENABLED -#define POLYVOX_LOG_DEBUG_ENABLED +//#define POLYVOX_LOG_DEBUG_ENABLED #define POLYVOX_LOG_INFO_ENABLED #define POLYVOX_LOG_WARNING_ENABLED #define POLYVOX_LOG_ERROR_ENABLED #define POLYVOX_LOG_FATAL_ENABLED -#define POLYVOX_ASSERTS_ENABLED +//#define POLYVOX_ASSERTS_ENABLED #define POLYVOX_THROW_ENABLED #endif diff --git a/include/PolyVox/LowPassFilter.inl b/include/PolyVox/LowPassFilter.inl index d4211f44..78e402c2 100644 --- a/include/PolyVox/LowPassFilter.inl +++ b/include/PolyVox/LowPassFilter.inl @@ -114,7 +114,7 @@ namespace PolyVox tSrcVoxel /= 27; //tSrcVoxel.setDensity(uDensity); - m_pVolDst->setVoxelAt(iSrcX, iSrcY, iSrcZ, static_cast(tSrcVoxel)); + m_pVolDst->setVoxel(iSrcX, iSrcY, iSrcZ, static_cast(tSrcVoxel)); } } } @@ -141,7 +141,7 @@ namespace PolyVox { for(int32_t x = satLowerCorner.getX(); x <= satUpperCorner.getX(); x++) { - satVolume.setVoxelAt(x,y,z,0); + satVolume.setVoxel(x,y,z,0); } } } @@ -178,10 +178,10 @@ namespace PolyVox { for(int32_t x = satLowerCorner.getX(); x <= satUpperCorner.getX(); x++) { - AccumulationType previousSum = static_cast(satVolume.getVoxelAt(x-1,y,z)); - AccumulationType currentVal = static_cast(m_pVolSrc->getVoxelAt(x,y,z)); + AccumulationType previousSum = static_cast(satVolume.getVoxel(x-1,y,z)); + AccumulationType currentVal = static_cast(m_pVolSrc->getVoxel(x,y,z)); - satVolume.setVoxelAt(x,y,z,previousSum + currentVal); + satVolume.setVoxel(x,y,z,previousSum + currentVal); } } }*/ @@ -195,7 +195,7 @@ namespace PolyVox AccumulationType previousSum = static_cast(satVolume.getVoxel(x,y-1,z, WrapModes::Border)); AccumulationType currentSum = static_cast(satVolume.getVoxel(x,y,z, WrapModes::Border)); - satVolume.setVoxelAt(x,y,z,previousSum + currentSum); + satVolume.setVoxel(x,y,z,previousSum + currentSum); } } } @@ -209,7 +209,7 @@ namespace PolyVox AccumulationType previousSum = static_cast(satVolume.getVoxel(x,y,z-1, WrapModes::Border)); AccumulationType currentSum = static_cast(satVolume.getVoxel(x,y,z, WrapModes::Border)); - satVolume.setVoxelAt(x,y,z,previousSum + currentSum); + satVolume.setVoxel(x,y,z,previousSum + currentSum); } } } @@ -247,7 +247,7 @@ namespace PolyVox uint32_t sideLength = border * 2 + 1; AccumulationType average = sum / (sideLength*sideLength*sideLength); - m_pVolDst->setVoxelAt(iDstX, iDstY, iDstZ, static_cast(average)); + m_pVolDst->setVoxel(iDstX, iDstY, iDstZ, static_cast(average)); } } } diff --git a/include/PolyVox/PagedVolume.h b/include/PolyVox/PagedVolume.h index e5ca536f..0256032d 100644 --- a/include/PolyVox/PagedVolume.h +++ b/include/PolyVox/PagedVolume.h @@ -130,8 +130,8 @@ namespace PolyVox VoxelType getVoxel(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos) const; VoxelType getVoxel(const Vector3DUint16& v3dPos) const; - void setVoxelAt(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos, VoxelType tValue); - void setVoxelAt(const Vector3DUint16& v3dPos, VoxelType tValue); + void setVoxel(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos, VoxelType tValue); + void setVoxel(const Vector3DUint16& v3dPos, VoxelType tValue); private: /// Private copy constructor to prevent accisdental copying @@ -270,21 +270,13 @@ namespace PolyVox /// Gets a voxel at the position given by a 3D vector VoxelType getVoxel(const Vector3DInt32& v3dPos, WrapMode eWrapMode = WrapModes::Validate, VoxelType tBorder = VoxelType()) const; - /// Gets a voxel at the position given by x,y,z coordinates - POLYVOX_DEPRECATED VoxelType getVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos) const; - /// Gets a voxel at the position given by a 3D vector - POLYVOX_DEPRECATED VoxelType getVoxelAt(const Vector3DInt32& v3dPos) const; - /// Sets the number of chunks for which uncompressed data is stored void setMemoryUsageLimit(uint32_t uMemoryUsageInBytes); /// Sets the voxel at the position given by x,y,z coordinates void setVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue, WrapMode eWrapMode = WrapModes::Validate); /// Sets the voxel at the position given by a 3D vector void setVoxel(const Vector3DInt32& v3dPos, VoxelType tValue, WrapMode eWrapMode = WrapModes::Validate); - /// 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); + /// Tries to ensure that the voxels within the specified Region are loaded into memory. void prefetch(Region regPrefetch); /// Ensures that any voxels within the specified Region are removed from memory. diff --git a/include/PolyVox/PagedVolume.inl b/include/PolyVox/PagedVolume.inl index e6c5b04b..d24edc10 100644 --- a/include/PolyVox/PagedVolume.inl +++ b/include/PolyVox/PagedVolume.inl @@ -203,45 +203,6 @@ namespace PolyVox return getVoxel(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), eWrapMode, 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 - /// \return The voxel value - //////////////////////////////////////////////////////////////////////////////// - template - VoxelType PagedVolume::getVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos) const - { - if(this->m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos))) - { - const int32_t chunkX = uXPos >> m_uChunkSideLengthPower; - const int32_t chunkY = uYPos >> m_uChunkSideLengthPower; - const int32_t chunkZ = uZPos >> m_uChunkSideLengthPower; - - const uint16_t xOffset = static_cast(uXPos - (chunkX << m_uChunkSideLengthPower)); - const uint16_t yOffset = static_cast(uYPos - (chunkY << m_uChunkSideLengthPower)); - const uint16_t zOffset = static_cast(uZPos - (chunkZ << m_uChunkSideLengthPower)); - - auto pChunk = getChunk(chunkX, chunkY, chunkZ); - - return pChunk->getVoxel(xOffset, yOffset, zOffset); - } - else - { - return this->getBorderValue(); - } - } - - //////////////////////////////////////////////////////////////////////////////// - /// \param v3dPos The 3D position of the voxel - /// \return The voxel value - //////////////////////////////////////////////////////////////////////////////// - template - VoxelType PagedVolume::getVoxelAt(const Vector3DInt32& v3dPos) const - { - return getVoxelAt(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ()); - } - //////////////////////////////////////////////////////////////////////////////// /// Increasing the size of the chunk cache will increase memory but may improve performance. /// You may want to set this to a large value (e.g. 1024) when you are first loading your @@ -307,7 +268,7 @@ namespace PolyVox const uint16_t zOffset = static_cast(uZPos - (chunkZ << m_uChunkSideLengthPower)); auto pChunk = getChunk(chunkX, chunkY, chunkZ); - pChunk->setVoxelAt(xOffset, yOffset, zOffset, tValue); + pChunk->setVoxel(xOffset, yOffset, zOffset, tValue); } //////////////////////////////////////////////////////////////////////////////// @@ -322,47 +283,6 @@ namespace PolyVox setVoxel(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), tValue, eWrapMode); } - //////////////////////////////////////////////////////////////////////////////// - /// \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 PagedVolume::setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue) - { - // PolyVox does not throw an exception when a voxel is out of range. Please see 'Error Handling' in the User Manual. - POLYVOX_ASSERT(this->m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos)), "Position is outside valid region"); - - const int32_t chunkX = uXPos >> m_uChunkSideLengthPower; - const int32_t chunkY = uYPos >> m_uChunkSideLengthPower; - const int32_t chunkZ = uZPos >> m_uChunkSideLengthPower; - - const uint16_t xOffset = static_cast(uXPos - (chunkX << m_uChunkSideLengthPower)); - const uint16_t yOffset = static_cast(uYPos - (chunkY << m_uChunkSideLengthPower)); - const uint16_t zOffset = static_cast(uZPos - (chunkZ << m_uChunkSideLengthPower)); - - auto pChunk = getChunk(chunkX, chunkY, chunkZ); - - pChunk->setVoxelAt(xOffset, yOffset, zOffset, tValue); - - //Return true to indicate that we modified a voxel. - return true; - } - - //////////////////////////////////////////////////////////////////////////////// - /// \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 PagedVolume::setVoxelAt(const Vector3DInt32& v3dPos, VoxelType tValue) - { - return setVoxelAt(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), tValue); - } - - //////////////////////////////////////////////////////////////////////////////// /// Note that if the memory usage limit is not large enough to support the region this function will only load part of the region. In this case it is undefined which parts will actually be loaded. If all the voxels in the given region are already loaded, this function will not do anything. Other voxels might be unloaded to make space for the new voxels. /// \param regPrefetch The Region of voxels to prefetch into memory. diff --git a/include/PolyVox/PagedVolumeChunk.inl b/include/PolyVox/PagedVolumeChunk.inl index 7a51c79b..c1bf5c71 100644 --- a/include/PolyVox/PagedVolumeChunk.inl +++ b/include/PolyVox/PagedVolumeChunk.inl @@ -118,7 +118,7 @@ namespace PolyVox } template - void PagedVolume::Chunk::setVoxelAt(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos, VoxelType tValue) + void PagedVolume::Chunk::setVoxel(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos, VoxelType tValue) { // This code is not usually expected to be called by the user, with the exception of when implementing paging // of uncompressed data. It's a performance critical code path so we use asserts rather than exceptions. @@ -138,9 +138,9 @@ namespace PolyVox } template - void PagedVolume::Chunk::setVoxelAt(const Vector3DUint16& v3dPos, VoxelType tValue) + void PagedVolume::Chunk::setVoxel(const Vector3DUint16& v3dPos, VoxelType tValue) { - setVoxelAt(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), tValue); + setVoxel(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), tValue); } template diff --git a/include/PolyVox/PagedVolumeSampler.inl b/include/PolyVox/PagedVolumeSampler.inl index 90909cb7..e92ef0e2 100644 --- a/include/PolyVox/PagedVolumeSampler.inl +++ b/include/PolyVox/PagedVolumeSampler.inl @@ -71,7 +71,7 @@ namespace PolyVox { for(uint8_t x = 0; x < uSize; ++x) { - tValue = (std::min)(tValue, this->mVolume->getVoxelAt(this->mXPosInVolume + x, this->mYPosInVolume + y, this->mZPosInVolume + z)); + tValue = (std::min)(tValue, this->mVolume->getVoxel(this->mXPosInVolume + x, this->mYPosInVolume + y, this->mZPosInVolume + z)); } } } diff --git a/include/PolyVox/RawVolume.h b/include/PolyVox/RawVolume.h index 73a2f1e5..099aefe8 100644 --- a/include/PolyVox/RawVolume.h +++ b/include/PolyVox/RawVolume.h @@ -127,19 +127,10 @@ namespace PolyVox /// Gets a voxel at the position given by a 3D vector VoxelType getVoxel(const Vector3DInt32& v3dPos, WrapMode eWrapMode = WrapModes::Validate, VoxelType tBorder = VoxelType()) const; - /// Gets a voxel at the position given by x,y,z coordinates - POLYVOX_DEPRECATED VoxelType getVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos) const; - /// Gets a voxel at the position given by a 3D vector - POLYVOX_DEPRECATED VoxelType getVoxelAt(const Vector3DInt32& v3dPos) const; - /// Sets the voxel at the position given by x,y,z coordinates void setVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue, WrapMode eWrapMode = WrapModes::Validate); /// Sets the voxel at the position given by a 3D vector void setVoxel(const Vector3DInt32& v3dPos, VoxelType tValue, WrapMode eWrapMode = WrapModes::Validate); - /// 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); diff --git a/include/PolyVox/RawVolume.inl b/include/PolyVox/RawVolume.inl index 3dd0ef5d..da2b0e43 100644 --- a/include/PolyVox/RawVolume.inl +++ b/include/PolyVox/RawVolume.inl @@ -153,45 +153,6 @@ namespace PolyVox return getVoxel(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), eWrapMode, 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 - /// \return The voxel value - //////////////////////////////////////////////////////////////////////////////// - template - VoxelType RawVolume::getVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos) const - { - if(this->m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos))) - { - const Vector3DInt32& v3dLowerCorner = this->m_regValidRegion.getLowerCorner(); - int32_t iLocalXPos = uXPos - v3dLowerCorner.getX(); - int32_t iLocalYPos = uYPos - v3dLowerCorner.getY(); - int32_t iLocalZPos = uZPos - v3dLowerCorner.getZ(); - - return m_pData - [ - iLocalXPos + - iLocalYPos * this->getWidth() + - iLocalZPos * this->getWidth() * this->getHeight() - ]; - } - else - { - return this->getBorderValue(); - } - } - - //////////////////////////////////////////////////////////////////////////////// - /// \param v3dPos The 3D position of the voxel - /// \return The voxel value - //////////////////////////////////////////////////////////////////////////////// - template - VoxelType RawVolume::getVoxelAt(const Vector3DInt32& v3dPos) const - { - return getVoxelAt(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ()); - } - //////////////////////////////////////////////////////////////////////////////// /// \param uXPos the \c x position of the voxel /// \param uYPos the \c y position of the voxel @@ -242,50 +203,6 @@ namespace PolyVox setVoxel(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), tValue, eWrapMode); } - //////////////////////////////////////////////////////////////////////////////// - /// \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 RawVolume::setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue) - { - if(this->m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos))) - { - const Vector3DInt32& v3dLowerCorner = this->m_regValidRegion.getLowerCorner(); - int32_t iLocalXPos = uXPos - v3dLowerCorner.getX(); - int32_t iLocalYPos = uYPos - v3dLowerCorner.getY(); - int32_t iLocalZPos = uZPos - v3dLowerCorner.getZ(); - - m_pData - [ - iLocalXPos + - iLocalYPos * this->getWidth() + - iLocalZPos * this->getWidth() * this->getHeight() - ] = tValue; - - //Return true to indicate that we modified a voxel. - return true; - } - else - { - 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 RawVolume::setVoxelAt(const Vector3DInt32& v3dPos, VoxelType tValue) - { - return setVoxelAt(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), tValue); - } - //////////////////////////////////////////////////////////////////////////////// /// This function should probably be made internal... //////////////////////////////////////////////////////////////////////////////// diff --git a/include/PolyVox/VolumeResampler.inl b/include/PolyVox/VolumeResampler.inl index 3360d54b..7c1cf3fc 100644 --- a/include/PolyVox/VolumeResampler.inl +++ b/include/PolyVox/VolumeResampler.inl @@ -74,7 +74,7 @@ namespace PolyVox { const typename SrcVolumeType::VoxelType& tSrcVoxel = m_pVolSrc->getVoxel(sx,sy,sz, WrapModes::AssumeValid); // FIXME use templatised version of getVoxel(), but watch out for Linux compile issues. const typename DstVolumeType::VoxelType& tDstVoxel = static_cast(tSrcVoxel); - m_pVolDst->setVoxelAt(dx,dy,dz,tDstVoxel); + m_pVolDst->setVoxel(dx,dy,dz,tDstVoxel); } } } @@ -130,7 +130,7 @@ namespace PolyVox typename SrcVolumeType::VoxelType tInterpolatedValue = trilerp(voxel000,voxel100,voxel010,voxel110,voxel001,voxel101,voxel011,voxel111,sx,sy,sz); typename DstVolumeType::VoxelType result = static_cast(tInterpolatedValue); - m_pVolDst->setVoxelAt(dx,dy,dz,result); + m_pVolDst->setVoxel(dx,dy,dz,result); } } } diff --git a/tests/TestAStarPathfinder.cpp b/tests/TestAStarPathfinder.cpp index e1cefbad..36cbfb82 100644 --- a/tests/TestAStarPathfinder.cpp +++ b/tests/TestAStarPathfinder.cpp @@ -92,7 +92,7 @@ void TestAStarPathfinder::testExecute() for(int x = 0; x < uVolumeSideLength; x++) { uint8_t solidVoxel(0); - volData.setVoxelAt(x,y,z,solidVoxel); + volData.setVoxel(x,y,z,solidVoxel); } } } @@ -105,7 +105,7 @@ void TestAStarPathfinder::testExecute() for(int x = 4; x < 12; x++) { uint8_t solidVoxel(1); - volData.setVoxelAt(x,y,z,solidVoxel); + volData.setVoxel(x,y,z,solidVoxel); } } } diff --git a/tests/TestAmbientOcclusionGenerator.cpp b/tests/TestAmbientOcclusionGenerator.cpp index 253af603..f08b7111 100644 --- a/tests/TestAmbientOcclusionGenerator.cpp +++ b/tests/TestAmbientOcclusionGenerator.cpp @@ -60,7 +60,7 @@ void TestAmbientOcclusionGenerator::testExecute() { for (int32_t x = 0; x < g_uVolumeSideLength; x++) { - volData.setVoxelAt(x, y, z, 1); + volData.setVoxel(x, y, z, 1); } } } diff --git a/tests/TestCubicSurfaceExtractor.cpp b/tests/TestCubicSurfaceExtractor.cpp index df821f30..db029e66 100644 --- a/tests/TestCubicSurfaceExtractor.cpp +++ b/tests/TestCubicSurfaceExtractor.cpp @@ -78,7 +78,7 @@ VolumeType* createAndFillVolumeWithNoise(int32_t iVolumeSideLength, typename Vol if (minValue == maxValue) { // In this case we are filling the whole volume with a single value. - volData->setVoxelAt(x, y, z, minValue); + volData->setVoxel(x, y, z, minValue); } else { @@ -86,7 +86,7 @@ VolumeType* createAndFillVolumeWithNoise(int32_t iVolumeSideLength, typename Vol // We can't use std distributions because they vary between platforms (breaking tests). int voxelValue = (rng() % (maxValue - minValue + 1)) + minValue; // +1 for inclusive bounds - volData->setVoxelAt(x, y, z, static_cast(voxelValue)); + volData->setVoxel(x, y, z, static_cast(voxelValue)); } } } @@ -113,11 +113,11 @@ VolumeType* createAndFillVolumeRealistic(int32_t iVolumeSideLength) // that it's not empty/random data, and should allow significant decimation to be performed. if ((x ^ y) & 0x01) { - volData->setVoxelAt(x, y, z, 0); + volData->setVoxel(x, y, z, 0); } else { - volData->setVoxelAt(x, y, z, 1); + volData->setVoxel(x, y, z, 1); } } } diff --git a/tests/TestLowPassFilter.cpp b/tests/TestLowPassFilter.cpp index 849cf927..b6263115 100644 --- a/tests/TestLowPassFilter.cpp +++ b/tests/TestLowPassFilter.cpp @@ -50,7 +50,7 @@ void TestLowPassFilter::testExecute() if(x % 2 == 0) { Density8 voxel(32); - volData.setVoxelAt(x, y, z, voxel); + volData.setVoxel(x, y, z, voxel); } } } diff --git a/tests/TestPicking.cpp b/tests/TestPicking.cpp index 78f2b5c6..0dda302c 100644 --- a/tests/TestPicking.cpp +++ b/tests/TestPicking.cpp @@ -43,11 +43,11 @@ void TestPicking::testExecute() { if((x > uVolumeSideLength/2)) //x > 16 is filled { - volData.setVoxelAt(x, y, z, 100); + volData.setVoxel(x, y, z, 100); } else { - volData.setVoxelAt(x, y, z, 0); + volData.setVoxel(x, y, z, 0); } } } diff --git a/tests/TestRaycast.cpp b/tests/TestRaycast.cpp index 655d2b0b..22ab2c20 100644 --- a/tests/TestRaycast.cpp +++ b/tests/TestRaycast.cpp @@ -82,11 +82,11 @@ void TestRaycast::testExecute() { if((x == 0) || (x == uVolumeSideLength-1) || (y == 0) || (y == uVolumeSideLength-1)) { - volData.setVoxelAt(x, y, z, 100); + volData.setVoxel(x, y, z, 100); } else { - volData.setVoxelAt(x, y, z, -100); + volData.setVoxel(x, y, z, -100); } } } diff --git a/tests/TestSurfaceExtractor.cpp b/tests/TestSurfaceExtractor.cpp index 6be9aa2d..14623f9d 100644 --- a/tests/TestSurfaceExtractor.cpp +++ b/tests/TestSurfaceExtractor.cpp @@ -120,7 +120,7 @@ VolumeType* createAndFillVolume(void) typename VolumeType::VoxelType voxelValue; writeDensityValueToVoxel(x + y + z, voxelValue); writeMaterialValueToVoxel(z > uVolumeSideLength / 2 ? 42 : 79, voxelValue); - volData->setVoxelAt(x, y, z, voxelValue); + volData->setVoxel(x, y, z, voxelValue); } } } @@ -150,7 +150,7 @@ VolumeType* createAndFillVolumeWithNoise(int32_t iVolumeSideLength, float minVal float voxelValue = static_cast(rng()) / static_cast(std::numeric_limits::max()); // Float in range 0.0 to 1.0 voxelValue = voxelValue * (maxValue - minValue) + minValue; // Float in range minValue to maxValue - volData->setVoxelAt(x, y, z, voxelValue); + volData->setVoxel(x, y, z, voxelValue); } } } diff --git a/tests/TestVolumeSubclass.cpp b/tests/TestVolumeSubclass.cpp index 0a301e3e..2441e883 100644 --- a/tests/TestVolumeSubclass.cpp +++ b/tests/TestVolumeSubclass.cpp @@ -145,7 +145,7 @@ public: /// 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) + bool setVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue) { if(this->m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos))) { @@ -158,7 +158,7 @@ public: } } /// 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); } + bool setVoxel(const Vector3DInt32& v3dPos, VoxelType tValue) { return setVoxel(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; } @@ -181,7 +181,7 @@ void TestVolumeSubclass::testExtractSurface() for(int32_t x = 0; x < volumeSubclass.getWidth(); x++) { Material8 mat(1); - volumeSubclass.setVoxelAt(Vector3DInt32(x,y,z),mat); + volumeSubclass.setVoxel(Vector3DInt32(x,y,z),mat); } } } diff --git a/tests/testvolume.cpp b/tests/testvolume.cpp index 98fb2c0f..612b4cac 100644 --- a/tests/testvolume.cpp +++ b/tests/testvolume.cpp @@ -255,8 +255,8 @@ TestVolume::TestVolume() for(int x = region.getLowerX(); x <= region.getUpperX(); x++) { int32_t value = x + y + z; - m_pRawVolume->setVoxelAt(x, y, z, value); - m_pPagedVolume->setVoxelAt(x, y, z, value); + m_pRawVolume->setVoxel(x, y, z, value); + m_pPagedVolume->setVoxel(x, y, z, value); } } }