From 6d7246f907a2bc088d054e7db0ec4cee6b0fe5bd Mon Sep 17 00:00:00 2001 From: David Williams Date: Sat, 24 Nov 2012 21:32:17 +0100 Subject: [PATCH] More dilation and erosion functions for region. --- .../PolyVoxCore/include/PolyVoxCore/Region.h | 11 +++- library/PolyVoxCore/source/Region.cpp | 60 ++++++++++++++----- 2 files changed, 54 insertions(+), 17 deletions(-) diff --git a/library/PolyVoxCore/include/PolyVoxCore/Region.h b/library/PolyVoxCore/include/PolyVoxCore/Region.h index 3c937ca5..e5dc784f 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Region.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Region.h @@ -119,10 +119,15 @@ namespace PolyVox void shift(const Vector3DInt32& amount); void shiftLowerCorner(const Vector3DInt32& amount); void shiftUpperCorner(const Vector3DInt32& amount); - //FIXME - Add dilate and erode functions? - void dilate(int32_t amount); - void erode(int32_t amount); + void dilate(int32_t iAmount); + void dilate(int32_t iAmountX, int32_t iAmountY, int32_t iAmountZ); + void dilate(const Vector3DInt32& v3dAmount); + + + void erode(int32_t iAmount); + void erode(int32_t iAmountX, int32_t iAmountY, int32_t iAmountZ); + void erode(const Vector3DInt32& v3dAmount); private: diff --git a/library/PolyVoxCore/source/Region.cpp b/library/PolyVoxCore/source/Region.cpp index e3c9a4ba..ed7b6419 100644 --- a/library/PolyVoxCore/source/Region.cpp +++ b/library/PolyVoxCore/source/Region.cpp @@ -307,25 +307,57 @@ namespace PolyVox m_iUpperZ += amount.getZ(); } - void Region::dilate(int32_t amount) + void Region::dilate(int32_t iAmount) { - m_iLowerX -= amount; - m_iLowerY -= amount; - m_iLowerZ -= amount; + m_iLowerX -= iAmount; + m_iLowerY -= iAmount; + m_iLowerZ -= iAmount; - m_iUpperX += amount; - m_iUpperY += amount; - m_iUpperZ += amount; + m_iUpperX += iAmount; + m_iUpperY += iAmount; + m_iUpperZ += iAmount; } - void Region::erode(int32_t amount) + void Region::dilate(int32_t iAmountX, int32_t iAmountY, int32_t iAmountZ) { - m_iLowerX += amount; - m_iLowerY += amount; - m_iLowerZ += amount; + m_iLowerX -= iAmountX; + m_iLowerY -= iAmountY; + m_iLowerZ -= iAmountZ; - m_iUpperX -= amount; - m_iUpperY -= amount; - m_iUpperZ -= amount; + m_iUpperX += iAmountX; + m_iUpperY += iAmountY; + m_iUpperZ += iAmountZ; + } + + void Region::dilate(const Vector3DInt32& v3dAmount) + { + dilate(v3dAmount.getX(), v3dAmount.getY(), v3dAmount.getZ()); + } + + void Region::erode(int32_t iAmount) + { + m_iLowerX += iAmount; + m_iLowerY += iAmount; + m_iLowerZ += iAmount; + + m_iUpperX -= iAmount; + m_iUpperY -= iAmount; + m_iUpperZ -= iAmount; + } + + void Region::erode(int32_t iAmountX, int32_t iAmountY, int32_t iAmountZ) + { + m_iLowerX += iAmountX; + m_iLowerY += iAmountY; + m_iLowerZ += iAmountZ; + + m_iUpperX -= iAmountX; + m_iUpperY -= iAmountY; + m_iUpperZ -= iAmountZ; + } + + void Region::erode(const Vector3DInt32& v3dAmount) + { + erode(v3dAmount.getX(), v3dAmount.getY(), v3dAmount.getZ()); } }