Switched to integer naming conventions from C++0x (e.g. uint16_t)
This commit is contained in:
@ -43,7 +43,7 @@ namespace PolyVox
|
||||
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, int32, and uint32. They are used as follows:
|
||||
vectors with type float, double, int32_t, and uint32_t. They are used as follows:
|
||||
|
||||
Vector2DInt4 test(1,2); //Declares a 2 dimensional Vector of type int4.
|
||||
*/
|
||||
@ -55,7 +55,7 @@ namespace PolyVox
|
||||
\param x x component to set.
|
||||
\param y y component to set.
|
||||
*/
|
||||
template <uint32 Size,typename Type>
|
||||
template <uint32_t Size,typename Type>
|
||||
Vector<Size,Type>::Vector(Type x, Type y) throw()
|
||||
{
|
||||
m_tElements[0] = x;
|
||||
@ -69,7 +69,7 @@ namespace PolyVox
|
||||
\param y y component to set.
|
||||
\param z z component to set.
|
||||
*/
|
||||
template <uint32 Size,typename Type>
|
||||
template <uint32_t Size,typename Type>
|
||||
Vector<Size,Type>::Vector(Type x, Type y, Type z) throw()
|
||||
{
|
||||
m_tElements[0] = x;
|
||||
@ -85,7 +85,7 @@ namespace PolyVox
|
||||
\param z z component to set.
|
||||
\param w w component to set.
|
||||
*/
|
||||
template <uint32 Size,typename Type>
|
||||
template <uint32_t Size,typename Type>
|
||||
Vector<Size,Type>::Vector(Type x, Type y, Type z, Type w) throw()
|
||||
{
|
||||
m_tElements[0] = x;
|
||||
@ -97,7 +97,7 @@ namespace PolyVox
|
||||
/**
|
||||
Creates a Vector object but does not initialise it.
|
||||
*/
|
||||
template <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
Vector<Size, Type>::Vector(void) throw()
|
||||
{
|
||||
}
|
||||
@ -106,7 +106,7 @@ namespace PolyVox
|
||||
Copy constructor builds object based on object passed as parameter.
|
||||
\param vector A reference to the Vector to be copied.
|
||||
*/
|
||||
template <uint32 Size, typename Type>
|
||||
template <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);
|
||||
@ -121,11 +121,11 @@ namespace PolyVox
|
||||
|
||||
\param vector A reference to the Vector to be copied.
|
||||
*/
|
||||
template <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
template <typename CastType>
|
||||
Vector<Size, Type>::Vector(const Vector<Size, CastType>& vector) throw()
|
||||
{
|
||||
for(uint32 ct = 0; ct < Size; ++ct)
|
||||
for(uint32_t ct = 0; ct < Size; ++ct)
|
||||
{
|
||||
m_tElements[ct] = static_cast<CastType>(vector.getElement(ct));
|
||||
}
|
||||
@ -134,7 +134,7 @@ namespace PolyVox
|
||||
/**
|
||||
Destroys the Vector.
|
||||
*/
|
||||
template <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
Vector<Size, Type>::~Vector(void) throw()
|
||||
{
|
||||
}
|
||||
@ -146,7 +146,7 @@ namespace PolyVox
|
||||
\param rhs Vector to assign to.
|
||||
\return A reference to the result to allow chaining.
|
||||
*/
|
||||
template <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
Vector<Size, Type>& Vector<Size, Type>::operator=(const Vector<Size, Type>& rhs) throw()
|
||||
{
|
||||
if(this == &rhs)
|
||||
@ -163,11 +163,11 @@ namespace PolyVox
|
||||
\return true if the Vectors match.
|
||||
\see operator!=
|
||||
*/
|
||||
template <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
inline bool Vector<Size, Type>::operator==(const Vector<Size, Type> &rhs) const throw()
|
||||
{
|
||||
bool equal = true;
|
||||
for(uint32 ct = 0; ct < Size; ++ct)
|
||||
for(uint32_t ct = 0; ct < Size; ++ct)
|
||||
{
|
||||
if(m_tElements[ct] != rhs.m_tElements[ct])
|
||||
{
|
||||
@ -185,7 +185,7 @@ namespace PolyVox
|
||||
\return true if this is less than the parameter
|
||||
\see operator!=
|
||||
*/
|
||||
template <uint32 Size, typename Type>
|
||||
template <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)
|
||||
@ -203,10 +203,10 @@ namespace PolyVox
|
||||
\param rhs Vector to add
|
||||
\return The resulting Vector.
|
||||
*/
|
||||
template <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
inline Vector<Size, Type>& Vector<Size, Type>::operator+=(const Vector<Size, Type>& rhs) throw()
|
||||
{
|
||||
for(uint32 ct = 0; ct < Size; ++ct)
|
||||
for(uint32_t ct = 0; ct < Size; ++ct)
|
||||
{
|
||||
m_tElements[ct] += rhs.m_tElements[ct];
|
||||
}
|
||||
@ -219,7 +219,7 @@ namespace PolyVox
|
||||
\param rhs Vector to add.
|
||||
\return The resulting Vector.
|
||||
*/
|
||||
template <uint32 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> result = lhs;
|
||||
@ -232,10 +232,10 @@ namespace PolyVox
|
||||
\param rhs Vector to subtract
|
||||
\return The resulting Vector.
|
||||
*/
|
||||
template <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
inline Vector<Size, Type>& Vector<Size, Type>::operator-=(const Vector<Size, Type>& rhs) throw()
|
||||
{
|
||||
for(uint32 ct = 0; ct < Size; ++ct)
|
||||
for(uint32_t ct = 0; ct < Size; ++ct)
|
||||
{
|
||||
m_tElements[ct] -= rhs.m_tElements[ct];
|
||||
}
|
||||
@ -248,7 +248,7 @@ namespace PolyVox
|
||||
\param rhs Vector to subtract.
|
||||
\return The resulting Vector.
|
||||
*/
|
||||
template <uint32 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> result = lhs;
|
||||
@ -261,10 +261,10 @@ namespace PolyVox
|
||||
\param rhs the number the Vector is multiplied by.
|
||||
\return The resulting Vector.
|
||||
*/
|
||||
template <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
inline Vector<Size, Type>& Vector<Size, Type>::operator*=(const Type& rhs) throw()
|
||||
{
|
||||
for(uint32 ct = 0; ct < Size; ++ct)
|
||||
for(uint32_t ct = 0; ct < Size; ++ct)
|
||||
{
|
||||
m_tElements[ct] *= rhs;
|
||||
}
|
||||
@ -277,7 +277,7 @@ namespace PolyVox
|
||||
\param rhs the number the Vector is multiplied by.
|
||||
\return The resulting Vector.
|
||||
*/
|
||||
template <uint32 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> result = lhs;
|
||||
@ -290,10 +290,10 @@ namespace PolyVox
|
||||
\param rhs the number the Vector is divided by.
|
||||
\return The resulting Vector.
|
||||
*/
|
||||
template <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
inline Vector<Size, Type>& Vector<Size, Type>::operator/=(const Type& rhs) throw()
|
||||
{
|
||||
for(uint32 ct = 0; ct < Size; ++ct)
|
||||
for(uint32_t ct = 0; ct < Size; ++ct)
|
||||
{
|
||||
m_tElements[ct] /= rhs;
|
||||
}
|
||||
@ -306,7 +306,7 @@ namespace PolyVox
|
||||
\param rhs the number the Vector is divided by.
|
||||
\return The resulting Vector.
|
||||
*/
|
||||
template <uint32 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> result = lhs;
|
||||
@ -320,11 +320,11 @@ namespace PolyVox
|
||||
\param vector The Vector to write to the stream.
|
||||
\return A reference to the output stream to allow chaining.
|
||||
*/
|
||||
template <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
std::ostream& operator<<(std::ostream& os, const Vector<Size, Type>& vector) throw()
|
||||
{
|
||||
os << "(";
|
||||
for(uint32 ct = 0; ct < Size; ++ct)
|
||||
for(uint32_t ct = 0; ct < Size; ++ct)
|
||||
{
|
||||
os << vector.getElement(ct);
|
||||
if(ct < (Size-1))
|
||||
@ -343,8 +343,8 @@ namespace PolyVox
|
||||
\param index The index of the element to return.
|
||||
\return The element.
|
||||
*/
|
||||
template <uint32 Size, typename Type>
|
||||
inline Type Vector<Size, Type>::getElement(uint32 index) const throw()
|
||||
template <uint32_t Size, typename Type>
|
||||
inline Type Vector<Size, Type>::getElement(uint32_t index) const throw()
|
||||
{
|
||||
return m_tElements[index];
|
||||
}
|
||||
@ -352,7 +352,7 @@ namespace PolyVox
|
||||
/**
|
||||
\return A const reference to the X component of a 1, 2, 3, or 4 dimensional Vector.
|
||||
*/
|
||||
template <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
inline Type Vector<Size, Type>::getX(void) const throw()
|
||||
{
|
||||
return m_tElements[0];
|
||||
@ -361,7 +361,7 @@ namespace PolyVox
|
||||
/**
|
||||
\return A const reference to the Y component of a 2, 3, or 4 dimensional Vector.
|
||||
*/
|
||||
template <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
inline Type Vector<Size, Type>::getY(void) const throw()
|
||||
{
|
||||
return m_tElements[1];
|
||||
@ -370,7 +370,7 @@ namespace PolyVox
|
||||
/**
|
||||
\return A const reference to the Z component of a 3 or 4 dimensional Vector.
|
||||
*/
|
||||
template <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
inline Type Vector<Size, Type>::getZ(void) const throw()
|
||||
{
|
||||
return m_tElements[2];
|
||||
@ -379,7 +379,7 @@ namespace PolyVox
|
||||
/**
|
||||
\return A const reference to the W component of a 4 dimensional Vector.
|
||||
*/
|
||||
template <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
inline Type Vector<Size, Type>::getW(void) const throw()
|
||||
{
|
||||
return m_tElements[3];
|
||||
@ -391,8 +391,8 @@ namespace PolyVox
|
||||
\param index The index of the element to set.
|
||||
\param tValue The new value for the element.
|
||||
*/
|
||||
template <uint32 Size, typename Type>
|
||||
inline void Vector<Size, Type>::setElement(uint32 index, Type tValue) throw()
|
||||
template <uint32_t Size, typename Type>
|
||||
inline void Vector<Size, Type>::setElement(uint32_t index, Type tValue) throw()
|
||||
{
|
||||
m_tElements[index] = tValue;
|
||||
}
|
||||
@ -402,7 +402,7 @@ namespace PolyVox
|
||||
\param x x component to set.
|
||||
\param y y component to set.
|
||||
*/
|
||||
template <uint32 Size,typename Type>
|
||||
template <uint32_t Size,typename Type>
|
||||
inline void Vector<Size,Type>::setElements(Type x, Type y) throw()
|
||||
{
|
||||
m_tElements[0] = x;
|
||||
@ -416,7 +416,7 @@ namespace PolyVox
|
||||
\param y y component to set.
|
||||
\param z z component to set.
|
||||
*/
|
||||
template <uint32 Size,typename Type>
|
||||
template <uint32_t Size,typename Type>
|
||||
inline void Vector<Size,Type>::setElements(Type x, Type y, Type z) throw()
|
||||
{
|
||||
m_tElements[0] = x;
|
||||
@ -432,7 +432,7 @@ namespace PolyVox
|
||||
\param z z component to set.
|
||||
\param w w component to set.
|
||||
*/
|
||||
template <uint32 Size,typename Type>
|
||||
template <uint32_t Size,typename Type>
|
||||
inline void Vector<Size,Type>::setElements(Type x, Type y, Type z, Type w) throw()
|
||||
{
|
||||
m_tElements[0] = x;
|
||||
@ -444,7 +444,7 @@ namespace PolyVox
|
||||
/**
|
||||
\param tX The new value for the X component of a 1, 2, 3, or 4 dimensional Vector.
|
||||
*/
|
||||
template <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
inline void Vector<Size, Type>::setX(Type tX) throw()
|
||||
{
|
||||
m_tElements[0] = tX;
|
||||
@ -453,7 +453,7 @@ namespace PolyVox
|
||||
/**
|
||||
\param tX The new value for the Y component of a 2, 3, or 4 dimensional Vector.
|
||||
*/
|
||||
template <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
inline void Vector<Size, Type>::setY(Type tY) throw()
|
||||
{
|
||||
m_tElements[1] = tY;
|
||||
@ -462,7 +462,7 @@ namespace PolyVox
|
||||
/**
|
||||
\param tX The new value for the Z component of a 3 or 4 dimensional Vector.
|
||||
*/
|
||||
template <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
inline void Vector<Size, Type>::setZ(Type tZ) throw()
|
||||
{
|
||||
m_tElements[2] = tZ;
|
||||
@ -471,7 +471,7 @@ namespace PolyVox
|
||||
/**
|
||||
\param tX The new value for the W component of a 4 dimensional Vector.
|
||||
*/
|
||||
template <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
inline void Vector<Size, Type>::setW(Type tW) throw()
|
||||
{
|
||||
m_tElements[3] = tW;
|
||||
@ -483,7 +483,7 @@ namespace PolyVox
|
||||
NOTE: This function does not make much sense on integer Vectors.
|
||||
\return Length of the Vector.
|
||||
*/
|
||||
template <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
inline double Vector<Size, Type>::length(void) const throw()
|
||||
{
|
||||
return sqrt(lengthSquared());
|
||||
@ -492,11 +492,11 @@ namespace PolyVox
|
||||
/**
|
||||
\return Squared length of the Vector.
|
||||
*/
|
||||
template <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
inline double Vector<Size, Type>::lengthSquared(void) const throw()
|
||||
{
|
||||
double result = 0.0f;
|
||||
for(uint32 ct = 0; ct < Size; ++ct)
|
||||
for(uint32_t ct = 0; ct < Size; ++ct)
|
||||
{
|
||||
result += m_tElements[ct] * m_tElements[ct];
|
||||
}
|
||||
@ -512,7 +512,7 @@ namespace PolyVox
|
||||
\param Vector3D The Vector to find the angle to.
|
||||
\return The angle between them in radians.
|
||||
*/
|
||||
template <uint32 Size, typename Type>
|
||||
template <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()));
|
||||
@ -531,7 +531,7 @@ namespace PolyVox
|
||||
\return The value of the cross product.
|
||||
\see dot()
|
||||
*/
|
||||
template <uint32 Size, typename Type>
|
||||
template <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();
|
||||
@ -547,11 +547,11 @@ namespace PolyVox
|
||||
\return The value of the dot product.
|
||||
\see cross()
|
||||
*/
|
||||
template <uint32 Size, typename Type>
|
||||
template <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(uint32 ct = 0; ct < Size; ++ct)
|
||||
for(uint32_t ct = 0; ct < Size; ++ct)
|
||||
{
|
||||
dotProduct += m_tElements[ct] * rhs.m_tElements[ct];
|
||||
}
|
||||
@ -563,7 +563,7 @@ namespace PolyVox
|
||||
|
||||
NOTE: This function does not make much sense on integer Vectors.
|
||||
*/
|
||||
template <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
inline void Vector<Size, Type>::normalise(void) throw()
|
||||
{
|
||||
double length = this->length();
|
||||
@ -572,7 +572,7 @@ namespace PolyVox
|
||||
{
|
||||
return;
|
||||
}
|
||||
for(uint32 ct = 0; ct < Size; ++ct)
|
||||
for(uint32_t ct = 0; ct < Size; ++ct)
|
||||
{
|
||||
m_tElements[ct] /= static_cast<Type>(length);
|
||||
}
|
||||
|
Reference in New Issue
Block a user