diff --git a/library/PolyVoxCore/include/Array.h b/library/PolyVoxCore/include/Array.h index b451da5d..d213a9a8 100644 --- a/library/PolyVoxCore/include/Array.h +++ b/library/PolyVoxCore/include/Array.h @@ -97,6 +97,8 @@ namespace PolyVox void resize(const uint32_t (&pDimensions)[noOfDims]); ///Swaps the contents of this array with the one specified void swap(Array& rhs); + ///Get the size of the Array along the specified dimension + uint32_t getDimension(uint32_t uDimension); private: Array(const Array& rhs); diff --git a/library/PolyVoxCore/include/Array.inl b/library/PolyVoxCore/include/Array.inl index 8f70c0b9..39d59701 100644 --- a/library/PolyVoxCore/include/Array.inl +++ b/library/PolyVoxCore/include/Array.inl @@ -155,7 +155,7 @@ namespace PolyVox //////////////////////////////////////////////////////////////////////////////// /// Because this class does not have a public assignment operator or copy constructor - /// it cnnot be used with the STL swap() function. This function provides an efficient + /// it cannot be used with the STL swap() function. This function provides an efficient /// implementation of that feature. /// \param rhs The array to swap this object with. //////////////////////////////////////////////////////////////////////////////// @@ -180,6 +180,16 @@ namespace PolyVox rhs.m_pElements = m_pTempElements; } + //////////////////////////////////////////////////////////////////////////////// + /// \param uDimension The dimension to get the size of. + //////////////////////////////////////////////////////////////////////////////// + template + uint32_t Array::getDimension(uint32_t uDimension) + { + assert(uDimension < noOfDims); + return m_pDimensions[uDimension]; + } + template Array::Array(const Array& rhs) :m_pElements(0) diff --git a/library/PolyVoxCore/include/Vector.h b/library/PolyVoxCore/include/Vector.h index 35358b22..16ba4e3a 100644 --- a/library/PolyVoxCore/include/Vector.h +++ b/library/PolyVoxCore/include/Vector.h @@ -84,6 +84,10 @@ namespace PolyVox Vector& operator+=(const Vector &rhs) throw(); ///Subtraction and Assignment Operator. Vector& operator-=(const Vector &rhs) throw(); + ///Multiplication and Assignment Operator. + Vector& operator*=(const Vector &rhs) throw(); + ///Division and Assignment Operator. + Vector& operator/=(const Vector &rhs) throw(); ///Multiplication and Assignment Operator. Vector& operator*=(const Type& rhs) throw(); ///Division and Assignment Operator. @@ -143,6 +147,12 @@ namespace PolyVox template Vector operator-(const Vector& lhs, const Vector& rhs) throw(); ///Multiplication operator. + template + Vector operator*(const Vector& lhs, const Vector& rhs) throw(); + ///Division operator. + template + Vector operator/(const Vector& lhs, const Vector& rhs) throw(); + ///Multiplication operator. template Vector operator*(const Vector& lhs, const Type& rhs) throw(); ///Division operator. diff --git a/library/PolyVoxCore/include/Vector.inl b/library/PolyVoxCore/include/Vector.inl index 4ea00984..2c45bf2e 100644 --- a/library/PolyVoxCore/include/Vector.inl +++ b/library/PolyVoxCore/include/Vector.inl @@ -190,20 +190,6 @@ 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 @@ -220,18 +206,34 @@ namespace PolyVox } /** - Subtraction operator subtracts corresponding elements of one Vector from the other. - \param lhs Vector to subtract from. - \param rhs Vector to subtract. + Multiplication operator multiplies corresponding elements of the two Vectors. + \param rhs Vector to multiply by \return The resulting Vector. */ - template - Vector operator-(const Vector& lhs, const Vector& rhs) throw() - { - Vector result = lhs; - result -= rhs; - return result; - } + template + inline Vector& Vector::operator*=(const Vector& rhs) throw() + { + for(uint32_t ct = 0; ct < Size; ++ct) + { + m_tElements[ct] *= rhs.m_tElements[ct]; + } + return *this; + } + + /** + Division operator divides corresponding elements of one Vector by the other. + \param rhs Vector to divide by + \return The resulting Vector. + */ + template + inline Vector& Vector::operator/=(const Vector& rhs) throw() + { + for(uint32_t ct = 0; ct < Size; ++ct) + { + m_tElements[ct] /= rhs.m_tElements[ct]; + } + return *this; + } /** Multiplication operator multiplies each element of the Vector by a number. @@ -248,20 +250,6 @@ 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. @@ -277,6 +265,76 @@ 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 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 mulitplies corresponding elements of the two Vectors. + \param lhs Vector to multiply. + \param rhs Vector to multiply by. + \return The resulting Vector. + */ + template + Vector operator*(const Vector& lhs, const Vector& rhs) throw() + { + Vector result = lhs; + result *= rhs; + return result; + } + + /** + Division operator divides corresponding elements of one Vector by the other. + \param lhs Vector to divide. + \param rhs Vector to divide by. + \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.