Added getCentre() to Region class.

This commit is contained in:
David Williams 2013-01-02 23:03:07 +01:00
parent 8fe824eb58
commit bf5a9f7ab8

View File

@ -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.
*/