From bf5a9f7ab8c068461f491b384214036b892e4caf Mon Sep 17 00:00:00 2001 From: David Williams Date: Wed, 2 Jan 2013 23:03:07 +0100 Subject: [PATCH] Added getCentre() to Region class. --- .../PolyVoxCore/include/PolyVoxCore/Region.h | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/library/PolyVoxCore/include/PolyVoxCore/Region.h b/library/PolyVoxCore/include/PolyVoxCore/Region.h index aa7681fa..d65fb022 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Region.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Region.h @@ -74,6 +74,12 @@ namespace PolyVox /// Inequality Operator. bool operator!=(const Region& rhs) const; + /// Gets the 'x' position of the centre. + int32_t getCentreX(void) const; + /// Gets the 'y' position of the centre. + int32_t getCentreY(void) const; + /// Gets the 'z' position of the centrer. + int32_t getCentreZ(void) const; /// Gets the 'x' position of the lower corner. int32_t getLowerX(void) const; /// Gets the 'y' position of the lower corner. @@ -87,6 +93,8 @@ namespace PolyVox /// Gets the 'z' position of the upper corner. int32_t getUpperZ(void) const; + /// Gets the centre of the region + Vector3DInt32 getCentre(void) const; /// Gets the position of the lower corner. Vector3DInt32 getLowerCorner(void) const; /// Gets the position of the upper corner. @@ -203,6 +211,30 @@ namespace PolyVox // 'inline' keyword is used for the definition rather than the declaration. // See also http://www.parashift.com/c++-faq-lite/inline-functions.html + /** + * \return The 'x' position of the centre. + */ + inline int32_t Region::getCentreX(void) const + { + return (m_iLowerX + m_iUpperX) / 2; + } + + /** + * \return The 'y' position of the centre. + */ + inline int32_t Region::getCentreY(void) const + { + return (m_iLowerY + m_iUpperY) / 2; + } + + /** + * \return The 'z' position of the centre. + */ + inline int32_t Region::getCentreZ(void) const + { + return (m_iLowerZ + m_iUpperZ) / 2; + } + /** * \return The 'x' position of the lower corner. */ @@ -251,6 +283,14 @@ namespace PolyVox return m_iUpperZ; } + /** + * \return The position of the lower corner. + */ + inline Vector3DInt32 Region::getCentre(void) const + { + return Vector3DInt32(getCentreX(), getCentreY(), getCentreZ()); + } + /** * \return The position of the lower corner. */