diff --git a/library/PolyVoxCore/include/Region.h b/library/PolyVoxCore/include/Region.h index e8542a2b..69f7d467 100644 --- a/library/PolyVoxCore/include/Region.h +++ b/library/PolyVoxCore/include/Region.h @@ -37,6 +37,7 @@ namespace PolyVox const Vector3DInt16& getLowerCorner(void) const; const Vector3DInt16& getUpperCorner(void) const; + const Vector3DInt16& getCentre(void) const; void setLowerCorner(const Vector3DInt16& v3dLowerCorner); void setUpperCorner(const Vector3DInt16& v3dUpperCorner); diff --git a/library/PolyVoxCore/source/Region.cpp b/library/PolyVoxCore/source/Region.cpp index 32641dd1..877c1c87 100644 --- a/library/PolyVoxCore/source/Region.cpp +++ b/library/PolyVoxCore/source/Region.cpp @@ -24,6 +24,13 @@ namespace PolyVox return m_v3dUpperCorner; } + const Vector3DInt16& Region::getCentre(void) const + { + Vector3DInt32 v3dMidpoint = static_cast(m_v3dLowerCorner) + static_cast(m_v3dUpperCorner); + v3dMidpoint = v3dMidpoint / static_cast(2); + return m_v3dLowerCorner + static_cast(v3dMidpoint); + } + void Region::setLowerCorner(const Vector3DInt16& v3dLowerCorner) { m_v3dLowerCorner = v3dLowerCorner;