Fixed increment and decrement operators for matrix types

This commit is contained in:
Christophe Riccio 2013-05-10 23:08:30 +02:00
parent 95e72aa545
commit 66e3e52592
19 changed files with 214 additions and 284 deletions

View File

@ -135,8 +135,14 @@ namespace detail
GLM_FUNC_DECL tmat2x2<T, P> & operator/=(U const & s);
template <typename U>
GLM_FUNC_DECL tmat2x2<T, P> & operator/=(tmat2x2<U, P> const & m);
GLM_FUNC_DECL tmat2x2<T, P> & operator++();
GLM_FUNC_DECL tmat2x2<T, P> & operator--();
//////////////////////////////////////
// Increment and decrement operators
GLM_FUNC_DECL tmat2x2<T, P> & operator++ ();
GLM_FUNC_DECL tmat2x2<T, P> & operator-- ();
GLM_FUNC_DECL tmat2x2<T, P> operator++(int);
GLM_FUNC_DECL tmat2x2<T, P> operator--(int);
};
// Binary operators
@ -232,18 +238,9 @@ namespace detail
// Unary constant operators
template <typename T, precision P>
tmat2x2<T, P> const operator- (
tmat2x2<T, P> const operator-(
tmat2x2<T, P> const & m);
template <typename T, precision P>
tmat2x2<T, P> const operator-- (
tmat2x2<T, P> const & m,
int);
template <typename T, precision P>
tmat2x2<T, P> const operator++ (
tmat2x2<T, P> const & m,
int);
} //namespace detail
} //namespace glm

View File

@ -397,7 +397,7 @@ namespace detail
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x2<T, P>& tmat2x2<T, P>::operator++ ()
GLM_FUNC_QUALIFIER tmat2x2<T, P>& tmat2x2<T, P>::operator++()
{
++this->value[0];
++this->value[1];
@ -405,13 +405,29 @@ namespace detail
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x2<T, P>& tmat2x2<T, P>::operator-- ()
GLM_FUNC_QUALIFIER tmat2x2<T, P>& tmat2x2<T, P>::operator--()
{
--this->value[0];
--this->value[1];
return *this;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x2<T, P> tmat2x2<T, P>::operator++(int)
{
tmat2x2<T, P> Result(*this);
++*this;
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x2<T, P> tmat2x2<T, P>::operator--(int)
{
tmat2x2<T, P> Result(*this);
--*this;
return Result;
}
//////////////////////////////////////////////////////////////
// Binary operators
@ -649,30 +665,6 @@ namespace detail
-m[1]);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x2<T, P> const operator++
(
tmat2x2<T, P> const & m,
int
)
{
return tmat2x2<T, P>(
m[0] + T(1),
m[1] + T(1));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x2<T, P> const operator--
(
tmat2x2<T, P> const & m,
int
)
{
return tmat2x2<T, P>(
m[0] - T(1),
m[1] - T(1));
}
//////////////////////////////////////
// Boolean operators

View File

@ -124,8 +124,13 @@ namespace detail
template <typename U>
GLM_FUNC_DECL tmat2x3<T, P> & operator/= (U const & s);
//////////////////////////////////////
// Increment and decrement operators
GLM_FUNC_DECL tmat2x3<T, P> & operator++ ();
GLM_FUNC_DECL tmat2x3<T, P> & operator-- ();
GLM_FUNC_DECL tmat2x3<T, P> operator++(int);
GLM_FUNC_DECL tmat2x3<T, P> operator--(int);
};
// Binary operators
@ -196,18 +201,9 @@ namespace detail
// Unary constant operators
template <typename T, precision P>
tmat2x3<T, P> const operator- (
tmat2x3<T, P> const operator- (
tmat2x3<T, P> const & m);
template <typename T, precision P>
tmat2x3<T, P> const operator-- (
tmat2x3<T, P> const & m,
int);
template <typename T, precision P>
tmat2x3<T, P> const operator++ (
tmat2x3<T, P> const & m,
int);
}//namespace detail
}//namespace glm

View File

@ -374,7 +374,7 @@ namespace detail
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x3<T, P> & tmat2x3<T, P>::operator++ ()
GLM_FUNC_QUALIFIER tmat2x3<T, P> & tmat2x3<T, P>::operator++()
{
++this->value[0];
++this->value[1];
@ -382,13 +382,29 @@ namespace detail
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x3<T, P> & tmat2x3<T, P>::operator-- ()
GLM_FUNC_QUALIFIER tmat2x3<T, P> & tmat2x3<T, P>::operator--()
{
--this->value[0];
--this->value[1];
return *this;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x3<T, P> tmat2x3<T, P>::operator++(int)
{
tmat2x3<T, P> Result(*this);
++*this;
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x3<T, P> tmat2x3<T, P>::operator--(int)
{
tmat2x3<T, P> Result(*this);
--*this;
return Result;
}
//////////////////////////////////////////////////////////////
// Binary operators
@ -595,30 +611,6 @@ namespace detail
-m[1]);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x3<T, P> const operator++
(
tmat2x3<T, P> const & m,
int
)
{
return tmat2x3<T, P>(
m[0] + typename tmat2x3<T, P>::value_type(1),
m[1] + typename tmat2x3<T, P>::value_type(1));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x3<T, P> const operator--
(
tmat2x3<T, P> const & m,
int
)
{
return tmat2x3<T, P>(
m[0] - typename tmat2x3<T, P>::value_type(1),
m[1] - typename tmat2x3<T, P>::value_type(1));
}
//////////////////////////////////////
// Boolean operators

View File

@ -126,8 +126,13 @@ namespace detail
template <typename U>
GLM_FUNC_DECL tmat2x4<T, P>& operator/= (U const & s);
GLM_FUNC_DECL tmat2x4<T, P>& operator++ ();
GLM_FUNC_DECL tmat2x4<T, P>& operator-- ();
//////////////////////////////////////
// Increment and decrement operators
GLM_FUNC_DECL tmat2x4<T, P> & operator++ ();
GLM_FUNC_DECL tmat2x4<T, P> & operator-- ();
GLM_FUNC_DECL tmat2x4<T, P> operator++(int);
GLM_FUNC_DECL tmat2x4<T, P> operator--(int);
};
// Binary operators
@ -201,16 +206,6 @@ namespace detail
tmat2x4<T, P> const operator- (
tmat2x4<T, P> const & m);
template <typename T, precision P>
tmat2x4<T, P> const operator-- (
tmat2x4<T, P> const & m,
int);
template <typename T, precision P>
tmat2x4<T, P> const operator++ (
tmat2x4<T, P> const & m,
int);
}//namespace detail
}//namespace glm

View File

@ -377,7 +377,7 @@ namespace detail
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x4<T, P>& tmat2x4<T, P>::operator++ ()
GLM_FUNC_QUALIFIER tmat2x4<T, P>& tmat2x4<T, P>::operator++()
{
++this->value[0];
++this->value[1];
@ -385,13 +385,29 @@ namespace detail
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x4<T, P>& tmat2x4<T, P>::operator-- ()
GLM_FUNC_QUALIFIER tmat2x4<T, P>& tmat2x4<T, P>::operator--()
{
--this->value[0];
--this->value[1];
return *this;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x4<T, P> tmat2x4<T, P>::operator++(int)
{
tmat2x4<T, P> Result(*this);
++*this;
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x4<T, P> tmat2x4<T, P>::operator--(int)
{
tmat2x4<T, P> Result(*this);
--*this;
return Result;
}
//////////////////////////////////////////////////////////////
// Binary operators
@ -614,30 +630,6 @@ namespace detail
-m[1]);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x4<T, P> const operator++
(
tmat2x4<T, P> const & m,
int
)
{
return tmat2x4<T, P>(
m[0] + typename tmat2x4<T, P>::value_type(1),
m[1] + typename tmat2x4<T, P>::value_type(1));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x4<T, P> const operator--
(
tmat2x4<T, P> const & m,
int
)
{
return tmat2x4<T, P>(
m[0] - typename tmat2x4<T, P>::value_type(1),
m[1] - typename tmat2x4<T, P>::value_type(1));
}
//////////////////////////////////////
// Boolean operators

View File

@ -132,8 +132,13 @@ namespace detail
template <typename U>
GLM_FUNC_DECL tmat3x2<T, P> & operator/= (U const & s);
//////////////////////////////////////
// Increment and decrement operators
GLM_FUNC_DECL tmat3x2<T, P> & operator++ ();
GLM_FUNC_DECL tmat3x2<T, P> & operator-- ();
GLM_FUNC_DECL tmat3x2<T, P> operator++(int);
GLM_FUNC_DECL tmat3x2<T, P> operator--(int);
};
// Binary operators
@ -204,18 +209,9 @@ namespace detail
// Unary constant operators
template <typename T, precision P>
tmat3x2<T, P> const operator- (
tmat3x2<T, P> const operator-(
tmat3x2<T, P> const & m);
template <typename T, precision P>
tmat3x2<T, P> const operator-- (
tmat3x2<T, P> const & m,
int);
template <typename T, precision P>
tmat3x2<T, P> const operator++ (
tmat3x2<T, P> const & m,
int);
}//namespace detail
}//namespace glm

View File

@ -421,6 +421,22 @@ namespace detail
return *this;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x2<T, P> tmat3x2<T, P>::operator++(int)
{
tmat3x2<T, P> Result(*this);
++*this;
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x2<T, P> tmat3x2<T, P>::operator--(int)
{
tmat3x2<T, P> Result(*this);
--*this;
return Result;
}
//////////////////////////////////////////////////////////////
// Binary operators
@ -627,34 +643,6 @@ namespace detail
-m[2]);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x2<T, P> const operator++
(
tmat3x2<T, P> const & m,
int
)
{
typename tmat3x2<T, P>::value_type One(1);
return tmat3x2<T, P>(
m[0] + One,
m[1] + One,
m[2] + One);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x2<T, P> const operator--
(
tmat3x2<T, P> const & m,
int
)
{
typename tmat3x2<T, P>::value_type One(1);
return tmat3x2<T, P>(
m[0] - One,
m[1] - One,
m[2] - One);
}
//////////////////////////////////////
// Boolean operators

View File

@ -139,8 +139,14 @@ namespace detail
GLM_FUNC_DECL tmat3x3<T, P>& operator/= (U const & s);
template <typename U>
GLM_FUNC_DECL tmat3x3<T, P>& operator/= (tmat3x3<U, P> const & m);
GLM_FUNC_DECL tmat3x3<T, P>& operator++ ();
GLM_FUNC_DECL tmat3x3<T, P>& operator-- ();
//////////////////////////////////////
// Increment and decrement operators
GLM_FUNC_DECL tmat3x3<T, P> & operator++ ();
GLM_FUNC_DECL tmat3x3<T, P> & operator-- ();
GLM_FUNC_DECL tmat3x3<T, P> operator++(int);
GLM_FUNC_DECL tmat3x3<T, P> operator--(int);
};
// Binary operators
@ -236,18 +242,9 @@ namespace detail
// Unary constant operators
template <typename T, precision P>
tmat3x3<T, P> const operator- (
tmat3x3<T, P> const operator-(
tmat3x3<T, P> const & m);
template <typename T, precision P>
tmat3x3<T, P> const operator-- (
tmat3x3<T, P> const & m,
int);
template <typename T, precision P>
tmat3x3<T, P> const operator++ (
tmat3x3<T, P> const & m,
int);
}//namespace detail
}//namespace glm

View File

@ -426,7 +426,7 @@ namespace detail
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P> & tmat3x3<T, P>::operator-- ()
GLM_FUNC_QUALIFIER tmat3x3<T, P> & tmat3x3<T, P>::operator--()
{
--this->value[0];
--this->value[1];
@ -434,6 +434,22 @@ namespace detail
return *this;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P> tmat3x3<T, P>::operator++(int)
{
tmat3x3<T, P> Result(*this);
++*this;
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P> tmat3x3<T, P>::operator--(int)
{
tmat3x3<T, P> Result(*this);
--*this;
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P> tmat3x3<T, P>::_inverse() const
{
@ -759,32 +775,6 @@ namespace detail
-m[2]);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P> const operator++
(
tmat3x3<T, P> const & m,
int
)
{
return tmat3x3<T, P>(
m[0] + T(1),
m[1] + T(1),
m[2] + T(1));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P> const operator--
(
tmat3x3<T, P> const & m,
int
)
{
return tmat3x3<T, P>(
m[0] - T(1),
m[1] - T(1),
m[2] - T(1));
}
//////////////////////////////////////
// Boolean operators

View File

@ -132,8 +132,13 @@ namespace detail
template <typename U>
GLM_FUNC_DECL tmat3x4<T, P> & operator/= (U const & s);
//////////////////////////////////////
// Increment and decrement operators
GLM_FUNC_DECL tmat3x4<T, P> & operator++ ();
GLM_FUNC_DECL tmat3x4<T, P> & operator-- ();
GLM_FUNC_DECL tmat3x4<T, P> operator++(int);
GLM_FUNC_DECL tmat3x4<T, P> operator--(int);
};
// Binary operators
@ -204,19 +209,9 @@ namespace detail
// Unary constant operators
template <typename T, precision P>
tmat3x4<T, P> const operator- (
tmat3x4<T, P> const operator-(
tmat3x4<T, P> const & m);
template <typename T, precision P>
tmat3x4<T, P> const operator-- (
tmat3x4<T, P> const & m,
int);
template <typename T, precision P>
tmat3x4<T, P> const operator++ (
tmat3x4<T, P> const & m,
int);
}//namespace detail
}//namespace glm

View File

@ -420,6 +420,22 @@ namespace detail
return *this;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x4<T, P> tmat3x4<T, P>::operator++(int)
{
tmat3x4<T, P> Result(*this);
++*this;
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x4<T, P> tmat3x4<T, P>::operator--(int)
{
tmat3x4<T, P> Result(*this);
--*this;
return Result;
}
//////////////////////////////////////////////////////////////
// Binary operators
@ -660,32 +676,6 @@ namespace detail
-m[2]);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x4<T, P> const operator++
(
tmat3x4<T, P> const & m,
int
)
{
return tmat3x4<T, P>(
m[0] + T(1),
m[1] + T(1),
m[2] + T(1));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x4<T, P> const operator--
(
tmat3x4<T, P> const & m,
int
)
{
return tmat3x4<T, P>(
m[0] - T(1),
m[1] - T(1),
m[2] - T(1));
}
//////////////////////////////////////
// Boolean operators

View File

@ -137,8 +137,13 @@ namespace detail
template <typename U>
GLM_FUNC_DECL tmat4x2<T, P>& operator/= (U const & s);
GLM_FUNC_DECL tmat4x2<T, P>& operator++ ();
GLM_FUNC_DECL tmat4x2<T, P>& operator-- ();
//////////////////////////////////////
// Increment and decrement operators
GLM_FUNC_DECL tmat4x2<T, P> & operator++ ();
GLM_FUNC_DECL tmat4x2<T, P> & operator-- ();
GLM_FUNC_DECL tmat4x2<T, P> operator++(int);
GLM_FUNC_DECL tmat4x2<T, P> operator--(int);
};
// Binary operators
@ -209,18 +214,9 @@ namespace detail
// Unary constant operators
template <typename T, precision P>
tmat4x2<T, P> const operator- (
tmat4x2<T, P> const operator-(
tmat4x2<T, P> const & m);
template <typename T, precision P>
tmat4x2<T, P> const operator-- (
tmat4x2<T, P> const & m,
int);
template <typename T, precision P>
tmat4x2<T, P> const operator++ (
tmat4x2<T, P> const & m,
int);
}//namespace detail
}//namespace glm

View File

@ -454,6 +454,22 @@ namespace detail
return *this;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x2<T, P> tmat4x2<T, P>::operator++(int)
{
tmat4x2<T, P> Result(*this);
++*this;
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x2<T, P> tmat4x2<T, P>::operator--(int)
{
tmat4x2<T, P> Result(*this);
--*this;
return Result;
}
//////////////////////////////////////////////////////////////
// Binary operators
@ -676,34 +692,6 @@ namespace detail
-m[3]);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x2<T, P> const operator++
(
tmat4x2<T, P> const & m,
int
)
{
return tmat4x2<T, P>(
m[0] + typename tmat4x2<T, P>::value_type(1),
m[1] + typename tmat4x2<T, P>::value_type(1),
m[2] + typename tmat4x2<T, P>::value_type(1),
m[3] + typename tmat4x2<T, P>::value_type(1));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x2<T, P> const operator--
(
tmat4x2<T, P> const & m,
int
)
{
return tmat4x2<T, P>(
m[0] - typename tmat4x2<T, P>::value_type(1),
m[1] - typename tmat4x2<T, P>::value_type(1),
m[2] - typename tmat4x2<T, P>::value_type(1),
m[3] - typename tmat4x2<T, P>::value_type(1));
}
//////////////////////////////////////
// Boolean operators

View File

@ -135,8 +135,13 @@ namespace detail
template <typename U>
GLM_FUNC_DECL tmat4x3<T, P> & operator/= (U const & s);
//////////////////////////////////////
// Increment and decrement operators
GLM_FUNC_DECL tmat4x3<T, P> & operator++ ();
GLM_FUNC_DECL tmat4x3<T, P> & operator-- ();
GLM_FUNC_DECL tmat4x3<T, P> operator++(int);
GLM_FUNC_DECL tmat4x3<T, P> operator--(int);
};
// Binary operators
@ -210,15 +215,6 @@ namespace detail
tmat4x3<T, P> const operator- (
tmat4x3<T, P> const & m);
template <typename T, precision P>
tmat4x3<T, P> const operator-- (
tmat4x3<T, P> const & m,
int);
template <typename T, precision P>
tmat4x3<T, P> const operator++ (
tmat4x3<T, P> const & m,
int);
}//namespace detail
}//namespace glm

View File

@ -710,6 +710,22 @@ namespace detail
m[3] - T(1));
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x3<T, P> tmat4x3<T, P>::operator++(int)
{
tmat4x3<T, P> Result(*this);
++*this;
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x3<T, P> tmat4x3<T, P>::operator--(int)
{
tmat4x3<T, P> Result(*this);
--*this;
return Result;
}
//////////////////////////////////////
// Boolean operators

View File

@ -142,8 +142,14 @@ namespace detail
GLM_FUNC_DECL tmat4x4<T, P> & operator/= (U const & s);
template <typename U>
GLM_FUNC_DECL tmat4x4<T, P> & operator/= (tmat4x4<U, P> const & m);
//////////////////////////////////////
// Increment and decrement operators
GLM_FUNC_DECL tmat4x4<T, P> & operator++ ();
GLM_FUNC_DECL tmat4x4<T, P> & operator-- ();
GLM_FUNC_DECL tmat4x4<T, P> operator++(int);
GLM_FUNC_DECL tmat4x4<T, P> operator--(int);
};
// Binary operators
@ -242,14 +248,6 @@ namespace detail
tmat4x4<T, P> const operator- (
tmat4x4<T, P> const & m);
template <typename T, precision P>
tmat4x4<T, P> const operator-- (
tmat4x4<T, P> const & m, int);
template <typename T, precision P>
tmat4x4<T, P> const operator++ (
tmat4x4<T, P> const & m, int);
}//namespace detail
}//namespace glm

View File

@ -496,6 +496,22 @@ namespace detail
return *this;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x4<T, P> tmat4x4<T, P>::operator++(int)
{
tmat4x4<T, P> Result(*this);
++*this;
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x4<T, P> tmat4x4<T, P>::operator--(int)
{
tmat4x4<T, P> Result(*this);
--*this;
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x4<T, P> tmat4x4<T, P>::_inverse() const
{

View File

@ -349,7 +349,7 @@ int test_mat4x4_col_get()
glm::vec4 D = glm::column(m, 3);
Error += D == glm::vec4(0, 0, 0, 1) ? 0 : 1;
return Error;
return Error;
}
int main()