Made all Vector2 and Vector3 functions inline

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1220 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
LaurentGom 2009-09-24 07:40:49 +00:00
parent 01181af3e0
commit 1852614e16
2 changed files with 28 additions and 28 deletions

View File

@ -27,7 +27,7 @@
/// Default constructor /// Default constructor
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
template <typename T> template <typename T>
Vector2<T>::Vector2() : inline Vector2<T>::Vector2() :
x(0), x(0),
y(0) y(0)
{ {
@ -39,7 +39,7 @@ y(0)
/// Construct the color from its coordinates /// Construct the color from its coordinates
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
template <typename T> template <typename T>
Vector2<T>::Vector2(T X, T Y) : inline Vector2<T>::Vector2(T X, T Y) :
x(X), x(X),
y(Y) y(Y)
{ {
@ -51,7 +51,7 @@ y(Y)
/// Operator - overload ; returns the opposite of a vector /// Operator - overload ; returns the opposite of a vector
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
template <typename T> template <typename T>
Vector2<T> operator -(const Vector2<T>& left) inline Vector2<T> operator -(const Vector2<T>& left)
{ {
return Vector2<T>(-left.x, -left.y); return Vector2<T>(-left.x, -left.y);
} }
@ -61,7 +61,7 @@ Vector2<T> operator -(const Vector2<T>& left)
/// Operator += overload ; add two vectors and assign to the first op /// Operator += overload ; add two vectors and assign to the first op
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
template <typename T> template <typename T>
Vector2<T>& operator +=(Vector2<T>& left, const Vector2<T>& right) inline Vector2<T>& operator +=(Vector2<T>& left, const Vector2<T>& right)
{ {
left.x += right.x; left.x += right.x;
left.y += right.y; left.y += right.y;
@ -74,7 +74,7 @@ Vector2<T>& operator +=(Vector2<T>& left, const Vector2<T>& right)
/// Operator -= overload ; subtract two vectors and assign to the first op /// Operator -= overload ; subtract two vectors and assign to the first op
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
template <typename T> template <typename T>
Vector2<T>& operator -=(Vector2<T>& left, const Vector2<T>& right) inline Vector2<T>& operator -=(Vector2<T>& left, const Vector2<T>& right)
{ {
left.x -= right.x; left.x -= right.x;
left.y -= right.y; left.y -= right.y;
@ -87,7 +87,7 @@ Vector2<T>& operator -=(Vector2<T>& left, const Vector2<T>& right)
/// Operator + overload ; adds two vectors /// Operator + overload ; adds two vectors
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
template <typename T> template <typename T>
Vector2<T> operator +(const Vector2<T>& left, const Vector2<T>& right) inline Vector2<T> operator +(const Vector2<T>& left, const Vector2<T>& right)
{ {
return Vector2<T>(left.x + right.x, left.y + right.y); return Vector2<T>(left.x + right.x, left.y + right.y);
} }
@ -97,7 +97,7 @@ Vector2<T> operator +(const Vector2<T>& left, const Vector2<T>& right)
/// Operator - overload ; subtracts two vectors /// Operator - overload ; subtracts two vectors
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
template <typename T> template <typename T>
Vector2<T> operator -(const Vector2<T>& left, const Vector2<T>& right) inline Vector2<T> operator -(const Vector2<T>& left, const Vector2<T>& right)
{ {
return Vector2<T>(left.x - right.x, left.y - right.y); return Vector2<T>(left.x - right.x, left.y - right.y);
} }
@ -107,7 +107,7 @@ Vector2<T> operator -(const Vector2<T>& left, const Vector2<T>& right)
/// Operator * overload ; multiply a vector by a scalar value /// Operator * overload ; multiply a vector by a scalar value
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
template <typename T> template <typename T>
Vector2<T> operator *(const Vector2<T>& left, T right) inline Vector2<T> operator *(const Vector2<T>& left, T right)
{ {
return Vector2<T>(left.x * right, left.y * right); return Vector2<T>(left.x * right, left.y * right);
} }
@ -117,7 +117,7 @@ Vector2<T> operator *(const Vector2<T>& left, T right)
/// Operator * overload ; multiply a scalar value by a vector /// Operator * overload ; multiply a scalar value by a vector
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
template <typename T> template <typename T>
Vector2<T> operator *(T left, const Vector2<T>& right) inline Vector2<T> operator *(T left, const Vector2<T>& right)
{ {
return Vector2<T>(right.x * left, right.y * left); return Vector2<T>(right.x * left, right.y * left);
} }
@ -127,7 +127,7 @@ Vector2<T> operator *(T left, const Vector2<T>& right)
/// Operator *= overload ; multiply-assign a vector by a scalar value /// Operator *= overload ; multiply-assign a vector by a scalar value
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
template <typename T> template <typename T>
Vector2<T>& operator *=(Vector2<T>& left, T right) inline Vector2<T>& operator *=(Vector2<T>& left, T right)
{ {
left.x *= right; left.x *= right;
left.y *= right; left.y *= right;
@ -140,7 +140,7 @@ Vector2<T>& operator *=(Vector2<T>& left, T right)
/// Operator / overload ; divide a vector by a scalar value /// Operator / overload ; divide a vector by a scalar value
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
template <typename T> template <typename T>
Vector2<T> operator /(const Vector2<T>& left, T right) inline Vector2<T> operator /(const Vector2<T>& left, T right)
{ {
return Vector2<T>(left.x / right, left.y / right); return Vector2<T>(left.x / right, left.y / right);
} }
@ -150,7 +150,7 @@ Vector2<T> operator /(const Vector2<T>& left, T right)
/// Operator /= overload ; divide-assign a vector by a scalar value /// Operator /= overload ; divide-assign a vector by a scalar value
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
template <typename T> template <typename T>
Vector2<T>& operator /=(Vector2<T>& left, T right) inline Vector2<T>& operator /=(Vector2<T>& left, T right)
{ {
left.x /= right; left.x /= right;
left.y /= right; left.y /= right;
@ -163,7 +163,7 @@ Vector2<T>& operator /=(Vector2<T>& left, T right)
/// Operator == overload ; compares the equality of two vectors /// Operator == overload ; compares the equality of two vectors
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
template <typename T> template <typename T>
bool operator ==(const Vector2<T>& left, const Vector2<T>& right) inline bool operator ==(const Vector2<T>& left, const Vector2<T>& right)
{ {
return (left.x == right.x) && (left.y == right.y); return (left.x == right.x) && (left.y == right.y);
} }
@ -173,7 +173,7 @@ bool operator ==(const Vector2<T>& left, const Vector2<T>& right)
/// Operator != overload ; compares the difference of two vectors /// Operator != overload ; compares the difference of two vectors
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
template <typename T> template <typename T>
bool operator !=(const Vector2<T>& left, const Vector2<T>& right) inline bool operator !=(const Vector2<T>& left, const Vector2<T>& right)
{ {
return (left.x != right.x) || (left.y != right.y); return (left.x != right.x) || (left.y != right.y);
} }

View File

@ -27,7 +27,7 @@
/// Default constructor /// Default constructor
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
template <typename T> template <typename T>
Vector3<T>::Vector3() : inline Vector3<T>::Vector3() :
x(0), x(0),
y(0), y(0),
z(0) z(0)
@ -40,7 +40,7 @@ z(0)
/// Construct the color from its coordinates /// Construct the color from its coordinates
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
template <typename T> template <typename T>
Vector3<T>::Vector3(T X, T Y, T Z) : inline Vector3<T>::Vector3(T X, T Y, T Z) :
x(X), x(X),
y(Y), y(Y),
z(Z) z(Z)
@ -53,7 +53,7 @@ z(Z)
/// Operator - overload ; returns the opposite of a vector /// Operator - overload ; returns the opposite of a vector
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
template <typename T> template <typename T>
Vector3<T> operator -(const Vector3<T>& left) inline Vector3<T> operator -(const Vector3<T>& left)
{ {
return Vector3<T>(-left.x, -left.y, -left.z); return Vector3<T>(-left.x, -left.y, -left.z);
} }
@ -63,7 +63,7 @@ Vector3<T> operator -(const Vector3<T>& left)
/// Operator += overload ; add two vectors and assign to the first op /// Operator += overload ; add two vectors and assign to the first op
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
template <typename T> template <typename T>
Vector3<T>& operator +=(Vector3<T>& left, const Vector3<T>& right) inline Vector3<T>& operator +=(Vector3<T>& left, const Vector3<T>& right)
{ {
left.x += right.x; left.x += right.x;
left.y += right.y; left.y += right.y;
@ -77,7 +77,7 @@ Vector3<T>& operator +=(Vector3<T>& left, const Vector3<T>& right)
/// Operator -= overload ; subtract two vectors and assign to the first op /// Operator -= overload ; subtract two vectors and assign to the first op
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
template <typename T> template <typename T>
Vector3<T>& operator -=(Vector3<T>& left, const Vector3<T>& right) inline Vector3<T>& operator -=(Vector3<T>& left, const Vector3<T>& right)
{ {
left.x -= right.x; left.x -= right.x;
left.y -= right.y; left.y -= right.y;
@ -91,7 +91,7 @@ Vector3<T>& operator -=(Vector3<T>& left, const Vector3<T>& right)
/// Operator + overload ; adds two vectors /// Operator + overload ; adds two vectors
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
template <typename T> template <typename T>
Vector3<T> operator +(const Vector3<T>& left, const Vector3<T>& right) inline Vector3<T> operator +(const Vector3<T>& left, const Vector3<T>& right)
{ {
return Vector3<T>(left.x + right.x, left.y + right.y, left.z + right.z); return Vector3<T>(left.x + right.x, left.y + right.y, left.z + right.z);
} }
@ -101,7 +101,7 @@ Vector3<T> operator +(const Vector3<T>& left, const Vector3<T>& right)
/// Operator - overload ; subtracts two vectors /// Operator - overload ; subtracts two vectors
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
template <typename T> template <typename T>
Vector3<T> operator -(const Vector3<T>& left, const Vector3<T>& right) inline Vector3<T> operator -(const Vector3<T>& left, const Vector3<T>& right)
{ {
return Vector3<T>(left.x - right.x, left.y - right.y, left.z - right.z); return Vector3<T>(left.x - right.x, left.y - right.y, left.z - right.z);
} }
@ -111,7 +111,7 @@ Vector3<T> operator -(const Vector3<T>& left, const Vector3<T>& right)
/// Operator * overload ; multiply a vector by a scalar value /// Operator * overload ; multiply a vector by a scalar value
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
template <typename T> template <typename T>
Vector3<T> operator *(const Vector3<T>& left, T right) inline Vector3<T> operator *(const Vector3<T>& left, T right)
{ {
return Vector3<T>(left.x * right, left.y * right, left.z * right); return Vector3<T>(left.x * right, left.y * right, left.z * right);
} }
@ -121,7 +121,7 @@ Vector3<T> operator *(const Vector3<T>& left, T right)
/// Operator * overload ; multiply a scalar value by a vector /// Operator * overload ; multiply a scalar value by a vector
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
template <typename T> template <typename T>
Vector3<T> operator *(T left, const Vector3<T>& right) inline Vector3<T> operator *(T left, const Vector3<T>& right)
{ {
return Vector3<T>(right.x * left, right.y * left, right.z * left); return Vector3<T>(right.x * left, right.y * left, right.z * left);
} }
@ -131,7 +131,7 @@ Vector3<T> operator *(T left, const Vector3<T>& right)
/// Operator *= overload ; multiply-assign a vector by a scalar value /// Operator *= overload ; multiply-assign a vector by a scalar value
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
template <typename T> template <typename T>
Vector3<T>& operator *=(Vector3<T>& left, T right) inline Vector3<T>& operator *=(Vector3<T>& left, T right)
{ {
left.x *= right; left.x *= right;
left.y *= right; left.y *= right;
@ -145,7 +145,7 @@ Vector3<T>& operator *=(Vector3<T>& left, T right)
/// Operator / overload ; divide a vector by a scalar value /// Operator / overload ; divide a vector by a scalar value
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
template <typename T> template <typename T>
Vector3<T> operator /(const Vector3<T>& left, T right) inline Vector3<T> operator /(const Vector3<T>& left, T right)
{ {
return Vector3<T>(left.x / right, left.y / right, left.z / right); return Vector3<T>(left.x / right, left.y / right, left.z / right);
} }
@ -155,7 +155,7 @@ Vector3<T> operator /(const Vector3<T>& left, T right)
/// Operator /= overload ; divide-assign a vector by a scalar value /// Operator /= overload ; divide-assign a vector by a scalar value
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
template <typename T> template <typename T>
Vector3<T>& operator /=(Vector3<T>& left, T right) inline Vector3<T>& operator /=(Vector3<T>& left, T right)
{ {
left.x /= right; left.x /= right;
left.y /= right; left.y /= right;
@ -169,7 +169,7 @@ Vector3<T>& operator /=(Vector3<T>& left, T right)
/// Operator == overload ; compares the equality of two vectors /// Operator == overload ; compares the equality of two vectors
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
template <typename T> template <typename T>
bool operator ==(const Vector3<T>& left, const Vector3<T>& right) inline bool operator ==(const Vector3<T>& left, const Vector3<T>& right)
{ {
return (left.x == right.x) && (left.y == right.y) && (left.z == right.z); return (left.x == right.x) && (left.y == right.y) && (left.z == right.z);
} }
@ -179,7 +179,7 @@ bool operator ==(const Vector3<T>& left, const Vector3<T>& right)
/// Operator != overload ; compares the difference of two vectors /// Operator != overload ; compares the difference of two vectors
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
template <typename T> template <typename T>
bool operator !=(const Vector3<T>& left, const Vector3<T>& right) inline bool operator !=(const Vector3<T>& left, const Vector3<T>& right)
{ {
return (left.x != right.x) || (left.y != right.y) || (left.z != right.z); return (left.x != right.x) || (left.y != right.y) || (left.z != right.z);
} }