Removed boost dependency.

This commit is contained in:
David Williams
2008-06-25 21:13:59 +00:00
parent 9a58b83b6d
commit 27f6e461c0
34 changed files with 346 additions and 317 deletions

View File

@@ -39,10 +39,10 @@ namespace PolyVox
A variety of overloaded operators are also provided for comparison and arithmetic
operations. For most of these arithmetic operators only the unary versions are
documented below - however often binary versions are also generated by boost::operators.
documented below - however often binary versions are also generated by std::operators.
Lastly, note that for convienience a set of typedefs are included for 2 and 3 dimentionsal
vectors with type float, double, boost::int32_t, and boost::uint32_t. They are used as follows:
vectors with type float, double, std::int32_t, and std::uint32_t. They are used as follows:
Vector2DInt4 test(1,2); //Declares a 2 dimensional Vector of type int4.
*/
@@ -54,7 +54,7 @@ namespace PolyVox
\param x x component to set.
\param y y component to set.
*/
template <boost::uint32_t Size,typename Type>
template <std::uint32_t Size,typename Type>
Vector<Size,Type>::Vector(Type x, Type y) throw()
{
m_tElements[0] = x;
@@ -68,7 +68,7 @@ namespace PolyVox
\param y y component to set.
\param z z component to set.
*/
template <boost::uint32_t Size,typename Type>
template <std::uint32_t Size,typename Type>
Vector<Size,Type>::Vector(Type x, Type y, Type z) throw()
{
m_tElements[0] = x;
@@ -84,7 +84,7 @@ namespace PolyVox
\param z z component to set.
\param w w component to set.
*/
template <boost::uint32_t Size,typename Type>
template <std::uint32_t Size,typename Type>
Vector<Size,Type>::Vector(Type x, Type y, Type z, Type w) throw()
{
m_tElements[0] = x;
@@ -96,7 +96,7 @@ namespace PolyVox
/**
Creates a Vector object but does not initialise it.
*/
template <boost::uint32_t Size, typename Type>
template <std::uint32_t Size, typename Type>
Vector<Size, Type>::Vector(void) throw()
{
}
@@ -105,7 +105,7 @@ namespace PolyVox
Copy constructor builds object based on object passed as parameter.
\param vector A reference to the Vector to be copied.
*/
template <boost::uint32_t Size, typename Type>
template <std::uint32_t Size, typename Type>
Vector<Size, Type>::Vector(const Vector<Size, Type>& vector) throw()
{
std::memcpy(m_tElements, vector.m_tElements, sizeof(Type) * Size);
@@ -120,11 +120,11 @@ namespace PolyVox
\param vector A reference to the Vector to be copied.
*/
template <boost::uint32_t Size, typename Type>
template <std::uint32_t Size, typename Type>
template <typename CastType>
Vector<Size, Type>::Vector(const Vector<Size, CastType>& vector) throw()
{
for(boost::uint32_t ct = 0; ct < Size; ++ct)
for(std::uint32_t ct = 0; ct < Size; ++ct)
{
m_tElements[ct] = static_cast<CastType>(vector.getElement(ct));
}
@@ -133,7 +133,7 @@ namespace PolyVox
/**
Destroys the Vector.
*/
template <boost::uint32_t Size, typename Type>
template <std::uint32_t Size, typename Type>
Vector<Size, Type>::~Vector(void) throw()
{
}
@@ -145,7 +145,7 @@ namespace PolyVox
\param rhs Vector to assign to.
\return A reference to the result to allow chaining.
*/
template <boost::uint32_t Size, typename Type>
template <std::uint32_t Size, typename Type>
Vector<Size, Type>& Vector<Size, Type>::operator=(const Vector<Size, Type>& rhs) throw()
{
if(this == &rhs)
@@ -162,11 +162,11 @@ namespace PolyVox
\return true if the Vectors match.
\see operator!=
*/
template <boost::uint32_t Size, typename Type>
template <std::uint32_t Size, typename Type>
inline bool Vector<Size, Type>::operator==(const Vector<Size, Type> &rhs) const throw()
{
bool equal = true;
for(boost::uint32_t ct = 0; ct < Size; ++ct)
for(std::uint32_t ct = 0; ct < Size; ++ct)
{
if(m_tElements[ct] != rhs(ct))
{
@@ -184,7 +184,7 @@ namespace PolyVox
\return true if this is less than the parameter
\see operator!=
*/
template <boost::uint32_t Size, typename Type>
template <std::uint32_t Size, typename Type>
inline bool Vector<Size, Type>::operator<(const Vector<Size, Type> &rhs) const throw()
{
for(int ct = 0; ct < Size; ++ct)
@@ -202,10 +202,10 @@ namespace PolyVox
\param rhs Vector to add
\return The resulting Vector.
*/
template <boost::uint32_t Size, typename Type>
template <std::uint32_t Size, typename Type>
inline Vector<Size, Type>& Vector<Size, Type>::operator+=(const Vector<Size, Type>& rhs) throw()
{
for(boost::uint32_t ct = 0; ct < Size; ++ct)
for(std::uint32_t ct = 0; ct < Size; ++ct)
{
m_tElements[ct] += rhs.m_tElements[ct];
}
@@ -218,7 +218,7 @@ namespace PolyVox
\param rhs Vector to add.
\return The resulting Vector.
*/
template <boost::uint32_t Size,typename Type>
template <std::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;
@@ -231,10 +231,10 @@ namespace PolyVox
\param rhs Vector to subtract
\return The resulting Vector.
*/
template <boost::uint32_t Size, typename Type>
template <std::uint32_t Size, typename Type>
inline Vector<Size, Type>& Vector<Size, Type>::operator-=(const Vector<Size, Type>& rhs) throw()
{
for(boost::uint32_t ct = 0; ct < Size; ++ct)
for(std::uint32_t ct = 0; ct < Size; ++ct)
{
m_tElements[ct] -= rhs.m_tElements[ct];
}
@@ -247,7 +247,7 @@ namespace PolyVox
\param rhs Vector to subtract.
\return The resulting Vector.
*/
template <boost::uint32_t Size,typename Type>
template <std::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;
@@ -260,10 +260,10 @@ namespace PolyVox
\param rhs the number the Vector is multiplied by.
\return The resulting Vector.
*/
template <boost::uint32_t Size, typename Type>
template <std::uint32_t Size, typename Type>
inline Vector<Size, Type>& Vector<Size, Type>::operator*=(const Type& rhs) throw()
{
for(boost::uint32_t ct = 0; ct < Size; ++ct)
for(std::uint32_t ct = 0; ct < Size; ++ct)
{
m_tElements[ct] *= rhs;
}
@@ -276,7 +276,7 @@ namespace PolyVox
\param rhs the number the Vector is multiplied by.
\return The resulting Vector.
*/
template <boost::uint32_t Size,typename Type>
template <std::uint32_t Size,typename Type>
Vector<Size,Type> operator*(const Vector<Size,Type>& lhs, const Type& rhs) throw()
{
Vector<Size,Type> result = lhs;
@@ -289,10 +289,10 @@ namespace PolyVox
\param rhs the number the Vector is divided by.
\return The resulting Vector.
*/
template <boost::uint32_t Size, typename Type>
template <std::uint32_t Size, typename Type>
inline Vector<Size, Type>& Vector<Size, Type>::operator/=(const Type& rhs) throw()
{
for(boost::uint32_t ct = 0; ct < Size; ++ct)
for(std::uint32_t ct = 0; ct < Size; ++ct)
{
m_tElements[ct] /= rhs;
}
@@ -305,7 +305,7 @@ namespace PolyVox
\param rhs the number the Vector is divided by.
\return The resulting Vector.
*/
template <boost::uint32_t Size,typename Type>
template <std::uint32_t Size,typename Type>
Vector<Size,Type> operator/(const Vector<Size,Type>& lhs, const Type& rhs) throw()
{
Vector<Size,Type> result = lhs;
@@ -319,11 +319,11 @@ namespace PolyVox
\param vector The Vector to write to the stream.
\return A reference to the output stream to allow chaining.
*/
template <boost::uint32_t Size, typename Type>
template <std::uint32_t Size, typename Type>
std::ostream& operator<<(std::ostream& os, const Vector<Size, Type>& vector) throw()
{
os << "(";
for(boost::uint32_t ct = 0; ct < Size; ++ct)
for(std::uint32_t ct = 0; ct < Size; ++ct)
{
os << vector.getElement(ct);
if(ct < (Size-1))
@@ -342,8 +342,8 @@ namespace PolyVox
\param index The index of the element to return.
\return The element.
*/
template <boost::uint32_t Size, typename Type>
inline Type Vector<Size, Type>::getElement(boost::uint32_t index) const throw()
template <std::uint32_t Size, typename Type>
inline Type Vector<Size, Type>::getElement(std::uint32_t index) const throw()
{
return m_tElements[index];
}
@@ -351,7 +351,7 @@ namespace PolyVox
/**
\return A const reference to the X component of a 1, 2, 3, or 4 dimensional Vector.
*/
template <boost::uint32_t Size, typename Type>
template <std::uint32_t Size, typename Type>
inline Type Vector<Size, Type>::getX(void) const throw()
{
return m_tElements[0];
@@ -360,7 +360,7 @@ namespace PolyVox
/**
\return A const reference to the Y component of a 2, 3, or 4 dimensional Vector.
*/
template <boost::uint32_t Size, typename Type>
template <std::uint32_t Size, typename Type>
inline Type Vector<Size, Type>::getY(void) const throw()
{
return m_tElements[1];
@@ -369,7 +369,7 @@ namespace PolyVox
/**
\return A const reference to the Z component of a 3 or 4 dimensional Vector.
*/
template <boost::uint32_t Size, typename Type>
template <std::uint32_t Size, typename Type>
inline Type Vector<Size, Type>::getZ(void) const throw()
{
return m_tElements[2];
@@ -378,7 +378,7 @@ namespace PolyVox
/**
\return A const reference to the W component of a 4 dimensional Vector.
*/
template <boost::uint32_t Size, typename Type>
template <std::uint32_t Size, typename Type>
inline Type Vector<Size, Type>::getW(void) const throw()
{
return m_tElements[3];
@@ -390,8 +390,8 @@ namespace PolyVox
\param index The index of the element to set.
\param tValue The new value for the element.
*/
template <boost::uint32_t Size, typename Type>
inline void Vector<Size, Type>::setElement(boost::uint32_t index, Type tValue) throw()
template <std::uint32_t Size, typename Type>
inline void Vector<Size, Type>::setElement(std::uint32_t index, Type tValue) throw()
{
m_tElements[index] = tValue;
}
@@ -399,7 +399,7 @@ namespace PolyVox
/**
\param tX The new value for the X component of a 1, 2, 3, or 4 dimensional Vector.
*/
template <boost::uint32_t Size, typename Type>
template <std::uint32_t Size, typename Type>
inline void Vector<Size, Type>::setX(Type tX) throw()
{
m_tElements[0] = tX;
@@ -408,7 +408,7 @@ namespace PolyVox
/**
\param tX The new value for the Y component of a 2, 3, or 4 dimensional Vector.
*/
template <boost::uint32_t Size, typename Type>
template <std::uint32_t Size, typename Type>
inline void Vector<Size, Type>::setY(Type tY) throw()
{
m_tElements[1] = tY;
@@ -417,7 +417,7 @@ namespace PolyVox
/**
\param tX The new value for the Z component of a 3 or 4 dimensional Vector.
*/
template <boost::uint32_t Size, typename Type>
template <std::uint32_t Size, typename Type>
inline void Vector<Size, Type>::setZ(Type tZ) throw()
{
m_tElements[2] = tZ;
@@ -426,7 +426,7 @@ namespace PolyVox
/**
\param tX The new value for the W component of a 4 dimensional Vector.
*/
template <boost::uint32_t Size, typename Type>
template <std::uint32_t Size, typename Type>
inline void Vector<Size, Type>::setW(Type tW) throw()
{
m_tElements[3] = tW;
@@ -438,7 +438,7 @@ namespace PolyVox
NOTE: This function does not make much sense on integer Vectors.
\return Length of the Vector.
*/
template <boost::uint32_t Size, typename Type>
template <std::uint32_t Size, typename Type>
inline double Vector<Size, Type>::length(void) const throw()
{
return sqrt(lengthSquared());
@@ -447,11 +447,11 @@ namespace PolyVox
/**
\return Squared length of the Vector.
*/
template <boost::uint32_t Size, typename Type>
template <std::uint32_t Size, typename Type>
inline double Vector<Size, Type>::lengthSquared(void) const throw()
{
double result = 0.0f;
for(boost::uint32_t ct = 0; ct < Size; ++ct)
for(std::uint32_t ct = 0; ct < Size; ++ct)
{
result += m_tElements[ct] * m_tElements[ct];
}
@@ -467,7 +467,7 @@ namespace PolyVox
\param Vector3D The Vector to find the angle to.
\return The angle between them in radians.
*/
template <boost::uint32_t Size, typename Type>
template <std::uint32_t Size, typename Type>
inline double Vector<Size, Type>::angleTo(const Vector<Size, Type>& vector) const throw()
{
return acos(dot(vector) / (vector.length() * this->length()));
@@ -486,7 +486,7 @@ namespace PolyVox
\return The value of the cross product.
\see dot()
*/
template <boost::uint32_t Size, typename Type>
template <std::uint32_t Size, typename Type>
inline Vector<Size, Type> Vector<Size, Type>::cross(const Vector<Size, Type>& vector) const throw()
{
Type i = vector.getZ() * this->getY() - vector.getY() * this->getZ();
@@ -502,11 +502,11 @@ namespace PolyVox
\return The value of the dot product.
\see cross()
*/
template <boost::uint32_t Size, typename Type>
template <std::uint32_t Size, typename Type>
inline Type Vector<Size, Type>::dot(const Vector<Size, Type>& rhs) const throw()
{
Type dotProduct = static_cast<Type>(0);
for(boost::uint32_t ct = 0; ct < Size; ++ct)
for(std::uint32_t ct = 0; ct < Size; ++ct)
{
dotProduct += m_tElements[ct] * rhs.m_tElements[ct];
}
@@ -518,7 +518,7 @@ namespace PolyVox
NOTE: This function does not make much sense on integer Vectors.
*/
template <boost::uint32_t Size, typename Type>
template <std::uint32_t Size, typename Type>
inline void Vector<Size, Type>::normalise(void) throw()
{
double length = this->length();
@@ -527,7 +527,7 @@ namespace PolyVox
{
return;
}
for(boost::uint32_t ct = 0; ct < Size; ++ct)
for(std::uint32_t ct = 0; ct < Size; ++ct)
{
m_tElements[ct] /= static_cast<Type>(length);
}