Browse Source

- Added unary + operator #435

Christophe Riccio 10 years ago
parent
commit
32fc69ee11

+ 4 - 1
glm/detail/type_mat2x2.hpp

@@ -161,7 +161,10 @@ namespace glm
 	// -- Unary operators --
 	// -- Unary operators --
 
 
 	template <typename T, precision P>
 	template <typename T, precision P>
-	GLM_FUNC_DECL tmat2x2<T, P> const operator-(tmat2x2<T, P> const & m);
+	GLM_FUNC_DECL tmat2x2<T, P> operator+(tmat2x2<T, P> const & m);
+
+	template <typename T, precision P>
+	GLM_FUNC_DECL tmat2x2<T, P> operator-(tmat2x2<T, P> const & m);
 
 
 	// -- Binary operators --
 	// -- Binary operators --
 
 

+ 7 - 1
glm/detail/type_mat2x2.inl

@@ -374,7 +374,13 @@ namespace detail
 	// -- Unary arithmetic operators --
 	// -- Unary arithmetic operators --
 
 
 	template <typename T, precision P>
 	template <typename T, precision P>
-	GLM_FUNC_QUALIFIER tmat2x2<T, P> const operator-(tmat2x2<T, P> const & m)
+	GLM_FUNC_QUALIFIER tmat2x2<T, P> operator+(tmat2x2<T, P> const & m)
+	{
+		return m;
+	}
+
+	template <typename T, precision P>
+	GLM_FUNC_QUALIFIER tmat2x2<T, P> operator-(tmat2x2<T, P> const & m)
 	{
 	{
 		return tmat2x2<T, P>(
 		return tmat2x2<T, P>(
 			-m[0], 
 			-m[0], 

+ 4 - 1
glm/detail/type_mat2x3.hpp

@@ -154,7 +154,10 @@ namespace glm
 	// -- Unary operators --
 	// -- Unary operators --
 
 
 	template <typename T, precision P>
 	template <typename T, precision P>
-	GLM_FUNC_DECL tmat2x3<T, P> const operator-(tmat2x3<T, P> const & m);
+	GLM_FUNC_DECL tmat2x3<T, P> operator+(tmat2x3<T, P> const & m);
+
+	template <typename T, precision P>
+	GLM_FUNC_DECL tmat2x3<T, P> operator-(tmat2x3<T, P> const & m);
 
 
 	// -- Binary operators --
 	// -- Binary operators --
 
 

+ 7 - 1
glm/detail/type_mat2x3.inl

@@ -344,7 +344,13 @@ namespace glm
 	// -- Unary arithmetic operators --
 	// -- Unary arithmetic operators --
 
 
 	template <typename T, precision P>
 	template <typename T, precision P>
-	GLM_FUNC_QUALIFIER tmat2x3<T, P> const operator-(tmat2x3<T, P> const & m)
+	GLM_FUNC_QUALIFIER tmat2x3<T, P> operator+(tmat2x3<T, P> const & m)
+	{
+		return m;
+	}
+
+	template <typename T, precision P>
+	GLM_FUNC_QUALIFIER tmat2x3<T, P> operator-(tmat2x3<T, P> const & m)
 	{
 	{
 		return tmat2x3<T, P>(
 		return tmat2x3<T, P>(
 			-m[0],
 			-m[0],

+ 4 - 1
glm/detail/type_mat2x4.hpp

@@ -156,7 +156,10 @@ namespace glm
 	// -- Unary operators --
 	// -- Unary operators --
 
 
 	template <typename T, precision P>
 	template <typename T, precision P>
-	GLM_FUNC_DECL tmat2x4<T, P> const operator-(tmat2x4<T, P> const & m);
+	GLM_FUNC_DECL tmat2x4<T, P> operator+(tmat2x4<T, P> const & m);
+
+	template <typename T, precision P>
+	GLM_FUNC_DECL tmat2x4<T, P> operator-(tmat2x4<T, P> const & m);
 
 
 	// -- Binary operators --
 	// -- Binary operators --
 
 

+ 7 - 1
glm/detail/type_mat2x4.inl

@@ -345,7 +345,13 @@ namespace glm
 	// -- Unary arithmetic operators --
 	// -- Unary arithmetic operators --
 
 
 	template <typename T, precision P>
 	template <typename T, precision P>
-	GLM_FUNC_QUALIFIER tmat2x4<T, P> const operator-(tmat2x4<T, P> const & m)
+	GLM_FUNC_QUALIFIER tmat2x4<T, P> operator+(tmat2x4<T, P> const & m)
+	{
+		return m;
+	}
+
+	template <typename T, precision P>
+	GLM_FUNC_QUALIFIER tmat2x4<T, P> operator-(tmat2x4<T, P> const & m)
 	{
 	{
 		return tmat2x4<T, P>(
 		return tmat2x4<T, P>(
 			-m[0], 
 			-m[0], 

+ 4 - 1
glm/detail/type_mat3x2.hpp

@@ -161,7 +161,10 @@ namespace glm
 	// -- Unary operators --
 	// -- Unary operators --
 
 
 	template <typename T, precision P>
 	template <typename T, precision P>
-	GLM_FUNC_DECL tmat3x2<T, P> const operator-(tmat3x2<T, P> const & m);
+	GLM_FUNC_DECL tmat3x2<T, P> operator+(tmat3x2<T, P> const & m);
+
+	template <typename T, precision P>
+	GLM_FUNC_DECL tmat3x2<T, P> operator-(tmat3x2<T, P> const & m);
 
 
 	// -- Binary operators --
 	// -- Binary operators --
 
 

+ 7 - 1
glm/detail/type_mat3x2.inl

@@ -383,8 +383,14 @@ namespace glm
 
 
 	// -- Unary arithmetic operators --
 	// -- Unary arithmetic operators --
 
 
+	template <typename T, precision P>
+	GLM_FUNC_QUALIFIER tmat3x2<T, P> operator+(tmat3x2<T, P> const & m)
+	{
+		return m;
+	}
+
 	template <typename T, precision P> 
 	template <typename T, precision P> 
-	GLM_FUNC_QUALIFIER tmat3x2<T, P> const operator-(tmat3x2<T, P> const & m)
+	GLM_FUNC_QUALIFIER tmat3x2<T, P> operator-(tmat3x2<T, P> const & m)
 	{
 	{
 		return tmat3x2<T, P>(
 		return tmat3x2<T, P>(
 			-m[0],
 			-m[0],

+ 4 - 1
glm/detail/type_mat3x3.hpp

@@ -169,7 +169,10 @@ namespace glm
 	// -- Unary operators --
 	// -- Unary operators --
 
 
 	template <typename T, precision P>
 	template <typename T, precision P>
-	GLM_FUNC_DECL tmat3x3<T, P> const operator-(tmat3x3<T, P> const & m);
+	GLM_FUNC_DECL tmat3x3<T, P> operator+(tmat3x3<T, P> const & m);
+
+	template <typename T, precision P>
+	GLM_FUNC_DECL tmat3x3<T, P> operator-(tmat3x3<T, P> const & m);
 
 
 	// -- Binary operators --
 	// -- Binary operators --
 
 

+ 7 - 1
glm/detail/type_mat3x3.inl

@@ -423,7 +423,13 @@ namespace detail
 	// -- Unary arithmetic operators --
 	// -- Unary arithmetic operators --
 
 
 	template <typename T, precision P>
 	template <typename T, precision P>
-	GLM_FUNC_QUALIFIER tmat3x3<T, P> const operator-(tmat3x3<T, P> const & m)
+	GLM_FUNC_QUALIFIER tmat3x3<T, P> operator+(tmat3x3<T, P> const & m)
+	{
+		return m;
+	}
+
+	template <typename T, precision P>
+	GLM_FUNC_QUALIFIER tmat3x3<T, P> operator-(tmat3x3<T, P> const & m)
 	{
 	{
 		return tmat3x3<T, P>(
 		return tmat3x3<T, P>(
 			-m[0], 
 			-m[0], 

+ 4 - 1
glm/detail/type_mat3x4.hpp

@@ -161,7 +161,10 @@ namespace glm
 	// -- Unary operators --
 	// -- Unary operators --
 
 
 	template <typename T, precision P>
 	template <typename T, precision P>
-	GLM_FUNC_DECL tmat3x4<T, P> const operator-(tmat3x4<T, P> const & m);
+	GLM_FUNC_DECL tmat3x4<T, P> operator+(tmat3x4<T, P> const & m);
+
+	template <typename T, precision P>
+	GLM_FUNC_DECL tmat3x4<T, P> operator-(tmat3x4<T, P> const & m);
 
 
 	// -- Binary operators --
 	// -- Binary operators --
 
 

+ 7 - 1
glm/detail/type_mat3x4.inl

@@ -384,7 +384,13 @@ namespace glm
 	// -- Unary arithmetic operators --
 	// -- Unary arithmetic operators --
 
 
 	template <typename T, precision P>
 	template <typename T, precision P>
-	GLM_FUNC_QUALIFIER tmat3x4<T, P> const operator-(tmat3x4<T, P> const & m)
+	GLM_FUNC_QUALIFIER tmat3x4<T, P> operator+(tmat3x4<T, P> const & m)
+	{
+		return m;
+	}
+
+	template <typename T, precision P>
+	GLM_FUNC_QUALIFIER tmat3x4<T, P> operator-(tmat3x4<T, P> const & m)
 	{
 	{
 		return tmat3x4<T, P>(
 		return tmat3x4<T, P>(
 			-m[0],
 			-m[0],

+ 4 - 1
glm/detail/type_mat4x2.hpp

@@ -166,7 +166,10 @@ namespace glm
 	// -- Unary operators --
 	// -- Unary operators --
 
 
 	template <typename T, precision P>
 	template <typename T, precision P>
-	GLM_FUNC_DECL tmat4x2<T, P> const operator-(tmat4x2<T, P> const & m);
+	GLM_FUNC_DECL tmat4x2<T, P> operator+(tmat4x2<T, P> const & m);
+
+	template <typename T, precision P>
+	GLM_FUNC_DECL tmat4x2<T, P> operator-(tmat4x2<T, P> const & m);
 
 
 	// -- Binary operators --
 	// -- Binary operators --
 
 

+ 7 - 1
glm/detail/type_mat4x2.inl

@@ -416,7 +416,13 @@ namespace glm
 	// -- Unary arithmetic operators --
 	// -- Unary arithmetic operators --
 
 
 	template <typename T, precision P>
 	template <typename T, precision P>
-	GLM_FUNC_QUALIFIER tmat4x2<T, P> const operator-(tmat4x2<T, P> const & m)
+	GLM_FUNC_QUALIFIER tmat4x2<T, P> operator+(tmat4x2<T, P> const & m)
+	{
+		return m;
+	}
+
+	template <typename T, precision P>
+	GLM_FUNC_QUALIFIER tmat4x2<T, P> operator-(tmat4x2<T, P> const & m)
 	{
 	{
 		return tmat4x2<T, P>(
 		return tmat4x2<T, P>(
 			-m[0],
 			-m[0],

+ 4 - 1
glm/detail/type_mat4x3.hpp

@@ -166,7 +166,10 @@ namespace glm
 	// -- Unary operators --
 	// -- Unary operators --
 
 
 	template <typename T, precision P>
 	template <typename T, precision P>
-	GLM_FUNC_DECL tmat4x3<T, P> const operator-(tmat4x3<T, P> const & m);
+	GLM_FUNC_DECL tmat4x3<T, P> operator+(tmat4x3<T, P> const & m);
+
+	template <typename T, precision P>
+	GLM_FUNC_DECL tmat4x3<T, P> operator-(tmat4x3<T, P> const & m);
 
 
 	// -- Binary operators --
 	// -- Binary operators --
 
 

+ 7 - 1
glm/detail/type_mat4x3.inl

@@ -416,7 +416,13 @@ namespace glm
 	// -- Unary arithmetic operators --
 	// -- Unary arithmetic operators --
 
 
 	template <typename T, precision P>
 	template <typename T, precision P>
-	GLM_FUNC_QUALIFIER tmat4x3<T, P> const operator-(tmat4x3<T, P> const & m)
+	GLM_FUNC_QUALIFIER tmat4x3<T, P> operator+(tmat4x3<T, P> const & m)
+	{
+		return m;
+	}
+
+	template <typename T, precision P>
+	GLM_FUNC_QUALIFIER tmat4x3<T, P> operator-(tmat4x3<T, P> const & m)
 	{
 	{
 		return tmat4x3<T, P>(
 		return tmat4x3<T, P>(
 			-m[0],
 			-m[0],

+ 4 - 1
glm/detail/type_mat4x4.hpp

@@ -174,7 +174,10 @@ namespace glm
 	// -- Unary operators --
 	// -- Unary operators --
 
 
 	template <typename T, precision P>
 	template <typename T, precision P>
-	GLM_FUNC_DECL tmat4x4<T, P> const operator-(tmat4x4<T, P> const & m);
+	GLM_FUNC_DECL tmat4x4<T, P> operator+(tmat4x4<T, P> const & m);
+
+	template <typename T, precision P>
+	GLM_FUNC_DECL tmat4x4<T, P> operator-(tmat4x4<T, P> const & m);
 
 
 	// -- Binary operators --
 	// -- Binary operators --
 
 

+ 7 - 1
glm/detail/type_mat4x4.inl

@@ -522,7 +522,13 @@ namespace detail
 	// -- Unary constant operators --
 	// -- Unary constant operators --
 
 
 	template <typename T, precision P>
 	template <typename T, precision P>
-	GLM_FUNC_QUALIFIER tmat4x4<T, P> const operator-(tmat4x4<T, P> const & m)
+	GLM_FUNC_QUALIFIER tmat4x4<T, P> operator+(tmat4x4<T, P> const & m)
+	{
+		return m;
+	}
+
+	template <typename T, precision P>
+	GLM_FUNC_QUALIFIER tmat4x4<T, P> operator-(tmat4x4<T, P> const & m)
 	{
 	{
 		return tmat4x4<T, P>(
 		return tmat4x4<T, P>(
 			-m[0],
 			-m[0],

+ 3 - 0
glm/detail/type_vec1.hpp

@@ -208,6 +208,9 @@ namespace glm
 
 
 	// -- Unary operators --
 	// -- Unary operators --
 
 
+	template <typename T, precision P>
+	GLM_FUNC_DECL tvec1<T, P> operator+(tvec1<T, P> const & v);
+
 	template <typename T, precision P>
 	template <typename T, precision P>
 	GLM_FUNC_DECL tvec1<T, P> operator-(tvec1<T, P> const & v);
 	GLM_FUNC_DECL tvec1<T, P> operator-(tvec1<T, P> const & v);
 
 

+ 6 - 0
glm/detail/type_vec1.inl

@@ -359,6 +359,12 @@ namespace glm
 
 
 	// -- Unary constant operators --
 	// -- Unary constant operators --
 
 
+	template <typename T, precision P>
+	GLM_FUNC_QUALIFIER tvec1<T, P> operator+(tvec1<T, P> const & v)
+	{
+		return v;
+	}
+
 	template <typename T, precision P>
 	template <typename T, precision P>
 	GLM_FUNC_QUALIFIER tvec1<T, P> operator-(tvec1<T, P> const & v)
 	GLM_FUNC_QUALIFIER tvec1<T, P> operator-(tvec1<T, P> const & v)
 	{
 	{

+ 3 - 0
glm/detail/type_vec2.hpp

@@ -237,6 +237,9 @@ namespace glm
 
 
 	// -- Unary operators --
 	// -- Unary operators --
 
 
+	template <typename T, precision P>
+	GLM_FUNC_DECL tvec2<T, P> operator+(tvec2<T, P> const & v);
+
 	template <typename T, precision P>
 	template <typename T, precision P>
 	GLM_FUNC_DECL tvec2<T, P> operator-(tvec2<T, P> const & v);
 	GLM_FUNC_DECL tvec2<T, P> operator-(tvec2<T, P> const & v);
 
 

+ 6 - 0
glm/detail/type_vec2.inl

@@ -493,6 +493,12 @@ namespace glm
 
 
 	// -- Unary arithmetic operators --
 	// -- Unary arithmetic operators --
 
 
+	template <typename T, precision P>
+	GLM_FUNC_QUALIFIER tvec2<T, P> operator+(tvec2<T, P> const & v)
+	{
+		return v;
+	}
+
 	template <typename T, precision P>
 	template <typename T, precision P>
 	GLM_FUNC_QUALIFIER tvec2<T, P> operator-(tvec2<T, P> const & v)
 	GLM_FUNC_QUALIFIER tvec2<T, P> operator-(tvec2<T, P> const & v)
 	{
 	{

+ 3 - 0
glm/detail/type_vec3.hpp

@@ -263,6 +263,9 @@ namespace glm
 
 
 	// -- Unary operators --
 	// -- Unary operators --
 
 
+	template <typename T, precision P>
+	GLM_FUNC_DECL tvec3<T, P> operator+(tvec3<T, P> const & v);
+
 	template <typename T, precision P>
 	template <typename T, precision P>
 	GLM_FUNC_DECL tvec3<T, P> operator-(tvec3<T, P> const & v);
 	GLM_FUNC_DECL tvec3<T, P> operator-(tvec3<T, P> const & v);
 
 

+ 6 - 0
glm/detail/type_vec3.inl

@@ -573,6 +573,12 @@ namespace glm
 
 
 	// -- Unary arithmetic operators --
 	// -- Unary arithmetic operators --
 
 
+	template <typename T, precision P>
+	GLM_FUNC_QUALIFIER tvec3<T, P> operator+(tvec3<T, P> const & v)
+	{
+		return v;
+	}
+
 	template <typename T, precision P>
 	template <typename T, precision P>
 	GLM_FUNC_QUALIFIER tvec3<T, P> operator-(tvec3<T, P> const & v)
 	GLM_FUNC_QUALIFIER tvec3<T, P> operator-(tvec3<T, P> const & v)
 	{
 	{

+ 3 - 0
glm/detail/type_vec4.hpp

@@ -370,6 +370,9 @@ namespace detail
 
 
 	// -- Unary operators --
 	// -- Unary operators --
 
 
+	template <typename T, precision P>
+	GLM_FUNC_DECL tvec4<T, P> operator+(tvec4<T, P> const & v);
+
 	template <typename T, precision P>
 	template <typename T, precision P>
 	GLM_FUNC_DECL tvec4<T, P> operator-(tvec4<T, P> const & v);
 	GLM_FUNC_DECL tvec4<T, P> operator-(tvec4<T, P> const & v);
 
 

+ 6 - 0
glm/detail/type_vec4.inl

@@ -711,6 +711,12 @@ namespace glm
 
 
 	// -- Unary constant operators --
 	// -- Unary constant operators --
 
 
+	template <typename T, precision P>
+	GLM_FUNC_QUALIFIER tvec4<T, P> operator+(tvec4<T, P> const & v)
+	{
+		return v;
+	}
+
 	template <typename T, precision P>
 	template <typename T, precision P>
 	GLM_FUNC_QUALIFIER tvec4<T, P> operator-(tvec4<T, P> const & v)
 	GLM_FUNC_QUALIFIER tvec4<T, P> operator-(tvec4<T, P> const & v)
 	{
 	{

+ 3 - 0
glm/gtc/quaternion.hpp

@@ -169,6 +169,9 @@ namespace glm
 
 
 	// -- Unary bit operators --
 	// -- Unary bit operators --
 
 
+	template <typename T, precision P>
+	GLM_FUNC_DECL tquat<T, P> operator+(tquat<T, P> const & q);
+
 	template <typename T, precision P>
 	template <typename T, precision P>
 	GLM_FUNC_DECL tquat<T, P> operator-(tquat<T, P> const & q);
 	GLM_FUNC_DECL tquat<T, P> operator-(tquat<T, P> const & q);
 
 

+ 6 - 0
glm/gtc/quaternion.inl

@@ -363,6 +363,12 @@ namespace detail
 
 
 	// -- Unary bit operators --
 	// -- Unary bit operators --
 
 
+	template <typename T, precision P>
+	GLM_FUNC_QUALIFIER tquat<T, P> operator+(tquat<T, P> const & q)
+	{
+		return q;
+	}
+
 	template <typename T, precision P>
 	template <typename T, precision P>
 	GLM_FUNC_QUALIFIER tquat<T, P> operator-(tquat<T, P> const & q)
 	GLM_FUNC_QUALIFIER tquat<T, P> operator-(tquat<T, P> const & q)
 	{
 	{

+ 4 - 1
glm/gtx/dual_quaternion.hpp

@@ -130,7 +130,10 @@ namespace glm
 	// -- Unary bit operators --
 	// -- Unary bit operators --
 
 
 	template <typename T, precision P>
 	template <typename T, precision P>
-	GLM_FUNC_DECL tquat<T, P> operator-(tquat<T, P> const & q);
+	GLM_FUNC_DECL tdualquat<T, P> operator+(tdualquat<T, P> const & q);
+
+	template <typename T, precision P>
+	GLM_FUNC_DECL tdualquat<T, P> operator-(tdualquat<T, P> const & q);
 
 
 	// -- Binary operators --
 	// -- Binary operators --
 
 

+ 1 - 1
glm/gtx/dual_quaternion.inl

@@ -196,7 +196,7 @@ namespace glm
 	template <typename T, precision P>
 	template <typename T, precision P>
 	GLM_FUNC_QUALIFIER tdualquat<T, P> operator-(tdualquat<T, P> const & q)
 	GLM_FUNC_QUALIFIER tdualquat<T, P> operator-(tdualquat<T, P> const & q)
 	{
 	{
-		return tdualquat<T, P>(-q.real,-q.dual);
+		return q;
 	}
 	}
 
 
 	// -- Binary operators --
 	// -- Binary operators --

+ 1 - 0
readme.md

@@ -64,6 +64,7 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate)
 ##### Improvements:
 ##### Improvements:
 - Improved GTC_random linearRand documentation
 - Improved GTC_random linearRand documentation
 - Improved GTC_reciprocal documentation
 - Improved GTC_reciprocal documentation
+- Added unary + operator #435
 
 
 ##### Fixes:
 ##### Fixes:
 - Fixed GTX_extended_min_max filename typo #386
 - Fixed GTX_extended_min_max filename typo #386