Added function to get Array size.
Added new operators to Vector.
This commit is contained in:
parent
b607653e9f
commit
359c9ec343
@ -97,6 +97,8 @@ namespace PolyVox
|
|||||||
void resize(const uint32_t (&pDimensions)[noOfDims]);
|
void resize(const uint32_t (&pDimensions)[noOfDims]);
|
||||||
///Swaps the contents of this array with the one specified
|
///Swaps the contents of this array with the one specified
|
||||||
void swap(Array<noOfDims, ElementType>& rhs);
|
void swap(Array<noOfDims, ElementType>& rhs);
|
||||||
|
///Get the size of the Array along the specified dimension
|
||||||
|
uint32_t getDimension(uint32_t uDimension);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Array<noOfDims, ElementType>(const Array<noOfDims, ElementType>& rhs);
|
Array<noOfDims, ElementType>(const Array<noOfDims, ElementType>& rhs);
|
||||||
|
@ -155,7 +155,7 @@ namespace PolyVox
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// Because this class does not have a public assignment operator or copy constructor
|
/// 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.
|
/// implementation of that feature.
|
||||||
/// \param rhs The array to swap this object with.
|
/// \param rhs The array to swap this object with.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -180,6 +180,16 @@ namespace PolyVox
|
|||||||
rhs.m_pElements = m_pTempElements;
|
rhs.m_pElements = m_pTempElements;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// \param uDimension The dimension to get the size of.
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template <uint32_t noOfDims, typename ElementType>
|
||||||
|
uint32_t Array<noOfDims, ElementType>::getDimension(uint32_t uDimension)
|
||||||
|
{
|
||||||
|
assert(uDimension < noOfDims);
|
||||||
|
return m_pDimensions[uDimension];
|
||||||
|
}
|
||||||
|
|
||||||
template <uint32_t noOfDims, typename ElementType>
|
template <uint32_t noOfDims, typename ElementType>
|
||||||
Array<noOfDims, ElementType>::Array(const Array<noOfDims, ElementType>& rhs)
|
Array<noOfDims, ElementType>::Array(const Array<noOfDims, ElementType>& rhs)
|
||||||
:m_pElements(0)
|
:m_pElements(0)
|
||||||
|
@ -84,6 +84,10 @@ namespace PolyVox
|
|||||||
Vector<Size,Type>& operator+=(const Vector<Size,Type> &rhs) throw();
|
Vector<Size,Type>& operator+=(const Vector<Size,Type> &rhs) throw();
|
||||||
///Subtraction and Assignment Operator.
|
///Subtraction and Assignment Operator.
|
||||||
Vector<Size,Type>& operator-=(const Vector<Size,Type> &rhs) throw();
|
Vector<Size,Type>& operator-=(const Vector<Size,Type> &rhs) throw();
|
||||||
|
///Multiplication and Assignment Operator.
|
||||||
|
Vector<Size,Type>& operator*=(const Vector<Size,Type> &rhs) throw();
|
||||||
|
///Division and Assignment Operator.
|
||||||
|
Vector<Size,Type>& operator/=(const Vector<Size,Type> &rhs) throw();
|
||||||
///Multiplication and Assignment Operator.
|
///Multiplication and Assignment Operator.
|
||||||
Vector<Size,Type>& operator*=(const Type& rhs) throw();
|
Vector<Size,Type>& operator*=(const Type& rhs) throw();
|
||||||
///Division and Assignment Operator.
|
///Division and Assignment Operator.
|
||||||
@ -143,6 +147,12 @@ namespace PolyVox
|
|||||||
template <uint32_t Size,typename Type>
|
template <uint32_t Size,typename Type>
|
||||||
Vector<Size,Type> operator-(const Vector<Size,Type>& lhs, const Vector<Size,Type>& rhs) throw();
|
Vector<Size,Type> operator-(const Vector<Size,Type>& lhs, const Vector<Size,Type>& rhs) throw();
|
||||||
///Multiplication operator.
|
///Multiplication operator.
|
||||||
|
template <uint32_t Size,typename Type>
|
||||||
|
Vector<Size,Type> operator*(const Vector<Size,Type>& lhs, const Vector<Size,Type>& rhs) throw();
|
||||||
|
///Division operator.
|
||||||
|
template <uint32_t Size,typename Type>
|
||||||
|
Vector<Size,Type> operator/(const Vector<Size,Type>& lhs, const Vector<Size,Type>& rhs) throw();
|
||||||
|
///Multiplication operator.
|
||||||
template <uint32_t Size,typename Type>
|
template <uint32_t Size,typename Type>
|
||||||
Vector<Size,Type> operator*(const Vector<Size,Type>& lhs, const Type& rhs) throw();
|
Vector<Size,Type> operator*(const Vector<Size,Type>& lhs, const Type& rhs) throw();
|
||||||
///Division operator.
|
///Division operator.
|
||||||
|
@ -190,20 +190,6 @@ namespace PolyVox
|
|||||||
return *this;
|
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 <uint32_t Size,typename Type>
|
|
||||||
Vector<Size,Type> operator+(const Vector<Size,Type>& lhs, const Vector<Size,Type>& rhs) throw()
|
|
||||||
{
|
|
||||||
Vector<Size,Type> result = lhs;
|
|
||||||
result += rhs;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Subtraction operator subtracts corresponding elements of one Vector from the other.
|
Subtraction operator subtracts corresponding elements of one Vector from the other.
|
||||||
\param rhs Vector to subtract
|
\param rhs Vector to subtract
|
||||||
@ -220,18 +206,34 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Subtraction operator subtracts corresponding elements of one Vector from the other.
|
Multiplication operator multiplies corresponding elements of the two Vectors.
|
||||||
\param lhs Vector to subtract from.
|
\param rhs Vector to multiply by
|
||||||
\param rhs Vector to subtract.
|
|
||||||
\return The resulting Vector.
|
\return The resulting Vector.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size,typename Type>
|
template <uint32_t Size, typename Type>
|
||||||
Vector<Size,Type> operator-(const Vector<Size,Type>& lhs, const Vector<Size,Type>& rhs) throw()
|
inline Vector<Size, Type>& Vector<Size, Type>::operator*=(const Vector<Size, Type>& rhs) throw()
|
||||||
{
|
{
|
||||||
Vector<Size,Type> result = lhs;
|
for(uint32_t ct = 0; ct < Size; ++ct)
|
||||||
result -= rhs;
|
{
|
||||||
return result;
|
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 <uint32_t Size, typename Type>
|
||||||
|
inline Vector<Size, Type>& Vector<Size, Type>::operator/=(const Vector<Size, Type>& 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.
|
Multiplication operator multiplies each element of the Vector by a number.
|
||||||
@ -248,20 +250,6 @@ namespace PolyVox
|
|||||||
return *this;
|
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 <uint32_t Size,typename Type>
|
|
||||||
Vector<Size,Type> operator*(const Vector<Size,Type>& lhs, const Type& rhs) throw()
|
|
||||||
{
|
|
||||||
Vector<Size,Type> result = lhs;
|
|
||||||
result *= rhs;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Division operator divides each element of the Vector by a number.
|
Division operator divides each element of the Vector by a number.
|
||||||
\param rhs the number the Vector is divided by.
|
\param rhs the number the Vector is divided by.
|
||||||
@ -277,6 +265,76 @@ namespace PolyVox
|
|||||||
return *this;
|
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 <uint32_t Size,typename Type>
|
||||||
|
Vector<Size,Type> operator+(const Vector<Size,Type>& lhs, const Vector<Size,Type>& rhs) throw()
|
||||||
|
{
|
||||||
|
Vector<Size,Type> 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 <uint32_t Size,typename Type>
|
||||||
|
Vector<Size,Type> operator-(const Vector<Size,Type>& lhs, const Vector<Size,Type>& rhs) throw()
|
||||||
|
{
|
||||||
|
Vector<Size,Type> 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 <uint32_t Size,typename Type>
|
||||||
|
Vector<Size,Type> operator*(const Vector<Size,Type>& lhs, const Vector<Size,Type>& rhs) throw()
|
||||||
|
{
|
||||||
|
Vector<Size,Type> 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 <uint32_t Size,typename Type>
|
||||||
|
Vector<Size,Type> operator/(const Vector<Size,Type>& lhs, const Vector<Size,Type>& rhs) throw()
|
||||||
|
{
|
||||||
|
Vector<Size,Type> 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 <uint32_t Size,typename Type>
|
||||||
|
Vector<Size,Type> operator*(const Vector<Size,Type>& lhs, const Type& rhs) throw()
|
||||||
|
{
|
||||||
|
Vector<Size,Type> result = lhs;
|
||||||
|
result *= rhs;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Division operator divides each element of the Vector by a number.
|
Division operator divides each element of the Vector by a number.
|
||||||
\param lhs the Vector to divide.
|
\param lhs the Vector to divide.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user