From 5791919f01f6a1cabbccf01689584990a43b48cd Mon Sep 17 00:00:00 2001 From: David Williams Date: Sun, 30 Mar 2008 22:05:18 +0000 Subject: [PATCH] Simplyfing and improving updatePolyVoxGeometry() --- include/Vector.h | 2 ++ include/Vector.inl | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/include/Vector.h b/include/Vector.h index 4f58f1f5..109c3251 100644 --- a/include/Vector.h +++ b/include/Vector.h @@ -40,6 +40,8 @@ namespace PolyVox Vector& operator=(const Vector& rhs) throw(); ///Equality Operator. bool operator==(const Vector& rhs) const throw(); + ///Comparison Operator. + bool operator<(const Vector& rhs) const throw(); ///Addition and Assignment Operator. Vector& operator+=(const Vector &rhs) throw(); ///Subtraction and Assignment Operator. diff --git a/include/Vector.inl b/include/Vector.inl index 3b614474..3677b681 100644 --- a/include/Vector.inl +++ b/include/Vector.inl @@ -155,6 +155,26 @@ namespace PolyVox return equal; } + /** + Checks whether this vector is less than the parameter. The metric is + meaningless but it allows Vectors to me used as key in sdt::map, etc. + \param rhs The Vector to compare to. + \return true if this is less than the parameter + \see operator!= + */ + template + inline bool Vector::operator<(const Vector &rhs) const throw() + { + for(int ct = 0; ct < Size; ++ct) + { + if (m_tElements[ct] < rhs.m_tElements[ct]) + return true; + if (rhs.m_tElements[ct] < m_tElements[ct]) + return false; + } + return false; + } + /** Subtraction operator subtracts corresponding elements of one Vector from the other. \param rhs Vector to subtract