From 1709e9abcabb5c1a2655cd85f27cee13d8f0aa3b Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Sat, 17 Oct 2015 04:11:52 +0200 Subject: [PATCH] Added unary + operator #435 --- glm/detail/type_mat2x2.hpp | 5 ++++- glm/detail/type_mat2x2.inl | 8 +++++++- glm/detail/type_mat2x3.hpp | 5 ++++- glm/detail/type_mat2x3.inl | 8 +++++++- glm/detail/type_mat2x4.hpp | 5 ++++- glm/detail/type_mat2x4.inl | 8 +++++++- glm/detail/type_mat3x2.hpp | 5 ++++- glm/detail/type_mat3x2.inl | 8 +++++++- glm/detail/type_mat3x3.hpp | 5 ++++- glm/detail/type_mat3x3.inl | 8 +++++++- glm/detail/type_mat3x4.hpp | 5 ++++- glm/detail/type_mat3x4.inl | 8 +++++++- glm/detail/type_mat4x2.hpp | 5 ++++- glm/detail/type_mat4x2.inl | 8 +++++++- glm/detail/type_mat4x3.hpp | 5 ++++- glm/detail/type_mat4x3.inl | 8 +++++++- glm/detail/type_mat4x4.hpp | 5 ++++- glm/detail/type_mat4x4.inl | 8 +++++++- glm/detail/type_vec1.hpp | 3 +++ glm/detail/type_vec1.inl | 6 ++++++ glm/detail/type_vec2.hpp | 3 +++ glm/detail/type_vec2.inl | 6 ++++++ glm/detail/type_vec3.hpp | 3 +++ glm/detail/type_vec3.inl | 6 ++++++ glm/detail/type_vec4.hpp | 3 +++ glm/detail/type_vec4.inl | 6 ++++++ glm/gtc/quaternion.hpp | 3 +++ glm/gtc/quaternion.inl | 6 ++++++ glm/gtx/dual_quaternion.hpp | 5 ++++- glm/gtx/dual_quaternion.inl | 2 +- readme.md | 1 + 31 files changed, 150 insertions(+), 20 deletions(-) diff --git a/glm/detail/type_mat2x2.hpp b/glm/detail/type_mat2x2.hpp index aa0c81d7..9761adfe 100644 --- a/glm/detail/type_mat2x2.hpp +++ b/glm/detail/type_mat2x2.hpp @@ -157,7 +157,10 @@ namespace glm // -- Unary operators -- template - GLM_FUNC_DECL tmat2x2 const operator-(tmat2x2 const & m); + GLM_FUNC_DECL tmat2x2 operator+(tmat2x2 const & m); + + template + GLM_FUNC_DECL tmat2x2 operator-(tmat2x2 const & m); // -- Binary operators -- diff --git a/glm/detail/type_mat2x2.inl b/glm/detail/type_mat2x2.inl index 202839f4..960fee57 100644 --- a/glm/detail/type_mat2x2.inl +++ b/glm/detail/type_mat2x2.inl @@ -367,7 +367,13 @@ namespace detail // -- Unary arithmetic operators -- template - GLM_FUNC_QUALIFIER tmat2x2 const operator-(tmat2x2 const & m) + GLM_FUNC_QUALIFIER tmat2x2 operator+(tmat2x2 const & m) + { + return m; + } + + template + GLM_FUNC_QUALIFIER tmat2x2 operator-(tmat2x2 const & m) { return tmat2x2( -m[0], diff --git a/glm/detail/type_mat2x3.hpp b/glm/detail/type_mat2x3.hpp index 4cacc46c..eeb69ad2 100644 --- a/glm/detail/type_mat2x3.hpp +++ b/glm/detail/type_mat2x3.hpp @@ -149,7 +149,10 @@ namespace glm // -- Unary operators -- template - GLM_FUNC_DECL tmat2x3 const operator-(tmat2x3 const & m); + GLM_FUNC_DECL tmat2x3 operator+(tmat2x3 const & m); + + template + GLM_FUNC_DECL tmat2x3 operator-(tmat2x3 const & m); // -- Binary operators -- diff --git a/glm/detail/type_mat2x3.inl b/glm/detail/type_mat2x3.inl index 267f0c0c..76c00f50 100644 --- a/glm/detail/type_mat2x3.inl +++ b/glm/detail/type_mat2x3.inl @@ -337,7 +337,13 @@ namespace glm // -- Unary arithmetic operators -- template - GLM_FUNC_QUALIFIER tmat2x3 const operator-(tmat2x3 const & m) + GLM_FUNC_QUALIFIER tmat2x3 operator+(tmat2x3 const & m) + { + return m; + } + + template + GLM_FUNC_QUALIFIER tmat2x3 operator-(tmat2x3 const & m) { return tmat2x3( -m[0], diff --git a/glm/detail/type_mat2x4.hpp b/glm/detail/type_mat2x4.hpp index d87ce074..8e3c616a 100644 --- a/glm/detail/type_mat2x4.hpp +++ b/glm/detail/type_mat2x4.hpp @@ -151,7 +151,10 @@ namespace glm // -- Unary operators -- template - GLM_FUNC_DECL tmat2x4 const operator-(tmat2x4 const & m); + GLM_FUNC_DECL tmat2x4 operator+(tmat2x4 const & m); + + template + GLM_FUNC_DECL tmat2x4 operator-(tmat2x4 const & m); // -- Binary operators -- diff --git a/glm/detail/type_mat2x4.inl b/glm/detail/type_mat2x4.inl index 766640e4..42299787 100644 --- a/glm/detail/type_mat2x4.inl +++ b/glm/detail/type_mat2x4.inl @@ -338,7 +338,13 @@ namespace glm // -- Unary arithmetic operators -- template - GLM_FUNC_QUALIFIER tmat2x4 const operator-(tmat2x4 const & m) + GLM_FUNC_QUALIFIER tmat2x4 operator+(tmat2x4 const & m) + { + return m; + } + + template + GLM_FUNC_QUALIFIER tmat2x4 operator-(tmat2x4 const & m) { return tmat2x4( -m[0], diff --git a/glm/detail/type_mat3x2.hpp b/glm/detail/type_mat3x2.hpp index ac2ea0d4..fedf8c9e 100644 --- a/glm/detail/type_mat3x2.hpp +++ b/glm/detail/type_mat3x2.hpp @@ -156,7 +156,10 @@ namespace glm // -- Unary operators -- template - GLM_FUNC_DECL tmat3x2 const operator-(tmat3x2 const & m); + GLM_FUNC_DECL tmat3x2 operator+(tmat3x2 const & m); + + template + GLM_FUNC_DECL tmat3x2 operator-(tmat3x2 const & m); // -- Binary operators -- diff --git a/glm/detail/type_mat3x2.inl b/glm/detail/type_mat3x2.inl index d112a054..f497e395 100644 --- a/glm/detail/type_mat3x2.inl +++ b/glm/detail/type_mat3x2.inl @@ -376,8 +376,14 @@ namespace glm // -- Unary arithmetic operators -- + template + GLM_FUNC_QUALIFIER tmat3x2 operator+(tmat3x2 const & m) + { + return m; + } + template - GLM_FUNC_QUALIFIER tmat3x2 const operator-(tmat3x2 const & m) + GLM_FUNC_QUALIFIER tmat3x2 operator-(tmat3x2 const & m) { return tmat3x2( -m[0], diff --git a/glm/detail/type_mat3x3.hpp b/glm/detail/type_mat3x3.hpp index 7b0945ac..e7e2e6de 100644 --- a/glm/detail/type_mat3x3.hpp +++ b/glm/detail/type_mat3x3.hpp @@ -164,7 +164,10 @@ namespace glm // -- Unary operators -- template - GLM_FUNC_DECL tmat3x3 const operator-(tmat3x3 const & m); + GLM_FUNC_DECL tmat3x3 operator+(tmat3x3 const & m); + + template + GLM_FUNC_DECL tmat3x3 operator-(tmat3x3 const & m); // -- Binary operators -- diff --git a/glm/detail/type_mat3x3.inl b/glm/detail/type_mat3x3.inl index 6f936036..9ee0111e 100644 --- a/glm/detail/type_mat3x3.inl +++ b/glm/detail/type_mat3x3.inl @@ -415,7 +415,13 @@ namespace detail // -- Unary arithmetic operators -- template - GLM_FUNC_QUALIFIER tmat3x3 const operator-(tmat3x3 const & m) + GLM_FUNC_QUALIFIER tmat3x3 operator+(tmat3x3 const & m) + { + return m; + } + + template + GLM_FUNC_QUALIFIER tmat3x3 operator-(tmat3x3 const & m) { return tmat3x3( -m[0], diff --git a/glm/detail/type_mat3x4.hpp b/glm/detail/type_mat3x4.hpp index 8f59f2ad..11261589 100644 --- a/glm/detail/type_mat3x4.hpp +++ b/glm/detail/type_mat3x4.hpp @@ -156,7 +156,10 @@ namespace glm // -- Unary operators -- template - GLM_FUNC_DECL tmat3x4 const operator-(tmat3x4 const & m); + GLM_FUNC_DECL tmat3x4 operator+(tmat3x4 const & m); + + template + GLM_FUNC_DECL tmat3x4 operator-(tmat3x4 const & m); // -- Binary operators -- diff --git a/glm/detail/type_mat3x4.inl b/glm/detail/type_mat3x4.inl index 8862df47..3991d95d 100644 --- a/glm/detail/type_mat3x4.inl +++ b/glm/detail/type_mat3x4.inl @@ -377,7 +377,13 @@ namespace glm // -- Unary arithmetic operators -- template - GLM_FUNC_QUALIFIER tmat3x4 const operator-(tmat3x4 const & m) + GLM_FUNC_QUALIFIER tmat3x4 operator+(tmat3x4 const & m) + { + return m; + } + + template + GLM_FUNC_QUALIFIER tmat3x4 operator-(tmat3x4 const & m) { return tmat3x4( -m[0], diff --git a/glm/detail/type_mat4x2.hpp b/glm/detail/type_mat4x2.hpp index 65666d5c..62cd7aed 100644 --- a/glm/detail/type_mat4x2.hpp +++ b/glm/detail/type_mat4x2.hpp @@ -161,7 +161,10 @@ namespace glm // -- Unary operators -- template - GLM_FUNC_DECL tmat4x2 const operator-(tmat4x2 const & m); + GLM_FUNC_DECL tmat4x2 operator+(tmat4x2 const & m); + + template + GLM_FUNC_DECL tmat4x2 operator-(tmat4x2 const & m); // -- Binary operators -- diff --git a/glm/detail/type_mat4x2.inl b/glm/detail/type_mat4x2.inl index d012b884..811f4622 100644 --- a/glm/detail/type_mat4x2.inl +++ b/glm/detail/type_mat4x2.inl @@ -409,7 +409,13 @@ namespace glm // -- Unary arithmetic operators -- template - GLM_FUNC_QUALIFIER tmat4x2 const operator-(tmat4x2 const & m) + GLM_FUNC_QUALIFIER tmat4x2 operator+(tmat4x2 const & m) + { + return m; + } + + template + GLM_FUNC_QUALIFIER tmat4x2 operator-(tmat4x2 const & m) { return tmat4x2( -m[0], diff --git a/glm/detail/type_mat4x3.hpp b/glm/detail/type_mat4x3.hpp index 55c0b516..eea24667 100644 --- a/glm/detail/type_mat4x3.hpp +++ b/glm/detail/type_mat4x3.hpp @@ -161,7 +161,10 @@ namespace glm // -- Unary operators -- template - GLM_FUNC_DECL tmat4x3 const operator-(tmat4x3 const & m); + GLM_FUNC_DECL tmat4x3 operator+(tmat4x3 const & m); + + template + GLM_FUNC_DECL tmat4x3 operator-(tmat4x3 const & m); // -- Binary operators -- diff --git a/glm/detail/type_mat4x3.inl b/glm/detail/type_mat4x3.inl index e7368619..c2979782 100644 --- a/glm/detail/type_mat4x3.inl +++ b/glm/detail/type_mat4x3.inl @@ -409,7 +409,13 @@ namespace glm // -- Unary arithmetic operators -- template - GLM_FUNC_QUALIFIER tmat4x3 const operator-(tmat4x3 const & m) + GLM_FUNC_QUALIFIER tmat4x3 operator+(tmat4x3 const & m) + { + return m; + } + + template + GLM_FUNC_QUALIFIER tmat4x3 operator-(tmat4x3 const & m) { return tmat4x3( -m[0], diff --git a/glm/detail/type_mat4x4.hpp b/glm/detail/type_mat4x4.hpp index 5d36b490..1690bf1d 100644 --- a/glm/detail/type_mat4x4.hpp +++ b/glm/detail/type_mat4x4.hpp @@ -169,7 +169,10 @@ namespace glm // -- Unary operators -- template - GLM_FUNC_DECL tmat4x4 const operator-(tmat4x4 const & m); + GLM_FUNC_DECL tmat4x4 operator+(tmat4x4 const & m); + + template + GLM_FUNC_DECL tmat4x4 operator-(tmat4x4 const & m); // -- Binary operators -- diff --git a/glm/detail/type_mat4x4.inl b/glm/detail/type_mat4x4.inl index c075122b..319325a7 100644 --- a/glm/detail/type_mat4x4.inl +++ b/glm/detail/type_mat4x4.inl @@ -515,7 +515,13 @@ namespace detail // -- Unary constant operators -- template - GLM_FUNC_QUALIFIER tmat4x4 const operator-(tmat4x4 const & m) + GLM_FUNC_QUALIFIER tmat4x4 operator+(tmat4x4 const & m) + { + return m; + } + + template + GLM_FUNC_QUALIFIER tmat4x4 operator-(tmat4x4 const & m) { return tmat4x4( -m[0], diff --git a/glm/detail/type_vec1.hpp b/glm/detail/type_vec1.hpp index e18c8a3a..6c30a438 100644 --- a/glm/detail/type_vec1.hpp +++ b/glm/detail/type_vec1.hpp @@ -204,6 +204,9 @@ namespace glm // -- Unary operators -- + template + GLM_FUNC_DECL tvec1 operator+(tvec1 const & v); + template GLM_FUNC_DECL tvec1 operator-(tvec1 const & v); diff --git a/glm/detail/type_vec1.inl b/glm/detail/type_vec1.inl index 39485782..effac06f 100644 --- a/glm/detail/type_vec1.inl +++ b/glm/detail/type_vec1.inl @@ -352,6 +352,12 @@ namespace glm // -- Unary constant operators -- + template + GLM_FUNC_QUALIFIER tvec1 operator+(tvec1 const & v) + { + return v; + } + template GLM_FUNC_QUALIFIER tvec1 operator-(tvec1 const & v) { diff --git a/glm/detail/type_vec2.hpp b/glm/detail/type_vec2.hpp index 2f78c67e..76029f49 100644 --- a/glm/detail/type_vec2.hpp +++ b/glm/detail/type_vec2.hpp @@ -230,6 +230,9 @@ namespace glm // -- Unary operators -- + template + GLM_FUNC_DECL tvec2 operator+(tvec2 const & v); + template GLM_FUNC_DECL tvec2 operator-(tvec2 const & v); diff --git a/glm/detail/type_vec2.inl b/glm/detail/type_vec2.inl index 39d0549e..b8cb1ff8 100644 --- a/glm/detail/type_vec2.inl +++ b/glm/detail/type_vec2.inl @@ -480,6 +480,12 @@ namespace glm // -- Unary arithmetic operators -- + template + GLM_FUNC_QUALIFIER tvec2 operator+(tvec2 const & v) + { + return v; + } + template GLM_FUNC_QUALIFIER tvec2 operator-(tvec2 const & v) { diff --git a/glm/detail/type_vec3.hpp b/glm/detail/type_vec3.hpp index 4b7fa1a6..f155b076 100644 --- a/glm/detail/type_vec3.hpp +++ b/glm/detail/type_vec3.hpp @@ -252,6 +252,9 @@ namespace glm // -- Unary operators -- + template + GLM_FUNC_DECL tvec3 operator+(tvec3 const & v); + template GLM_FUNC_DECL tvec3 operator-(tvec3 const & v); diff --git a/glm/detail/type_vec3.inl b/glm/detail/type_vec3.inl index 1e5081d4..fa8102c8 100644 --- a/glm/detail/type_vec3.inl +++ b/glm/detail/type_vec3.inl @@ -547,6 +547,12 @@ namespace glm // -- Unary arithmetic operators -- + template + GLM_FUNC_QUALIFIER tvec3 operator+(tvec3 const & v) + { + return v; + } + template GLM_FUNC_QUALIFIER tvec3 operator-(tvec3 const & v) { diff --git a/glm/detail/type_vec4.hpp b/glm/detail/type_vec4.hpp index ffe8066f..e9fe6c1d 100644 --- a/glm/detail/type_vec4.hpp +++ b/glm/detail/type_vec4.hpp @@ -351,6 +351,9 @@ namespace detail // -- Unary operators -- + template + GLM_FUNC_DECL tvec4 operator+(tvec4 const & v); + template GLM_FUNC_DECL tvec4 operator-(tvec4 const & v); diff --git a/glm/detail/type_vec4.inl b/glm/detail/type_vec4.inl index 80c75945..8e215d00 100644 --- a/glm/detail/type_vec4.inl +++ b/glm/detail/type_vec4.inl @@ -645,6 +645,12 @@ namespace glm // -- Unary constant operators -- + template + GLM_FUNC_QUALIFIER tvec4 operator+(tvec4 const & v) + { + return v; + } + template GLM_FUNC_QUALIFIER tvec4 operator-(tvec4 const & v) { diff --git a/glm/gtc/quaternion.hpp b/glm/gtc/quaternion.hpp index 71817dfa..6fae5cc6 100644 --- a/glm/gtc/quaternion.hpp +++ b/glm/gtc/quaternion.hpp @@ -149,6 +149,9 @@ namespace glm // -- Unary bit operators -- + template + GLM_FUNC_DECL tquat operator+(tquat const & q); + template GLM_FUNC_DECL tquat operator-(tquat const & q); diff --git a/glm/gtc/quaternion.inl b/glm/gtc/quaternion.inl index 4c8565bc..83a1b66f 100644 --- a/glm/gtc/quaternion.inl +++ b/glm/gtc/quaternion.inl @@ -296,6 +296,12 @@ namespace detail // -- Unary bit operators -- + template + GLM_FUNC_QUALIFIER tquat operator+(tquat const & q) + { + return q; + } + template GLM_FUNC_QUALIFIER tquat operator-(tquat const & q) { diff --git a/glm/gtx/dual_quaternion.hpp b/glm/gtx/dual_quaternion.hpp index 1c26b34d..0b083295 100644 --- a/glm/gtx/dual_quaternion.hpp +++ b/glm/gtx/dual_quaternion.hpp @@ -130,7 +130,10 @@ namespace glm // -- Unary bit operators -- template - GLM_FUNC_DECL tquat operator-(tquat const & q); + GLM_FUNC_DECL tdualquat operator+(tdualquat const & q); + + template + GLM_FUNC_DECL tdualquat operator-(tdualquat const & q); // -- Binary operators -- diff --git a/glm/gtx/dual_quaternion.inl b/glm/gtx/dual_quaternion.inl index c6b057f2..961dd1ca 100644 --- a/glm/gtx/dual_quaternion.inl +++ b/glm/gtx/dual_quaternion.inl @@ -196,7 +196,7 @@ namespace glm template GLM_FUNC_QUALIFIER tdualquat operator-(tdualquat const & q) { - return tdualquat(-q.real,-q.dual); + return q; } // -- Binary operators -- diff --git a/readme.md b/readme.md index b4c261d3..17134d10 100644 --- a/readme.md +++ b/readme.md @@ -61,6 +61,7 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate) - Fixed "Declaration shadows a field" warning #468 - Fixed 'GLM_COMPILER_VC2005 is not defined' warning #468 - Fixed various 'X is not defined' warnings #468 +- Fixed missing unary + operator #435 #### [GLM 0.9.7.1](https://github.com/g-truc/glm/releases/tag/0.9.7.1) - 2015-09-07 ##### Improvements: