diff --git a/include/PolyVox/BaseVolume.h b/include/PolyVox/BaseVolume.h index 5a401ec6..b0a0c8cc 100644 --- a/include/PolyVox/BaseVolume.h +++ b/include/PolyVox/BaseVolume.h @@ -36,23 +36,6 @@ namespace PolyVox //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// More details to come... //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - namespace WrapModes - { - enum WrapMode - { - Validate = 0, - Clamp = 1, - Border = 2, - AssumeValid = 3 - }; - } - typedef WrapModes::WrapMode WrapMode; - - // Required for a trick to implement specialization of template member - // functions in template classes. See http://stackoverflow.com/a/4951057 - template struct WrapModeType{}; - template class BaseVolume { @@ -73,7 +56,6 @@ namespace PolyVox void setPosition(const Vector3DInt32& v3dNewPos); void setPosition(int32_t xPos, int32_t yPos, int32_t zPos); inline bool setVoxel(VoxelType tValue); - void setWrapMode(WrapMode eWrapMode, VoxelType tBorder = VoxelType()); void movePositiveX(void); void movePositiveY(void); @@ -114,7 +96,6 @@ namespace PolyVox inline VoxelType peekVoxel1px1py1pz(void) const; protected: - VoxelType getVoxelImpl(int32_t uXPos, int32_t uYPos, int32_t uZPos) const; DerivedVolumeType* mVolume; @@ -122,30 +103,19 @@ namespace PolyVox int32_t mXPosInVolume; int32_t mYPosInVolume; int32_t mZPosInVolume; - - WrapMode m_eWrapMode; - VoxelType m_tBorder; }; #endif public: - /// Gets a voxel at the position given by x,y,z coordinates - template - VoxelType getVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tBorder = VoxelType()) const; + VoxelType getVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos) const; /// Gets a voxel at the position given by a 3D vector - template - VoxelType getVoxel(const Vector3DInt32& v3dPos, VoxelType tBorder = VoxelType()) const; - - /// Gets a voxel at the position given by x,y,z coordinates - 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; + VoxelType getVoxel(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); + void setVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue); /// Sets the voxel at the position given by a 3D vector - void setVoxel(const Vector3DInt32& v3dPos, VoxelType tValue, WrapMode eWrapMode = WrapModes::Validate); + void setVoxel(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 3fc9287a..6ba07f1f 100644 --- a/include/PolyVox/BaseVolume.inl +++ b/include/PolyVox/BaseVolume.inl @@ -67,54 +67,16 @@ namespace PolyVox POLYVOX_THROW(not_implemented, "Volume assignment operator not implemented for performance reasons."); } - //////////////////////////////////////////////////////////////////////////////// - /// This version of the function requires the wrap mode to be specified as a - /// template parameter, which can provide better performance. - /// \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 - /// \tparam eWrapMode Specifies the behaviour when the requested position is outside of the volume. - /// \param tBorder The border value to use if the wrap mode is set to 'Border'. - /// \return The voxel value - //////////////////////////////////////////////////////////////////////////////// - template - template - VoxelType BaseVolume::getVoxel(int32_t /*uXPos*/, int32_t /*uYPos*/, int32_t /*uZPos*/, VoxelType /*tBorder*/) const - { - POLYVOX_ASSERT(false, "You should never call the base class version of this function."); - return VoxelType(); - } - - //////////////////////////////////////////////////////////////////////////////// - /// This version of the function requires the wrap mode to be specified as a - /// template parameter, which can provide better performance. - /// \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 - /// \tparam eWrapMode Specifies the behaviour when the requested position is outside of the volume. - /// \param tBorder The border value to use if the wrap mode is set to 'Border'. - /// \return The voxel value - //////////////////////////////////////////////////////////////////////////////// - template - template - VoxelType BaseVolume::getVoxel(const Vector3DInt32& /*v3dPos*/, VoxelType /*tBorder*/) const - { - POLYVOX_ASSERT(false, "You should never call the base class version of this function."); - return VoxelType(); - } - //////////////////////////////////////////////////////////////////////////////// /// This version of the function is provided so that the wrap mode does not need /// to be specified as a template parameter, as it may be confusing to some users. /// \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 eWrapMode Specifies the behaviour when the requested position is outside of the volume. - /// \param tBorder The border value to use if the wrap mode is set to 'Border'. /// \return The voxel value //////////////////////////////////////////////////////////////////////////////// template - VoxelType BaseVolume::getVoxel(int32_t /*uXPos*/, int32_t /*uYPos*/, int32_t /*uZPos*/, WrapMode /*eWrapMode*/, VoxelType /*tBorder*/) const + VoxelType BaseVolume::getVoxel(int32_t /*uXPos*/, int32_t /*uYPos*/, int32_t /*uZPos*/) const { POLYVOX_ASSERT(false, "You should never call the base class version of this function."); return VoxelType(); @@ -124,12 +86,10 @@ namespace PolyVox /// This version of the function is provided so that the wrap mode does not need /// to be specified as a template parameter, as it may be confusing to some users. /// \param v3dPos The 3D position of the voxel - /// \param eWrapMode Specifies the behaviour when the requested position is outside of the volume. - /// \param tBorder The border value to use if the wrap mode is set to 'Border'. /// \return The voxel value //////////////////////////////////////////////////////////////////////////////// template - VoxelType BaseVolume::getVoxel(const Vector3DInt32& /*v3dPos*/, WrapMode /*eWrapMode*/, VoxelType /*tBorder*/) const + VoxelType BaseVolume::getVoxel(const Vector3DInt32& /*v3dPos*/) const { POLYVOX_ASSERT(false, "You should never call the base class version of this function."); return VoxelType(); @@ -142,7 +102,7 @@ namespace PolyVox /// \param tValue the value to which the voxel will be set //////////////////////////////////////////////////////////////////////////////// template - void BaseVolume::setVoxel(int32_t /*uXPos*/, int32_t /*uYPos*/, int32_t /*uZPos*/, VoxelType /*tValue*/, WrapMode /*eWrapMode*/) + void BaseVolume::setVoxel(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."); } @@ -152,7 +112,7 @@ namespace PolyVox /// \param tValue the value to which the voxel will be set //////////////////////////////////////////////////////////////////////////////// template - void BaseVolume::setVoxel(const Vector3DInt32& /*v3dPos*/, VoxelType /*tValue*/, WrapMode /*eWrapMode*/) + void BaseVolume::setVoxel(const Vector3DInt32& /*v3dPos*/, VoxelType /*tValue*/) { POLYVOX_THROW(not_implemented, "You should never call the base class version of this function."); } diff --git a/include/PolyVox/BaseVolumeSampler.inl b/include/PolyVox/BaseVolumeSampler.inl index 6e0d134d..ccd14410 100644 --- a/include/PolyVox/BaseVolumeSampler.inl +++ b/include/PolyVox/BaseVolumeSampler.inl @@ -32,8 +32,6 @@ namespace PolyVox ,mXPosInVolume(0) ,mYPosInVolume(0) ,mZPosInVolume(0) - ,m_eWrapMode(WrapModes::Border) - ,m_tBorder() { } @@ -80,14 +78,6 @@ namespace PolyVox return mVolume->setVoxel(mXPosInVolume, mYPosInVolume, mZPosInVolume, tValue); } - template - template - void BaseVolume::Sampler::setWrapMode(WrapMode eWrapMode, VoxelType tBorder) - { - m_eWrapMode = eWrapMode; - m_tBorder = tBorder; - } - template template void BaseVolume::Sampler::movePositiveX(void) @@ -134,63 +124,63 @@ namespace PolyVox template VoxelType BaseVolume::Sampler::peekVoxel1nx1ny1nz(void) const { - return getVoxelImpl(mXPosInVolume - 1, mYPosInVolume - 1, mZPosInVolume - 1); + return mVolume->getVoxel(mXPosInVolume - 1, mYPosInVolume - 1, mZPosInVolume - 1); } template template VoxelType BaseVolume::Sampler::peekVoxel1nx1ny0pz(void) const { - return getVoxelImpl(mXPosInVolume - 1, mYPosInVolume - 1, mZPosInVolume ); + return mVolume->getVoxel(mXPosInVolume - 1, mYPosInVolume - 1, mZPosInVolume); } template template VoxelType BaseVolume::Sampler::peekVoxel1nx1ny1pz(void) const { - return getVoxelImpl(mXPosInVolume - 1, mYPosInVolume - 1, mZPosInVolume + 1); + return mVolume->getVoxel(mXPosInVolume - 1, mYPosInVolume - 1, mZPosInVolume + 1); } template template VoxelType BaseVolume::Sampler::peekVoxel1nx0py1nz(void) const { - return getVoxelImpl(mXPosInVolume - 1, mYPosInVolume , mZPosInVolume - 1); + return mVolume->getVoxel(mXPosInVolume - 1, mYPosInVolume, mZPosInVolume - 1); } template template VoxelType BaseVolume::Sampler::peekVoxel1nx0py0pz(void) const { - return getVoxelImpl(mXPosInVolume - 1, mYPosInVolume , mZPosInVolume ); + return mVolume->getVoxel(mXPosInVolume - 1, mYPosInVolume, mZPosInVolume); } template template VoxelType BaseVolume::Sampler::peekVoxel1nx0py1pz(void) const { - return getVoxelImpl(mXPosInVolume - 1, mYPosInVolume , mZPosInVolume + 1); + return mVolume->getVoxel(mXPosInVolume - 1, mYPosInVolume, mZPosInVolume + 1); } template template VoxelType BaseVolume::Sampler::peekVoxel1nx1py1nz(void) const { - return getVoxelImpl(mXPosInVolume - 1, mYPosInVolume + 1, mZPosInVolume - 1); + return mVolume->getVoxel(mXPosInVolume - 1, mYPosInVolume + 1, mZPosInVolume - 1); } template template VoxelType BaseVolume::Sampler::peekVoxel1nx1py0pz(void) const { - return getVoxelImpl(mXPosInVolume - 1, mYPosInVolume + 1, mZPosInVolume ); + return mVolume->getVoxel(mXPosInVolume - 1, mYPosInVolume + 1, mZPosInVolume); } template template VoxelType BaseVolume::Sampler::peekVoxel1nx1py1pz(void) const { - return getVoxelImpl(mXPosInVolume - 1, mYPosInVolume + 1, mZPosInVolume + 1); + return mVolume->getVoxel(mXPosInVolume - 1, mYPosInVolume + 1, mZPosInVolume + 1); } ////////////////////////////////////////////////////////////////////////// @@ -199,63 +189,63 @@ namespace PolyVox template VoxelType BaseVolume::Sampler::peekVoxel0px1ny1nz(void) const { - return getVoxelImpl(mXPosInVolume , mYPosInVolume - 1, mZPosInVolume - 1); + return mVolume->getVoxel(mXPosInVolume, mYPosInVolume - 1, mZPosInVolume - 1); } template template VoxelType BaseVolume::Sampler::peekVoxel0px1ny0pz(void) const { - return getVoxelImpl(mXPosInVolume , mYPosInVolume - 1, mZPosInVolume ); + return mVolume->getVoxel(mXPosInVolume, mYPosInVolume - 1, mZPosInVolume); } template template VoxelType BaseVolume::Sampler::peekVoxel0px1ny1pz(void) const { - return getVoxelImpl(mXPosInVolume , mYPosInVolume - 1, mZPosInVolume + 1); + return mVolume->getVoxel(mXPosInVolume, mYPosInVolume - 1, mZPosInVolume + 1); } template template VoxelType BaseVolume::Sampler::peekVoxel0px0py1nz(void) const { - return getVoxelImpl(mXPosInVolume , mYPosInVolume , mZPosInVolume - 1); + return mVolume->getVoxel(mXPosInVolume, mYPosInVolume, mZPosInVolume - 1); } template template VoxelType BaseVolume::Sampler::peekVoxel0px0py0pz(void) const { - return getVoxelImpl(mXPosInVolume , mYPosInVolume , mZPosInVolume ); + return mVolume->getVoxel(mXPosInVolume, mYPosInVolume, mZPosInVolume); } template template VoxelType BaseVolume::Sampler::peekVoxel0px0py1pz(void) const { - return getVoxelImpl(mXPosInVolume , mYPosInVolume , mZPosInVolume + 1); + return mVolume->getVoxel(mXPosInVolume, mYPosInVolume, mZPosInVolume + 1); } template template VoxelType BaseVolume::Sampler::peekVoxel0px1py1nz(void) const { - return getVoxelImpl(mXPosInVolume , mYPosInVolume + 1, mZPosInVolume - 1); + return mVolume->getVoxel(mXPosInVolume, mYPosInVolume + 1, mZPosInVolume - 1); } template template VoxelType BaseVolume::Sampler::peekVoxel0px1py0pz(void) const { - return getVoxelImpl(mXPosInVolume , mYPosInVolume + 1, mZPosInVolume ); + return mVolume->getVoxel(mXPosInVolume, mYPosInVolume + 1, mZPosInVolume); } template template VoxelType BaseVolume::Sampler::peekVoxel0px1py1pz(void) const { - return getVoxelImpl(mXPosInVolume , mYPosInVolume + 1, mZPosInVolume + 1); + return mVolume->getVoxel(mXPosInVolume, mYPosInVolume + 1, mZPosInVolume + 1); } ////////////////////////////////////////////////////////////////////////// @@ -264,85 +254,62 @@ namespace PolyVox template VoxelType BaseVolume::Sampler::peekVoxel1px1ny1nz(void) const { - return getVoxelImpl(mXPosInVolume + 1, mYPosInVolume - 1, mZPosInVolume - 1); + return mVolume->getVoxel(mXPosInVolume + 1, mYPosInVolume - 1, mZPosInVolume - 1); } template template VoxelType BaseVolume::Sampler::peekVoxel1px1ny0pz(void) const { - return getVoxelImpl(mXPosInVolume + 1, mYPosInVolume - 1, mZPosInVolume ); + return mVolume->getVoxel(mXPosInVolume + 1, mYPosInVolume - 1, mZPosInVolume); } template template VoxelType BaseVolume::Sampler::peekVoxel1px1ny1pz(void) const { - return getVoxelImpl(mXPosInVolume + 1, mYPosInVolume - 1, mZPosInVolume + 1); + return mVolume->getVoxel(mXPosInVolume + 1, mYPosInVolume - 1, mZPosInVolume + 1); } template template VoxelType BaseVolume::Sampler::peekVoxel1px0py1nz(void) const { - return getVoxelImpl(mXPosInVolume + 1, mYPosInVolume , mZPosInVolume - 1); + return mVolume->getVoxel(mXPosInVolume + 1, mYPosInVolume, mZPosInVolume - 1); } template template VoxelType BaseVolume::Sampler::peekVoxel1px0py0pz(void) const { - return getVoxelImpl(mXPosInVolume + 1, mYPosInVolume , mZPosInVolume ); + return mVolume->getVoxel(mXPosInVolume + 1, mYPosInVolume, mZPosInVolume); } template template VoxelType BaseVolume::Sampler::peekVoxel1px0py1pz(void) const { - return getVoxelImpl(mXPosInVolume + 1, mYPosInVolume , mZPosInVolume + 1); + return mVolume->getVoxel(mXPosInVolume + 1, mYPosInVolume, mZPosInVolume + 1); } template template VoxelType BaseVolume::Sampler::peekVoxel1px1py1nz(void) const { - return getVoxelImpl(mXPosInVolume + 1, mYPosInVolume + 1, mZPosInVolume - 1); + return mVolume->getVoxel(mXPosInVolume + 1, mYPosInVolume + 1, mZPosInVolume - 1); } template template VoxelType BaseVolume::Sampler::peekVoxel1px1py0pz(void) const { - return getVoxelImpl(mXPosInVolume + 1, mYPosInVolume + 1, mZPosInVolume ); + return mVolume->getVoxel(mXPosInVolume + 1, mYPosInVolume + 1, mZPosInVolume); } template template VoxelType BaseVolume::Sampler::peekVoxel1px1py1pz(void) const { - return getVoxelImpl(mXPosInVolume + 1, mYPosInVolume + 1, mZPosInVolume + 1); - } - - template - template - VoxelType BaseVolume::Sampler::getVoxelImpl(int32_t uXPos, int32_t uYPos, int32_t uZPos) const - { - return mVolume->getVoxel(uXPos, uYPos, uZPos); - - /*switch(m_eWrapMode) - { - case WrapModes::Validate: - return mVolume->getVoxel(uXPos, uYPos, uZPos, WrapModes::Validate, m_tBorder); - case WrapModes::Clamp: - return mVolume->getVoxel(uXPos, uYPos, uZPos, WrapModes::Clamp, m_tBorder); - case WrapModes::Border: - return mVolume->getVoxel(uXPos, uYPos, uZPos, WrapModes::Border, m_tBorder); - case WrapModes::AssumeValid: - return mVolume->getVoxel(uXPos, uYPos, uZPos, WrapModes::AssumeValid, m_tBorder); - default: - // Should never happen - POLYVOX_ASSERT(false, "Invalid wrap mode"); - return VoxelType(); - }*/ + return mVolume->getVoxel(mXPosInVolume + 1, mYPosInVolume + 1, mZPosInVolume + 1); } } diff --git a/include/PolyVox/CubicSurfaceExtractor.h b/include/PolyVox/CubicSurfaceExtractor.h index b0855061..19f726b7 100644 --- a/include/PolyVox/CubicSurfaceExtractor.h +++ b/include/PolyVox/CubicSurfaceExtractor.h @@ -112,7 +112,7 @@ namespace PolyVox }; public: - CubicSurfaceExtractor(VolumeType* volData, Region region, MeshType* result, IsQuadNeeded isQuadNeeded = IsQuadNeeded(), WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = typename VolumeType::VoxelType(), bool bMergeQuads = true); + CubicSurfaceExtractor(VolumeType* volData, Region region, MeshType* result, IsQuadNeeded isQuadNeeded = IsQuadNeeded(), bool bMergeQuads = true); void execute(); @@ -147,10 +147,6 @@ namespace PolyVox //This constant defines the maximum number of quads which can share a //vertex in a cubic style mesh. See the initialisation for more details. static const uint32_t MaxVerticesPerPosition; - - //The wrap mode - WrapMode m_eWrapMode; - typename VolumeType::VoxelType m_tBorderValue; }; // This version of the function performs the extraction into a user-provided mesh rather than allocating a mesh automatically. @@ -167,9 +163,9 @@ namespace PolyVox // are provided (would the third parameter be a controller or a mesh?). It seems this can be fixed by using enable_if/static_assert to emulate concepts, // but this is relatively complex and I haven't done it yet. Could always add it later as another overload. template > - void extractCubicMeshCustom(VolumeType* volData, Region region, MeshType* result, IsQuadNeeded isQuadNeeded = IsQuadNeeded(), WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = typename VolumeType::VoxelType(), bool bMergeQuads = true) + void extractCubicMeshCustom(VolumeType* volData, Region region, MeshType* result, IsQuadNeeded isQuadNeeded = IsQuadNeeded(), bool bMergeQuads = true) { - CubicSurfaceExtractor extractor(volData, region, result, isQuadNeeded, eWrapMode, tBorderValue, bMergeQuads); + CubicSurfaceExtractor extractor(volData, region, result, isQuadNeeded, bMergeQuads); extractor.execute(); } @@ -215,10 +211,10 @@ namespace PolyVox /// Another scenario which sometimes results in confusion is when you wish to extract a region which corresponds to the whole volume, partcularly when solid voxels extend right to the edge of the volume. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// template > - Mesh > extractCubicMesh(VolumeType* volData, Region region, IsQuadNeeded isQuadNeeded = IsQuadNeeded(), WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = typename VolumeType::VoxelType(), bool bMergeQuads = true) + Mesh > extractCubicMesh(VolumeType* volData, Region region, IsQuadNeeded isQuadNeeded = IsQuadNeeded(), bool bMergeQuads = true) { Mesh< CubicVertex > result; - extractCubicMeshCustom(volData, region, &result, isQuadNeeded, eWrapMode, tBorderValue, bMergeQuads); + extractCubicMeshCustom(volData, region, &result, isQuadNeeded, bMergeQuads); return result; } } diff --git a/include/PolyVox/CubicSurfaceExtractor.inl b/include/PolyVox/CubicSurfaceExtractor.inl index 6eefe3ec..24ea0609 100644 --- a/include/PolyVox/CubicSurfaceExtractor.inl +++ b/include/PolyVox/CubicSurfaceExtractor.inl @@ -36,15 +36,13 @@ namespace PolyVox const uint32_t CubicSurfaceExtractor::MaxVerticesPerPosition = 8; template - CubicSurfaceExtractor::CubicSurfaceExtractor(VolumeType* volData, Region region, MeshType* result, IsQuadNeeded isQuadNeeded, WrapMode eWrapMode, typename VolumeType::VoxelType tBorderValue, bool bMergeQuads) + CubicSurfaceExtractor::CubicSurfaceExtractor(VolumeType* volData, Region region, MeshType* result, IsQuadNeeded isQuadNeeded, bool bMergeQuads) :m_volData(volData) ,m_regSizeInVoxels(region) ,m_meshCurrent(result) ,m_previousSliceVertices(m_regSizeInVoxels.getUpperX() - m_regSizeInVoxels.getLowerX() + 2, m_regSizeInVoxels.getUpperY() - m_regSizeInVoxels.getLowerY() + 2, MaxVerticesPerPosition) ,m_currentSliceVertices(m_regSizeInVoxels.getUpperX() - m_regSizeInVoxels.getLowerX() + 2, m_regSizeInVoxels.getUpperY() - m_regSizeInVoxels.getLowerY() + 2, MaxVerticesPerPosition) ,m_bMergeQuads(bMergeQuads) - ,m_eWrapMode(eWrapMode) - ,m_tBorderValue(tBorderValue) { m_funcIsQuadNeededCallback = isQuadNeeded; @@ -80,7 +78,6 @@ namespace PolyVox m_vecQuads[PositiveZ].resize(m_regSizeInVoxels.getUpperZ() - m_regSizeInVoxels.getLowerZ() + 2); typename VolumeType::Sampler volumeSampler(m_volData); - volumeSampler.setWrapMode(m_eWrapMode, m_tBorderValue); for(int32_t z = m_regSizeInVoxels.getLowerZ(); z <= m_regSizeInVoxels.getUpperZ(); z++) { diff --git a/include/PolyVox/MarchingCubesSurfaceExtractor.h b/include/PolyVox/MarchingCubesSurfaceExtractor.h index 69ec0569..565034ff 100644 --- a/include/PolyVox/MarchingCubesSurfaceExtractor.h +++ b/include/PolyVox/MarchingCubesSurfaceExtractor.h @@ -157,7 +157,7 @@ namespace PolyVox class MarchingCubesSurfaceExtractor { public: - MarchingCubesSurfaceExtractor(VolumeType* volData, Region region, MeshType* result, ControllerType controller, WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = typename VolumeType::VoxelType()); + MarchingCubesSurfaceExtractor(VolumeType* volData, Region region, MeshType* result, ControllerType controller); void execute(); @@ -338,17 +338,17 @@ namespace PolyVox // are provided (would the third parameter be a controller or a mesh?). It seems this can be fixed by using enable_if/static_assert to emulate concepts, // but this is relatively complex and I haven't done it yet. Could always add it later as another overload. template< typename VolumeType, typename MeshType, typename ControllerType = DefaultMarchingCubesController > - void extractMarchingCubesMeshCustom(VolumeType* volData, Region region, MeshType* result, ControllerType controller = ControllerType(), WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = typename VolumeType::VoxelType()) + void extractMarchingCubesMeshCustom(VolumeType* volData, Region region, MeshType* result, ControllerType controller = ControllerType()) { - MarchingCubesSurfaceExtractor extractor(volData, region, result, controller, eWrapMode, tBorderValue); + MarchingCubesSurfaceExtractor extractor(volData, region, result, controller); extractor.execute(); } template< typename VolumeType, typename ControllerType = DefaultMarchingCubesController > - Mesh > extractMarchingCubesMesh(VolumeType* volData, Region region, ControllerType controller = ControllerType(), WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = typename VolumeType::VoxelType()) + Mesh > extractMarchingCubesMesh(VolumeType* volData, Region region, ControllerType controller = ControllerType()) { Mesh > result; - extractMarchingCubesMeshCustom, DefaultIndexType > >(volData, region, &result, controller, eWrapMode, tBorderValue); + extractMarchingCubesMeshCustom, DefaultIndexType > >(volData, region, &result, controller); return result; } } diff --git a/include/PolyVox/MarchingCubesSurfaceExtractor.inl b/include/PolyVox/MarchingCubesSurfaceExtractor.inl index 4fb98272..1d81e3f0 100644 --- a/include/PolyVox/MarchingCubesSurfaceExtractor.inl +++ b/include/PolyVox/MarchingCubesSurfaceExtractor.inl @@ -26,7 +26,7 @@ freely, subject to the following restrictions: namespace PolyVox { template - MarchingCubesSurfaceExtractor::MarchingCubesSurfaceExtractor(VolumeType* volData, Region region, MeshType* result, ControllerType controller, WrapMode eWrapMode, typename VolumeType::VoxelType tBorderValue) + MarchingCubesSurfaceExtractor::MarchingCubesSurfaceExtractor(VolumeType* volData, Region region, MeshType* result, ControllerType controller) :m_volData(volData) ,m_sampVolume(volData) ,m_meshCurrent(result) @@ -38,8 +38,6 @@ namespace PolyVox //m_regSizeInVoxels.cropTo(m_volData->getEnclosingRegion()); m_regSizeInCells = m_regSizeInVoxels; m_regSizeInCells.setUpperCorner(m_regSizeInCells.getUpperCorner() - Vector3DInt32(1,1,1)); - - m_sampVolume.setWrapMode(eWrapMode, tBorderValue); } template diff --git a/include/PolyVox/PagedVolume.inl b/include/PolyVox/PagedVolume.inl index 5419e920..82c55e54 100644 --- a/include/PolyVox/PagedVolume.inl +++ b/include/PolyVox/PagedVolume.inl @@ -128,8 +128,6 @@ namespace PolyVox /// \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 eWrapMode Specifies the behaviour when the requested position is outside of the volume. - /// \param tBorder The border value to use if the wrap mode is set to 'Border'. /// \return The voxel value //////////////////////////////////////////////////////////////////////////////// template @@ -151,14 +149,12 @@ namespace PolyVox /// This version of the function is provided so that the wrap mode does not need /// to be specified as a template parameter, as it may be confusing to some users. /// \param v3dPos The 3D position of the voxel - /// \param eWrapMode Specifies the behaviour when the requested position is outside of the volume. - /// \param tBorder The border value to use if the wrap mode is set to 'Border'. /// \return The voxel value //////////////////////////////////////////////////////////////////////////////// template VoxelType PagedVolume::getVoxel(const Vector3DInt32& v3dPos) const { - return getVoxel(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), eWrapMode, tBorder); + return getVoxel(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ()); } //////////////////////////////////////////////////////////////////////////////// @@ -196,9 +192,6 @@ namespace PolyVox /// \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 - /// \param eWrapMode Specifies the behaviour when the requested position is outside of the volume. - /// This must be set to 'None' or 'DontCheck'. Other wrap modes cannot be used when writing to volume data. //////////////////////////////////////////////////////////////////////////////// template void PagedVolume::setVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue) @@ -218,8 +211,6 @@ namespace PolyVox //////////////////////////////////////////////////////////////////////////////// /// \param v3dPos the 3D position of the voxel /// \param tValue the value to which the voxel will be set - /// \param eWrapMode Specifies the behaviour when the requested position is outside of the volume. - /// This must be set to 'None' or 'DontCheck'. Other wrap modes cannot be used when writing to volume data. //////////////////////////////////////////////////////////////////////////////// template void PagedVolume::setVoxel(const Vector3DInt32& v3dPos, VoxelType tValue) diff --git a/include/PolyVox/PagedVolumeSampler.inl b/include/PolyVox/PagedVolumeSampler.inl index 19eff82a..3de9ca10 100644 --- a/include/PolyVox/PagedVolumeSampler.inl +++ b/include/PolyVox/PagedVolumeSampler.inl @@ -82,7 +82,7 @@ namespace PolyVox template VoxelType PagedVolume::Sampler::getVoxel(void) const { - return this->getVoxelImpl(this->mXPosInVolume, this->mYPosInVolume, this->mZPosInVolume); + return this->mVolume->getVoxel(this->mXPosInVolume, this->mYPosInVolume, this->mZPosInVolume); } template diff --git a/include/PolyVox/RawVolume.inl b/include/PolyVox/RawVolume.inl index 2f0419d5..0a04655b 100644 --- a/include/PolyVox/RawVolume.inl +++ b/include/PolyVox/RawVolume.inl @@ -165,8 +165,6 @@ namespace PolyVox /// \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 eWrapMode Specifies the behaviour when the requested position is outside of the volume. - /// \param tBorder The border value to use if the wrap mode is set to 'Border'. /// \return The voxel value //////////////////////////////////////////////////////////////////////////////// template @@ -196,8 +194,6 @@ namespace PolyVox /// This version of the function is provided so that the wrap mode does not need /// to be specified as a template parameter, as it may be confusing to some users. /// \param v3dPos The 3D position of the voxel - /// \param eWrapMode Specifies the behaviour when the requested position is outside of the volume. - /// \param tBorder The border value to use if the wrap mode is set to 'Border'. /// \return The voxel value //////////////////////////////////////////////////////////////////////////////// template @@ -220,8 +216,6 @@ namespace PolyVox /// \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 - /// \param eWrapMode Specifies the behaviour when the requested position is outside of the volume. - /// This must be set to 'None' or 'DontCheck'. Other wrap modes cannot be used when writing to volume data. //////////////////////////////////////////////////////////////////////////////// template void RawVolume::setVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue) @@ -247,8 +241,6 @@ namespace PolyVox //////////////////////////////////////////////////////////////////////////////// /// \param v3dPos the 3D position of the voxel /// \param tValue the value to which the voxel will be set - /// \param eWrapMode Specifies the behaviour when the requested position is outside of the volume. - /// This must be set to 'None' or 'DontCheck'. Other wrap modes cannot be used when writing to volume data. //////////////////////////////////////////////////////////////////////////////// template void RawVolume::setVoxel(const Vector3DInt32& v3dPos, VoxelType tValue) diff --git a/include/PolyVox/RawVolumeSampler.inl b/include/PolyVox/RawVolumeSampler.inl index a1ff0bec..16766c2f 100644 --- a/include/PolyVox/RawVolumeSampler.inl +++ b/include/PolyVox/RawVolumeSampler.inl @@ -54,7 +54,7 @@ namespace PolyVox } else { - return this->getVoxelImpl(this->mXPosInVolume, this->mYPosInVolume, this->mZPosInVolume); + return this->mVolume->getVoxel(this->mXPosInVolume, this->mYPosInVolume, this->mZPosInVolume); } }