diff --git a/include/Vector.h b/include/Vector.h index a9176cee..8a90c2e5 100644 --- a/include/Vector.h +++ b/include/Vector.h @@ -22,10 +22,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #ifndef __PolyVox_Vector_H__ #define __PolyVox_Vector_H__ -#include - +#pragma region Headers #include "boost/cstdint.hpp" +#include +#pragma endregion + namespace PolyVox { ///Represents a vector in space. diff --git a/include/Vector.inl b/include/Vector.inl index 5856c0a0..5a6366dd 100644 --- a/include/Vector.inl +++ b/include/Vector.inl @@ -47,6 +47,7 @@ namespace PolyVox Vector2DInt4 test(1,2); //Declares a 2 dimensional Vector of type int4. */ + #pragma region Constructors/Destructors //-------------------------- Constructors, etc --------------------------------- /** Creates a Vector object and initialises it with given values. @@ -136,9 +137,9 @@ namespace PolyVox Vector::~Vector(void) throw() { } + #pragma endregion - //------------------------------- Overloaded Operators ------------------------- - + #pragma region Operators /** Assignment operator copies each element of first Vector to the second. \param rhs Vector to assign to. @@ -211,6 +212,20 @@ namespace PolyVox return *this; } + /** + Addition operator adds corresponding elements of the two Vectors. + \param lhs Vector to add to. + \param rhs Vector to add. + \return The resulting Vector. + */ + template + Vector operator+(const Vector& lhs, const Vector& rhs) throw() + { + Vector result = lhs; + result += rhs; + return result; + } + /** Subtraction operator subtracts corresponding elements of one Vector from the other. \param rhs Vector to subtract @@ -226,6 +241,20 @@ namespace PolyVox return *this; } + /** + Subtraction operator subtracts corresponding elements of one Vector from the other. + \param lhs Vector to subtract from. + \param rhs Vector to subtract. + \return The resulting Vector. + */ + template + Vector operator-(const Vector& lhs, const Vector& rhs) throw() + { + Vector result = lhs; + result -= rhs; + return result; + } + /** Multiplication operator multiplies each element of the Vector by a number. \param rhs the number the Vector is multiplied by. @@ -241,6 +270,20 @@ namespace PolyVox return *this; } + /** + Multiplication operator multiplies each element of the Vector by a number. + \param lhs the Vector to multiply. + \param rhs the number the Vector is multiplied by. + \return The resulting Vector. + */ + template + Vector operator*(const Vector& lhs, const Type& rhs) throw() + { + Vector result = lhs; + result *= rhs; + return result; + } + /** Division operator divides each element of the Vector by a number. \param rhs the number the Vector is divided by. @@ -256,6 +299,20 @@ namespace PolyVox return *this; } + /** + Division operator divides each element of the Vector by a number. + \param lhs the Vector to divide. + \param rhs the number the Vector is divided by. + \return The resulting Vector. + */ + template + Vector operator/(const Vector& lhs, const Type& rhs) throw() + { + Vector result = lhs; + result /= rhs; + return result; + } + /** Enables the Vector to be used intuitively with output streams such as cout. \param os The output stream to write to. @@ -277,9 +334,9 @@ namespace PolyVox os << ")"; return os; } + #pragma endregion - //----------------------------------- Getters ---------------------------------- - + #pragma region Getters /** Returns the element at the given position. \param index The index of the element to return. @@ -325,10 +382,10 @@ namespace PolyVox inline Type Vector::getW(void) const throw() { return m_tElements[3]; - } - - //----------------------------------- Setters ---------------------------------- + } + #pragma endregion + #pragma region Setters /** \param index The index of the element to set. \param tValue The new value for the element. @@ -374,9 +431,9 @@ namespace PolyVox { m_tElements[3] = tW; } + #pragma endregion - //-------------------------------- Other Functions ----------------------------- - + #pragma region Others /** NOTE: This function does not make much sense on integer Vectors. \return Length of the Vector. @@ -475,60 +532,5 @@ namespace PolyVox m_tElements[ct] /= static_cast(length); } } - - /** - Addition operator adds corresponding elements of the two Vectors. - \param lhs Vector to add to. - \param rhs Vector to add. - \return The resulting Vector. - */ - template - Vector operator+(const Vector& lhs, const Vector& rhs) throw() - { - Vector result = lhs; - result += rhs; - return result; - } - - /** - Subtraction operator subtracts corresponding elements of one Vector from the other. - \param lhs Vector to subtract from. - \param rhs Vector to subtract. - \return The resulting Vector. - */ - template - Vector operator-(const Vector& lhs, const Vector& rhs) throw() - { - Vector result = lhs; - result -= rhs; - return result; - } - - /** - Multiplication operator multiplies each element of the Vector by a number. - \param lhs the Vector to multiply. - \param rhs the number the Vector is multiplied by. - \return The resulting Vector. - */ - template - Vector operator*(const Vector& lhs, const Type& rhs) throw() - { - Vector result = lhs; - result *= rhs; - return result; - } - - /** - Division operator divides each element of the Vector by a number. - \param lhs the Vector to divide. - \param rhs the number the Vector is divided by. - \return The resulting Vector. - */ - template - Vector operator/(const Vector& lhs, const Type& rhs) throw() - { - Vector result = lhs; - result /= rhs; - return result; - } + #pragma endregion }//namespace Thermite