From a257beb5de12c66df5ce154da69d69c89441afdf Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Thu, 15 Oct 2015 04:28:08 +0200 Subject: [PATCH 1/6] Added missing bvec* && and || operators --- glm/detail/type_vec1.hpp | 6 ++++++ glm/detail/type_vec1.inl | 12 ++++++++++++ glm/detail/type_vec2.hpp | 6 ++++++ glm/detail/type_vec2.inl | 12 ++++++++++++ glm/detail/type_vec3.hpp | 6 ++++++ glm/detail/type_vec3.inl | 12 ++++++++++++ glm/detail/type_vec4.hpp | 6 ++++++ glm/detail/type_vec4.inl | 12 ++++++++++++ readme.md | 1 + test/core/core_type_vec4.cpp | 21 +++++++++++++++++++++ test/gtc/gtc_packing.cpp | 1 + 11 files changed, 95 insertions(+) diff --git a/glm/detail/type_vec1.hpp b/glm/detail/type_vec1.hpp index f59e1c96..4da5cd93 100644 --- a/glm/detail/type_vec1.hpp +++ b/glm/detail/type_vec1.hpp @@ -314,6 +314,12 @@ namespace glm template GLM_FUNC_DECL bool operator!=(tvec1 const & v1, tvec1 const & v2); + template + GLM_FUNC_DECL bool operator&&(tvec1 const & v1, tvec1 const & v2); + + template + GLM_FUNC_DECL bool operator||(tvec1 const & v1, tvec1 const & v2); + // -- Is type -- template diff --git a/glm/detail/type_vec1.inl b/glm/detail/type_vec1.inl index 0da79982..dde1e0de 100644 --- a/glm/detail/type_vec1.inl +++ b/glm/detail/type_vec1.inl @@ -601,4 +601,16 @@ namespace glm { return (v1.x != v2.x); } + + template + GLM_FUNC_QUALIFIER tvec1 operator&&(tvec1 const & v1, tvec1 const & v2) + { + return tvec1(v1.x && v2.x); + } + + template + GLM_FUNC_QUALIFIER tvec1 operator||(tvec1 const & v1, tvec1 const & v2) + { + return tvec1(v1.x || v2.x); + } }//namespace glm diff --git a/glm/detail/type_vec2.hpp b/glm/detail/type_vec2.hpp index ddd45564..196cff85 100644 --- a/glm/detail/type_vec2.hpp +++ b/glm/detail/type_vec2.hpp @@ -406,6 +406,12 @@ namespace glm template GLM_FUNC_DECL bool operator!=(tvec2 const & v1, tvec2 const & v2); + template + GLM_FUNC_DECL bool operator&&(tvec2 const & v1, tvec2 const & v2); + + template + GLM_FUNC_DECL bool operator||(tvec2 const & v1, tvec2 const & v2); + // -- Is type -- template diff --git a/glm/detail/type_vec2.inl b/glm/detail/type_vec2.inl index 1bcaf772..6a8153e6 100644 --- a/glm/detail/type_vec2.inl +++ b/glm/detail/type_vec2.inl @@ -926,4 +926,16 @@ namespace glm { return (v1.x != v2.x) || (v1.y != v2.y); } + + template + GLM_FUNC_QUALIFIER tvec2 operator&&(tvec2 const & v1, tvec2 const & v2) + { + return tvec2(v1.x && v2.x, v1.y && v2.y); + } + + template + GLM_FUNC_QUALIFIER tvec2 operator||(tvec2 const & v1, tvec2 const & v2) + { + return tvec2(v1.x || v2.x, v1.y || v2.y); + } }//namespace glm diff --git a/glm/detail/type_vec3.hpp b/glm/detail/type_vec3.hpp index d08b7c29..18ffb44d 100644 --- a/glm/detail/type_vec3.hpp +++ b/glm/detail/type_vec3.hpp @@ -429,6 +429,12 @@ namespace glm template GLM_FUNC_DECL bool operator!=(tvec3 const & v1, tvec3 const & v2); + template + GLM_FUNC_DECL bool operator&&(tvec3 const & v1, tvec3 const & v2); + + template + GLM_FUNC_DECL bool operator||(tvec3 const & v1, tvec3 const & v2); + // -- Is type -- template diff --git a/glm/detail/type_vec3.inl b/glm/detail/type_vec3.inl index f231a682..629214c4 100644 --- a/glm/detail/type_vec3.inl +++ b/glm/detail/type_vec3.inl @@ -1058,4 +1058,16 @@ namespace glm { return (v1.x != v2.x) || (v1.y != v2.y) || (v1.z != v2.z); } + + template + GLM_FUNC_QUALIFIER tvec3 operator&&(tvec3 const & v1, tvec3 const & v2) + { + return tvec3(v1.x && v2.x, v1.y && v2.y, v1.z && v2.z); + } + + template + GLM_FUNC_QUALIFIER tvec3 operator||(tvec3 const & v1, tvec3 const & v2) + { + return tvec3(v1.x || v2.x, v1.y || v2.y, v1.z || v2.z); + } }//namespace glm diff --git a/glm/detail/type_vec4.hpp b/glm/detail/type_vec4.hpp index 489ef6f8..7589acfd 100644 --- a/glm/detail/type_vec4.hpp +++ b/glm/detail/type_vec4.hpp @@ -542,6 +542,12 @@ namespace detail template GLM_FUNC_DECL bool operator!=(tvec4 const & v1, tvec4 const & v2); + template + GLM_FUNC_DECL bool operator&&(tvec4 const & v1, tvec4 const & v2); + + template + GLM_FUNC_DECL bool operator||(tvec4 const & v1, tvec4 const & v2); + // -- Is type -- template diff --git a/glm/detail/type_vec4.inl b/glm/detail/type_vec4.inl index 23b8c8b3..eaaa4fc3 100644 --- a/glm/detail/type_vec4.inl +++ b/glm/detail/type_vec4.inl @@ -1168,6 +1168,18 @@ namespace glm { return (v1.x != v2.x) || (v1.y != v2.y) || (v1.z != v2.z) || (v1.w != v2.w); } + + template + GLM_FUNC_QUALIFIER tvec4 operator&&(tvec4 const & v1, tvec4 const & v2) + { + return tvec4(v1.x && v2.x, v1.y && v2.y, v1.z && v2.z, v1.w && v2.w); + } + + template + GLM_FUNC_QUALIFIER tvec4 operator||(tvec4 const & v1, tvec4 const & v2) + { + return tvec4(v1.x || v2.x, v1.y || v2.y, v1.z || v2.z, v1.w || v2.w); + } }//namespace glm #if GLM_HAS_ANONYMOUS_UNION && GLM_NOT_BUGGY_VC32BITS diff --git a/readme.md b/readme.md index 67b4566f..6d769eda 100644 --- a/readme.md +++ b/readme.md @@ -59,6 +59,7 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate) - Added (un)packUnorm and (un)packSnorm to GTC_packing - Added 16bit pack and unpack to GTC_packing - Added 8bit pack and unpack to GTC_packing +- Added missing bvec* && and || operators ##### Improvements: - Improved GTC_random linearRand documentation diff --git a/test/core/core_type_vec4.cpp b/test/core/core_type_vec4.cpp index 5c48eccd..143fbb99 100644 --- a/test/core/core_type_vec4.cpp +++ b/test/core/core_type_vec4.cpp @@ -159,6 +159,26 @@ int test_vec4_ctor() return Error; } +int test_bvec4_ctor() +{ + int Error = 0; + + glm::bvec4 const A(true); + glm::bvec4 const B(true); + glm::bvec4 const C(false); + glm::bvec4 const D = A && B; + glm::bvec4 const E = A && C; + glm::bvec4 const F = A || C; + bool const G = A == C; + bool const H = A != C; + + Error += D == glm::bvec4(true) ? 0 : 1; + Error += E == glm::bvec4(false) ? 0 : 1; + Error += F == glm::bvec4(true) ? 0 : 1; + + return Error; +} + int test_vec4_operators() { int Error = 0; @@ -511,6 +531,7 @@ int main() Error += test_vec4_static_const(); Error += test_vec4_ctor(); + Error += test_bvec4_ctor(); Error += test_vec4_size(); Error += test_vec4_operators(); Error += test_vec4_swizzle_partial(); diff --git a/test/gtc/gtc_packing.cpp b/test/gtc/gtc_packing.cpp index 2f7a1c3e..dff652a0 100644 --- a/test/gtc/gtc_packing.cpp +++ b/test/gtc/gtc_packing.cpp @@ -438,6 +438,7 @@ int test_packSnorm1x8() std::vector A; A.push_back(glm::vec1( 1.0f)); A.push_back(glm::vec1(-0.7f)); + A.push_back(glm::vec1(-1.0f)); for(std::size_t i = 0; i < A.size(); ++i) { From 5cd49977e6d18770c74bb89fc7615a56a175b483 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Thu, 15 Oct 2015 04:38:26 +0200 Subject: [PATCH 2/6] Fixed build --- glm/detail/type_vec1.hpp | 4 ++-- glm/detail/type_vec2.hpp | 4 ++-- glm/detail/type_vec3.hpp | 4 ++-- glm/detail/type_vec4.hpp | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/glm/detail/type_vec1.hpp b/glm/detail/type_vec1.hpp index 4da5cd93..5f4c0012 100644 --- a/glm/detail/type_vec1.hpp +++ b/glm/detail/type_vec1.hpp @@ -315,10 +315,10 @@ namespace glm GLM_FUNC_DECL bool operator!=(tvec1 const & v1, tvec1 const & v2); template - GLM_FUNC_DECL bool operator&&(tvec1 const & v1, tvec1 const & v2); + GLM_FUNC_DECL tvec1 operator&&(tvec1 const & v1, tvec1 const & v2); template - GLM_FUNC_DECL bool operator||(tvec1 const & v1, tvec1 const & v2); + GLM_FUNC_DECL tvec1 operator||(tvec1 const & v1, tvec1 const & v2); // -- Is type -- diff --git a/glm/detail/type_vec2.hpp b/glm/detail/type_vec2.hpp index 196cff85..73b9b82d 100644 --- a/glm/detail/type_vec2.hpp +++ b/glm/detail/type_vec2.hpp @@ -407,10 +407,10 @@ namespace glm GLM_FUNC_DECL bool operator!=(tvec2 const & v1, tvec2 const & v2); template - GLM_FUNC_DECL bool operator&&(tvec2 const & v1, tvec2 const & v2); + GLM_FUNC_DECL tvec2 operator&&(tvec2 const & v1, tvec2 const & v2); template - GLM_FUNC_DECL bool operator||(tvec2 const & v1, tvec2 const & v2); + GLM_FUNC_DECL tvec2 operator||(tvec2 const & v1, tvec2 const & v2); // -- Is type -- diff --git a/glm/detail/type_vec3.hpp b/glm/detail/type_vec3.hpp index 18ffb44d..594a7980 100644 --- a/glm/detail/type_vec3.hpp +++ b/glm/detail/type_vec3.hpp @@ -430,10 +430,10 @@ namespace glm GLM_FUNC_DECL bool operator!=(tvec3 const & v1, tvec3 const & v2); template - GLM_FUNC_DECL bool operator&&(tvec3 const & v1, tvec3 const & v2); + GLM_FUNC_DECL tvec3 operator&&(tvec3 const & v1, tvec3 const & v2); template - GLM_FUNC_DECL bool operator||(tvec3 const & v1, tvec3 const & v2); + GLM_FUNC_DECL tvec3 operator||(tvec3 const & v1, tvec3 const & v2); // -- Is type -- diff --git a/glm/detail/type_vec4.hpp b/glm/detail/type_vec4.hpp index 7589acfd..2c95cc76 100644 --- a/glm/detail/type_vec4.hpp +++ b/glm/detail/type_vec4.hpp @@ -543,10 +543,10 @@ namespace detail GLM_FUNC_DECL bool operator!=(tvec4 const & v1, tvec4 const & v2); template - GLM_FUNC_DECL bool operator&&(tvec4 const & v1, tvec4 const & v2); + GLM_FUNC_DECL tvec4 operator&&(tvec4 const & v1, tvec4 const & v2); template - GLM_FUNC_DECL bool operator||(tvec4 const & v1, tvec4 const & v2); + GLM_FUNC_DECL tvec4 operator||(tvec4 const & v1, tvec4 const & v2); // -- Is type -- From 32fc69ee11e83a9366e4bd187d6f955b8ba66585 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Sat, 17 Oct 2015 04:11:52 +0200 Subject: [PATCH 3/6] - 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 78faf314..9df68720 100644 --- a/glm/detail/type_mat2x2.hpp +++ b/glm/detail/type_mat2x2.hpp @@ -161,7 +161,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 b7f09d7d..3f215e3f 100644 --- a/glm/detail/type_mat2x2.inl +++ b/glm/detail/type_mat2x2.inl @@ -374,7 +374,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 0477c0f9..493548f4 100644 --- a/glm/detail/type_mat2x3.hpp +++ b/glm/detail/type_mat2x3.hpp @@ -154,7 +154,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 23018c19..e7cabb72 100644 --- a/glm/detail/type_mat2x3.inl +++ b/glm/detail/type_mat2x3.inl @@ -344,7 +344,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 36840f12..e15714ca 100644 --- a/glm/detail/type_mat2x4.hpp +++ b/glm/detail/type_mat2x4.hpp @@ -156,7 +156,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 ebb9170c..4399e0be 100644 --- a/glm/detail/type_mat2x4.inl +++ b/glm/detail/type_mat2x4.inl @@ -345,7 +345,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 06549837..63e0a659 100644 --- a/glm/detail/type_mat3x2.hpp +++ b/glm/detail/type_mat3x2.hpp @@ -161,7 +161,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 7e3ff4be..24079cfe 100644 --- a/glm/detail/type_mat3x2.inl +++ b/glm/detail/type_mat3x2.inl @@ -383,8 +383,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 4ef3708d..799d645d 100644 --- a/glm/detail/type_mat3x3.hpp +++ b/glm/detail/type_mat3x3.hpp @@ -169,7 +169,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 ec6f3eb6..c3b07108 100644 --- a/glm/detail/type_mat3x3.inl +++ b/glm/detail/type_mat3x3.inl @@ -423,7 +423,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 f9c7b908..7453673b 100644 --- a/glm/detail/type_mat3x4.hpp +++ b/glm/detail/type_mat3x4.hpp @@ -161,7 +161,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 16ff84d3..dd1f0563 100644 --- a/glm/detail/type_mat3x4.inl +++ b/glm/detail/type_mat3x4.inl @@ -384,7 +384,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 b3c27261..8cb7d70e 100644 --- a/glm/detail/type_mat4x2.hpp +++ b/glm/detail/type_mat4x2.hpp @@ -166,7 +166,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 187b4579..2040d4a6 100644 --- a/glm/detail/type_mat4x2.inl +++ b/glm/detail/type_mat4x2.inl @@ -416,7 +416,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 7a870a86..0a5de95b 100644 --- a/glm/detail/type_mat4x3.hpp +++ b/glm/detail/type_mat4x3.hpp @@ -166,7 +166,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 da76cdcc..58eeb6f9 100644 --- a/glm/detail/type_mat4x3.inl +++ b/glm/detail/type_mat4x3.inl @@ -416,7 +416,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 fa585e5b..a90a5978 100644 --- a/glm/detail/type_mat4x4.hpp +++ b/glm/detail/type_mat4x4.hpp @@ -174,7 +174,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 1d463836..acfa318c 100644 --- a/glm/detail/type_mat4x4.inl +++ b/glm/detail/type_mat4x4.inl @@ -522,7 +522,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 5f4c0012..833468d8 100644 --- a/glm/detail/type_vec1.hpp +++ b/glm/detail/type_vec1.hpp @@ -208,6 +208,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 dde1e0de..9d397d64 100644 --- a/glm/detail/type_vec1.inl +++ b/glm/detail/type_vec1.inl @@ -359,6 +359,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 73b9b82d..1d857ac7 100644 --- a/glm/detail/type_vec2.hpp +++ b/glm/detail/type_vec2.hpp @@ -237,6 +237,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 6a8153e6..dfb3a33a 100644 --- a/glm/detail/type_vec2.inl +++ b/glm/detail/type_vec2.inl @@ -493,6 +493,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 594a7980..d4d8ff6a 100644 --- a/glm/detail/type_vec3.hpp +++ b/glm/detail/type_vec3.hpp @@ -263,6 +263,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 629214c4..38104a3a 100644 --- a/glm/detail/type_vec3.inl +++ b/glm/detail/type_vec3.inl @@ -573,6 +573,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 2c95cc76..f26350c6 100644 --- a/glm/detail/type_vec4.hpp +++ b/glm/detail/type_vec4.hpp @@ -370,6 +370,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 eaaa4fc3..a650e494 100644 --- a/glm/detail/type_vec4.inl +++ b/glm/detail/type_vec4.inl @@ -711,6 +711,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 f5711c64..daf9cc19 100644 --- a/glm/gtc/quaternion.hpp +++ b/glm/gtc/quaternion.hpp @@ -169,6 +169,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 4ee7f802..e5fe5505 100644 --- a/glm/gtc/quaternion.inl +++ b/glm/gtc/quaternion.inl @@ -363,6 +363,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 02786f47..c62fcda4 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 6d769eda..f4d601fb 100644 --- a/readme.md +++ b/readme.md @@ -64,6 +64,7 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate) ##### Improvements: - Improved GTC_random linearRand documentation - Improved GTC_reciprocal documentation +- Added unary + operator #435 ##### Fixes: - Fixed GTX_extended_min_max filename typo #386 From 85e88a366dfb54c620fd7d86df71192c619243f7 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Thu, 22 Oct 2015 00:27:10 +0200 Subject: [PATCH 4/6] Cygwin GCC doesn't have a C++11 STL library --- glm/detail/setup.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/glm/detail/setup.hpp b/glm/detail/setup.hpp index ebbdd45d..bec53614 100644 --- a/glm/detail/setup.hpp +++ b/glm/detail/setup.hpp @@ -65,6 +65,8 @@ #ifdef GLM_FORCE_PLATFORM_UNKNOWN # define GLM_PLATFORM GLM_PLATFORM_UNKNOWN +#elif defined(__CYGWIN__) +# define GLM_PLATFORM GLM_PLATFORM_CYGWIN #elif defined(__QNXNTO__) # define GLM_PLATFORM GLM_PLATFORM_QNXNTO #elif defined(__APPLE__) @@ -650,7 +652,7 @@ // http://gcc.gnu.org/projects/cxx0x.html // http://msdn.microsoft.com/en-us/library/vstudio/hh567368(v=vs.120).aspx -#if GLM_PLATFORM == GLM_PLATFORM_ANDROID +#if GLM_PLATFORM == GLM_PLATFORM_ANDROID || GLM_PLATFORM == GLM_PLATFORM_CYGWIN # define GLM_HAS_CXX11_STL 0 #elif GLM_COMPILER & (GLM_COMPILER_LLVM | GLM_COMPILER_APPLE_CLANG) # if __has_include(<__config>) // libc++ From f1e9c2f186ef8787c33a7645d16028d7c809ea89 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Thu, 22 Oct 2015 00:30:27 +0200 Subject: [PATCH 5/6] Fixed Cygwin build errors when using C++11 #405 --- readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.md b/readme.md index 8097856f..929b9ee8 100644 --- a/readme.md +++ b/readme.md @@ -56,6 +56,7 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate) - Fixed GTC_round floorMultiple/ceilMultiple #412 - Fixed GTC_packing unpackUnorm3x10_1x2 #414 - Fixed GTC_matrix_inverse affineInverse #192 +- Fixed Cygwin build errors when using C++11 #405 #### [GLM 0.9.7.1](https://github.com/g-truc/glm/releases/tag/0.9.7.1) - 2015-09-07 ##### Improvements: From 627d36fd4781774bf4f68651cb95b0934573d90a Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Thu, 22 Oct 2015 00:31:15 +0200 Subject: [PATCH 6/6] Updated GLM version --- glm/detail/setup.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/glm/detail/setup.hpp b/glm/detail/setup.hpp index bec53614..7a4a36b3 100644 --- a/glm/detail/setup.hpp +++ b/glm/detail/setup.hpp @@ -42,11 +42,11 @@ #define GLM_VERSION_MAJOR 0 #define GLM_VERSION_MINOR 9 #define GLM_VERSION_PATCH 7 -#define GLM_VERSION_REVISION 1 +#define GLM_VERSION_REVISION 2 #if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_VERSION_DISPLAYED)) # define GLM_MESSAGE_VERSION_DISPLAYED -# pragma message ("GLM: version 0.9.7.1") +# pragma message ("GLM: version 0.9.7.2") #endif//GLM_MESSAGE ///////////////////////////////////////////////////////////////////////////////////