From 8a1bf4410b1dad073eaed028e804f32b9682bfdc Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Wed, 15 Oct 2014 02:53:46 +0200 Subject: [PATCH] Completed GTC_vec1 --- glm/detail/type_vec1.hpp | 11 + glm/detail/type_vec2.hpp | 32 +- glm/detail/type_vec2.inl | 12 +- glm/detail/type_vec3.hpp | 101 ++--- glm/detail/type_vec3.inl | 670 ++++++++++++++++++------------- glm/detail/type_vec4.hpp | 142 +++++-- glm/detail/type_vec4.inl | 735 ++++++++++++++++++++--------------- readme.txt | 2 +- test/core/core_type_vec1.cpp | 77 +++- test/core/core_type_vec2.cpp | 7 +- 10 files changed, 1092 insertions(+), 697 deletions(-) diff --git a/glm/detail/type_vec1.hpp b/glm/detail/type_vec1.hpp index 50f15515..696ce788 100644 --- a/glm/detail/type_vec1.hpp +++ b/glm/detail/type_vec1.hpp @@ -130,6 +130,17 @@ namespace glm template GLM_FUNC_DECL explicit tvec1(tvec4 const & v); + ////////////////////////////////////// + // Swizzle constructors + +# if(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)) + template + GLM_FUNC_DECL tvec1(detail::_swizzle<1, T, P, tvec1, E0, -1,-2,-3> const & that) + { + *this = that(); + } +# endif//(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)) + ////////////////////////////////////// // Unary arithmetic operators diff --git a/glm/detail/type_vec2.hpp b/glm/detail/type_vec2.hpp index 3585cdeb..8b1b6211 100644 --- a/glm/detail/type_vec2.hpp +++ b/glm/detail/type_vec2.hpp @@ -117,25 +117,14 @@ namespace glm GLM_FUNC_DECL explicit tvec2(T const & s); GLM_FUNC_DECL tvec2(T const & s1, T const & s2); - ////////////////////////////////////// - // Swizzle constructors - -# if(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)) - template - GLM_FUNC_DECL tvec2(detail::_swizzle<2, T, P, tvec2, E0, E1,-1,-2> const & that) - { - *this = that(); - } -# endif//(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)) - ////////////////////////////////////// // Conversion constructors - //! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) - template - GLM_FUNC_DECL tvec2(U const & x, V const & y); - template - GLM_FUNC_DECL tvec2(tvec1 const & v1, tvec1 const & v2); + /// Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + template + GLM_FUNC_DECL tvec2(A const & x, B const & y); + template + GLM_FUNC_DECL tvec2(tvec1 const & v1, tvec1 const & v2); ////////////////////////////////////// // Conversion vector constructors @@ -150,6 +139,17 @@ namespace glm template GLM_FUNC_DECL explicit tvec2(tvec4 const & v); + ////////////////////////////////////// + // Swizzle constructors + +# if GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE) + template + GLM_FUNC_DECL tvec2(detail::_swizzle<2, T, P, tvec2, E0, E1,-1,-2> const & that) + { + *this = that(); + } +# endif// GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE) + ////////////////////////////////////// // Unary arithmetic operators diff --git a/glm/detail/type_vec2.inl b/glm/detail/type_vec2.inl index 1ba2e269..c02a5c3f 100644 --- a/glm/detail/type_vec2.inl +++ b/glm/detail/type_vec2.inl @@ -104,17 +104,17 @@ namespace glm // Conversion scalar constructors template - template - GLM_FUNC_QUALIFIER tvec2::tvec2(U const & a, V const & b) : + template + GLM_FUNC_QUALIFIER tvec2::tvec2(A const & a, B const & b) : x(static_cast(a)), y(static_cast(b)) {} template - template - GLM_FUNC_QUALIFIER tvec2::tvec2(tvec1 const & v1, tvec1 const & v2) : - x(v1.x), - y(v2.x) + template + GLM_FUNC_QUALIFIER tvec2::tvec2(tvec1 const & a, tvec1 const & b) : + x(a.x), + y(b.x) {} ////////////////////////////////////// diff --git a/glm/detail/type_vec3.hpp b/glm/detail/type_vec3.hpp index bac192ce..04064a96 100644 --- a/glm/detail/type_vec3.hpp +++ b/glm/detail/type_vec3.hpp @@ -111,10 +111,48 @@ namespace glm template GLM_FUNC_DECL tvec3(tvec3 const & v); + ////////////////////////////////////// + // Explicit basic constructors + + GLM_FUNC_DECL explicit tvec3(ctor); + GLM_FUNC_DECL explicit tvec3(T const & s); + GLM_FUNC_DECL tvec3(T const & a, T const & b, T const & c); + + ////////////////////////////////////// + // Conversion scalar constructors + + /// Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + template + GLM_FUNC_DECL tvec3(A const & a, B const & b, C const & c); + template + GLM_FUNC_DECL tvec3(tvec1 const & a, tvec1 const & b, tvec1 const & c); + + ////////////////////////////////////// + // Conversion vector constructors + + //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + template + GLM_FUNC_DECL explicit tvec3(tvec2 const & a, B const & b); + //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + template + GLM_FUNC_DECL explicit tvec3(tvec2 const & a, tvec1 const & b); + //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + template + GLM_FUNC_DECL explicit tvec3(A const & a, tvec2 const & b); + //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + template + GLM_FUNC_DECL explicit tvec3(tvec1 const & a, tvec2 const & b); + //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + template + GLM_FUNC_DECL explicit tvec3(tvec3 const & v); + //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + template + GLM_FUNC_DECL explicit tvec3(tvec4 const & v); + ////////////////////////////////////// // Swizzle constructors -# if(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)) +# if GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE) template GLM_FUNC_DECL tvec3(detail::_swizzle<3, T, P, tvec3, E0, E1, E2, -1> const & that) { @@ -132,71 +170,38 @@ namespace glm { *this = tvec3(s, v()); } -# endif//(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)) - - ////////////////////////////////////// - // Explicit basic constructors - - GLM_FUNC_DECL explicit tvec3(ctor); - GLM_FUNC_DECL explicit tvec3(T const & s); - GLM_FUNC_DECL tvec3(T const & s1, T const & s2, T const & s3); - - ////////////////////////////////////// - // Conversion scalar constructors - - //! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) - template - GLM_FUNC_DECL tvec3( - U const & x, - V const & y, - W const & z); - - ////////////////////////////////////// - // Conversion vector constructors - - //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) - template - GLM_FUNC_DECL explicit tvec3(tvec2 const & v, B const & s); - //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) - template - GLM_FUNC_DECL explicit tvec3(A const & s, tvec2 const & v); - //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) - template - GLM_FUNC_DECL explicit tvec3(tvec3 const & v); - //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) - template - GLM_FUNC_DECL explicit tvec3(tvec4 const & v); +# endif// GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE) ////////////////////////////////////// // Unary arithmetic operators GLM_FUNC_DECL tvec3 & operator= (tvec3 const & v); - template + template GLM_FUNC_DECL tvec3 & operator= (tvec3 const & v); - template + template GLM_FUNC_DECL tvec3 & operator+=(U s); - template + template GLM_FUNC_DECL tvec3 & operator+=(tvec1 const & v); - template + template GLM_FUNC_DECL tvec3 & operator+=(tvec3 const & v); - template + template GLM_FUNC_DECL tvec3 & operator-=(U s); - template + template GLM_FUNC_DECL tvec3 & operator-=(tvec1 const & v); - template + template GLM_FUNC_DECL tvec3 & operator-=(tvec3 const & v); - template + template GLM_FUNC_DECL tvec3 & operator*=(U s); - template + template GLM_FUNC_DECL tvec3 & operator*=(tvec1 const & v); - template + template GLM_FUNC_DECL tvec3 & operator*=(tvec3 const & v); - template + template GLM_FUNC_DECL tvec3 & operator/=(U s); - template + template GLM_FUNC_DECL tvec3 & operator/=(tvec1 const & v); - template + template GLM_FUNC_DECL tvec3 & operator/=(tvec3 const & v); ////////////////////////////////////// diff --git a/glm/detail/type_vec3.inl b/glm/detail/type_vec3.inl index 4f357814..74bf891d 100644 --- a/glm/detail/type_vec3.inl +++ b/glm/detail/type_vec3.inl @@ -99,15 +99,10 @@ namespace glm {} template - GLM_FUNC_QUALIFIER tvec3::tvec3 - ( - T const & s0, - T const & s1, - T const & s2 - ) : - x(s0), - y(s1), - z(s2) + GLM_FUNC_QUALIFIER tvec3::tvec3(T const & a, T const & b, T const & c) : + x(a), + y(b), + z(c) {} ////////////////////////////////////// @@ -115,15 +110,18 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec3::tvec3 - ( - A const & x, - B const & y, - C const & z - ) : - x(static_cast(x)), - y(static_cast(y)), - z(static_cast(z)) + GLM_FUNC_QUALIFIER tvec3::tvec3(A const & a, B const & b, C const & c) : + x(static_cast(a)), + y(static_cast(b)), + z(static_cast(c)) + {} + + template + template + GLM_FUNC_QUALIFIER tvec3::tvec3(tvec1 const & a, tvec1 const & b, tvec1 const & c) : + x(static_cast(a)), + y(static_cast(b)), + z(static_cast(c)) {} ////////////////////////////////////// @@ -131,34 +129,39 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec3::tvec3 - ( - tvec2 const & v, - B const & s - ) : - x(static_cast(v.x)), - y(static_cast(v.y)), - z(static_cast(s)) + GLM_FUNC_QUALIFIER tvec3::tvec3(tvec2 const & a, B const & b) : + x(static_cast(a.x)), + y(static_cast(a.y)), + z(static_cast(b)) {} template template - GLM_FUNC_QUALIFIER tvec3::tvec3 - ( - A const & s, - tvec2 const & v - ) : - x(static_cast(s)), - y(static_cast(v.x)), - z(static_cast(v.y)) + GLM_FUNC_QUALIFIER tvec3::tvec3(tvec2 const & a, tvec1 const & b) : + x(static_cast(a.x)), + y(static_cast(a.y)), + z(static_cast(b.x)) + {} + + template + template + GLM_FUNC_QUALIFIER tvec3::tvec3(A const & a, tvec2 const & b) : + x(static_cast(a)), + y(static_cast(b.x)), + z(static_cast(b.y)) + {} + + template + template + GLM_FUNC_QUALIFIER tvec3::tvec3(tvec1 const & a, tvec2 const & b) : + x(static_cast(a.x)), + y(static_cast(b.x)), + z(static_cast(b.y)) {} template template - GLM_FUNC_QUALIFIER tvec3::tvec3 - ( - tvec3 const & v - ) : + GLM_FUNC_QUALIFIER tvec3::tvec3(tvec3 const & v) : x(static_cast(v.x)), y(static_cast(v.y)), z(static_cast(v.z)) @@ -166,10 +169,7 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec3::tvec3 - ( - tvec4 const & v - ) : + GLM_FUNC_QUALIFIER tvec3::tvec3(tvec4 const & v) : x(static_cast(v.x)), y(static_cast(v.y)), z(static_cast(v.z)) @@ -179,7 +179,7 @@ namespace glm // Unary arithmetic operators template - GLM_FUNC_QUALIFIER tvec3& tvec3::operator= (tvec3 const & v) + GLM_FUNC_QUALIFIER tvec3& tvec3::operator=(tvec3 const & v) { this->x = v.x; this->y = v.y; @@ -189,7 +189,7 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec3& tvec3::operator= (tvec3 const & v) + GLM_FUNC_QUALIFIER tvec3& tvec3::operator=(tvec3 const & v) { this->x = static_cast(v.x); this->y = static_cast(v.y); @@ -199,7 +199,7 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec3 & tvec3::operator+= (U s) + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator+=(U s) { this->x += static_cast(s); this->y += static_cast(s); @@ -207,6 +207,16 @@ namespace glm return *this; } + template + template + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator+= (tvec1 const & v) + { + this->x += static_cast(v.x); + this->y += static_cast(v.x); + this->z += static_cast(v.x); + return *this; + } + template template GLM_FUNC_QUALIFIER tvec3 & tvec3::operator+= (tvec3 const & v) @@ -227,6 +237,16 @@ namespace glm return *this; } + template + template + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator-= (tvec1 const & v) + { + this->x -= static_cast(v.x); + this->y -= static_cast(v.x); + this->z -= static_cast(v.x); + return *this; + } + template template GLM_FUNC_QUALIFIER tvec3 & tvec3::operator-= (tvec3 const & v) @@ -247,6 +267,16 @@ namespace glm return *this; } + template + template + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator*= (tvec1 const & v) + { + this->x *= static_cast(v.x); + this->y *= static_cast(v.x); + this->z *= static_cast(v.x); + return *this; + } + template template GLM_FUNC_QUALIFIER tvec3 & tvec3::operator*= (tvec3 const & v) @@ -267,6 +297,16 @@ namespace glm return *this; } + template + template + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator/= (tvec1 const & v) + { + this->x /= static_cast(v.x); + this->y /= static_cast(v.x); + this->z /= static_cast(v.x); + return *this; + } + template template GLM_FUNC_QUALIFIER tvec3 & tvec3::operator/= (tvec3 const & v) @@ -314,29 +354,6 @@ namespace glm return Result; } - ////////////////////////////////////// - // Boolean operators - - template - GLM_FUNC_QUALIFIER bool operator== - ( - tvec3 const & v1, - tvec3 const & v2 - ) - { - return (v1.x == v2.x) && (v1.y == v2.y) && (v1.z == v2.z); - } - - template - GLM_FUNC_QUALIFIER bool operator!= - ( - tvec3 const & v1, - tvec3 const & v2 - ) - { - return (v1.x != v2.x) || (v1.y != v2.y) || (v1.z != v2.z); - } - ////////////////////////////////////// // Unary bit operators @@ -350,6 +367,16 @@ namespace glm return *this; } + template + template + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator%= (tvec1 const & v) + { + this->x %= v.x; + this->y %= v.x; + this->z %= v.x; + return *this; + } + template template GLM_FUNC_QUALIFIER tvec3 & tvec3::operator%= (tvec3 const & v) @@ -370,6 +397,16 @@ namespace glm return *this; } + template + template + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator&= (tvec1 const & v) + { + this->x &= v.x; + this->y &= v.x; + this->z &= v.x; + return *this; + } + template template GLM_FUNC_QUALIFIER tvec3 & tvec3::operator&= (tvec3 const & v) @@ -390,6 +427,16 @@ namespace glm return *this; } + template + template + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator|= (tvec1 const & v) + { + this->x |= v.x; + this->y |= v.x; + this->z |= v.x; + return *this; + } + template template GLM_FUNC_QUALIFIER tvec3 & tvec3::operator|= (tvec3 const & v) @@ -410,6 +457,16 @@ namespace glm return *this; } + template + template + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator^= (tvec1 const & v) + { + this->x ^= v.x; + this->y ^= v.x; + this->z ^= v.x; + return *this; + } + template template GLM_FUNC_QUALIFIER tvec3 & tvec3::operator^= (tvec3 const & v) @@ -430,6 +487,16 @@ namespace glm return *this; } + template + template + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator<<= (tvec1 const & v) + { + this->x <<= static_cast(v.x); + this->y <<= static_cast(v.x); + this->z <<= static_cast(v.x); + return *this; + } + template template GLM_FUNC_QUALIFIER tvec3 & tvec3::operator<<= (tvec3 const & v) @@ -450,6 +517,16 @@ namespace glm return *this; } + template + template + GLM_FUNC_QUALIFIER tvec3 & tvec3::operator>>= (tvec1 const & v) + { + this->x >>= static_cast(v.x); + this->y >>= static_cast(v.x); + this->z >>= static_cast(v.x); + return *this; + } + template template GLM_FUNC_QUALIFIER tvec3 & tvec3::operator>>= (tvec3 const & v) @@ -460,15 +537,26 @@ namespace glm return *this; } + ////////////////////////////////////// + // Boolean operators + + template + GLM_FUNC_QUALIFIER bool operator==(tvec3 const & v1, tvec3 const & v2) + { + return (v1.x == v2.x) && (v1.y == v2.y) && (v1.z == v2.z); + } + + template + GLM_FUNC_QUALIFIER bool operator!=(tvec3 const & v1, tvec3 const & v2) + { + return (v1.x != v2.x) || (v1.y != v2.y) || (v1.z != v2.z); + } + ////////////////////////////////////// // Binary arithmetic operators - template - GLM_FUNC_QUALIFIER tvec3 operator+ - ( - tvec3 const & v, - T const & s - ) + template + GLM_FUNC_QUALIFIER tvec3 operator+(tvec3 const & v, T const & s) { return tvec3( v.x + s, @@ -476,12 +564,17 @@ namespace glm v.z + s); } - template - GLM_FUNC_QUALIFIER tvec3 operator+ - ( - T const & s, - tvec3 const & v - ) + template + GLM_FUNC_QUALIFIER tvec3 operator+(tvec3 const & v, tvec1 const & s) + { + return tvec3( + v.x + s.x, + v.y + s.x, + v.z + s.x); + } + + template + GLM_FUNC_QUALIFIER tvec3 operator+(T const & s, tvec3 const & v) { return tvec3( s + v.x, @@ -489,12 +582,17 @@ namespace glm s + v.z); } - template - GLM_FUNC_QUALIFIER tvec3 operator+ - ( - tvec3 const & v1, - tvec3 const & v2 - ) + template + GLM_FUNC_QUALIFIER tvec3 operator+(tvec1 const & s, tvec3 const & v) + { + return tvec3( + s.x + v.x, + s.x + v.y, + s.x + v.z); + } + + template + GLM_FUNC_QUALIFIER tvec3 operator+(tvec3 const & v1, tvec3 const & v2) { return tvec3( v1.x + v2.x, @@ -503,12 +601,8 @@ namespace glm } //operator- - template - GLM_FUNC_QUALIFIER tvec3 operator- - ( - tvec3 const & v, - T const & s - ) + template + GLM_FUNC_QUALIFIER tvec3 operator-(tvec3 const & v, T const & s) { return tvec3( v.x - s, @@ -516,12 +610,17 @@ namespace glm v.z - s); } + template + GLM_FUNC_QUALIFIER tvec3 operator-(tvec3 const & v, tvec1 const & s) + { + return tvec3( + v.x - s.x, + v.y - s.x, + v.z - s.x); + } + template - GLM_FUNC_QUALIFIER tvec3 operator- - ( - T const & s, - tvec3 const & v - ) + GLM_FUNC_QUALIFIER tvec3 operator-(T const & s, tvec3 const & v) { return tvec3( s - v.x, @@ -530,11 +629,16 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec3 operator- - ( - tvec3 const & v1, - tvec3 const & v2 - ) + GLM_FUNC_QUALIFIER tvec3 operator-(tvec1 const & s, tvec3 const & v) + { + return tvec3( + s.x - v.x, + s.x - v.y, + s.x - v.z); + } + + template + GLM_FUNC_QUALIFIER tvec3 operator-(tvec3 const & v1, tvec3 const & v2) { return tvec3( v1.x - v2.x, @@ -543,12 +647,8 @@ namespace glm } //operator* - template - GLM_FUNC_QUALIFIER tvec3 operator* - ( - tvec3 const & v, - T const & s - ) + template + GLM_FUNC_QUALIFIER tvec3 operator*(tvec3 const & v, T const & s) { return tvec3( v.x * s, @@ -556,12 +656,17 @@ namespace glm v.z * s); } - template - GLM_FUNC_QUALIFIER tvec3 operator* - ( - T const & s, - tvec3 const & v - ) + template + GLM_FUNC_QUALIFIER tvec3 operator*(tvec3 const & v, tvec1 const & s) + { + return tvec3( + v.x * s.x, + v.y * s.x, + v.z * s.x); + } + + template + GLM_FUNC_QUALIFIER tvec3 operator*(T const & s, tvec3 const & v) { return tvec3( s * v.x, @@ -569,12 +674,17 @@ namespace glm s * v.z); } - template - GLM_FUNC_QUALIFIER tvec3 operator* - ( - tvec3 const & v1, - tvec3 const & v2 - ) + template + GLM_FUNC_QUALIFIER tvec3 operator*(tvec1 const & s, tvec3 const & v) + { + return tvec3( + s.x * v.x, + s.x * v.y, + s.x * v.z); + } + + template + GLM_FUNC_QUALIFIER tvec3 operator*(tvec3 const & v1, tvec3 const & v2) { return tvec3( v1.x * v2.x, @@ -583,12 +693,8 @@ namespace glm } //operator/ - template - GLM_FUNC_QUALIFIER tvec3 operator/ - ( - tvec3 const & v, - T const & s - ) + template + GLM_FUNC_QUALIFIER tvec3 operator/(tvec3 const & v, T const & s) { return tvec3( v.x / s, @@ -596,12 +702,17 @@ namespace glm v.z / s); } - template - GLM_FUNC_QUALIFIER tvec3 operator/ - ( - T const & s, - tvec3 const & v - ) + template + GLM_FUNC_QUALIFIER tvec3 operator/(tvec3 const & v, tvec1 const & s) + { + return tvec3( + v.x / s.x, + v.y / s.x, + v.z / s.x); + } + + template + GLM_FUNC_QUALIFIER tvec3 operator/(T const & s, tvec3 const & v) { return tvec3( s / v.x, @@ -609,12 +720,17 @@ namespace glm s / v.z); } - template - GLM_FUNC_QUALIFIER tvec3 operator/ - ( - tvec3 const & v1, - tvec3 const & v2 - ) + template + GLM_FUNC_QUALIFIER tvec3 operator/(tvec1 const & s, tvec3 const & v) + { + return tvec3( + s.x / v.x, + s.x / v.y, + s.x / v.z); + } + + template + GLM_FUNC_QUALIFIER tvec3 operator/(tvec3 const & v1, tvec3 const & v2) { return tvec3( v1.x / v2.x, @@ -623,11 +739,8 @@ namespace glm } // Unary constant operators - template - GLM_FUNC_QUALIFIER tvec3 operator- - ( - tvec3 const & v - ) + template + GLM_FUNC_QUALIFIER tvec3 operator-(tvec3 const & v) { return tvec3( -v.x, @@ -639,11 +752,7 @@ namespace glm // Binary bit operators template - GLM_FUNC_QUALIFIER tvec3 operator% - ( - tvec3 const & v, - T const & s - ) + GLM_FUNC_QUALIFIER tvec3 operator%(tvec3 const & v, T const & s) { return tvec3( v.x % s, @@ -652,11 +761,16 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec3 operator% - ( - T const & s, - tvec3 const & v - ) + GLM_FUNC_QUALIFIER tvec3 operator%(tvec3 const & v, tvec1 const & s) + { + return tvec3( + v.x % s.x, + v.y % s.x, + v.z % s.x); + } + + template + GLM_FUNC_QUALIFIER tvec3 operator%(T const & s, tvec3 const & v) { return tvec3( s % v.x, @@ -665,11 +779,16 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec3 operator% - ( - tvec3 const & v1, - tvec3 const & v2 - ) + GLM_FUNC_QUALIFIER tvec3 operator%(tvec1 const & s, tvec3 const & v) + { + return tvec3( + s.x % v.x, + s.x % v.y, + s.x % v.z); + } + + template + GLM_FUNC_QUALIFIER tvec3 operator%(tvec3 const & v1, tvec3 const & v2) { return tvec3( v1.x % v2.x, @@ -678,11 +797,7 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec3 operator& - ( - tvec3 const & v, - T const & s - ) + GLM_FUNC_QUALIFIER tvec3 operator&(tvec3 const & v, T const & s) { return tvec3( v.x & s, @@ -691,11 +806,16 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec3 operator& - ( - T const & s, - tvec3 const & v - ) + GLM_FUNC_QUALIFIER tvec3 operator&(tvec3 const & v, tvec1 const & s) + { + return tvec3( + v.x & s.x, + v.y & s.x, + v.z & s.x); + } + + template + GLM_FUNC_QUALIFIER tvec3 operator&(T const & s, tvec3 const & v) { return tvec3( s & v.x, @@ -704,11 +824,16 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec3 operator& - ( - tvec3 const & v1, - tvec3 const & v2 - ) + GLM_FUNC_QUALIFIER tvec3 operator&(tvec1 const & s, tvec3 const & v) + { + return tvec3( + s.x & v.x, + s.x & v.y, + s.x & v.z); + } + + template + GLM_FUNC_QUALIFIER tvec3 operator&(tvec3 const & v1, tvec3 const & v2) { return tvec3( v1.x & v2.x, @@ -717,11 +842,7 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec3 operator| - ( - tvec3 const & v, - T const & s - ) + GLM_FUNC_QUALIFIER tvec3 operator|(tvec3 const & v, T const & s) { return tvec3( v.x | s, @@ -730,11 +851,16 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec3 operator| - ( - T const & s, - tvec3 const & v - ) + GLM_FUNC_QUALIFIER tvec3 operator|(tvec3 const & v, tvec1 const & s) + { + return tvec3( + v.x | s.x, + v.y | s.x, + v.z | s.x); + } + + template + GLM_FUNC_QUALIFIER tvec3 operator|(T const & s, tvec3 const & v) { return tvec3( s | v.x, @@ -743,24 +869,25 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec3 operator| - ( - tvec3 const & v1, - tvec3 const & v2 - ) + GLM_FUNC_QUALIFIER tvec3 operator|(tvec1 const & s, tvec3 const & v) + { + return tvec3( + s.x | v.x, + s.x | v.y, + s.x | v.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 & v, - T const & s - ) + GLM_FUNC_QUALIFIER tvec3 operator^(tvec3 const & v, T const & s) { return tvec3( v.x ^ s, @@ -769,114 +896,133 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec3 operator^ - ( - T const & s, - tvec3 const & v - ) + GLM_FUNC_QUALIFIER tvec3 operator^(tvec3 const & v, tvec1 const & s) { return tvec3( - T(s) ^ v.x, - T(s) ^ v.y, - T(s) ^ v.z); + v.x ^ s.x, + v.y ^ s.x, + v.z ^ s.x); } template - GLM_FUNC_QUALIFIER tvec3 operator^ - ( - tvec3 const & v1, - tvec3 const & v2 - ) + GLM_FUNC_QUALIFIER tvec3 operator^(T const & s, tvec3 const & v) { return tvec3( - v1.x ^ T(v2.x), - v1.y ^ T(v2.y), - v1.z ^ T(v2.z)); + s ^ v.x, + s ^ v.y, + s ^ v.z); } template - GLM_FUNC_QUALIFIER tvec3 operator<< - ( - tvec3 const & v, - T const & s - ) + GLM_FUNC_QUALIFIER tvec3 operator^(tvec1 const & s, tvec3 const & v) { return tvec3( - v.x << T(s), - v.y << T(s), - v.z << T(s)); + s.x ^ v.x, + s.x ^ v.y, + s.x ^ v.z); } template - GLM_FUNC_QUALIFIER tvec3 operator<< - ( - T const & s, - tvec3 const & v - ) + GLM_FUNC_QUALIFIER tvec3 operator^(tvec3 const & v1, tvec3 const & v2) { return tvec3( - T(s) << v.x, - T(s) << v.y, - T(s) << v.z); + v1.x ^ v2.x, + v1.y ^ v2.y, + v1.z ^ v2.z); } template - GLM_FUNC_QUALIFIER tvec3 operator<< - ( - tvec3 const & v1, - tvec3 const & v2 - ) + GLM_FUNC_QUALIFIER tvec3 operator<<(tvec3 const & v, T const & s) { return tvec3( - v1.x << T(v2.x), - v1.y << T(v2.y), - v1.z << T(v2.z)); + v.x << s, + v.y << s, + v.z << s); } template - GLM_FUNC_QUALIFIER tvec3 operator>> - ( - tvec3 const & v, - T const & s - ) + GLM_FUNC_QUALIFIER tvec3 operator<<(tvec3 const & v, tvec1 const & s) { return tvec3( - v.x >> T(s), - v.y >> T(s), - v.z >> T(s)); + v.x << s.x, + v.y << s.x, + v.z << s.x); } template - GLM_FUNC_QUALIFIER tvec3 operator>> - ( - T const & s, - tvec3 const & v - ) + GLM_FUNC_QUALIFIER tvec3 operator<<(T const & s, tvec3 const & v) { return tvec3( - s >> T(v.x), - s >> T(v.y), - s >> T(v.z)); + s << v.x, + s << v.y, + s << v.z); } template - GLM_FUNC_QUALIFIER tvec3 operator>> - ( - tvec3 const & v1, - tvec3 const & v2 - ) + GLM_FUNC_QUALIFIER tvec3 operator<<(tvec1 const & s, tvec3 const & v) { return tvec3( - v1.x >> T(v2.x), - v1.y >> T(v2.y), - v1.z >> T(v2.z)); + s.x << v.x, + s.x << v.y, + s.x << v.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 & v, T const & s) + { + return tvec3( + v.x >> s, + v.y >> s, + v.z >> s); + } + + template + GLM_FUNC_QUALIFIER tvec3 operator>>(tvec3 const & v, tvec1 const & s) + { + return tvec3( + v.x >> s.x, + v.y >> s.x, + v.z >> s.x); + } + + template + GLM_FUNC_QUALIFIER tvec3 operator>>(T const & s, tvec3 const & v) + { + return tvec3( + s >> v.x, + s >> v.y, + s >> v.z); + } + + template + GLM_FUNC_QUALIFIER tvec3 operator>>(tvec1 const & s, tvec3 const & v) + { + return tvec3( + s.x >> v.x, + s.x >> v.y, + s.x >> v.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 & v - ) + GLM_FUNC_QUALIFIER tvec3 operator~(tvec3 const & v) { return tvec3( ~v.x, diff --git a/glm/detail/type_vec4.hpp b/glm/detail/type_vec4.hpp index 23fc52a1..a5769f65 100644 --- a/glm/detail/type_vec4.hpp +++ b/glm/detail/type_vec4.hpp @@ -153,48 +153,55 @@ namespace glm ////////////////////////////////////// // Explicit basic constructors - GLM_FUNC_DECL explicit tvec4( - ctor); - GLM_FUNC_DECL explicit tvec4( - T const & s); - GLM_FUNC_DECL tvec4( - T const & s0, - T const & s1, - T const & s2, - T const & s3); + GLM_FUNC_DECL explicit tvec4(ctor); + GLM_FUNC_DECL explicit tvec4(T const & s); + GLM_FUNC_DECL tvec4(T const & s0, T const & s1, T const & s2, T const & s3); ////////////////////////////////////// // Conversion scalar constructors /// Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) template - GLM_FUNC_DECL tvec4( - A const & x, - B const & y, - C const & z, - D const & w); + GLM_FUNC_DECL tvec4(A const & x, B const & y, C const & z, D const & w); + template + GLM_FUNC_DECL tvec4(tvec1 const & a, tvec1 const & b, tvec1 const & c, tvec1 const & d); ////////////////////////////////////// // Conversion vector constructors //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) template - GLM_FUNC_DECL explicit tvec4(tvec2 const & v, B const & s1, C const & s2); + GLM_FUNC_DECL explicit tvec4(tvec2 const & a, B const & b, C const & c); //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) template - GLM_FUNC_DECL explicit tvec4(A const & s1, tvec2 const & v, C const & s2); + GLM_FUNC_DECL explicit tvec4(tvec2 const & a, tvec1 const & b, tvec1 const & c); //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) template - GLM_FUNC_DECL explicit tvec4(A const & s1, B const & s2, tvec2 const & v); + GLM_FUNC_DECL explicit tvec4(A const & a, tvec2 const & b, C const & c); + //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + template + GLM_FUNC_DECL explicit tvec4(tvec1 const & a, tvec2 const & b, tvec1 const & c); + //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + template + GLM_FUNC_DECL explicit tvec4(A const & a, B const & b, tvec2 const & c); + //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + template + GLM_FUNC_DECL explicit tvec4(tvec1 const & a, tvec1 const & b, tvec2 const & c); //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) template - GLM_FUNC_DECL explicit tvec4(tvec3 const & v, B const & s); + GLM_FUNC_DECL explicit tvec4(tvec3 const & a, B const & b); //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) template - GLM_FUNC_DECL explicit tvec4(A const & s, tvec3 const & v); + GLM_FUNC_DECL explicit tvec4(tvec3 const & a, tvec1 const & b); //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) template - GLM_FUNC_DECL explicit tvec4(tvec2 const & v1, tvec2 const & v2); + GLM_FUNC_DECL explicit tvec4(A const & a, tvec3 const & b); + //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + template + GLM_FUNC_DECL explicit tvec4(tvec1 const & a, tvec3 const & b); + //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) + template + GLM_FUNC_DECL explicit tvec4(tvec2 const & a, tvec2 const & b); //! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification) template GLM_FUNC_DECL explicit tvec4(tvec4 const & v); @@ -251,32 +258,31 @@ namespace glm GLM_FUNC_DECL tvec4 & operator= (tvec4 const & v); - GLM_FUNC_DECL tvec4 & operator+=(T v); - GLM_FUNC_DECL tvec4 & operator+=(tvec4 const & v); - GLM_FUNC_DECL tvec4 & operator-=(T v); - GLM_FUNC_DECL tvec4 & operator-=(tvec4 const & v); - GLM_FUNC_DECL tvec4 & operator*=(T v); - GLM_FUNC_DECL tvec4 & operator*=(tvec4 const & v); - GLM_FUNC_DECL tvec4 & operator/=(T v); - GLM_FUNC_DECL tvec4 & operator/=(tvec4 const & v); - - template - GLM_FUNC_DECL tvec4 & operator= (tvec4 const & v); + template + GLM_FUNC_DECL tvec4 & operator= (tvec4 const & v); template GLM_FUNC_DECL tvec4 & operator+=(U s); template + GLM_FUNC_DECL tvec4 & operator+=(tvec1 const & v); + template GLM_FUNC_DECL tvec4 & operator+=(tvec4 const & v); template GLM_FUNC_DECL tvec4 & operator-=(U s); template + GLM_FUNC_DECL tvec4 & operator-=(tvec1 const & v); + template GLM_FUNC_DECL tvec4 & operator-=(tvec4 const & v); template GLM_FUNC_DECL tvec4 & operator*=(U s); template + GLM_FUNC_DECL tvec4 & operator*=(tvec1 const & v); + template GLM_FUNC_DECL tvec4 & operator*=(tvec4 const & v); template GLM_FUNC_DECL tvec4 & operator/=(U s); template + GLM_FUNC_DECL tvec4 & operator/=(tvec1 const & v); + template GLM_FUNC_DECL tvec4 & operator/=(tvec4 const & v); ////////////////////////////////////// @@ -293,62 +299,98 @@ namespace glm template GLM_FUNC_DECL tvec4 & operator%= (U s); template + GLM_FUNC_DECL tvec4 & operator%= (tvec1 const & v); + template GLM_FUNC_DECL tvec4 & operator%= (tvec4 const & v); template GLM_FUNC_DECL tvec4 & operator&= (U s); template + GLM_FUNC_DECL tvec4 & operator&= (tvec1 const & v); + template GLM_FUNC_DECL tvec4 & operator&= (tvec4 const & v); template GLM_FUNC_DECL tvec4 & operator|= (U s); template + GLM_FUNC_DECL tvec4 & operator|= (tvec1 const & v); + template GLM_FUNC_DECL tvec4 & operator|= (tvec4 const & v); template GLM_FUNC_DECL tvec4 & operator^= (U s); template + GLM_FUNC_DECL tvec4 & operator^= (tvec1 const & v); + template GLM_FUNC_DECL tvec4 & operator^= (tvec4 const & v); template GLM_FUNC_DECL tvec4 & operator<<=(U s); template + GLM_FUNC_DECL tvec4 & operator<<=(tvec1 const & v); + template GLM_FUNC_DECL tvec4 & operator<<=(tvec4 const & v); template GLM_FUNC_DECL tvec4 & operator>>=(U s); template + GLM_FUNC_DECL tvec4 & operator>>=(tvec1 const & v); + template GLM_FUNC_DECL tvec4 & operator>>=(tvec4 const & v); }; template GLM_FUNC_DECL tvec4 operator+(tvec4 const & v, T const & s); + template + GLM_FUNC_DECL tvec4 operator+(tvec4 const & v, tvec1 const & s); + template GLM_FUNC_DECL tvec4 operator+(T const & s, tvec4 const & v); + template + GLM_FUNC_DECL tvec4 operator+(tvec1 const & s, tvec4 const & v); + template GLM_FUNC_DECL tvec4 operator+(tvec4 const & v1, tvec4 const & v2); template GLM_FUNC_DECL tvec4 operator-(tvec4 const & v, T const & s); + template + GLM_FUNC_DECL tvec4 operator-(tvec4 const & v, tvec1 const & s); + template GLM_FUNC_DECL tvec4 operator-(T const & s, tvec4 const & v); template - GLM_FUNC_DECL tvec4 operator- (tvec4 const & v1, tvec4 const & v2); + GLM_FUNC_DECL tvec4 operator-(tvec1 const & s, tvec4 const & v); + + template + GLM_FUNC_DECL tvec4 operator-(tvec4 const & v1, tvec4 const & v2); template GLM_FUNC_DECL tvec4 operator*(tvec4 const & v, T const & s); + template + GLM_FUNC_DECL tvec4 operator*(tvec4 const & v, tvec1 const & s); + template GLM_FUNC_DECL tvec4 operator*(T const & s, tvec4 const & v); + template + GLM_FUNC_DECL tvec4 operator*(tvec1 const & s, tvec4 const & v); + template GLM_FUNC_DECL tvec4 operator*(tvec4 const & v1, tvec4 const & v2); template GLM_FUNC_DECL tvec4 operator/(tvec4 const & v, T const & s); + template + GLM_FUNC_DECL tvec4 operator/(tvec4 const & v, tvec1 const & s); + template GLM_FUNC_DECL tvec4 operator/(T const & s, tvec4 const & v); + template + GLM_FUNC_DECL tvec4 operator/(tvec1 const & s, tvec4 const & v); + template GLM_FUNC_DECL tvec4 operator/(tvec4 const & v1, tvec4 const & v2); @@ -364,54 +406,90 @@ namespace glm template GLM_FUNC_DECL tvec4 operator%(tvec4 const & v, T const & s); + template + GLM_FUNC_DECL tvec4 operator%(tvec4 const & v, tvec1 const & s); + template GLM_FUNC_DECL tvec4 operator%(T const & s, tvec4 const & v); + template + GLM_FUNC_DECL tvec4 operator%(tvec1 const & s, tvec4 const & v); + template GLM_FUNC_DECL tvec4 operator%(tvec4 const & v1, tvec4 const & v2); template GLM_FUNC_DECL tvec4 operator&(tvec4 const & v, T const & s); + template + GLM_FUNC_DECL tvec4 operator&(tvec4 const & v, tvec1 const & s); + template GLM_FUNC_DECL tvec4 operator&(T const & s, tvec4 const & v); + template + GLM_FUNC_DECL tvec4 operator&(tvec1 const & s, tvec4 const & v); + template GLM_FUNC_DECL tvec4 operator&(tvec4 const & v1, tvec4 const & v2); template GLM_FUNC_DECL tvec4 operator|(tvec4 const & v, T const & s); + template + GLM_FUNC_DECL tvec4 operator|(tvec4 const & v, tvec1 const & s); + template GLM_FUNC_DECL tvec4 operator|(T const & s, tvec4 const & v); + template + GLM_FUNC_DECL tvec4 operator|(tvec1 const & s, tvec4 const & v); + template GLM_FUNC_DECL tvec4 operator|(tvec4 const & v1, tvec4 const & v2); template GLM_FUNC_DECL tvec4 operator^(tvec4 const & v, T const & s); + template + GLM_FUNC_DECL tvec4 operator^(tvec4 const & v, tvec1 const & s); + template GLM_FUNC_DECL tvec4 operator^(T const & s, tvec4 const & v); + template + GLM_FUNC_DECL tvec4 operator^(tvec1 const & s, tvec4 const & v); + template GLM_FUNC_DECL tvec4 operator^(tvec4 const & v1, tvec4 const & v2); template GLM_FUNC_DECL tvec4 operator<<(tvec4 const & v, T const & s); + template + GLM_FUNC_DECL tvec4 operator<<(tvec4 const & v, tvec1 const & s); + template GLM_FUNC_DECL tvec4 operator<<(T const & s, tvec4 const & v); + template + GLM_FUNC_DECL tvec4 operator<<(tvec1 const & s, tvec4 const & v); + template GLM_FUNC_DECL tvec4 operator<<(tvec4 const & v1, tvec4 const & v2); template GLM_FUNC_DECL tvec4 operator>>(tvec4 const & v, T const & s); + template + GLM_FUNC_DECL tvec4 operator>>(tvec4 const & v, tvec1 const & s); + template GLM_FUNC_DECL tvec4 operator>>(T const & s, tvec4 const & v); + template + GLM_FUNC_DECL tvec4 operator>>(tvec1 const & s, tvec4 const & v); + template GLM_FUNC_DECL tvec4 operator>>(tvec4 const & v1, tvec4 const & v2); diff --git a/glm/detail/type_vec4.inl b/glm/detail/type_vec4.inl index da5f2855..94568ade 100644 --- a/glm/detail/type_vec4.inl +++ b/glm/detail/type_vec4.inl @@ -70,7 +70,7 @@ namespace glm w(0) {} -#if((GLM_HAS_UNRESTRICTED_UNIONS) && (GLM_ARCH & GLM_ARCH_SSE2)) +#if (GLM_HAS_UNRESTRICTED_UNIONS) && (GLM_ARCH & GLM_ARCH_SSE2) template <> GLM_FUNC_QUALIFIER tvec4::tvec4() : data(_mm_setzero_ps()) @@ -90,7 +90,7 @@ namespace glm w(v.w) {} -#if((GLM_HAS_UNRESTRICTED_UNIONS) && (GLM_ARCH & GLM_ARCH_SSE2)) +#if (GLM_HAS_UNRESTRICTED_UNIONS) && (GLM_ARCH & GLM_ARCH_SSE2) template <> GLM_FUNC_QUALIFIER tvec4::tvec4(tvec4 const & v) : data(v.data) @@ -160,32 +160,23 @@ namespace glm ////////////////////////////////////// // Conversion scalar constructors - + template template - GLM_FUNC_QUALIFIER tvec4::tvec4 - ( - A const & x, - B const & y, - C const & z, - D const & w - ) : - x(static_cast(x)), - y(static_cast(y)), - z(static_cast(z)), - w(static_cast(w)) + GLM_FUNC_QUALIFIER tvec4::tvec4(A const & a, B const & b, C const & c, D const & d) : + x(static_cast(a)), + y(static_cast(b)), + z(static_cast(c)), + w(static_cast(d)) {} template - template - GLM_FUNC_QUALIFIER tvec4::tvec4 - ( - tvec4 const & v - ) : - x(static_cast(v.x)), - y(static_cast(v.y)), - z(static_cast(v.z)), - w(static_cast(v.w)) + template + GLM_FUNC_QUALIFIER tvec4::tvec4(tvec1 const & a, tvec1 const & b, tvec1 const & c, tvec1 const & d) : + x(static_cast(a.x)), + y(static_cast(b.x)), + z(static_cast(c.x)), + w(static_cast(d.x)) {} ////////////////////////////////////// @@ -193,26 +184,25 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec4::tvec4 - ( - tvec2 const & v, - B const & s1, - C const & s2 - ) : - x(static_cast(v.x)), - y(static_cast(v.y)), - z(static_cast(s1)), - w(static_cast(s2)) + GLM_FUNC_QUALIFIER tvec4::tvec4(tvec2 const & a, B const & b, C const & c) : + x(static_cast(a.x)), + y(static_cast(a.y)), + z(static_cast(b)), + w(static_cast(c)) {} template template - GLM_FUNC_QUALIFIER tvec4::tvec4 - ( - A const & s1, - tvec2 const & v, - C const & s2 - ) : + GLM_FUNC_QUALIFIER tvec4::tvec4(tvec2 const & a, tvec1 const & b, tvec1 const & c) : + x(static_cast(a.x)), + y(static_cast(a.y)), + z(static_cast(b.x)), + w(static_cast(c.x)) + {} + + template + template + GLM_FUNC_QUALIFIER tvec4::tvec4(A const & s1, tvec2 const & v, C const & s2) : x(static_cast(s1)), y(static_cast(v.x)), z(static_cast(v.y)), @@ -221,62 +211,90 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec4::tvec4 - ( - A const & s1, - B const & s2, - tvec2 const & v - ) : + GLM_FUNC_QUALIFIER tvec4::tvec4(tvec1 const & a, tvec2 const & b, tvec1 const & c) : + x(static_cast(a.x)), + y(static_cast(b.x)), + z(static_cast(b.y)), + w(static_cast(c.x)) + {} + + template + template + GLM_FUNC_QUALIFIER tvec4::tvec4(A const & s1, B const & s2, tvec2 const & v) : x(static_cast(s1)), y(static_cast(s2)), z(static_cast(v.x)), w(static_cast(v.y)) {} + template + template + GLM_FUNC_QUALIFIER tvec4::tvec4(tvec1 const & a, tvec1 const & b, tvec2 const & c) : + x(static_cast(a.x)), + y(static_cast(b.x)), + z(static_cast(c.x)), + w(static_cast(c.y)) + {} + template template - GLM_FUNC_QUALIFIER tvec4::tvec4 - ( - tvec3 const & v, - B const & s - ) : + GLM_FUNC_QUALIFIER tvec4::tvec4(tvec3 const & a, B const & b) : + x(static_cast(a.x)), + y(static_cast(a.y)), + z(static_cast(a.z)), + w(static_cast(b)) + {} + + template + template + GLM_FUNC_QUALIFIER tvec4::tvec4(tvec3 const & a, tvec1 const & b) : + x(static_cast(a.x)), + y(static_cast(a.y)), + z(static_cast(a.z)), + w(static_cast(b.x)) + {} + + template + template + GLM_FUNC_QUALIFIER tvec4::tvec4(A const & a, tvec3 const & b) : + x(static_cast(a)), + y(static_cast(b.x)), + z(static_cast(b.y)), + w(static_cast(b.z)) + {} + + template + template + GLM_FUNC_QUALIFIER tvec4::tvec4(tvec1 const & a, tvec3 const & b) : + x(static_cast(a.x)), + y(static_cast(b.x)), + z(static_cast(b.y)), + w(static_cast(b.z)) + {} + + template + template + GLM_FUNC_QUALIFIER tvec4::tvec4(tvec2 const & a, tvec2 const & b) : + x(static_cast(a.x)), + y(static_cast(a.y)), + z(static_cast(b.x)), + w(static_cast(b.y)) + {} + + template + template + GLM_FUNC_QUALIFIER tvec4::tvec4(tvec4 const & v) : x(static_cast(v.x)), y(static_cast(v.y)), z(static_cast(v.z)), - w(static_cast(s)) - {} - - template - template - GLM_FUNC_QUALIFIER tvec4::tvec4 - ( - A const & s, - tvec3 const & v - ) : - x(static_cast(s)), - y(static_cast(v.x)), - z(static_cast(v.y)), - w(static_cast(v.z)) - {} - - template - template - GLM_FUNC_QUALIFIER tvec4::tvec4 - ( - tvec2 const & v1, - tvec2 const & v2 - ) : - x(static_cast(v1.x)), - y(static_cast(v1.y)), - z(static_cast(v2.x)), - w(static_cast(v2.y)) + w(static_cast(v.w)) {} ////////////////////////////////////// // Unary arithmetic operators template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator= (tvec4 const & v) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator=(tvec4 const & v) { this->x = v.x; this->y = v.y; @@ -285,7 +303,7 @@ namespace glm return *this; } -#if((GLM_HAS_UNRESTRICTED_UNIONS) && (GLM_ARCH & GLM_ARCH_SSE2)) +#if (GLM_HAS_UNRESTRICTED_UNIONS) && (GLM_ARCH & GLM_ARCH_SSE2) template <> GLM_FUNC_QUALIFIER tvec4 & tvec4::operator= (tvec4 const & v) { @@ -300,106 +318,10 @@ namespace glm return *this; } #endif - - template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+= (T v) - { - this->x += v; - this->y += v; - this->z += v; - this->w += v; - return *this; - } - -#if((GLM_HAS_UNRESTRICTED_UNIONS) && (GLM_ARCH & GLM_ARCH_SSE2)) - template <> - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+= (float s) - { - this->data = _mm_add_ps(this->data, _mm_set_ps1(s)); - return *this; - } - - template <> - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+= (float s) - { - this->data = _mm_add_ps(this->data, _mm_set_ps1(s)); - return *this; - } -#endif - - template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+= (tvec4 const & v) - { - this->x += v.x; - this->y += v.y; - this->z += v.z; - this->w += v.w; - return *this; - } - - template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator-= (T v) - { - this->x -= v; - this->y -= v; - this->z -= v; - this->w -= v; - return *this; - } - - template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator-= (tvec4 const & v) - { - this->x -= v.x; - this->y -= v.y; - this->z -= v.z; - this->w -= v.w; - return *this; - } - - template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator*= (T v) - { - this->x *= v; - this->y *= v; - this->z *= v; - this->w *= v; - return *this; - } - - template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator*= (tvec4 const & v) - { - this->x *= v.x; - this->y *= v.y; - this->z *= v.z; - this->w *= v.w; - return *this; - } - - template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator/= (T v) - { - this->x /= v; - this->y /= v; - this->z /= v; - this->w /= v; - return *this; - } - - template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator/= (tvec4 const & v) - { - this->x /= v.x; - this->y /= v.y; - this->z /= v.z; - this->w /= v.w; - return *this; - } template - template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator= (tvec4 const & v) + template + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator=(tvec4 const & v) { this->x = static_cast(v.x); this->y = static_cast(v.y); @@ -410,7 +332,7 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+= (U s) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(U s) { this->x += static_cast(s); this->y += static_cast(s); @@ -419,27 +341,56 @@ namespace glm return *this; } -#if((GLM_HAS_UNRESTRICTED_UNIONS) && (GLM_ARCH & GLM_ARCH_SSE2)) +#if (GLM_HAS_UNRESTRICTED_UNIONS) && (GLM_ARCH & GLM_ARCH_SSE2) template <> template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+= (U s) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(U s) { this->data = _mm_add_ps(this->data, _mm_set_ps1(static_cast(s))); return *this; } - + template <> template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+= (U s) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(U s) { this->data = _mm_add_ps(this->data, _mm_set_ps1(static_cast(s))); return *this; } #endif - + template template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+= (tvec4 const & v) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(tvec1 const & s) + { + this->x += static_cast(s); + this->y += static_cast(s); + this->z += static_cast(s); + this->w += static_cast(s); + return *this; + } + +#if (GLM_HAS_UNRESTRICTED_UNIONS) && (GLM_ARCH & GLM_ARCH_SSE2) + template <> + template + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(tvec1 const & s) + { + this->data = _mm_add_ps(this->data, _mm_set_ps1(static_cast(s))); + return *this; + } + + template <> + template + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(tvec1 const & s) + { + this->data = _mm_add_ps(this->data, _mm_set_ps1(static_cast(s))); + return *this; + } +#endif + + template + template + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+=(tvec4 const & v) { this->x += static_cast(v.x); this->y += static_cast(v.y); @@ -450,7 +401,7 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator-= (U s) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator-=(U s) { this->x -= static_cast(s); this->y -= static_cast(s); @@ -461,7 +412,18 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator-= (tvec4 const & v) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator-=(tvec1 const & v) + { + this->x -= static_cast(v.x); + this->y -= static_cast(v.x); + this->z -= static_cast(v.x); + this->w -= static_cast(v.x); + return *this; + } + + template + template + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator-=(tvec4 const & v) { this->x -= static_cast(v.x); this->y -= static_cast(v.y); @@ -472,7 +434,7 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator*= (U s) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator*=(U s) { this->x *= static_cast(s); this->y *= static_cast(s); @@ -483,7 +445,18 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator*= (tvec4 const & v) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator*=(tvec1 const & v) + { + this->x *= static_cast(v.x); + this->y *= static_cast(v.x); + this->z *= static_cast(v.x); + this->w *= static_cast(v.x); + return *this; + } + + template + template + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator*=(tvec4 const & v) { this->x *= static_cast(v.x); this->y *= static_cast(v.y); @@ -494,7 +467,7 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator/= (U s) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator/=(U s) { this->x /= static_cast(s); this->y /= static_cast(s); @@ -505,7 +478,18 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator/= (tvec4 const & v) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator/=(tvec1 const & v) + { + this->x /= static_cast(v.x); + this->y /= static_cast(v.x); + this->z /= static_cast(v.x); + this->w /= static_cast(v.x); + return *this; + } + + template + template + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator/=(tvec4 const & v) { this->x /= static_cast(v.x); this->y /= static_cast(v.y); @@ -558,7 +542,7 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator%= (U s) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator%=(U s) { this->x %= static_cast(s); this->y %= static_cast(s); @@ -569,7 +553,18 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator%= (tvec4 const & v) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator%=(tvec1 const & v) + { + this->x %= static_cast(v.x); + this->y %= static_cast(v.x); + this->z %= static_cast(v.x); + this->w %= static_cast(v.x); + return *this; + } + + template + template + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator%=(tvec4 const & v) { this->x %= static_cast(v.x); this->y %= static_cast(v.y); @@ -580,7 +575,7 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator&= (U s) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator&=(U s) { this->x &= static_cast(s); this->y &= static_cast(s); @@ -591,7 +586,18 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator&= (tvec4 const & v) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator&=(tvec1 const & v) + { + this->x &= static_cast(v.x); + this->y &= static_cast(v.x); + this->z &= static_cast(v.x); + this->w &= static_cast(v.x); + return *this; + } + + template + template + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator&=(tvec4 const & v) { this->x &= static_cast(v.x); this->y &= static_cast(v.y); @@ -602,7 +608,7 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator|= (U s) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator|=(U s) { this->x |= static_cast(s); this->y |= static_cast(s); @@ -613,7 +619,18 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator|= (tvec4 const & v) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator|=(tvec1 const & v) + { + this->x |= static_cast(v.x); + this->y |= static_cast(v.x); + this->z |= static_cast(v.x); + this->w |= static_cast(v.x); + return *this; + } + + template + template + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator|=(tvec4 const & v) { this->x |= static_cast(v.x); this->y |= static_cast(v.y); @@ -624,7 +641,7 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator^= (U s) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator^=(U s) { this->x ^= static_cast(s); this->y ^= static_cast(s); @@ -635,7 +652,18 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator^= (tvec4 const & v) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator^=(tvec1 const & v) + { + this->x ^= static_cast(v.x); + this->y ^= static_cast(v.x); + this->z ^= static_cast(v.x); + this->w ^= static_cast(v.x); + return *this; + } + + template + template + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator^=(tvec4 const & v) { this->x ^= static_cast(v.x); this->y ^= static_cast(v.y); @@ -646,7 +674,7 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator<<= (U s) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator<<=(U s) { this->x <<= static_cast(s); this->y <<= static_cast(s); @@ -657,7 +685,18 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator<<= (tvec4 const & v) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator<<=(tvec1 const & v) + { + this->x <<= static_cast(v.x); + this->y <<= static_cast(v.x); + this->z <<= static_cast(v.x); + this->w <<= static_cast(v.x); + return *this; + } + + template + template + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator<<=(tvec4 const & v) { this->x <<= static_cast(v.x); this->y <<= static_cast(v.y); @@ -668,7 +707,7 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator>>= (U s) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator>>=(U s) { this->x >>= static_cast(s); this->y >>= static_cast(s); @@ -679,7 +718,7 @@ namespace glm template template - GLM_FUNC_QUALIFIER tvec4 & tvec4::operator>>= (tvec4 const & v) + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator>>=(tvec1 const & v) { this->x >>= static_cast(v.x); this->y >>= static_cast(v.y); @@ -688,6 +727,32 @@ namespace glm return *this; } + template + template + GLM_FUNC_QUALIFIER tvec4 & tvec4::operator>>=(tvec4 const & v) + { + this->x >>= static_cast(v.x); + this->y >>= static_cast(v.y); + this->z >>= static_cast(v.z); + this->w >>= static_cast(v.w); + return *this; + } + + ////////////////////////////////////// + // Boolean operators + + template + GLM_FUNC_QUALIFIER bool operator==(tvec4 const & v1, tvec4 const & v2) + { + return (v1.x == v2.x) && (v1.y == v2.y) && (v1.z == v2.z) && (v1.w == v2.w); + } + + template + GLM_FUNC_QUALIFIER bool operator!=(tvec4 const & v1, tvec4 const & v2) + { + return (v1.x != v2.x) || (v1.y != v2.y) || (v1.z != v2.z) || (v1.w != v2.w); + } + ////////////////////////////////////// // Binary arithmetic operators @@ -821,7 +886,7 @@ namespace glm //operator/ template - GLM_FUNC_QUALIFIER tvec4 operator/ + GLM_FUNC_QUALIFIER tvec4 operator/ ( tvec4 const & v, T const & s @@ -835,7 +900,7 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec4 operator/ + GLM_FUNC_QUALIFIER tvec4 operator/ ( T const & s, tvec4 const & v @@ -849,7 +914,7 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec4 operator/ + GLM_FUNC_QUALIFIER tvec4 operator/ ( tvec4 const & v1, tvec4 const & v2 @@ -864,7 +929,7 @@ namespace glm // Unary constant operators template - GLM_FUNC_QUALIFIER tvec4 operator- + GLM_FUNC_QUALIFIER tvec4 operator- ( tvec4 const & v ) @@ -876,38 +941,11 @@ namespace glm -v.w); } - ////////////////////////////////////// - // Boolean operators - - template - GLM_FUNC_QUALIFIER bool operator== - ( - tvec4 const & v1, - tvec4 const & v2 - ) - { - return (v1.x == v2.x) && (v1.y == v2.y) && (v1.z == v2.z) && (v1.w == v2.w); - } - - template - GLM_FUNC_QUALIFIER bool operator!= - ( - tvec4 const & v1, - tvec4 const & v2 - ) - { - return (v1.x != v2.x) || (v1.y != v2.y) || (v1.z != v2.z) || (v1.w != v2.w); - } - ////////////////////////////////////// // Binary bit operators template - GLM_FUNC_QUALIFIER tvec4 operator% - ( - tvec4 const & v, - T const & s - ) + GLM_FUNC_QUALIFIER tvec4 operator%(tvec4 const & v, T const & s) { return tvec4( v.x % s, @@ -917,11 +955,17 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec4 operator% - ( - T const & s, - tvec4 const & v - ) + GLM_FUNC_QUALIFIER tvec4 operator%(tvec4 const & v, tvec1 const & s) + { + return tvec4( + v.x % s.x, + v.y % s.x, + v.z % s.x, + v.w % s.x); + } + + template + GLM_FUNC_QUALIFIER tvec4 operator%(T const & s, tvec4 const & v) { return tvec4( s % v.x, @@ -931,11 +975,17 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec4 operator% - ( - tvec4 const & v1, - tvec4 const & v2 - ) + GLM_FUNC_QUALIFIER tvec4 operator%(tvec1 const & s, tvec4 const & v) + { + return tvec4( + s.x % v.x, + s.x % v.y, + s.x % v.z, + s.x % v.w); + } + + template + GLM_FUNC_QUALIFIER tvec4 operator%(tvec4 const & v1, tvec4 const & v2) { return tvec4( v1.x % v2.x, @@ -945,11 +995,7 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec4 operator& - ( - tvec4 const & v, - T const & s - ) + GLM_FUNC_QUALIFIER tvec4 operator&(tvec4 const & v, T const & s) { return tvec4( v.x & s, @@ -959,11 +1005,17 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec4 operator& - ( - T const & s, - tvec4 const & v - ) + GLM_FUNC_QUALIFIER tvec4 operator&(tvec4 const & v, tvec1 const & s) + { + return tvec4( + v.x & s.x, + v.y & s.x, + v.z & s.x, + v.w & s.x); + } + + template + GLM_FUNC_QUALIFIER tvec4 operator&(T const & s, tvec4 const & v) { return tvec4( s & v.x, @@ -973,11 +1025,17 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec4 operator& - ( - tvec4 const & v1, - tvec4 const & v2 - ) + GLM_FUNC_QUALIFIER tvec4 operator&(tvec1 const & s, tvec4 const & v) + { + return tvec4( + s.x & v.x, + s.x & v.y, + s.x & v.z, + s.x & v.w); + } + + template + GLM_FUNC_QUALIFIER tvec4 operator&(tvec4 const & v1, tvec4 const & v2) { return tvec4( v1.x & v2.x, @@ -987,11 +1045,7 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec4 operator| - ( - tvec4 const & v, - T const & s - ) + GLM_FUNC_QUALIFIER tvec4 operator|(tvec4 const & v, T const & s) { return tvec4( v.x | s, @@ -1001,11 +1055,17 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec4 operator| - ( - T const & s, - tvec4 const & v - ) + GLM_FUNC_QUALIFIER tvec4 operator|(tvec4 const & v, tvec1 const & s) + { + return tvec4( + v.x | s.x, + v.y | s.x, + v.z | s.x, + v.w | s.x); + } + + template + GLM_FUNC_QUALIFIER tvec4 operator|(T const & s, tvec4 const & v) { return tvec4( s | v.x, @@ -1015,11 +1075,17 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec4 operator| - ( - tvec4 const & v1, - tvec4 const & v2 - ) + GLM_FUNC_QUALIFIER tvec4 operator|(tvec1 const & s, tvec4 const & v) + { + return tvec4( + s.x | v.x, + s.x | v.y, + s.x | v.z, + s.x | v.w); + } + + template + GLM_FUNC_QUALIFIER tvec4 operator|(tvec4 const & v1, tvec4 const & v2) { return tvec4( v1.x | v2.x, @@ -1027,13 +1093,9 @@ namespace glm v1.z | v2.z, v1.w | v2.w); } - + template - GLM_FUNC_QUALIFIER tvec4 operator^ - ( - tvec4 const & v, - T const & s - ) + GLM_FUNC_QUALIFIER tvec4 operator^(tvec4 const & v, T const & s) { return tvec4( v.x ^ s, @@ -1043,11 +1105,17 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec4 operator^ - ( - T const & s, - tvec4 const & v - ) + GLM_FUNC_QUALIFIER tvec4 operator^(tvec4 const & v, tvec1 const & s) + { + return tvec4( + v.x ^ s.x, + v.y ^ s.x, + v.z ^ s.x, + v.w ^ s.x); + } + + template + GLM_FUNC_QUALIFIER tvec4 operator^(T const & s, tvec4 const & v) { return tvec4( s ^ v.x, @@ -1057,11 +1125,17 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec4 operator^ - ( - tvec4 const & v1, - tvec4 const & v2 - ) + GLM_FUNC_QUALIFIER tvec4 operator^(tvec1 const & s, tvec4 const & v) + { + return tvec4( + s.x ^ v.x, + s.x ^ v.y, + s.x ^ v.z, + s.x ^ v.w); + } + + template + GLM_FUNC_QUALIFIER tvec4 operator^(tvec4 const & v1, tvec4 const & v2) { return tvec4( v1.x ^ v2.x, @@ -1071,11 +1145,7 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec4 operator<< - ( - tvec4 const & v, - T const & s - ) + GLM_FUNC_QUALIFIER tvec4 operator<<(tvec4 const & v, T const & s) { return tvec4( v.x << s, @@ -1085,11 +1155,17 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec4 operator<< - ( - T const & s, - tvec4 const & v - ) + GLM_FUNC_QUALIFIER tvec4 operator<<(tvec4 const & v, tvec1 const & s) + { + return tvec4( + v.x << s.x, + v.y << s.x, + v.z << s.x, + v.w << s.x); + } + + template + GLM_FUNC_QUALIFIER tvec4 operator<<(T const & s, tvec4 const & v) { return tvec4( s << v.x, @@ -1099,11 +1175,17 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec4 operator<< - ( - tvec4 const & v1, - tvec4 const & v2 - ) + GLM_FUNC_QUALIFIER tvec4 operator<<(tvec1 const & s, tvec4 const & v) + { + return tvec4( + s.x << v.x, + s.x << v.y, + s.x << v.z, + s.x << v.w); + } + + template + GLM_FUNC_QUALIFIER tvec4 operator<<(tvec4 const & v1, tvec4 const & v2) { return tvec4( v1.x << v2.x, @@ -1113,11 +1195,7 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec4 operator>> - ( - tvec4 const & v, - T const & s - ) + GLM_FUNC_QUALIFIER tvec4 operator>>(tvec4 const & v, T const & s) { return tvec4( v.x >> s, @@ -1127,11 +1205,17 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec4 operator>> - ( - T const & s, - tvec4 const & v - ) + GLM_FUNC_QUALIFIER tvec4 operator>>(tvec4 const & v, tvec1 const & s) + { + return tvec4( + v.x >> s.x, + v.y >> s.x, + v.z >> s.x, + v.w >> s.x); + } + + template + GLM_FUNC_QUALIFIER tvec4 operator>>(T const & s, tvec4 const & v) { return tvec4( s >> v.x, @@ -1141,11 +1225,17 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec4 operator>> - ( - tvec4 const & v1, - tvec4 const & v2 - ) + GLM_FUNC_QUALIFIER tvec4 operator>>(tvec1 const & s, tvec4 const & v) + { + return tvec4( + s.x >> v.x, + s.x >> v.y, + s.x >> v.z, + s.x >> v.w); + } + + template + GLM_FUNC_QUALIFIER tvec4 operator>>(tvec4 const & v1, tvec4 const & v2) { return tvec4( v1.x >> v2.x, @@ -1155,10 +1245,7 @@ namespace glm } template - GLM_FUNC_QUALIFIER tvec4 operator~ - ( - tvec4 const & v - ) + GLM_FUNC_QUALIFIER tvec4 operator~(tvec4 const & v) { return tvec4( ~v.x, diff --git a/readme.txt b/readme.txt index 2c1d1d0a..511fd14a 100644 --- a/readme.txt +++ b/readme.txt @@ -50,7 +50,7 @@ GLM 0.9.6.0: 2014-XX-XX - Added move contructors and assignment operators #141 - Use pragma once - Fixed Visual Studio 14 compiler warnings -- Added *vec1 support to *vec2 and *vec3 types +- Added GTC_vec1 extension, *vec1 support to *vec2 and *vec3 types - Limited extended integer type redifinition #233 - Improved linearRand: support precision and integers #230 - Added vec3 slerp #237 diff --git a/test/core/core_type_vec1.cpp b/test/core/core_type_vec1.cpp index 7b9c90fb..b0813911 100644 --- a/test/core/core_type_vec1.cpp +++ b/test/core/core_type_vec1.cpp @@ -8,9 +8,11 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #define GLM_SWIZZLE +#include #include +#include -int test_operators() +int test_vec1_operators() { int Error(0); @@ -38,7 +40,69 @@ int test_operators() return Error; } -int test_operator_increment() +int test_vec1_ctor() +{ + int Error = 0; + +/* +#if GLM_HAS_INITIALIZER_LISTS + { + glm::vec1 a{ 0 }; + std::vector v = { + {0.f}, + {4.f}, + {8.f}}; + } + + { + glm::dvec2 a{ 0 }; + std::vector v = { + {0.0}, + {4.0}, + {8.0}}; + } +#endif +*/ +#if GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE) + { + glm::vec2 A = glm::vec2(1.0f, 2.0f); + glm::vec2 B = A.xy; + glm::vec2 C(A.xy); + glm::vec2 D(A.xy()); + + Error += glm::all(glm::equal(A, B)) ? 0 : 1; + Error += glm::all(glm::equal(A, C)) ? 0 : 1; + Error += glm::all(glm::equal(A, D)) ? 0 : 1; + } +#endif// GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE) + + { + glm::vec2 A = glm::vec2(2.0f); + glm::vec2 B = glm::vec2(2.0f, 3.0f); + glm::vec2 C = glm::vec2(2.0f, 3.0); + //glm::vec2 D = glm::dvec2(2.0); // Build error TODO: What does the specification says? + glm::vec2 E(glm::dvec2(2.0)); + glm::vec2 F(glm::ivec2(2)); + } + + return Error; +} + +int test_vec1_size() +{ + int Error = 0; + + Error += sizeof(glm::vec1) == sizeof(glm::mediump_vec1) ? 0 : 1; + Error += 8 == sizeof(glm::mediump_vec1) ? 0 : 1; + Error += sizeof(glm::dvec1) == sizeof(glm::highp_dvec1) ? 0 : 1; + Error += 16 == sizeof(glm::highp_dvec1) ? 0 : 1; + Error += glm::vec1().length() == 2 ? 0 : 1; + Error += glm::dvec1().length() == 2 ? 0 : 1; + + return Error; +} + +int test_vec1_operator_increment() { int Error(0); @@ -69,8 +133,13 @@ int main() { int Error = 0; - Error += test_operators(); - Error += test_operator_increment(); + glm::vec1 v; + assert(v.length() == 1); + + Error += test_vec1_size(); + Error += test_vec1_ctor(); + Error += test_vec1_operators(); + Error += test_vec1_operator_increment(); return Error; } diff --git a/test/core/core_type_vec2.cpp b/test/core/core_type_vec2.cpp index c3cb3e6b..12a897e4 100644 --- a/test/core/core_type_vec2.cpp +++ b/test/core/core_type_vec2.cpp @@ -201,7 +201,7 @@ int test_vec2_ctor() { int Error = 0; -#if(GLM_HAS_INITIALIZER_LISTS) +#if GLM_HAS_INITIALIZER_LISTS { glm::vec2 a{ 0, 1 }; std::vector v = { @@ -219,7 +219,7 @@ int test_vec2_ctor() } #endif -#if(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)) +#if GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE) { glm::vec2 A = glm::vec2(1.0f, 2.0f); glm::vec2 B = A.xy; @@ -230,7 +230,7 @@ int test_vec2_ctor() Error += glm::all(glm::equal(A, C)) ? 0 : 1; Error += glm::all(glm::equal(A, D)) ? 0 : 1; } -#endif//(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)) +#endif// GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE) { glm::vec2 A = glm::vec2(2.0f); @@ -239,7 +239,6 @@ int test_vec2_ctor() //glm::vec2 D = glm::dvec2(2.0); // Build error TODO: What does the specification says? glm::vec2 E(glm::dvec2(2.0)); glm::vec2 F(glm::ivec2(2)); - } return Error;