From 2851081b66ef1914c9b69967a213c124f7868ea0 Mon Sep 17 00:00:00 2001 From: athile Date: Wed, 21 Sep 2011 16:49:42 -0400 Subject: [PATCH 1/6] Incremental work on improving swizzles. --- glm/core/_swizzle.hpp | 119 +++++++++++++++++++++++++++++------ test/core/core_type_vec3.cpp | 22 ++++--- 2 files changed, 115 insertions(+), 26 deletions(-) diff --git a/glm/core/_swizzle.hpp b/glm/core/_swizzle.hpp index 498d026f..b8bd3fff 100644 --- a/glm/core/_swizzle.hpp +++ b/glm/core/_swizzle.hpp @@ -56,21 +56,24 @@ namespace detail /*! Template parameters: - Type = type of scalar values (e.g. float, double) - Class = class the swizzle is applies to (e.g. vector3f) + ValueType = type of scalar values (e.g. float, double) + VecType = class the swizzle is applies to (e.g. vector3f) N = number of components in the vector (e.g. 3) E0...3 = what index the n-th element of this swizzle refers to */ - template + template struct swizzle_base { - typedef Derived derived_type; + typedef DerivedType derived_type; + typedef VecType vec_type; + typedef ValueType value_type; - swizzle_base& operator= (const Class& that) + swizzle_base& operator= (const VecType& that) { static const int offset_dst[4] = { E0, E1, E2, E3 }; - Type t[N]; + // Make a copy of the data in this == &that + ValueType t[N]; for (int i = 0; i < N; ++i) t[i] = that[i]; for (int i = 0; i < N; ++i) @@ -79,7 +82,7 @@ namespace detail return *this; } - swizzle_base& operator= (const Type& t) + swizzle_base& operator= (const ValueType& t) { static const int offset_dst[4] = { E0, E1, E2, E3 }; @@ -89,34 +92,80 @@ namespace detail return *this; } + void operator -= (const VecType& that) + { + static const int offset_dst[4] = { E0, E1, E2, E3 }; + + ValueType t[N]; + for (int i = 0; i < N; ++i) + t[i] = that[i]; + for (int i = 0; i < N; ++i) + elem(offset_dst[i]) -= t[i]; + } + + void operator += (const VecType& that) + { + static const int offset_dst[4] = { E0, E1, E2, E3 }; + + ValueType t[N]; + for (int i = 0; i < N; ++i) + t[i] = that[i]; + for (int i = 0; i < N; ++i) + elem(offset_dst[i]) += t[i]; + } + + void operator *= (const VecType& that) + { + static const int offset_dst[4] = { E0, E1, E2, E3 }; + + ValueType t[N]; + for (int i = 0; i < N; ++i) + t[i] = that[i]; + for (int i = 0; i < N; ++i) + elem(offset_dst[i]) *= t[i]; + } + + void operator /= (const VecType& that) + { + static const int offset_dst[4] = { E0, E1, E2, E3 }; + + ValueType t[N]; + for (int i = 0; i < N; ++i) + t[i] = that[i]; + for (int i = 0; i < N; ++i) + elem(offset_dst[i]) /= t[i]; + } + protected: - Type& elem (size_t i) { return (reinterpret_cast(_buffer))[i]; } - const Type& elem (size_t i) const { return (reinterpret_cast(_buffer))[i]; } + value_type& elem (size_t i) { return (reinterpret_cast(_buffer))[i]; } + const value_type& elem (size_t i) const { return (reinterpret_cast(_buffer))[i]; } // Use an opaque buffer to *ensure* the compiler doesn't call a constructor. // Otherwise, a vec4 containing all swizzles might end up with 1000s of // constructor calls - char _buffer[sizeof(Type) * N]; + char _buffer[sizeof(value_type) * N]; }; - template - struct swizzle_base + template + struct swizzle_base { - typedef Derived derived_type; + typedef DerivedType derived_type; + typedef VecType vec_type; + typedef ValueType value_type; struct Stub {}; swizzle_base& operator= (const Stub& that) {} protected: - Type& elem (size_t i) { return (reinterpret_cast(_buffer))[i]; } - const Type& elem (size_t i) const { return (reinterpret_cast(_buffer))[i]; } + value_type& elem (size_t i) { return (reinterpret_cast(_buffer))[i]; } + const value_type& elem (size_t i) const { return (reinterpret_cast(_buffer))[i]; } - char _buffer[sizeof(Type) * N]; + char _buffer[sizeof(value_type) * N]; }; //! Internal class for implementing swizzle operators template - struct swizzle2 : public swizzle_base, T,P,2,E0,E1,0,0,(E0 == E1)> + struct swizzle2 : public swizzle_base,T,P,2,E0,E1,0,0,(E0 == E1)> { using swizzle_base,T,P,2,E0,E1,0,0,(E0 == E1)>::operator=; P cast() const { return P(this->elem(E0), this->elem(E1)); } @@ -221,15 +270,49 @@ namespace detail return a OPERAND static_cast(b).cast(); \ } +#define _GLM_SWIZZLE_SCALAR_BINARY_OPERATOR_IMPLEMENTATION(OPERAND)\ + template \ + typename P operator OPERAND ( \ + const glm::detail::swizzle_base& a, \ + const typename T& b) \ + { \ + return static_cast(a).cast() OPERAND b; \ + } \ + \ + template \ + typename P operator OPERAND ( \ + const typename T& a, \ + const glm::detail::swizzle_base& b) \ + { \ + return a OPERAND static_cast(b).cast(); \ + } + +// +// To prevent the C++ syntax from getting *completely* overwhelming, define some alias macros +// +#define _GLM_SWIZZLE_TEMPLATE1 template +#define _GLM_SWIZZLE_TEMPLATE2 template +#define _GLM_SWIZZLE_TYPE1 glm::detail::swizzle_base +#define _GLM_SWIZZLE_TYPE2 glm::detail::swizzle_base + + _GLM_SWIZZLE_TEMPLATE1 typename S0::vec_type operator- (typename S0::value_type a, const _GLM_SWIZZLE_TYPE1& b) { return a - b; } + _GLM_SWIZZLE_BINARY_OPERATOR_IMPLEMENTATION(+) _GLM_SWIZZLE_BINARY_OPERATOR_IMPLEMENTATION(-) _GLM_SWIZZLE_BINARY_OPERATOR_IMPLEMENTATION(*) _GLM_SWIZZLE_BINARY_OPERATOR_IMPLEMENTATION(/) + _GLM_SWIZZLE_SCALAR_BINARY_OPERATOR_IMPLEMENTATION(*) + }//namespace detail }//namespace glm - +namespace glm +{ + /*_GLM_SWIZZLE_TEMPLATE2 typename S0::value_type dot (const _GLM_SWIZZLE_TYPE1& a, const _GLM_SWIZZLE_TYPE2& b) { return dot(a.cast(), b.cast()); } + _GLM_SWIZZLE_TEMPLATE1 typename S0::value_type dot (const _GLM_SWIZZLE_TYPE1& a, const typename S0::vec_type& b) { return dot(a.cast(), b); } + _GLM_SWIZZLE_TEMPLATE1 typename S0::value_type dot (const typename S0::vec_type& a, const _GLM_SWIZZLE_TYPE1& b) { return dot(a, b.cast()); }*/ +} #define _GLM_SWIZZLE2_2_MEMBERS(T,P,E0,E1) \ diff --git a/test/core/core_type_vec3.cpp b/test/core/core_type_vec3.cpp index b08b0c62..c4617582 100644 --- a/test/core/core_type_vec3.cpp +++ b/test/core/core_type_vec3.cpp @@ -239,14 +239,20 @@ vec4 grad4(float j, vec4 ip) const vec4 ones = vec4(1.0, 1.0, 1.0, -1.0); vec4 p,s; - p.xyz = floor( fract (vec3(j) * ip.xyz) * 7.0) * ip.z - 1.0; - p.w = 1.5 - dot(abs(p.xyz), ones.xyz); + auto t1 = abs(p.xyz); + auto t2 = ones.xyz; + auto t3 = dot(t1, t2); + auto t0 = dot(abs(p.xyz), ones.xyz); + + p.xyz = floor( fract (vec3(j) * ip.xyz) * 7.0f) * ip.z - 1.0f; + p.w = 1.5f - dot(abs(p.xyz), ones.xyz); s = vec4(lessThan(p, vec4(0.0))); - p.xyz = p.xyz + (s.xyz*2.0 - 1.0) * s.www; + p.xyz = p.xyz + (s.xyz*2.0f - 1.0f) * s.www; return p; } + float snoise(vec4 v) { const vec4 C = vec4( 0.138196601125011, // (5 - sqrt(5))/20 G4 @@ -269,12 +275,12 @@ float snoise(vec4 v) vec3 isYZ = step( x0.zww, x0.yyz ); // i0.x = dot( isX, vec3( 1.0 ) ); i0.x = isX.x + isX.y + isX.z; - i0.yzw = 1.0 - isX; + i0.yzw = 1.0f - isX; // i0.y += dot( isYZ.xy, vec2( 1.0 ) ); i0.y += isYZ.x + isYZ.y; - i0.zw += 1.0 - isYZ.xy; + i0.zw += 1.0f - isYZ.xy; i0.z += isYZ.z; - i0.w += 1.0 - isYZ.z; + i0.w += 1.0f - isYZ.z; // i0 now contains the unique values 0,1,2,3 in each channel vec4 i3 = clamp( i0, 0.0, 1.0 ); @@ -319,8 +325,8 @@ float snoise(vec4 v) p4 *= taylorInvSqrt(dot(p4,p4)); // Mix contributions from the five corners - vec3 m0 = max(0.6 - vec3(dot(x0,x0), dot(x1,x1), dot(x2,x2)), 0.0); - vec2 m1 = max(0.6 - vec2(dot(x3,x3), dot(x4,x4) ), 0.0); + vec3 m0 = max(0.6f - vec3(dot(x0,x0), dot(x1,x1), dot(x2,x2)), 0.0); + vec2 m1 = max(0.6f - vec2(dot(x3,x3), dot(x4,x4) ), 0.0); m0 = m0 * m0; m1 = m1 * m1; return 49.0 * ( dot(m0*m0, vec3( dot( p0, x0 ), dot( p1, x1 ), dot( p2, x2 ))) From 6dee4eabc4fc128c302930a578bf86699a436361 Mon Sep 17 00:00:00 2001 From: athile Date: Wed, 21 Sep 2011 20:09:34 -0400 Subject: [PATCH 2/6] WIP swizzle. Note: glm::dot() now working for swizzled vec3, but mysteriously not for vec2 or vec4. --- glm/core/_swizzle.hpp | 97 +++++++++++++++++++----------------- test/core/core_type_vec3.cpp | 34 +++++++++++++ 2 files changed, 85 insertions(+), 46 deletions(-) diff --git a/glm/core/_swizzle.hpp b/glm/core/_swizzle.hpp index b8bd3fff..5e943a88 100644 --- a/glm/core/_swizzle.hpp +++ b/glm/core/_swizzle.hpp @@ -242,51 +242,9 @@ namespace detail { using swizzle_base,T,P,4,E0,E1,E2,0,(E0==E1||E0==E2||E1==E2)>::operator=; P cast() const { return P(this->elem(E0), this->elem(E1), this->elem(E2)); } - operator P () { return cast(); } + operator P () const { return cast(); } }; -#define _GLM_SWIZZLE_BINARY_OPERATOR_IMPLEMENTATION(OPERAND)\ - template \ - typename P operator OPERAND ( \ - const glm::detail::swizzle_base& a, \ - const glm::detail::swizzle_base& b) \ - { \ - return static_cast(a).cast() OPERAND static_cast(b).cast(); \ - } \ - \ - template \ - typename P operator OPERAND ( \ - const glm::detail::swizzle_base& a, \ - const typename P& b) \ - { \ - return static_cast(a).cast() OPERAND b; \ - } \ - \ - template \ - typename P operator OPERAND ( \ - const typename P& a, \ - const glm::detail::swizzle_base& b) \ - { \ - return a OPERAND static_cast(b).cast(); \ - } - -#define _GLM_SWIZZLE_SCALAR_BINARY_OPERATOR_IMPLEMENTATION(OPERAND)\ - template \ - typename P operator OPERAND ( \ - const glm::detail::swizzle_base& a, \ - const typename T& b) \ - { \ - return static_cast(a).cast() OPERAND b; \ - } \ - \ - template \ - typename P operator OPERAND ( \ - const typename T& a, \ - const glm::detail::swizzle_base& b) \ - { \ - return a OPERAND static_cast(b).cast(); \ - } - // // To prevent the C++ syntax from getting *completely* overwhelming, define some alias macros // @@ -295,6 +253,52 @@ namespace detail #define _GLM_SWIZZLE_TYPE1 glm::detail::swizzle_base #define _GLM_SWIZZLE_TYPE2 glm::detail::swizzle_base +#define _GLM_SWIZZLE_BINARY_OPERATOR_IMPLEMENTATION(OPERAND)\ + _GLM_SWIZZLE_TEMPLATE2 \ + typename P operator OPERAND ( const _GLM_SWIZZLE_TYPE1& a, const _GLM_SWIZZLE_TYPE2& b) \ + { \ + return static_cast(a).cast() OPERAND static_cast(b).cast(); \ + } \ + _GLM_SWIZZLE_TEMPLATE1 \ + typename P operator OPERAND ( const _GLM_SWIZZLE_TYPE1& a, const typename P& b) \ + { \ + return static_cast(a).cast() OPERAND b; \ + } \ + _GLM_SWIZZLE_TEMPLATE1 \ + typename P operator OPERAND ( const typename P& a, const _GLM_SWIZZLE_TYPE1& b) \ + { \ + return a OPERAND static_cast(b).cast(); \ + } + +#define _GLM_SWIZZLE_SCALAR_BINARY_OPERATOR_IMPLEMENTATION(OPERAND)\ + _GLM_SWIZZLE_TEMPLATE1 \ + typename P operator OPERAND ( const _GLM_SWIZZLE_TYPE1& a, const typename T& b) \ + { \ + return static_cast(a).cast() OPERAND b; \ + } \ + _GLM_SWIZZLE_TEMPLATE1 \ + typename P operator OPERAND ( const typename T& a, const _GLM_SWIZZLE_TYPE1& b) \ + { \ + return a OPERAND static_cast(b).cast(); \ + } + +#define _GLM_SWIZZLE_FUNCTION2(RETURN_TYPE,FUNCTION)\ + _GLM_SWIZZLE_TEMPLATE2\ + typename S0::RETURN_TYPE FUNCTION(const typename _GLM_SWIZZLE_TYPE1& a, const typename _GLM_SWIZZLE_TYPE2& b)\ + {\ + return FUNCTION(static_cast(a).cast(), static_cast(b).cast());\ + }\ + _GLM_SWIZZLE_TEMPLATE1\ + typename S0::RETURN_TYPE FUNCTION(const typename _GLM_SWIZZLE_TYPE1& a, const typename S0::vec_type& b)\ + {\ + return FUNCTION(static_cast(a).cast(), b);\ + }\ + _GLM_SWIZZLE_TEMPLATE1\ + typename S0::RETURN_TYPE FUNCTION(const typename S0::vec_type& a, const typename _GLM_SWIZZLE_TYPE1& b)\ + {\ + return FUNCTION(a, static_cast(b).cast());\ + } + _GLM_SWIZZLE_TEMPLATE1 typename S0::vec_type operator- (typename S0::value_type a, const _GLM_SWIZZLE_TYPE1& b) { return a - b; } _GLM_SWIZZLE_BINARY_OPERATOR_IMPLEMENTATION(+) @@ -309,9 +313,10 @@ namespace detail namespace glm { - /*_GLM_SWIZZLE_TEMPLATE2 typename S0::value_type dot (const _GLM_SWIZZLE_TYPE1& a, const _GLM_SWIZZLE_TYPE2& b) { return dot(a.cast(), b.cast()); } - _GLM_SWIZZLE_TEMPLATE1 typename S0::value_type dot (const _GLM_SWIZZLE_TYPE1& a, const typename S0::vec_type& b) { return dot(a.cast(), b); } - _GLM_SWIZZLE_TEMPLATE1 typename S0::value_type dot (const typename S0::vec_type& a, const _GLM_SWIZZLE_TYPE1& b) { return dot(a, b.cast()); }*/ + + + _GLM_SWIZZLE_FUNCTION2(value_type, dot); + _GLM_SWIZZLE_FUNCTION2(vec_type, abs); } diff --git a/test/core/core_type_vec3.cpp b/test/core/core_type_vec3.cpp index c4617582..87572df3 100644 --- a/test/core/core_type_vec3.cpp +++ b/test/core/core_type_vec3.cpp @@ -196,6 +196,39 @@ int test_vec3_swizzle_operators() return Error; } +int test_vec3_swizzle_functions() +{ + int Error = 0; + + // vec3 - working as expected + glm::vec3 q, u, v; + u = glm::vec3(1, 2, 3); + v = glm::vec3(10, 20, 30); + glm::dot(u, v); + glm::dot(u.xyz, v.zyz); + glm::dot(u, v.zyx); + glm::dot(u.xyz, v); + + // vec2 - not working! how is vec3 working and not vec2? + glm::vec2 a, b; + glm::dot(a, b); + glm::dot(a.xy, b.xy); + //glm::dot(u.xy, v.xy); + + glm::dot(glm::vec4(1,2,3,4).xyz, v); + + glm::vec4 r, s, t; + + r = glm::vec4(1, 2, 3, 4); + s = glm::vec4(10, 20, 30, 40); + + glm::dot(r, s); + //glm::dot(r.xyzw, s.xyzw); + //glm::dot(r.xyz, s.xyz); + + return Error; +} + #if 0 using namespace glm; @@ -345,6 +378,7 @@ int main() Error += test_vec3_swizzle3_3(); Error += test_vec3_swizzle_half(); Error += test_vec3_swizzle_operators(); + Error += test_vec3_swizzle_functions(); return Error; } From a762f19861fc0c54b357393af3b28e3a4bd3269b Mon Sep 17 00:00:00 2001 From: athile Date: Thu, 22 Sep 2011 14:56:39 -0400 Subject: [PATCH 3/6] Further swizzle work. --- glm/core/_swizzle.hpp | 284 ++++++++--- glm/core/func_geometric.inl | 1 + glm/core/type_vec2.hpp | 16 + glm/core/type_vec3.hpp | 16 + glm/core/type_vec4.hpp | 16 + test/core/core_type_vec3.cpp | 901 +++++++++++++++++++++-------------- 6 files changed, 816 insertions(+), 418 deletions(-) diff --git a/glm/core/_swizzle.hpp b/glm/core/_swizzle.hpp index 5e943a88..439ac028 100644 --- a/glm/core/_swizzle.hpp +++ b/glm/core/_swizzle.hpp @@ -48,7 +48,6 @@ namespace glm }; }//namespace glm - namespace glm{ namespace detail { @@ -58,8 +57,8 @@ namespace detail ValueType = type of scalar values (e.g. float, double) VecType = class the swizzle is applies to (e.g. vector3f) - N = number of components in the vector (e.g. 3) - E0...3 = what index the n-th element of this swizzle refers to + N = number of components in the vector (e.g. 3) + E0...3 = what index the n-th element of this swizzle refers to in the unswizzled vec */ template struct swizzle_base @@ -68,20 +67,6 @@ namespace detail typedef VecType vec_type; typedef ValueType value_type; - swizzle_base& operator= (const VecType& that) - { - static const int offset_dst[4] = { E0, E1, E2, E3 }; - - // Make a copy of the data in this == &that - ValueType t[N]; - for (int i = 0; i < N; ++i) - t[i] = that[i]; - for (int i = 0; i < N; ++i) - elem(offset_dst[i]) = t[i]; - - return *this; - } - swizzle_base& operator= (const ValueType& t) { static const int offset_dst[4] = { E0, E1, E2, E3 }; @@ -92,51 +77,61 @@ namespace detail return *this; } + swizzle_base& operator= (const VecType& that) + { + struct op { + void operator() (value_type& e, value_type& t) { e = t; } + }; + _apply_op(that, op()); + return *this; + } + void operator -= (const VecType& that) { - static const int offset_dst[4] = { E0, E1, E2, E3 }; - - ValueType t[N]; - for (int i = 0; i < N; ++i) - t[i] = that[i]; - for (int i = 0; i < N; ++i) - elem(offset_dst[i]) -= t[i]; + struct op { + void operator() (value_type& e, value_type& t) { e -= t; } + }; + _apply_op(that, op()); } void operator += (const VecType& that) { - static const int offset_dst[4] = { E0, E1, E2, E3 }; - - ValueType t[N]; - for (int i = 0; i < N; ++i) - t[i] = that[i]; - for (int i = 0; i < N; ++i) - elem(offset_dst[i]) += t[i]; + struct op { + void operator() (value_type& e, value_type& t) { e += t; } + }; + _apply_op(that, op()); } void operator *= (const VecType& that) { - static const int offset_dst[4] = { E0, E1, E2, E3 }; - - ValueType t[N]; - for (int i = 0; i < N; ++i) - t[i] = that[i]; - for (int i = 0; i < N; ++i) - elem(offset_dst[i]) *= t[i]; + struct op { + void operator() (value_type& e, value_type& t) { e *= t; } + }; + _apply_op(that, op()); } void operator /= (const VecType& that) + { + struct op { + void operator() (value_type& e, value_type& t) { e /= t; } + }; + _apply_op(that, op()); + } + + protected: + template + void _apply_op(const VecType& that, T op) { static const int offset_dst[4] = { E0, E1, E2, E3 }; + // Make a copy of the data in this == &that ValueType t[N]; for (int i = 0; i < N; ++i) t[i] = that[i]; for (int i = 0; i < N; ++i) - elem(offset_dst[i]) /= t[i]; + op( elem(offset_dst[i]), t[i] ); } - protected: value_type& elem (size_t i) { return (reinterpret_cast(_buffer))[i]; } const value_type& elem (size_t i) const { return (reinterpret_cast(_buffer))[i]; } @@ -169,6 +164,7 @@ namespace detail { using swizzle_base,T,P,2,E0,E1,0,0,(E0 == E1)>::operator=; P cast() const { return P(this->elem(E0), this->elem(E1)); } + P operator ()() const { return cast(); } operator P () const { return cast(); } }; @@ -178,6 +174,7 @@ namespace detail { using swizzle_base,T,P,2,E0,E1,E2,0,1>::operator=; P cast() const { return P(this->elem(E0), this->elem(E1), this->elem(E2)); } + P operator ()() const { return cast(); } operator P () const { return cast(); } }; @@ -187,6 +184,7 @@ namespace detail { using swizzle_base,T,P,2,E0,E1,E2,E3,1>::operator=; P cast() const { return P(this->elem(E0), this->elem(E1), this->elem(E2), this->elem(E3)); } + P operator ()() const { return cast(); } operator P () const { return cast(); } }; @@ -196,6 +194,7 @@ namespace detail { using swizzle_base,T,P,3,E0,E1,E2,0,(E0==E1||E0==E2||E1==E2)>::operator=; P cast() const { return P(this->elem(E0), this->elem(E1), this->elem(E2)); } + P operator ()() const { return cast(); } operator P () const { return cast(); } }; @@ -205,6 +204,7 @@ namespace detail { using swizzle_base,T,P,2,E0,E1,0,0,(E0==E1)>::operator=; P cast() const { return P(this->elem(E0), this->elem(E1)); } + P operator ()() const { return cast(); } operator P () const { return cast(); } }; @@ -214,6 +214,7 @@ namespace detail { using swizzle_base,T,P,3,E0,E1,E2,E3,1>::operator=; P cast() const { return P(this->elem(E0), this->elem(E1), this->elem(E2), this->elem(E3)); } + P operator ()() const { return cast(); } operator P () const { return cast(); } }; @@ -223,6 +224,7 @@ namespace detail { using swizzle_base,T,P,4,E0,E1,E2,E3,(E0==E1||E0==E2||E0==E3||E1==E2||E1==E3||E2==E3)>::operator=; P cast() const { return P(this->elem(E0), this->elem(E1), this->elem(E2), this->elem(E3)); } + P operator ()() const { return cast(); } operator P () const { return cast(); } }; @@ -232,6 +234,7 @@ namespace detail { using swizzle_base,T,P,2,E0,E1,0,0,(E0==E1)>::operator=; P cast() const { return P(this->elem(E0), this->elem(E1)); } + P operator ()() const { return cast(); } operator P () const { return cast(); } }; @@ -242,18 +245,19 @@ namespace detail { using swizzle_base,T,P,4,E0,E1,E2,0,(E0==E1||E0==E2||E1==E2)>::operator=; P cast() const { return P(this->elem(E0), this->elem(E1), this->elem(E2)); } + P operator ()() const { return cast(); } operator P () const { return cast(); } }; // -// To prevent the C++ syntax from getting *completely* overwhelming, define some alias macros +// To prevent the C++ syntax from getting entirely overwhelming, define some alias macros // #define _GLM_SWIZZLE_TEMPLATE1 template #define _GLM_SWIZZLE_TEMPLATE2 template #define _GLM_SWIZZLE_TYPE1 glm::detail::swizzle_base #define _GLM_SWIZZLE_TYPE2 glm::detail::swizzle_base -#define _GLM_SWIZZLE_BINARY_OPERATOR_IMPLEMENTATION(OPERAND)\ +#define _GLM_SWIZZLE_VECTOR_BINARY_OPERATOR_IMPLEMENTATION(OPERAND)\ _GLM_SWIZZLE_TEMPLATE2 \ typename P operator OPERAND ( const _GLM_SWIZZLE_TYPE1& a, const _GLM_SWIZZLE_TYPE2& b) \ { \ @@ -282,13 +286,65 @@ namespace detail return a OPERAND static_cast(b).cast(); \ } -#define _GLM_SWIZZLE_FUNCTION2(RETURN_TYPE,FUNCTION)\ +#define _GLM_SWIZZLE_FUNCTION_1_ARGS(RETURN_TYPE,FUNCTION)\ + template \ + typename glm::detail::swizzle2::RETURN_TYPE FUNCTION(const glm::detail::swizzle2& a) \ + { \ + return FUNCTION(a.cast()); \ + } \ + template \ + typename glm::detail::swizzle2_3::RETURN_TYPE FUNCTION(const glm::detail::swizzle2_3& a) \ + { \ + return FUNCTION(a.cast()); \ + } \ + template \ + typename glm::detail::swizzle2_4::RETURN_TYPE FUNCTION(const glm::detail::swizzle2_4& a) \ + { \ + return FUNCTION(a.cast()); \ + } \ + template \ + typename glm::detail::swizzle3_2::RETURN_TYPE FUNCTION(const glm::detail::swizzle3_2& a) \ + { \ + return FUNCTION(a.cast()); \ + } \ + template \ + typename glm::detail::swizzle3::RETURN_TYPE FUNCTION(const glm::detail::swizzle3& a) \ + { \ + return FUNCTION(a.cast()); \ + } \ + template \ + typename glm::detail::swizzle3_4::RETURN_TYPE FUNCTION(const glm::detail::swizzle3_4& a) \ + { \ + return FUNCTION(a.cast()); \ + } \ + template \ + typename glm::detail::swizzle4_2::RETURN_TYPE FUNCTION(const glm::detail::swizzle4_2& a) \ + { \ + return FUNCTION(a.cast()); \ + } \ + template \ + typename glm::detail::swizzle4_3::RETURN_TYPE FUNCTION(const glm::detail::swizzle4_3& a) \ + { \ + return FUNCTION(a.cast()); \ + } \ + template \ + typename glm::detail::swizzle4::RETURN_TYPE FUNCTION(const glm::detail::swizzle4& a) \ + { \ + return FUNCTION(a.cast()); \ + } + +#define _GLM_SWIZZLE_FUNCTION_2_ARGS(RETURN_TYPE,FUNCTION)\ _GLM_SWIZZLE_TEMPLATE2\ typename S0::RETURN_TYPE FUNCTION(const typename _GLM_SWIZZLE_TYPE1& a, const typename _GLM_SWIZZLE_TYPE2& b)\ {\ return FUNCTION(static_cast(a).cast(), static_cast(b).cast());\ }\ _GLM_SWIZZLE_TEMPLATE1\ + typename S0::RETURN_TYPE FUNCTION(const typename _GLM_SWIZZLE_TYPE1& a, const typename _GLM_SWIZZLE_TYPE1& b)\ + {\ + return FUNCTION(static_cast(a).cast(), static_cast(b).cast());\ + }\ + _GLM_SWIZZLE_TEMPLATE1\ typename S0::RETURN_TYPE FUNCTION(const typename _GLM_SWIZZLE_TYPE1& a, const typename S0::vec_type& b)\ {\ return FUNCTION(static_cast(a).cast(), b);\ @@ -297,26 +353,146 @@ namespace detail typename S0::RETURN_TYPE FUNCTION(const typename S0::vec_type& a, const typename _GLM_SWIZZLE_TYPE1& b)\ {\ return FUNCTION(a, static_cast(b).cast());\ + } \ + template \ + typename glm::detail::swizzle2::RETURN_TYPE FUNCTION(const glm::detail::swizzle2& a, const glm::detail::swizzle2& b) \ + { \ + return FUNCTION(a.cast(), b.cast()); \ + } \ + template \ + typename glm::detail::swizzle2_3::RETURN_TYPE FUNCTION(const glm::detail::swizzle2_3& a, const glm::detail::swizzle2_3& b) \ + { \ + return FUNCTION(a.cast(), b.cast()); \ + } \ + template \ + typename glm::detail::swizzle2_4::RETURN_TYPE FUNCTION(const glm::detail::swizzle2_4& a, const glm::detail::swizzle2_4& b) \ + { \ + return FUNCTION(a.cast(), b.cast()); \ + } \ + template \ + typename glm::detail::swizzle3_2::RETURN_TYPE FUNCTION(const glm::detail::swizzle3_2& a, const glm::detail::swizzle3_2& b) \ + { \ + return FUNCTION(a.cast(), b.cast()); \ + } \ + template \ + typename glm::detail::swizzle3::RETURN_TYPE FUNCTION(const glm::detail::swizzle3& a, const glm::detail::swizzle3& b) \ + { \ + return FUNCTION(a.cast(), b.cast()); \ + } \ + template \ + typename glm::detail::swizzle3_4::RETURN_TYPE FUNCTION(const glm::detail::swizzle3_4& a, const glm::detail::swizzle3_4& b) \ + { \ + return FUNCTION(a.cast(), b.cast()); \ + } \ + template \ + typename glm::detail::swizzle4_2::RETURN_TYPE FUNCTION(const glm::detail::swizzle4_2& a, const glm::detail::swizzle4_2& b) \ + { \ + return FUNCTION(a.cast(), b.cast()); \ + } \ + template \ + typename glm::detail::swizzle4_3::RETURN_TYPE FUNCTION(const glm::detail::swizzle4_3& a, const glm::detail::swizzle4_3& b) \ + { \ + return FUNCTION(a.cast(), b.cast()); \ + } \ + template \ + typename glm::detail::swizzle4::RETURN_TYPE FUNCTION(const glm::detail::swizzle4& a, const glm::detail::swizzle4& b) \ + { \ + return FUNCTION(a.cast(), b.cast()); \ } - _GLM_SWIZZLE_TEMPLATE1 typename S0::vec_type operator- (typename S0::value_type a, const _GLM_SWIZZLE_TYPE1& b) { return a - b; } - - _GLM_SWIZZLE_BINARY_OPERATOR_IMPLEMENTATION(+) - _GLM_SWIZZLE_BINARY_OPERATOR_IMPLEMENTATION(-) - _GLM_SWIZZLE_BINARY_OPERATOR_IMPLEMENTATION(*) - _GLM_SWIZZLE_BINARY_OPERATOR_IMPLEMENTATION(/) - - _GLM_SWIZZLE_SCALAR_BINARY_OPERATOR_IMPLEMENTATION(*) +#define _GLM_SWIZZLE_FUNCTION_2_ARGS_SCALAR(RETURN_TYPE,FUNCTION)\ + _GLM_SWIZZLE_TEMPLATE2\ + typename S0::RETURN_TYPE FUNCTION(const typename _GLM_SWIZZLE_TYPE1& a, const typename _GLM_SWIZZLE_TYPE2& b, const typename S0::value_type& c)\ + {\ + return FUNCTION(static_cast(a).cast(), static_cast(b).cast(), c);\ + }\ + _GLM_SWIZZLE_TEMPLATE1\ + typename S0::RETURN_TYPE FUNCTION(const typename _GLM_SWIZZLE_TYPE1& a, const typename _GLM_SWIZZLE_TYPE1& b, const typename S0::value_type& c)\ + {\ + return FUNCTION(static_cast(a).cast(), static_cast(b).cast(), c);\ + }\ + _GLM_SWIZZLE_TEMPLATE1\ + typename S0::RETURN_TYPE FUNCTION(const typename _GLM_SWIZZLE_TYPE1& a, const typename S0::vec_type& b, const typename S0::value_type& c)\ + {\ + return FUNCTION(static_cast(a).cast(), b, c);\ + }\ + _GLM_SWIZZLE_TEMPLATE1\ + typename S0::RETURN_TYPE FUNCTION(const typename S0::vec_type& a, const typename _GLM_SWIZZLE_TYPE1& b, const typename S0::value_type& c)\ + {\ + return FUNCTION(a, static_cast(b).cast(), c);\ + } \ + template \ + typename glm::detail::swizzle2::RETURN_TYPE FUNCTION(const glm::detail::swizzle2& a, const glm::detail::swizzle2& b, const T& c) \ + { \ + return FUNCTION(a.cast(), b.cast(), c); \ + } \ + template \ + typename glm::detail::swizzle2_3::RETURN_TYPE FUNCTION(const glm::detail::swizzle2_3& a, const glm::detail::swizzle2_3& b, const T& c) \ + { \ + return FUNCTION(a.cast(), b.cast(), c); \ + } \ + template \ + typename glm::detail::swizzle2_4::RETURN_TYPE FUNCTION(const glm::detail::swizzle2_4& a, const glm::detail::swizzle2_4& b, const T& c) \ + { \ + return FUNCTION(a.cast(), b.cast(), c); \ + } \ + template \ + typename glm::detail::swizzle3_2::RETURN_TYPE FUNCTION(const glm::detail::swizzle3_2& a, const glm::detail::swizzle3_2& b, const T& c) \ + { \ + return FUNCTION(a.cast(), b.cast(), c); \ + } \ + template \ + typename glm::detail::swizzle3::RETURN_TYPE FUNCTION(const glm::detail::swizzle3& a, const glm::detail::swizzle3& b, const T& c) \ + { \ + return FUNCTION(a.cast(), b.cast(), c); \ + } + template \ + typename glm::detail::swizzle3_4::RETURN_TYPE FUNCTION(const glm::detail::swizzle3_4& a, const glm::detail::swizzle3_4& b, const T& c) \ + { \ + return FUNCTION(a.cast(), b.cast(), c); \ + } \ + template \ + typename glm::detail::swizzle4_2::RETURN_TYPE FUNCTION(const glm::detail::swizzle4_2& a, const glm::detail::swizzle4_2& b, const T& c) \ + { \ + return FUNCTION(a.cast(), b.cast(), c); \ + } \ + template \ + typename glm::detail::swizzle4_3::RETURN_TYPE FUNCTION(const glm::detail::swizzle4_3& a, const glm::detail::swizzle4_3& b, const T& c) \ + { \ + return FUNCTION(a.cast(), b.cast(), c); \ + } \ + template \ + typename glm::detail::swizzle4::RETURN_TYPE FUNCTION(const glm::detail::swizzle4& a, const glm::detail::swizzle4& b, const T& c) \ + { \ + return FUNCTION(a.cast(), b.cast(), c); \ + } }//namespace detail }//namespace glm namespace glm { - + namespace detail + { + _GLM_SWIZZLE_SCALAR_BINARY_OPERATOR_IMPLEMENTATION(-) + _GLM_SWIZZLE_SCALAR_BINARY_OPERATOR_IMPLEMENTATION(*) - _GLM_SWIZZLE_FUNCTION2(value_type, dot); - _GLM_SWIZZLE_FUNCTION2(vec_type, abs); + _GLM_SWIZZLE_VECTOR_BINARY_OPERATOR_IMPLEMENTATION(+) + _GLM_SWIZZLE_VECTOR_BINARY_OPERATOR_IMPLEMENTATION(-) + _GLM_SWIZZLE_VECTOR_BINARY_OPERATOR_IMPLEMENTATION(*) + _GLM_SWIZZLE_VECTOR_BINARY_OPERATOR_IMPLEMENTATION(/) + } + + _GLM_SWIZZLE_FUNCTION_1_ARGS(vec_type, abs); + _GLM_SWIZZLE_FUNCTION_1_ARGS(vec_type, acos); + _GLM_SWIZZLE_FUNCTION_1_ARGS(vec_type, acosh); + _GLM_SWIZZLE_FUNCTION_1_ARGS(vec_type, all); + _GLM_SWIZZLE_FUNCTION_1_ARGS(vec_type, any); + + _GLM_SWIZZLE_FUNCTION_2_ARGS(value_type, dot); + _GLM_SWIZZLE_FUNCTION_2_ARGS(vec_type, cross); + _GLM_SWIZZLE_FUNCTION_2_ARGS(vec_type, step); + _GLM_SWIZZLE_FUNCTION_2_ARGS_SCALAR(vec_type, mix); } diff --git a/glm/core/func_geometric.inl b/glm/core/func_geometric.inl index f83b590c..26a6b64e 100644 --- a/glm/core/func_geometric.inl +++ b/glm/core/func_geometric.inl @@ -132,6 +132,7 @@ namespace glm ( genType const & x, genType const & y + ) { GLM_STATIC_ASSERT(detail::type::is_float, "'dot' only accept floating-point inputs"); diff --git a/glm/core/type_vec2.hpp b/glm/core/type_vec2.hpp index a28fa6e7..c93157bb 100644 --- a/glm/core/type_vec2.hpp +++ b/glm/core/type_vec2.hpp @@ -114,6 +114,22 @@ namespace detail tvec2(tref2 const & r); + template + GLM_FUNC_DECL tvec2(glm::detail::swizzle2,E0,E1>& that) + { + *this = that(); + } + template + GLM_FUNC_DECL tvec2(glm::detail::swizzle3_2,E0,E1>& that) + { + *this = that(); + } + template + GLM_FUNC_DECL tvec2(glm::detail::swizzle4_2,E0,E1>& that) + { + *this = that(); + } + ////////////////////////////////////// // Convertion constructors diff --git a/glm/core/type_vec3.hpp b/glm/core/type_vec3.hpp index 8a6ababc..e65463f2 100644 --- a/glm/core/type_vec3.hpp +++ b/glm/core/type_vec3.hpp @@ -116,6 +116,22 @@ namespace detail GLM_FUNC_DECL tvec3(tref3 const & r); + template + GLM_FUNC_DECL tvec3(glm::detail::swizzle2_3,E0,E1,E2>& that) + { + *this = that(); + } + template + GLM_FUNC_DECL tvec3(glm::detail::swizzle3,E0,E1,E2>& that) + { + *this = that(); + } + template + GLM_FUNC_DECL tvec3(glm::detail::swizzle4_3,E0,E1,E2>& that) + { + *this = that(); + } + ////////////////////////////////////// // Convertion scalar constructors diff --git a/glm/core/type_vec4.hpp b/glm/core/type_vec4.hpp index 5761bcdd..296e1641 100644 --- a/glm/core/type_vec4.hpp +++ b/glm/core/type_vec4.hpp @@ -118,6 +118,22 @@ namespace detail GLM_FUNC_DECL tvec4(tref4 const & r); + template + GLM_FUNC_DECL tvec4(glm::detail::swizzle2_4,E0,E1,E2,E3>& that) + { + *this = that(); + } + template + GLM_FUNC_DECL tvec4(glm::detail::swizzle3_4,E0,E1,E2,E3>& that) + { + *this = that(); + } + template + GLM_FUNC_DECL tvec4(glm::detail::swizzle4,E0,E1,E2,E3>& that) + { + *this = that(); + } + ////////////////////////////////////// // Convertion scalar constructors diff --git a/test/core/core_type_vec3.cpp b/test/core/core_type_vec3.cpp index 87572df3..fb7add27 100644 --- a/test/core/core_type_vec3.cpp +++ b/test/core/core_type_vec3.cpp @@ -1,260 +1,264 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////// -// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net) -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Created : 2008-08-31 -// Updated : 2011-09-19 -// Licence : This source is under MIT License -// File : test/core/type_vec3.cpp -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#include -#include - -static int test_vec3_operators() -{ - glm::vec3 A(1.0f); - glm::vec3 B(1.0f); - bool R = A != B; - bool S = A == B; - - return (S && !R) ? 0 : 1; -} - -int test_vec3_size() -{ - int Error = 0; - - Error += sizeof(glm::vec3) == sizeof(glm::mediump_vec3) ? 0 : 1; - Error += 12 == sizeof(glm::mediump_vec3) ? 0 : 1; - Error += sizeof(glm::dvec3) == sizeof(glm::highp_vec3) ? 0 : 1; - Error += 24 == sizeof(glm::highp_vec3) ? 0 : 1; - Error += glm::vec3().length() == 3 ? 0 : 1; - Error += glm::dvec3().length() == 3 ? 0 : 1; - - return Error; -} - -int test_vec3_swizzle3_2() -{ - int Error = 0; - - glm::vec3 v(1, 2, 3); - glm::vec2 u; - - // Can not assign a vec3 swizzle to a vec2 - //u = v.xyz; //Illegal - //u = v.rgb; //Illegal - //u = v.stp; //Illegal - - u = v.xx; Error += (u.x == 1.0f && u.y == 1.0f) ? 0 : 1; - u = v.xy; Error += (u.x == 1.0f && u.y == 2.0f) ? 0 : 1; - u = v.xz; Error += (u.x == 1.0f && u.y == 3.0f) ? 0 : 1; - u = v.yx; Error += (u.x == 2.0f && u.y == 1.0f) ? 0 : 1; - u = v.yy; Error += (u.x == 2.0f && u.y == 2.0f) ? 0 : 1; - u = v.yz; Error += (u.x == 2.0f && u.y == 3.0f) ? 0 : 1; - u = v.zx; Error += (u.x == 3.0f && u.y == 1.0f) ? 0 : 1; - u = v.zy; Error += (u.x == 3.0f && u.y == 2.0f) ? 0 : 1; - u = v.zz; Error += (u.x == 3.0f && u.y == 3.0f) ? 0 : 1; - - u = v.rr; Error += (u.r == 1.0f && u.g == 1.0f) ? 0 : 1; - u = v.rg; Error += (u.r == 1.0f && u.g == 2.0f) ? 0 : 1; - u = v.rb; Error += (u.r == 1.0f && u.g == 3.0f) ? 0 : 1; - u = v.gr; Error += (u.r == 2.0f && u.g == 1.0f) ? 0 : 1; - u = v.gg; Error += (u.r == 2.0f && u.g == 2.0f) ? 0 : 1; - u = v.gb; Error += (u.r == 2.0f && u.g == 3.0f) ? 0 : 1; - u = v.br; Error += (u.r == 3.0f && u.g == 1.0f) ? 0 : 1; - u = v.bg; Error += (u.r == 3.0f && u.g == 2.0f) ? 0 : 1; - u = v.bb; Error += (u.r == 3.0f && u.g == 3.0f) ? 0 : 1; - - u = v.ss; Error += (u.s == 1.0f && u.t == 1.0f) ? 0 : 1; - u = v.st; Error += (u.s == 1.0f && u.t == 2.0f) ? 0 : 1; - u = v.sp; Error += (u.s == 1.0f && u.t == 3.0f) ? 0 : 1; - u = v.ts; Error += (u.s == 2.0f && u.t == 1.0f) ? 0 : 1; - u = v.tt; Error += (u.s == 2.0f && u.t == 2.0f) ? 0 : 1; - u = v.tp; Error += (u.s == 2.0f && u.t == 3.0f) ? 0 : 1; - u = v.ps; Error += (u.s == 3.0f && u.t == 1.0f) ? 0 : 1; - u = v.pt; Error += (u.s == 3.0f && u.t == 2.0f) ? 0 : 1; - u = v.pp; Error += (u.s == 3.0f && u.t == 3.0f) ? 0 : 1; - - // Mixed member aliases are not valid - //u = v.rx; //Illegal - //u = v.sy; //Illegal - - - u = glm::vec2(1, 2); - v = glm::vec3(1, 2, 3); - //v.xx = u; //Illegal - v.xy = u; Error += (v.x == 1.0f && v.y == 2.0f && v.z == 3.0f) ? 0 : 1; - v.xz = u; Error += (v.x == 1.0f && v.y == 2.0f && v.z == 2.0f) ? 0 : 1; - v.yx = u; Error += (v.x == 2.0f && v.y == 1.0f && v.z == 2.0f) ? 0 : 1; - //v.yy = u; //Illegal - v.yz = u; Error += (v.x == 2.0f && v.y == 1.0f && v.z == 2.0f) ? 0 : 1; - v.zx = u; Error += (v.x == 2.0f && v.y == 1.0f && v.z == 1.0f) ? 0 : 1; - v.zy = u; Error += (v.x == 2.0f && v.y == 2.0f && v.z == 1.0f) ? 0 : 1; - //v.zz = u; //Illegal - - return Error; -} - -int test_vec3_swizzle3_3() -{ - int Error = 0; - - glm::vec3 v(1, 2, 3); - glm::vec3 u; - - u = v; Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1; - - u = v.xyz; Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1; - u = v.zyx; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1; - u.zyx = v; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1; - - u = v.rgb; Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1; - u = v.bgr; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1; - u.bgr = v; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1; - - u = v.stp; Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1; - u = v.pts; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1; - u.pts = v; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1; - - return Error; -} - -int test_vec3_swizzle_half() -{ - int Error = 0; - - glm::half a1(1); - glm::half b1(2); - glm::half c1(3); - glm::hvec3 v(a1, b1, c1); - glm::hvec3 u; - - u = v; - - Error += (u.x.toFloat() == 1.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 3.0f) ? 0 : 1; - - u = v.xyz; - Error += (u.x.toFloat() == 1.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 3.0f) ? 0 : 1; - u = v.zyx; - Error += (u.x.toFloat() == 3.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 1.0f) ? 0 : 1; - u.zyx = v; - Error += (u.x.toFloat() == 3.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 1.0f) ? 0 : 1; - - u = v.rgb; - Error += (u.x.toFloat() == 1.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 3.0f) ? 0 : 1; - u = v.bgr; - Error += (u.x.toFloat() == 3.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 1.0f) ? 0 : 1; - u.bgr = v; - Error += (u.x.toFloat() == 3.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 1.0f) ? 0 : 1; - - u = v.stp; - Error += (u.x.toFloat() == 1.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 3.0f) ? 0 : 1; - u = v.pts; - Error += (u.x.toFloat() == 3.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 1.0f) ? 0 : 1; - u.pts = v; - Error += (u.x.toFloat() == 3.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 1.0f) ? 0 : 1; - - return Error; -} - -int test_vec3_swizzle_operators() -{ - int Error = 0; - - glm::vec3 q, u, v; - - u = glm::vec3(1, 2, 3); - v = glm::vec3(10, 20, 30); - - // Swizzle, swizzle binary operators - q = u.xyz + v.xyz; Error += (q == (u + v)) ? 0 : 1; - q = (u.zyx + v.zyx).zyx; Error += (q == (u + v)) ? 0 : 1; - q = (u.xyz - v.xyz); Error += (q == (u - v)) ? 0 : 1; - q = (u.xyz * v.xyz); Error += (q == (u * v)) ? 0 : 1; - q = (u.xxx * v.xxx); Error += (q == glm::vec3(u.x * v.x)) ? 0 : 1; - q = (u.xyz / v.xyz); Error += (q == (u / v)) ? 0 : 1; - - // vec, swizzle binary operators - q = u + v.xyz; Error += (q == (u + v)) ? 0 : 1; - q = (u - v.xyz); Error += (q == (u - v)) ? 0 : 1; - q = (u * v.xyz); Error += (q == (u * v)) ? 0 : 1; - q = (u * v.xxx); Error += (q == v.x * u) ? 0 : 1; - q = (u / v.xyz); Error += (q == (u / v)) ? 0 : 1; - - // swizzle,vec binary operators - q = u.xyz + v; Error += (q == (u + v)) ? 0 : 1; - q = (u.xyz - v); Error += (q == (u - v)) ? 0 : 1; - q = (u.xyz * v); Error += (q == (u * v)) ? 0 : 1; - q = (u.xxx * v); Error += (q == u.x * v) ? 0 : 1; - q = (u.xyz / v); Error += (q == (u / v)) ? 0 : 1; - - // Compile errors - //q = (u.yz * v.xyz); - //q = (u * v.xy); - - return Error; -} - -int test_vec3_swizzle_functions() -{ - int Error = 0; - - // vec3 - working as expected - glm::vec3 q, u, v; - u = glm::vec3(1, 2, 3); - v = glm::vec3(10, 20, 30); - glm::dot(u, v); - glm::dot(u.xyz, v.zyz); - glm::dot(u, v.zyx); - glm::dot(u.xyz, v); - - // vec2 - not working! how is vec3 working and not vec2? - glm::vec2 a, b; - glm::dot(a, b); - glm::dot(a.xy, b.xy); - //glm::dot(u.xy, v.xy); - - glm::dot(glm::vec4(1,2,3,4).xyz, v); - - glm::vec4 r, s, t; - - r = glm::vec4(1, 2, 3, 4); - s = glm::vec4(10, 20, 30, 40); - - glm::dot(r, s); - //glm::dot(r.xyzw, s.xyzw); - //glm::dot(r.xyz, s.xyz); - - return Error; -} - -#if 0 -using namespace glm; - -// -// Description : Array and textureless GLSL 2D/3D/4D simplex -// noise functions. -// Author : Ian McEwan, Ashima Arts. -// Maintainer : ijm -// Lastmod : 20110822 (ijm) -// License : Copyright (C) 2011 Ashima Arts. All rights reserved. -// Distributed under the MIT License. See LICENSE file. -// https://github.com/ashima/webgl-noise -// +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2008-08-31 +// Updated : 2011-09-19 +// Licence : This source is under MIT License +// File : test/core/type_vec3.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// -vec4 mod289(vec4 x) { - return x - floor(x * (1.0 / 289.0)) * 289.0; } +#include +#include -float mod289(float x) { - return x - floor(x * (1.0 / 289.0)) * 289.0; } +static int test_vec3_operators() +{ + glm::vec3 A(1.0f); + glm::vec3 B(1.0f); + bool R = A != B; + bool S = A == B; -vec4 permute(vec4 x) { - return mod289(((x*34.0)+1.0)*x); + return (S && !R) ? 0 : 1; } -float permute(float x) { - return mod289(((x*34.0)+1.0)*x); +int test_vec3_size() +{ + int Error = 0; + + Error += sizeof(glm::vec3) == sizeof(glm::mediump_vec3) ? 0 : 1; + Error += 12 == sizeof(glm::mediump_vec3) ? 0 : 1; + Error += sizeof(glm::dvec3) == sizeof(glm::highp_vec3) ? 0 : 1; + Error += 24 == sizeof(glm::highp_vec3) ? 0 : 1; + Error += glm::vec3().length() == 3 ? 0 : 1; + Error += glm::dvec3().length() == 3 ? 0 : 1; + + return Error; +} + +int test_vec3_swizzle3_2() +{ + int Error = 0; + + glm::vec3 v(1, 2, 3); + glm::vec2 u; + + // Can not assign a vec3 swizzle to a vec2 + //u = v.xyz; //Illegal + //u = v.rgb; //Illegal + //u = v.stp; //Illegal + + u = v.xx; Error += (u.x == 1.0f && u.y == 1.0f) ? 0 : 1; + u = v.xy; Error += (u.x == 1.0f && u.y == 2.0f) ? 0 : 1; + u = v.xz; Error += (u.x == 1.0f && u.y == 3.0f) ? 0 : 1; + u = v.yx; Error += (u.x == 2.0f && u.y == 1.0f) ? 0 : 1; + u = v.yy; Error += (u.x == 2.0f && u.y == 2.0f) ? 0 : 1; + u = v.yz; Error += (u.x == 2.0f && u.y == 3.0f) ? 0 : 1; + u = v.zx; Error += (u.x == 3.0f && u.y == 1.0f) ? 0 : 1; + u = v.zy; Error += (u.x == 3.0f && u.y == 2.0f) ? 0 : 1; + u = v.zz; Error += (u.x == 3.0f && u.y == 3.0f) ? 0 : 1; + + u = v.rr; Error += (u.r == 1.0f && u.g == 1.0f) ? 0 : 1; + u = v.rg; Error += (u.r == 1.0f && u.g == 2.0f) ? 0 : 1; + u = v.rb; Error += (u.r == 1.0f && u.g == 3.0f) ? 0 : 1; + u = v.gr; Error += (u.r == 2.0f && u.g == 1.0f) ? 0 : 1; + u = v.gg; Error += (u.r == 2.0f && u.g == 2.0f) ? 0 : 1; + u = v.gb; Error += (u.r == 2.0f && u.g == 3.0f) ? 0 : 1; + u = v.br; Error += (u.r == 3.0f && u.g == 1.0f) ? 0 : 1; + u = v.bg; Error += (u.r == 3.0f && u.g == 2.0f) ? 0 : 1; + u = v.bb; Error += (u.r == 3.0f && u.g == 3.0f) ? 0 : 1; + + u = v.ss; Error += (u.s == 1.0f && u.t == 1.0f) ? 0 : 1; + u = v.st; Error += (u.s == 1.0f && u.t == 2.0f) ? 0 : 1; + u = v.sp; Error += (u.s == 1.0f && u.t == 3.0f) ? 0 : 1; + u = v.ts; Error += (u.s == 2.0f && u.t == 1.0f) ? 0 : 1; + u = v.tt; Error += (u.s == 2.0f && u.t == 2.0f) ? 0 : 1; + u = v.tp; Error += (u.s == 2.0f && u.t == 3.0f) ? 0 : 1; + u = v.ps; Error += (u.s == 3.0f && u.t == 1.0f) ? 0 : 1; + u = v.pt; Error += (u.s == 3.0f && u.t == 2.0f) ? 0 : 1; + u = v.pp; Error += (u.s == 3.0f && u.t == 3.0f) ? 0 : 1; + + // Mixed member aliases are not valid + //u = v.rx; //Illegal + //u = v.sy; //Illegal + + + u = glm::vec2(1, 2); + v = glm::vec3(1, 2, 3); + //v.xx = u; //Illegal + v.xy = u; Error += (v.x == 1.0f && v.y == 2.0f && v.z == 3.0f) ? 0 : 1; + v.xz = u; Error += (v.x == 1.0f && v.y == 2.0f && v.z == 2.0f) ? 0 : 1; + v.yx = u; Error += (v.x == 2.0f && v.y == 1.0f && v.z == 2.0f) ? 0 : 1; + //v.yy = u; //Illegal + v.yz = u; Error += (v.x == 2.0f && v.y == 1.0f && v.z == 2.0f) ? 0 : 1; + v.zx = u; Error += (v.x == 2.0f && v.y == 1.0f && v.z == 1.0f) ? 0 : 1; + v.zy = u; Error += (v.x == 2.0f && v.y == 2.0f && v.z == 1.0f) ? 0 : 1; + //v.zz = u; //Illegal + + return Error; +} + +int test_vec3_swizzle3_3() +{ + int Error = 0; + + glm::vec3 v(1, 2, 3); + glm::vec3 u; + + u = v; Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1; + + u = v.xyz; Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1; + u = v.zyx; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1; + u.zyx = v; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1; + + u = v.rgb; Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1; + u = v.bgr; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1; + u.bgr = v; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1; + + u = v.stp; Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1; + u = v.pts; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1; + u.pts = v; Error += (u.x == 3.0f && u.y == 2.0f && u.z == 1.0f) ? 0 : 1; + + return Error; +} + +int test_vec3_swizzle_half() +{ + int Error = 0; + + glm::half a1(1); + glm::half b1(2); + glm::half c1(3); + glm::hvec3 v(a1, b1, c1); + glm::hvec3 u; + + u = v; + + Error += (u.x.toFloat() == 1.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 3.0f) ? 0 : 1; + + u = v.xyz; + Error += (u.x.toFloat() == 1.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 3.0f) ? 0 : 1; + u = v.zyx; + Error += (u.x.toFloat() == 3.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 1.0f) ? 0 : 1; + u.zyx = v; + Error += (u.x.toFloat() == 3.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 1.0f) ? 0 : 1; + + u = v.rgb; + Error += (u.x.toFloat() == 1.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 3.0f) ? 0 : 1; + u = v.bgr; + Error += (u.x.toFloat() == 3.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 1.0f) ? 0 : 1; + u.bgr = v; + Error += (u.x.toFloat() == 3.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 1.0f) ? 0 : 1; + + u = v.stp; + Error += (u.x.toFloat() == 1.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 3.0f) ? 0 : 1; + u = v.pts; + Error += (u.x.toFloat() == 3.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 1.0f) ? 0 : 1; + u.pts = v; + Error += (u.x.toFloat() == 3.0f && u.y.toFloat() == 2.0f && u.z.toFloat() == 1.0f) ? 0 : 1; + + return Error; +} + +int test_vec3_swizzle_operators() +{ + int Error = 0; + + glm::vec3 q, u, v; + + u = glm::vec3(1, 2, 3); + v = glm::vec3(10, 20, 30); + + // Swizzle, swizzle binary operators + q = u.xyz + v.xyz; Error += (q == (u + v)) ? 0 : 1; + q = (u.zyx + v.zyx).zyx; Error += (q == (u + v)) ? 0 : 1; + q = (u.xyz - v.xyz); Error += (q == (u - v)) ? 0 : 1; + q = (u.xyz * v.xyz); Error += (q == (u * v)) ? 0 : 1; + q = (u.xxx * v.xxx); Error += (q == glm::vec3(u.x * v.x)) ? 0 : 1; + q = (u.xyz / v.xyz); Error += (q == (u / v)) ? 0 : 1; + + // vec, swizzle binary operators + q = u + v.xyz; Error += (q == (u + v)) ? 0 : 1; + q = (u - v.xyz); Error += (q == (u - v)) ? 0 : 1; + q = (u * v.xyz); Error += (q == (u * v)) ? 0 : 1; + q = (u * v.xxx); Error += (q == v.x * u) ? 0 : 1; + q = (u / v.xyz); Error += (q == (u / v)) ? 0 : 1; + + // swizzle,vec binary operators + q = u.xyz + v; Error += (q == (u + v)) ? 0 : 1; + q = (u.xyz - v); Error += (q == (u - v)) ? 0 : 1; + q = (u.xyz * v); Error += (q == (u * v)) ? 0 : 1; + q = (u.xxx * v); Error += (q == u.x * v) ? 0 : 1; + q = (u.xyz / v); Error += (q == (u / v)) ? 0 : 1; + + // Compile errors + //q = (u.yz * v.xyz); + //q = (u * v.xy); + + return Error; +} + +int test_vec3_swizzle_functions() +{ + int Error = 0; + + // vec3 - working as expected + glm::vec3 q, u, v; + u = glm::vec3(1, 2, 3); + v = glm::vec3(10, 20, 30); + glm::dot(u, v); + glm::dot(u.xyz, v.zyz); + glm::dot(u, v.zyx); + glm::dot(u.xyz, v); + + // vec2 - not working! how is vec3 working and not vec2? + glm::vec2 a, b; + glm::dot(a, b); + glm::dot(a.xy, b.yy); + glm::dot(a.xy, b.xy); + glm::dot(u.xy, v.xy); + + glm::dot(glm::vec4(1,2,3,4).xyz, v); + + glm::vec4 r, s, t; + + r = glm::vec4(1, 2, 3, 4); + s = glm::vec4(10, 20, 30, 40); + + glm::dot(r, s); + glm::dot(r.xyzw, s.xyzw); + glm::dot(r.xyz, s.xyz); + + glm::cross(u, v); + glm::cross(u.zyx, v); + glm::cross(u.xxz, v.yyx); + + return Error; +} + +#if 1 +using namespace glm; + +// +// GLSL textureless classic 4D noise "cnoise", +// with an RSL-style periodic variant "pnoise". +// Author: Stefan Gustavson (stefan.gustavson@liu.se) +// Version: 2011-08-22 +// +// Many thanks to Ian McEwan of Ashima Arts for the +// ideas for permutation and gradient selection. +// +// Copyright (c) 2011 Stefan Gustavson. All rights reserved. +// Distributed under the MIT license. See LICENSE file. +// https://github.com/ashima/webgl-noise +// + +vec4 mod289(vec4 x) +{ + return x - floor(x * (1.0 / 289.0)) * 289.0; +} + +vec4 permute(vec4 x) +{ + return mod289(((x*34.0)+1.0)*x); } vec4 taylorInvSqrt(vec4 r) @@ -262,123 +266,292 @@ vec4 taylorInvSqrt(vec4 r) return 1.79284291400159 - 0.85373472095314 * r; } -float taylorInvSqrt(float r) -{ - return 1.79284291400159 - 0.85373472095314 * r; +vec4 fade(vec4 t) { + return t*t*t*(t*(t*6.0-15.0)+10.0); } -vec4 grad4(float j, vec4 ip) - { - const vec4 ones = vec4(1.0, 1.0, 1.0, -1.0); - vec4 p,s; +// Classic Perlin noise +float cnoise(vec4 P) +{ + vec4 Pi0 = floor(P); // Integer part for indexing + vec4 Pi1 = Pi0 + 1.0; // Integer part + 1 + Pi0 = mod289(Pi0); + Pi1 = mod289(Pi1); + vec4 Pf0 = fract(P); // Fractional part for interpolation + vec4 Pf1 = Pf0 - 1.0; // Fractional part - 1.0 + vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x); + vec4 iy = vec4(Pi0.yy(), Pi1.yy()); + vec4 iz0 = vec4(Pi0.zzzz()); + vec4 iz1 = vec4(Pi1.zzzz()); + vec4 iw0 = vec4(Pi0.wwww()); + vec4 iw1 = vec4(Pi1.wwww); - auto t1 = abs(p.xyz); - auto t2 = ones.xyz; - auto t3 = dot(t1, t2); - auto t0 = dot(abs(p.xyz), ones.xyz); + vec4 ixy = permute(permute(ix) + iy); + vec4 ixy0 = permute(ixy + iz0); + vec4 ixy1 = permute(ixy + iz1); + vec4 ixy00 = permute(ixy0 + iw0); + vec4 ixy01 = permute(ixy0 + iw1); + vec4 ixy10 = permute(ixy1 + iw0); + vec4 ixy11 = permute(ixy1 + iw1); - p.xyz = floor( fract (vec3(j) * ip.xyz) * 7.0f) * ip.z - 1.0f; - p.w = 1.5f - dot(abs(p.xyz), ones.xyz); - s = vec4(lessThan(p, vec4(0.0))); - p.xyz = p.xyz + (s.xyz*2.0f - 1.0f) * s.www; + vec4 gx00 = ixy00 * (1.0 / 7.0); + vec4 gy00 = floor(gx00) * (1.0 / 7.0); + vec4 gz00 = floor(gy00) * (1.0 / 6.0); + gx00 = fract(gx00) - 0.5; + gy00 = fract(gy00) - 0.5; + gz00 = fract(gz00) - 0.5; + vec4 gw00 = vec4(0.75) - abs(gx00) - abs(gy00) - abs(gz00); + vec4 sw00 = step(gw00, vec4(0.0)); + gx00 -= sw00 * (step(0.0, gx00) - 0.5); + gy00 -= sw00 * (step(0.0, gy00) - 0.5); - return p; + vec4 gx01 = ixy01 * (1.0 / 7.0); + vec4 gy01 = floor(gx01) * (1.0 / 7.0); + vec4 gz01 = floor(gy01) * (1.0 / 6.0); + gx01 = fract(gx01) - 0.5; + gy01 = fract(gy01) - 0.5; + gz01 = fract(gz01) - 0.5; + vec4 gw01 = vec4(0.75) - abs(gx01) - abs(gy01) - abs(gz01); + vec4 sw01 = step(gw01, vec4(0.0)); + gx01 -= sw01 * (step(0.0, gx01) - 0.5); + gy01 -= sw01 * (step(0.0, gy01) - 0.5); + + vec4 gx10 = ixy10 * (1.0 / 7.0); + vec4 gy10 = floor(gx10) * (1.0 / 7.0); + vec4 gz10 = floor(gy10) * (1.0 / 6.0); + gx10 = fract(gx10) - 0.5; + gy10 = fract(gy10) - 0.5; + gz10 = fract(gz10) - 0.5; + vec4 gw10 = vec4(0.75) - abs(gx10) - abs(gy10) - abs(gz10); + vec4 sw10 = step(gw10, vec4(0.0)); + gx10 -= sw10 * (step(0.0, gx10) - 0.5); + gy10 -= sw10 * (step(0.0, gy10) - 0.5); + + vec4 gx11 = ixy11 * (1.0 / 7.0); + vec4 gy11 = floor(gx11) * (1.0 / 7.0); + vec4 gz11 = floor(gy11) * (1.0 / 6.0); + gx11 = fract(gx11) - 0.5; + gy11 = fract(gy11) - 0.5; + gz11 = fract(gz11) - 0.5; + vec4 gw11 = vec4(0.75) - abs(gx11) - abs(gy11) - abs(gz11); + vec4 sw11 = step(gw11, vec4(0.0)); + gx11 -= sw11 * (step(0.0, gx11) - 0.5); + gy11 -= sw11 * (step(0.0, gy11) - 0.5); + + vec4 g0000 = vec4(gx00.x,gy00.x,gz00.x,gw00.x); + vec4 g1000 = vec4(gx00.y,gy00.y,gz00.y,gw00.y); + vec4 g0100 = vec4(gx00.z,gy00.z,gz00.z,gw00.z); + vec4 g1100 = vec4(gx00.w,gy00.w,gz00.w,gw00.w); + vec4 g0010 = vec4(gx10.x,gy10.x,gz10.x,gw10.x); + vec4 g1010 = vec4(gx10.y,gy10.y,gz10.y,gw10.y); + vec4 g0110 = vec4(gx10.z,gy10.z,gz10.z,gw10.z); + vec4 g1110 = vec4(gx10.w,gy10.w,gz10.w,gw10.w); + vec4 g0001 = vec4(gx01.x,gy01.x,gz01.x,gw01.x); + vec4 g1001 = vec4(gx01.y,gy01.y,gz01.y,gw01.y); + vec4 g0101 = vec4(gx01.z,gy01.z,gz01.z,gw01.z); + vec4 g1101 = vec4(gx01.w,gy01.w,gz01.w,gw01.w); + vec4 g0011 = vec4(gx11.x,gy11.x,gz11.x,gw11.x); + vec4 g1011 = vec4(gx11.y,gy11.y,gz11.y,gw11.y); + vec4 g0111 = vec4(gx11.z,gy11.z,gz11.z,gw11.z); + vec4 g1111 = vec4(gx11.w,gy11.w,gz11.w,gw11.w); + + vec4 norm00 = taylorInvSqrt(vec4(dot(g0000, g0000), dot(g0100, g0100), dot(g1000, g1000), dot(g1100, g1100))); + g0000 *= norm00.x; + g0100 *= norm00.y; + g1000 *= norm00.z; + g1100 *= norm00.w; + + vec4 norm01 = taylorInvSqrt(vec4(dot(g0001, g0001), dot(g0101, g0101), dot(g1001, g1001), dot(g1101, g1101))); + g0001 *= norm01.x; + g0101 *= norm01.y; + g1001 *= norm01.z; + g1101 *= norm01.w; + + vec4 norm10 = taylorInvSqrt(vec4(dot(g0010, g0010), dot(g0110, g0110), dot(g1010, g1010), dot(g1110, g1110))); + g0010 *= norm10.x; + g0110 *= norm10.y; + g1010 *= norm10.z; + g1110 *= norm10.w; + + vec4 norm11 = taylorInvSqrt(vec4(dot(g0011, g0011), dot(g0111, g0111), dot(g1011, g1011), dot(g1111, g1111))); + g0011 *= norm11.x; + g0111 *= norm11.y; + g1011 *= norm11.z; + g1111 *= norm11.w; + + float n0000 = dot(g0000, Pf0); + float n1000 = dot(g1000, vec4(Pf1.x, Pf0.yzw())); + float n0100 = dot(g0100, vec4(Pf0.x, Pf1.y, Pf0.zw())); + float n1100 = dot(g1100, vec4(Pf1.xy(), Pf0.zw())); + float n0010 = dot(g0010, vec4(Pf0.xy(), Pf1.z, Pf0.w)); + float n1010 = dot(g1010, vec4(Pf1.x, Pf0.y, Pf1.z, Pf0.w)); + float n0110 = dot(g0110, vec4(Pf0.x, Pf1.yz(), Pf0.w)); + float n1110 = dot(g1110, vec4(Pf1.xyz(), Pf0.w)); + float n0001 = dot(g0001, vec4(Pf0.xyz(), Pf1.w)); + float n1001 = dot(g1001, vec4(Pf1.x, Pf0.yz(), Pf1.w)); + float n0101 = dot(g0101, vec4(Pf0.x, Pf1.y, Pf0.z, Pf1.w)); + float n1101 = dot(g1101, vec4(Pf1.xy(), Pf0.z, Pf1.w)); + float n0011 = dot(g0011, vec4(Pf0.xy(), Pf1.zw())); + float n1011 = dot(g1011, vec4(Pf1.x, Pf0.y, Pf1.zw())); + float n0111 = dot(g0111, vec4(Pf0.x, Pf1.yzw())); + float n1111 = dot(g1111, Pf1); + + vec4 fade_xyzw = fade(Pf0); + vec4 n_0w = mix(vec4(n0000, n1000, n0100, n1100), vec4(n0001, n1001, n0101, n1101), fade_xyzw.w); + vec4 n_1w = mix(vec4(n0010, n1010, n0110, n1110), vec4(n0011, n1011, n0111, n1111), fade_xyzw.w); + vec4 n_zw = mix(n_0w, n_1w, fade_xyzw.z); + vec2 n_yzw = mix(n_zw.xy, n_zw.zw, fade_xyzw.y); + float n_xyzw = mix(n_yzw.x, n_yzw.y, fade_xyzw.x); + return 2.2 * n_xyzw; +} + +// Classic Perlin noise, periodic version +float pnoise(vec4 P, vec4 rep) +{ + vec4 Pi0 = mod(floor(P), rep); // Integer part modulo rep + vec4 Pi1 = mod(Pi0 + 1.0, rep); // Integer part + 1 mod rep + Pi0 = mod289(Pi0); + Pi1 = mod289(Pi1); + vec4 Pf0 = fract(P); // Fractional part for interpolation + vec4 Pf1 = Pf0 - 1.0; // Fractional part - 1.0 + vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x); + vec4 iy = vec4(Pi0.yy(), Pi1.yy()); + vec4 iz0 = vec4(Pi0.zzzz()); + vec4 iz1 = vec4(Pi1.zzzz()); + vec4 iw0 = vec4(Pi0.wwww()); + vec4 iw1 = vec4(Pi1.wwww()); + + vec4 ixy = permute(permute(ix) + iy); + vec4 ixy0 = permute(ixy + iz0); + vec4 ixy1 = permute(ixy + iz1); + vec4 ixy00 = permute(ixy0 + iw0); + vec4 ixy01 = permute(ixy0 + iw1); + vec4 ixy10 = permute(ixy1 + iw0); + vec4 ixy11 = permute(ixy1 + iw1); + + vec4 gx00 = ixy00 * (1.0 / 7.0); + vec4 gy00 = floor(gx00) * (1.0 / 7.0); + vec4 gz00 = floor(gy00) * (1.0 / 6.0); + gx00 = fract(gx00) - 0.5; + gy00 = fract(gy00) - 0.5; + gz00 = fract(gz00) - 0.5; + vec4 gw00 = vec4(0.75) - abs(gx00) - abs(gy00) - abs(gz00); + vec4 sw00 = step(gw00, vec4(0.0)); + gx00 -= sw00 * (step(0.0, gx00) - 0.5); + gy00 -= sw00 * (step(0.0, gy00) - 0.5); + + vec4 gx01 = ixy01 * (1.0 / 7.0); + vec4 gy01 = floor(gx01) * (1.0 / 7.0); + vec4 gz01 = floor(gy01) * (1.0 / 6.0); + gx01 = fract(gx01) - 0.5; + gy01 = fract(gy01) - 0.5; + gz01 = fract(gz01) - 0.5; + vec4 gw01 = vec4(0.75) - abs(gx01) - abs(gy01) - abs(gz01); + vec4 sw01 = step(gw01, vec4(0.0)); + gx01 -= sw01 * (step(0.0, gx01) - 0.5); + gy01 -= sw01 * (step(0.0, gy01) - 0.5); + + vec4 gx10 = ixy10 * (1.0 / 7.0); + vec4 gy10 = floor(gx10) * (1.0 / 7.0); + vec4 gz10 = floor(gy10) * (1.0 / 6.0); + gx10 = fract(gx10) - 0.5; + gy10 = fract(gy10) - 0.5; + gz10 = fract(gz10) - 0.5; + vec4 gw10 = vec4(0.75) - abs(gx10) - abs(gy10) - abs(gz10); + vec4 sw10 = step(gw10, vec4(0.0)); + gx10 -= sw10 * (step(0.0, gx10) - 0.5); + gy10 -= sw10 * (step(0.0, gy10) - 0.5); + + vec4 gx11 = ixy11 * (1.0 / 7.0); + vec4 gy11 = floor(gx11) * (1.0 / 7.0); + vec4 gz11 = floor(gy11) * (1.0 / 6.0); + gx11 = fract(gx11) - 0.5; + gy11 = fract(gy11) - 0.5; + gz11 = fract(gz11) - 0.5; + vec4 gw11 = vec4(0.75) - abs(gx11) - abs(gy11) - abs(gz11); + vec4 sw11 = step(gw11, vec4(0.0)); + gx11 -= sw11 * (step(0.0, gx11) - 0.5); + gy11 -= sw11 * (step(0.0, gy11) - 0.5); + + vec4 g0000 = vec4(gx00.x,gy00.x,gz00.x,gw00.x); + vec4 g1000 = vec4(gx00.y,gy00.y,gz00.y,gw00.y); + vec4 g0100 = vec4(gx00.z,gy00.z,gz00.z,gw00.z); + vec4 g1100 = vec4(gx00.w,gy00.w,gz00.w,gw00.w); + vec4 g0010 = vec4(gx10.x,gy10.x,gz10.x,gw10.x); + vec4 g1010 = vec4(gx10.y,gy10.y,gz10.y,gw10.y); + vec4 g0110 = vec4(gx10.z,gy10.z,gz10.z,gw10.z); + vec4 g1110 = vec4(gx10.w,gy10.w,gz10.w,gw10.w); + vec4 g0001 = vec4(gx01.x,gy01.x,gz01.x,gw01.x); + vec4 g1001 = vec4(gx01.y,gy01.y,gz01.y,gw01.y); + vec4 g0101 = vec4(gx01.z,gy01.z,gz01.z,gw01.z); + vec4 g1101 = vec4(gx01.w,gy01.w,gz01.w,gw01.w); + vec4 g0011 = vec4(gx11.x,gy11.x,gz11.x,gw11.x); + vec4 g1011 = vec4(gx11.y,gy11.y,gz11.y,gw11.y); + vec4 g0111 = vec4(gx11.z,gy11.z,gz11.z,gw11.z); + vec4 g1111 = vec4(gx11.w,gy11.w,gz11.w,gw11.w); + + vec4 norm00 = taylorInvSqrt(vec4(dot(g0000, g0000), dot(g0100, g0100), dot(g1000, g1000), dot(g1100, g1100))); + g0000 *= norm00.x; + g0100 *= norm00.y; + g1000 *= norm00.z; + g1100 *= norm00.w; + + vec4 norm01 = taylorInvSqrt(vec4(dot(g0001, g0001), dot(g0101, g0101), dot(g1001, g1001), dot(g1101, g1101))); + g0001 *= norm01.x; + g0101 *= norm01.y; + g1001 *= norm01.z; + g1101 *= norm01.w; + + vec4 norm10 = taylorInvSqrt(vec4(dot(g0010, g0010), dot(g0110, g0110), dot(g1010, g1010), dot(g1110, g1110))); + g0010 *= norm10.x; + g0110 *= norm10.y; + g1010 *= norm10.z; + g1110 *= norm10.w; + + vec4 norm11 = taylorInvSqrt(vec4(dot(g0011, g0011), dot(g0111, g0111), dot(g1011, g1011), dot(g1111, g1111))); + g0011 *= norm11.x; + g0111 *= norm11.y; + g1011 *= norm11.z; + g1111 *= norm11.w; + + float n0000 = dot(g0000, Pf0); + float n1000 = dot(g1000, vec4(Pf1.x, Pf0.yzw())); + float n0100 = dot(g0100, vec4(Pf0.x, Pf1.y, Pf0.zw())); + float n1100 = dot(g1100, vec4(Pf1.xy(), Pf0.zw())); + float n0010 = dot(g0010, vec4(Pf0.xy(), Pf1.z, Pf0.w)); + float n1010 = dot(g1010, vec4(Pf1.x, Pf0.y, Pf1.z, Pf0.w)); + float n0110 = dot(g0110, vec4(Pf0.x, Pf1.yz(), Pf0.w)); + float n1110 = dot(g1110, vec4(Pf1.xyz(), Pf0.w)); + float n0001 = dot(g0001, vec4(Pf0.xyz(), Pf1.w)); + float n1001 = dot(g1001, vec4(Pf1.x, Pf0.yz(), Pf1.w)); + float n0101 = dot(g0101, vec4(Pf0.x, Pf1.y, Pf0.z, Pf1.w)); + float n1101 = dot(g1101, vec4(Pf1.xy(), Pf0.z, Pf1.w)); + float n0011 = dot(g0011, vec4(Pf0.xy(), Pf1.zw())); + float n1011 = dot(g1011, vec4(Pf1.x, Pf0.y, Pf1.zw())); + float n0111 = dot(g0111, vec4(Pf0.x, Pf1.yzw())); + float n1111 = dot(g1111, Pf1); + + vec4 fade_xyzw = fade(Pf0); + vec4 n_0w = mix(vec4(n0000, n1000, n0100, n1100), vec4(n0001, n1001, n0101, n1101), fade_xyzw.w); + vec4 n_1w = mix(vec4(n0010, n1010, n0110, n1110), vec4(n0011, n1011, n0111, n1111), fade_xyzw.w); + vec4 n_zw = mix(n_0w, n_1w, fade_xyzw.z); + vec2 n_yzw = mix(n_zw.xy, n_zw.zw, fade_xyzw.y); + float n_xyzw = mix(n_yzw.x, n_yzw.y, fade_xyzw.x); + return 2.2 * n_xyzw; } +#endif +int main() +{ + int Error = 0; -float snoise(vec4 v) - { - const vec4 C = vec4( 0.138196601125011, // (5 - sqrt(5))/20 G4 - 0.276393202250021, // 2 * G4 - 0.414589803375032, // 3 * G4 - -0.447213595499958); // -1 + 4 * G4 - -// (sqrt(5) - 1)/4 = F4, used once below -#define F4 0.309016994374947451 - -// First corner - vec4 i = floor(v + dot(v, vec4(F4)) ); - vec4 x0 = v - i + dot(i, C.xxxx); - -// Other corners - -// Rank sorting originally contributed by Bill Licea-Kane, AMD (formerly ATI) - vec4 i0; - vec3 isX = step( x0.yzw, x0.xxx ); - vec3 isYZ = step( x0.zww, x0.yyz ); -// i0.x = dot( isX, vec3( 1.0 ) ); - i0.x = isX.x + isX.y + isX.z; - i0.yzw = 1.0f - isX; -// i0.y += dot( isYZ.xy, vec2( 1.0 ) ); - i0.y += isYZ.x + isYZ.y; - i0.zw += 1.0f - isYZ.xy; - i0.z += isYZ.z; - i0.w += 1.0f - isYZ.z; - - // i0 now contains the unique values 0,1,2,3 in each channel - vec4 i3 = clamp( i0, 0.0, 1.0 ); - vec4 i2 = clamp( i0-1.0, 0.0, 1.0 ); - vec4 i1 = clamp( i0-2.0, 0.0, 1.0 ); - - // x0 = x0 - 0.0 + 0.0 * C.xxxx - // x1 = x0 - i1 + 1.0 * C.xxxx - // x2 = x0 - i2 + 2.0 * C.xxxx - // x3 = x0 - i3 + 3.0 * C.xxxx - // x4 = x0 - 1.0 + 4.0 * C.xxxx - vec4 x1 = x0 - i1 + C.xxxx; - vec4 x2 = x0 - i2 + C.yyyy; - vec4 x3 = x0 - i3 + C.zzzz; - vec4 x4 = x0 + C.wwww; - -// Permutations - i = mod289(i); - float j0 = permute( permute( permute( permute(i.w) + i.z) + i.y) + i.x); - vec4 j1 = permute( permute( permute( permute ( - i.w + vec4(i1.w, i2.w, i3.w, 1.0 )) - + i.z + vec4(i1.z, i2.z, i3.z, 1.0 )) - + i.y + vec4(i1.y, i2.y, i3.y, 1.0 )) - + i.x + vec4(i1.x, i2.x, i3.x, 1.0 )); - -// Gradients: 7x7x6 points over a cube, mapped onto a 4-cross polytope -// 7*7*6 = 294, which is close to the ring size 17*17 = 289. - vec4 ip = vec4(1.0/294.0, 1.0/49.0, 1.0/7.0, 0.0) ; - - vec4 p0 = grad4(j0, ip); - vec4 p1 = grad4(j1.x, ip); - vec4 p2 = grad4(j1.y, ip); - vec4 p3 = grad4(j1.z, ip); - vec4 p4 = grad4(j1.w, ip); - -// Normalise gradients - vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3))); - p0 *= norm.x; - p1 *= norm.y; - p2 *= norm.z; - p3 *= norm.w; - p4 *= taylorInvSqrt(dot(p4,p4)); - -// Mix contributions from the five corners - vec3 m0 = max(0.6f - vec3(dot(x0,x0), dot(x1,x1), dot(x2,x2)), 0.0); - vec2 m1 = max(0.6f - vec2(dot(x3,x3), dot(x4,x4) ), 0.0); - m0 = m0 * m0; - m1 = m1 * m1; - return 49.0 * ( dot(m0*m0, vec3( dot( p0, x0 ), dot( p1, x1 ), dot( p2, x2 ))) - + dot(m1*m1, vec2( dot( p3, x3 ), dot( p4, x4 ) ) ) ) ; - - } -#endif - -int main() -{ - int Error = 0; - - Error += test_vec3_operators(); - Error += test_vec3_size(); - Error += test_vec3_swizzle3_2(); - Error += test_vec3_swizzle3_3(); - Error += test_vec3_swizzle_half(); - Error += test_vec3_swizzle_operators(); - Error += test_vec3_swizzle_functions(); - - return Error; -} + Error += test_vec3_operators(); + Error += test_vec3_size(); + Error += test_vec3_swizzle3_2(); + Error += test_vec3_swizzle3_3(); + Error += test_vec3_swizzle_half(); + Error += test_vec3_swizzle_operators(); + Error += test_vec3_swizzle_functions(); + + return Error; +} From 44bd721a416ca20062f72e2faab99139ecdaf299 Mon Sep 17 00:00:00 2001 From: athile Date: Fri, 23 Sep 2011 11:51:21 -0400 Subject: [PATCH 4/6] Swizzle clean-up --- glm/core/_swizzle.hpp | 85 ++++++-- test/core/core_type_vec3.cpp | 364 +++-------------------------------- 2 files changed, 98 insertions(+), 351 deletions(-) diff --git a/glm/core/_swizzle.hpp b/glm/core/_swizzle.hpp index 439ac028..007ca533 100644 --- a/glm/core/_swizzle.hpp +++ b/glm/core/_swizzle.hpp @@ -56,9 +56,12 @@ namespace detail Template parameters: ValueType = type of scalar values (e.g. float, double) - VecType = class the swizzle is applies to (e.g. vector3f) + VecType = class the swizzle is applies to (e.g. tvec3) N = number of components in the vector (e.g. 3) E0...3 = what index the n-th element of this swizzle refers to in the unswizzled vec + + DUPLICATE_ELEMENTS = 1 if there is a repeated element, 0 otherwise (used to specialize swizzles + containing duplicate elements so that they cannot be used as r-values). */ template struct swizzle_base @@ -69,11 +72,8 @@ namespace detail swizzle_base& operator= (const ValueType& t) { - static const int offset_dst[4] = { E0, E1, E2, E3 }; - for (int i = 0; i < N; ++i) - elem(offset_dst[i]) = t; - + (*this)[i] = t; return *this; } @@ -118,18 +118,29 @@ namespace detail _apply_op(that, op()); } + value_type& operator[] (size_t i) + { + static const int offset_dst[4] = { E0, E1, E2, E3 }; + return elem(offset_dst[i]); + } + value_type operator[] (size_t) const + { + static const int offset_dst[4] = { E0, E1, E2, E3 }; + return elem(offset_dst[i]); + } + protected: template void _apply_op(const VecType& that, T op) { - static const int offset_dst[4] = { E0, E1, E2, E3 }; - - // Make a copy of the data in this == &that + // Make a copy of the data in this == &that. + // The copier should optimize out the copy in cases where the function is + // properly inlined and the copy is not necessary. ValueType t[N]; for (int i = 0; i < N; ++i) t[i] = that[i]; for (int i = 0; i < N; ++i) - op( elem(offset_dst[i]), t[i] ); + op( (*this)[i], t[i] ); } value_type& elem (size_t i) { return (reinterpret_cast(_buffer))[i]; } @@ -141,6 +152,7 @@ namespace detail char _buffer[sizeof(value_type) * N]; }; + //! Specialization for swizzles containing duplicate elements. These cannot be modified. template struct swizzle_base { @@ -150,6 +162,12 @@ namespace detail struct Stub {}; swizzle_base& operator= (const Stub& that) {} + + value_type operator[] (size_t) const + { + static const int offset_dst[4] = { E0, E1, E2, E3 }; + return elem(offset_dst[i]); + } protected: value_type& elem (size_t i) { return (reinterpret_cast(_buffer))[i]; } @@ -257,6 +275,9 @@ namespace detail #define _GLM_SWIZZLE_TYPE1 glm::detail::swizzle_base #define _GLM_SWIZZLE_TYPE2 glm::detail::swizzle_base +// +// Wrapper for a binary operator (e.g. u.yy + v.zy) +// #define _GLM_SWIZZLE_VECTOR_BINARY_OPERATOR_IMPLEMENTATION(OPERAND)\ _GLM_SWIZZLE_TEMPLATE2 \ typename P operator OPERAND ( const _GLM_SWIZZLE_TYPE1& a, const _GLM_SWIZZLE_TYPE2& b) \ @@ -274,6 +295,9 @@ namespace detail return a OPERAND static_cast(b).cast(); \ } +// +// Wrapper for a operand between a swizzle and a binary (e.g. 1.0f - u.xyz) +// #define _GLM_SWIZZLE_SCALAR_BINARY_OPERATOR_IMPLEMENTATION(OPERAND)\ _GLM_SWIZZLE_TEMPLATE1 \ typename P operator OPERAND ( const _GLM_SWIZZLE_TYPE1& a, const typename T& b) \ @@ -286,6 +310,10 @@ namespace detail return a OPERAND static_cast(b).cast(); \ } +// +// Macro for wrapping a function taking one argument (e.g. abs()) +// Needs to wrap all 12 swizzle types. +// #define _GLM_SWIZZLE_FUNCTION_1_ARGS(RETURN_TYPE,FUNCTION)\ template \ typename glm::detail::swizzle2::RETURN_TYPE FUNCTION(const glm::detail::swizzle2& a) \ @@ -333,6 +361,14 @@ namespace detail return FUNCTION(a.cast()); \ } +// +// Macro for wrapping a function taking two vector arguments (e.g. dot()). +// +// Needs to wrap all 12 swizzle types when the same type is passed as +// both arguments (u.xyz, v.xyz), wrappers for when the arguments are +// different types (u.xyz, v.yyx), and lastly wrappers for swizzle/unswizzled +// combinations (u.xyz, v). +// #define _GLM_SWIZZLE_FUNCTION_2_ARGS(RETURN_TYPE,FUNCTION)\ _GLM_SWIZZLE_TEMPLATE2\ typename S0::RETURN_TYPE FUNCTION(const typename _GLM_SWIZZLE_TYPE1& a, const typename _GLM_SWIZZLE_TYPE2& b)\ @@ -400,6 +436,9 @@ namespace detail return FUNCTION(a.cast(), b.cast()); \ } +// +// Macro for wrapping a function take 2 vec arguments followed by a scalar (e.g. mix()). +// #define _GLM_SWIZZLE_FUNCTION_2_ARGS_SCALAR(RETURN_TYPE,FUNCTION)\ _GLM_SWIZZLE_TEMPLATE2\ typename S0::RETURN_TYPE FUNCTION(const typename _GLM_SWIZZLE_TYPE1& a, const typename _GLM_SWIZZLE_TYPE2& b, const typename S0::value_type& c)\ @@ -483,16 +522,26 @@ namespace glm _GLM_SWIZZLE_VECTOR_BINARY_OPERATOR_IMPLEMENTATION(/) } - _GLM_SWIZZLE_FUNCTION_1_ARGS(vec_type, abs); - _GLM_SWIZZLE_FUNCTION_1_ARGS(vec_type, acos); - _GLM_SWIZZLE_FUNCTION_1_ARGS(vec_type, acosh); - _GLM_SWIZZLE_FUNCTION_1_ARGS(vec_type, all); - _GLM_SWIZZLE_FUNCTION_1_ARGS(vec_type, any); + // + // Swizzles are distinct types from the unswizzled type. The below macros will + // provide template specializations for the swizzle types for the given functions + // so that the compiler does not have any ambiguity to choosing how to handle + // the function. + // + // The alternative is to use the operator()() when calling the function in order + // to explicitly convert the swizzled type to the unswizzled type. + // + + //_GLM_SWIZZLE_FUNCTION_1_ARGS(vec_type, abs); + //_GLM_SWIZZLE_FUNCTION_1_ARGS(vec_type, acos); + //_GLM_SWIZZLE_FUNCTION_1_ARGS(vec_type, acosh); + //_GLM_SWIZZLE_FUNCTION_1_ARGS(vec_type, all); + //_GLM_SWIZZLE_FUNCTION_1_ARGS(vec_type, any); - _GLM_SWIZZLE_FUNCTION_2_ARGS(value_type, dot); - _GLM_SWIZZLE_FUNCTION_2_ARGS(vec_type, cross); - _GLM_SWIZZLE_FUNCTION_2_ARGS(vec_type, step); - _GLM_SWIZZLE_FUNCTION_2_ARGS_SCALAR(vec_type, mix); + //_GLM_SWIZZLE_FUNCTION_2_ARGS(value_type, dot); + //_GLM_SWIZZLE_FUNCTION_2_ARGS(vec_type, cross); + //_GLM_SWIZZLE_FUNCTION_2_ARGS(vec_type, step); + //_GLM_SWIZZLE_FUNCTION_2_ARGS_SCALAR(vec_type, mix); } diff --git a/test/core/core_type_vec3.cpp b/test/core/core_type_vec3.cpp index fb7add27..23e4d04a 100644 --- a/test/core/core_type_vec3.cpp +++ b/test/core/core_type_vec3.cpp @@ -200,347 +200,45 @@ int test_vec3_swizzle_functions() { int Error = 0; - // vec3 - working as expected + // + // NOTE: template functions cannot pick up the implicit conversion from + // a swizzle to the unswizzled type, therefore the operator() must be + // used. E.g.: + // + // glm::dot(u.xy, v.xy); <--- Compile error + // glm::dot(u.xy(), v.xy()); <--- Compiles correctly + // + + float r; + + // vec2 + glm::vec2 a(1, 2); + glm::vec2 b(10, 20); + r = glm::dot(a, b); Error += (int(r) == 50) ? 0 : 1; + r = glm::dot(a.xy(), b.xy()); Error += (int(r) == 50) ? 0 : 1; + r = glm::dot(a.xy(), b.yy()); Error += (int(r) == 60) ? 0 : 1; + + // vec3 glm::vec3 q, u, v; u = glm::vec3(1, 2, 3); v = glm::vec3(10, 20, 30); - glm::dot(u, v); - glm::dot(u.xyz, v.zyz); - glm::dot(u, v.zyx); - glm::dot(u.xyz, v); + r = glm::dot(u, v); Error += (int(r) == 140) ? 0 : 1; + r = glm::dot(u.xyz(), v.zyz()); Error += (int(r) == 160) ? 0 : 1; + r = glm::dot(u, v.zyx()); Error += (int(r) == 100) ? 0 : 1; + r = glm::dot(u.xyz(), v); Error += (int(r) == 140) ? 0 : 1; + r = glm::dot(u.xy(), v.xy()); Error += (int(r) == 50) ? 0 : 1; - // vec2 - not working! how is vec3 working and not vec2? - glm::vec2 a, b; - glm::dot(a, b); - glm::dot(a.xy, b.yy); - glm::dot(a.xy, b.xy); - glm::dot(u.xy, v.xy); - - glm::dot(glm::vec4(1,2,3,4).xyz, v); - - glm::vec4 r, s, t; - - r = glm::vec4(1, 2, 3, 4); - s = glm::vec4(10, 20, 30, 40); - - glm::dot(r, s); - glm::dot(r.xyzw, s.xyzw); - glm::dot(r.xyz, s.xyz); - - glm::cross(u, v); - glm::cross(u.zyx, v); - glm::cross(u.xxz, v.yyx); + // vec4 + glm::vec4 s, t; + s = glm::vec4(1, 2, 3, 4); + t = glm::vec4(10, 20, 30, 40); + r = glm::dot(s, t); Error += (int(r) == 300) ? 0 : 1; + r = glm::dot(s.xyzw(), t.xyzw()); Error += (int(r) == 300) ? 0 : 1; + r = glm::dot(s.xyz(), t.xyz()); Error += (int(r) == 140) ? 0 : 1; return Error; } -#if 1 -using namespace glm; - -// -// GLSL textureless classic 4D noise "cnoise", -// with an RSL-style periodic variant "pnoise". -// Author: Stefan Gustavson (stefan.gustavson@liu.se) -// Version: 2011-08-22 -// -// Many thanks to Ian McEwan of Ashima Arts for the -// ideas for permutation and gradient selection. -// -// Copyright (c) 2011 Stefan Gustavson. All rights reserved. -// Distributed under the MIT license. See LICENSE file. -// https://github.com/ashima/webgl-noise -// - -vec4 mod289(vec4 x) -{ - return x - floor(x * (1.0 / 289.0)) * 289.0; -} - -vec4 permute(vec4 x) -{ - return mod289(((x*34.0)+1.0)*x); -} - -vec4 taylorInvSqrt(vec4 r) -{ - return 1.79284291400159 - 0.85373472095314 * r; -} - -vec4 fade(vec4 t) { - return t*t*t*(t*(t*6.0-15.0)+10.0); -} - -// Classic Perlin noise -float cnoise(vec4 P) -{ - vec4 Pi0 = floor(P); // Integer part for indexing - vec4 Pi1 = Pi0 + 1.0; // Integer part + 1 - Pi0 = mod289(Pi0); - Pi1 = mod289(Pi1); - vec4 Pf0 = fract(P); // Fractional part for interpolation - vec4 Pf1 = Pf0 - 1.0; // Fractional part - 1.0 - vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x); - vec4 iy = vec4(Pi0.yy(), Pi1.yy()); - vec4 iz0 = vec4(Pi0.zzzz()); - vec4 iz1 = vec4(Pi1.zzzz()); - vec4 iw0 = vec4(Pi0.wwww()); - vec4 iw1 = vec4(Pi1.wwww); - - vec4 ixy = permute(permute(ix) + iy); - vec4 ixy0 = permute(ixy + iz0); - vec4 ixy1 = permute(ixy + iz1); - vec4 ixy00 = permute(ixy0 + iw0); - vec4 ixy01 = permute(ixy0 + iw1); - vec4 ixy10 = permute(ixy1 + iw0); - vec4 ixy11 = permute(ixy1 + iw1); - - vec4 gx00 = ixy00 * (1.0 / 7.0); - vec4 gy00 = floor(gx00) * (1.0 / 7.0); - vec4 gz00 = floor(gy00) * (1.0 / 6.0); - gx00 = fract(gx00) - 0.5; - gy00 = fract(gy00) - 0.5; - gz00 = fract(gz00) - 0.5; - vec4 gw00 = vec4(0.75) - abs(gx00) - abs(gy00) - abs(gz00); - vec4 sw00 = step(gw00, vec4(0.0)); - gx00 -= sw00 * (step(0.0, gx00) - 0.5); - gy00 -= sw00 * (step(0.0, gy00) - 0.5); - - vec4 gx01 = ixy01 * (1.0 / 7.0); - vec4 gy01 = floor(gx01) * (1.0 / 7.0); - vec4 gz01 = floor(gy01) * (1.0 / 6.0); - gx01 = fract(gx01) - 0.5; - gy01 = fract(gy01) - 0.5; - gz01 = fract(gz01) - 0.5; - vec4 gw01 = vec4(0.75) - abs(gx01) - abs(gy01) - abs(gz01); - vec4 sw01 = step(gw01, vec4(0.0)); - gx01 -= sw01 * (step(0.0, gx01) - 0.5); - gy01 -= sw01 * (step(0.0, gy01) - 0.5); - - vec4 gx10 = ixy10 * (1.0 / 7.0); - vec4 gy10 = floor(gx10) * (1.0 / 7.0); - vec4 gz10 = floor(gy10) * (1.0 / 6.0); - gx10 = fract(gx10) - 0.5; - gy10 = fract(gy10) - 0.5; - gz10 = fract(gz10) - 0.5; - vec4 gw10 = vec4(0.75) - abs(gx10) - abs(gy10) - abs(gz10); - vec4 sw10 = step(gw10, vec4(0.0)); - gx10 -= sw10 * (step(0.0, gx10) - 0.5); - gy10 -= sw10 * (step(0.0, gy10) - 0.5); - - vec4 gx11 = ixy11 * (1.0 / 7.0); - vec4 gy11 = floor(gx11) * (1.0 / 7.0); - vec4 gz11 = floor(gy11) * (1.0 / 6.0); - gx11 = fract(gx11) - 0.5; - gy11 = fract(gy11) - 0.5; - gz11 = fract(gz11) - 0.5; - vec4 gw11 = vec4(0.75) - abs(gx11) - abs(gy11) - abs(gz11); - vec4 sw11 = step(gw11, vec4(0.0)); - gx11 -= sw11 * (step(0.0, gx11) - 0.5); - gy11 -= sw11 * (step(0.0, gy11) - 0.5); - - vec4 g0000 = vec4(gx00.x,gy00.x,gz00.x,gw00.x); - vec4 g1000 = vec4(gx00.y,gy00.y,gz00.y,gw00.y); - vec4 g0100 = vec4(gx00.z,gy00.z,gz00.z,gw00.z); - vec4 g1100 = vec4(gx00.w,gy00.w,gz00.w,gw00.w); - vec4 g0010 = vec4(gx10.x,gy10.x,gz10.x,gw10.x); - vec4 g1010 = vec4(gx10.y,gy10.y,gz10.y,gw10.y); - vec4 g0110 = vec4(gx10.z,gy10.z,gz10.z,gw10.z); - vec4 g1110 = vec4(gx10.w,gy10.w,gz10.w,gw10.w); - vec4 g0001 = vec4(gx01.x,gy01.x,gz01.x,gw01.x); - vec4 g1001 = vec4(gx01.y,gy01.y,gz01.y,gw01.y); - vec4 g0101 = vec4(gx01.z,gy01.z,gz01.z,gw01.z); - vec4 g1101 = vec4(gx01.w,gy01.w,gz01.w,gw01.w); - vec4 g0011 = vec4(gx11.x,gy11.x,gz11.x,gw11.x); - vec4 g1011 = vec4(gx11.y,gy11.y,gz11.y,gw11.y); - vec4 g0111 = vec4(gx11.z,gy11.z,gz11.z,gw11.z); - vec4 g1111 = vec4(gx11.w,gy11.w,gz11.w,gw11.w); - - vec4 norm00 = taylorInvSqrt(vec4(dot(g0000, g0000), dot(g0100, g0100), dot(g1000, g1000), dot(g1100, g1100))); - g0000 *= norm00.x; - g0100 *= norm00.y; - g1000 *= norm00.z; - g1100 *= norm00.w; - - vec4 norm01 = taylorInvSqrt(vec4(dot(g0001, g0001), dot(g0101, g0101), dot(g1001, g1001), dot(g1101, g1101))); - g0001 *= norm01.x; - g0101 *= norm01.y; - g1001 *= norm01.z; - g1101 *= norm01.w; - - vec4 norm10 = taylorInvSqrt(vec4(dot(g0010, g0010), dot(g0110, g0110), dot(g1010, g1010), dot(g1110, g1110))); - g0010 *= norm10.x; - g0110 *= norm10.y; - g1010 *= norm10.z; - g1110 *= norm10.w; - - vec4 norm11 = taylorInvSqrt(vec4(dot(g0011, g0011), dot(g0111, g0111), dot(g1011, g1011), dot(g1111, g1111))); - g0011 *= norm11.x; - g0111 *= norm11.y; - g1011 *= norm11.z; - g1111 *= norm11.w; - - float n0000 = dot(g0000, Pf0); - float n1000 = dot(g1000, vec4(Pf1.x, Pf0.yzw())); - float n0100 = dot(g0100, vec4(Pf0.x, Pf1.y, Pf0.zw())); - float n1100 = dot(g1100, vec4(Pf1.xy(), Pf0.zw())); - float n0010 = dot(g0010, vec4(Pf0.xy(), Pf1.z, Pf0.w)); - float n1010 = dot(g1010, vec4(Pf1.x, Pf0.y, Pf1.z, Pf0.w)); - float n0110 = dot(g0110, vec4(Pf0.x, Pf1.yz(), Pf0.w)); - float n1110 = dot(g1110, vec4(Pf1.xyz(), Pf0.w)); - float n0001 = dot(g0001, vec4(Pf0.xyz(), Pf1.w)); - float n1001 = dot(g1001, vec4(Pf1.x, Pf0.yz(), Pf1.w)); - float n0101 = dot(g0101, vec4(Pf0.x, Pf1.y, Pf0.z, Pf1.w)); - float n1101 = dot(g1101, vec4(Pf1.xy(), Pf0.z, Pf1.w)); - float n0011 = dot(g0011, vec4(Pf0.xy(), Pf1.zw())); - float n1011 = dot(g1011, vec4(Pf1.x, Pf0.y, Pf1.zw())); - float n0111 = dot(g0111, vec4(Pf0.x, Pf1.yzw())); - float n1111 = dot(g1111, Pf1); - - vec4 fade_xyzw = fade(Pf0); - vec4 n_0w = mix(vec4(n0000, n1000, n0100, n1100), vec4(n0001, n1001, n0101, n1101), fade_xyzw.w); - vec4 n_1w = mix(vec4(n0010, n1010, n0110, n1110), vec4(n0011, n1011, n0111, n1111), fade_xyzw.w); - vec4 n_zw = mix(n_0w, n_1w, fade_xyzw.z); - vec2 n_yzw = mix(n_zw.xy, n_zw.zw, fade_xyzw.y); - float n_xyzw = mix(n_yzw.x, n_yzw.y, fade_xyzw.x); - return 2.2 * n_xyzw; -} - -// Classic Perlin noise, periodic version -float pnoise(vec4 P, vec4 rep) -{ - vec4 Pi0 = mod(floor(P), rep); // Integer part modulo rep - vec4 Pi1 = mod(Pi0 + 1.0, rep); // Integer part + 1 mod rep - Pi0 = mod289(Pi0); - Pi1 = mod289(Pi1); - vec4 Pf0 = fract(P); // Fractional part for interpolation - vec4 Pf1 = Pf0 - 1.0; // Fractional part - 1.0 - vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x); - vec4 iy = vec4(Pi0.yy(), Pi1.yy()); - vec4 iz0 = vec4(Pi0.zzzz()); - vec4 iz1 = vec4(Pi1.zzzz()); - vec4 iw0 = vec4(Pi0.wwww()); - vec4 iw1 = vec4(Pi1.wwww()); - - vec4 ixy = permute(permute(ix) + iy); - vec4 ixy0 = permute(ixy + iz0); - vec4 ixy1 = permute(ixy + iz1); - vec4 ixy00 = permute(ixy0 + iw0); - vec4 ixy01 = permute(ixy0 + iw1); - vec4 ixy10 = permute(ixy1 + iw0); - vec4 ixy11 = permute(ixy1 + iw1); - - vec4 gx00 = ixy00 * (1.0 / 7.0); - vec4 gy00 = floor(gx00) * (1.0 / 7.0); - vec4 gz00 = floor(gy00) * (1.0 / 6.0); - gx00 = fract(gx00) - 0.5; - gy00 = fract(gy00) - 0.5; - gz00 = fract(gz00) - 0.5; - vec4 gw00 = vec4(0.75) - abs(gx00) - abs(gy00) - abs(gz00); - vec4 sw00 = step(gw00, vec4(0.0)); - gx00 -= sw00 * (step(0.0, gx00) - 0.5); - gy00 -= sw00 * (step(0.0, gy00) - 0.5); - - vec4 gx01 = ixy01 * (1.0 / 7.0); - vec4 gy01 = floor(gx01) * (1.0 / 7.0); - vec4 gz01 = floor(gy01) * (1.0 / 6.0); - gx01 = fract(gx01) - 0.5; - gy01 = fract(gy01) - 0.5; - gz01 = fract(gz01) - 0.5; - vec4 gw01 = vec4(0.75) - abs(gx01) - abs(gy01) - abs(gz01); - vec4 sw01 = step(gw01, vec4(0.0)); - gx01 -= sw01 * (step(0.0, gx01) - 0.5); - gy01 -= sw01 * (step(0.0, gy01) - 0.5); - - vec4 gx10 = ixy10 * (1.0 / 7.0); - vec4 gy10 = floor(gx10) * (1.0 / 7.0); - vec4 gz10 = floor(gy10) * (1.0 / 6.0); - gx10 = fract(gx10) - 0.5; - gy10 = fract(gy10) - 0.5; - gz10 = fract(gz10) - 0.5; - vec4 gw10 = vec4(0.75) - abs(gx10) - abs(gy10) - abs(gz10); - vec4 sw10 = step(gw10, vec4(0.0)); - gx10 -= sw10 * (step(0.0, gx10) - 0.5); - gy10 -= sw10 * (step(0.0, gy10) - 0.5); - - vec4 gx11 = ixy11 * (1.0 / 7.0); - vec4 gy11 = floor(gx11) * (1.0 / 7.0); - vec4 gz11 = floor(gy11) * (1.0 / 6.0); - gx11 = fract(gx11) - 0.5; - gy11 = fract(gy11) - 0.5; - gz11 = fract(gz11) - 0.5; - vec4 gw11 = vec4(0.75) - abs(gx11) - abs(gy11) - abs(gz11); - vec4 sw11 = step(gw11, vec4(0.0)); - gx11 -= sw11 * (step(0.0, gx11) - 0.5); - gy11 -= sw11 * (step(0.0, gy11) - 0.5); - - vec4 g0000 = vec4(gx00.x,gy00.x,gz00.x,gw00.x); - vec4 g1000 = vec4(gx00.y,gy00.y,gz00.y,gw00.y); - vec4 g0100 = vec4(gx00.z,gy00.z,gz00.z,gw00.z); - vec4 g1100 = vec4(gx00.w,gy00.w,gz00.w,gw00.w); - vec4 g0010 = vec4(gx10.x,gy10.x,gz10.x,gw10.x); - vec4 g1010 = vec4(gx10.y,gy10.y,gz10.y,gw10.y); - vec4 g0110 = vec4(gx10.z,gy10.z,gz10.z,gw10.z); - vec4 g1110 = vec4(gx10.w,gy10.w,gz10.w,gw10.w); - vec4 g0001 = vec4(gx01.x,gy01.x,gz01.x,gw01.x); - vec4 g1001 = vec4(gx01.y,gy01.y,gz01.y,gw01.y); - vec4 g0101 = vec4(gx01.z,gy01.z,gz01.z,gw01.z); - vec4 g1101 = vec4(gx01.w,gy01.w,gz01.w,gw01.w); - vec4 g0011 = vec4(gx11.x,gy11.x,gz11.x,gw11.x); - vec4 g1011 = vec4(gx11.y,gy11.y,gz11.y,gw11.y); - vec4 g0111 = vec4(gx11.z,gy11.z,gz11.z,gw11.z); - vec4 g1111 = vec4(gx11.w,gy11.w,gz11.w,gw11.w); - - vec4 norm00 = taylorInvSqrt(vec4(dot(g0000, g0000), dot(g0100, g0100), dot(g1000, g1000), dot(g1100, g1100))); - g0000 *= norm00.x; - g0100 *= norm00.y; - g1000 *= norm00.z; - g1100 *= norm00.w; - - vec4 norm01 = taylorInvSqrt(vec4(dot(g0001, g0001), dot(g0101, g0101), dot(g1001, g1001), dot(g1101, g1101))); - g0001 *= norm01.x; - g0101 *= norm01.y; - g1001 *= norm01.z; - g1101 *= norm01.w; - - vec4 norm10 = taylorInvSqrt(vec4(dot(g0010, g0010), dot(g0110, g0110), dot(g1010, g1010), dot(g1110, g1110))); - g0010 *= norm10.x; - g0110 *= norm10.y; - g1010 *= norm10.z; - g1110 *= norm10.w; - - vec4 norm11 = taylorInvSqrt(vec4(dot(g0011, g0011), dot(g0111, g0111), dot(g1011, g1011), dot(g1111, g1111))); - g0011 *= norm11.x; - g0111 *= norm11.y; - g1011 *= norm11.z; - g1111 *= norm11.w; - - float n0000 = dot(g0000, Pf0); - float n1000 = dot(g1000, vec4(Pf1.x, Pf0.yzw())); - float n0100 = dot(g0100, vec4(Pf0.x, Pf1.y, Pf0.zw())); - float n1100 = dot(g1100, vec4(Pf1.xy(), Pf0.zw())); - float n0010 = dot(g0010, vec4(Pf0.xy(), Pf1.z, Pf0.w)); - float n1010 = dot(g1010, vec4(Pf1.x, Pf0.y, Pf1.z, Pf0.w)); - float n0110 = dot(g0110, vec4(Pf0.x, Pf1.yz(), Pf0.w)); - float n1110 = dot(g1110, vec4(Pf1.xyz(), Pf0.w)); - float n0001 = dot(g0001, vec4(Pf0.xyz(), Pf1.w)); - float n1001 = dot(g1001, vec4(Pf1.x, Pf0.yz(), Pf1.w)); - float n0101 = dot(g0101, vec4(Pf0.x, Pf1.y, Pf0.z, Pf1.w)); - float n1101 = dot(g1101, vec4(Pf1.xy(), Pf0.z, Pf1.w)); - float n0011 = dot(g0011, vec4(Pf0.xy(), Pf1.zw())); - float n1011 = dot(g1011, vec4(Pf1.x, Pf0.y, Pf1.zw())); - float n0111 = dot(g0111, vec4(Pf0.x, Pf1.yzw())); - float n1111 = dot(g1111, Pf1); - - vec4 fade_xyzw = fade(Pf0); - vec4 n_0w = mix(vec4(n0000, n1000, n0100, n1100), vec4(n0001, n1001, n0101, n1101), fade_xyzw.w); - vec4 n_1w = mix(vec4(n0010, n1010, n0110, n1110), vec4(n0011, n1011, n0111, n1111), fade_xyzw.w); - vec4 n_zw = mix(n_0w, n_1w, fade_xyzw.z); - vec2 n_yzw = mix(n_zw.xy, n_zw.zw, fade_xyzw.y); - float n_xyzw = mix(n_yzw.x, n_yzw.y, fade_xyzw.x); - return 2.2 * n_xyzw; - } -#endif - int main() { int Error = 0; From 6d83744b390a4de0294afbc82799fba368759c84 Mon Sep 17 00:00:00 2001 From: athile Date: Fri, 23 Sep 2011 13:37:07 -0400 Subject: [PATCH 5/6] Simplify swizzling implementation into one swizzle class --- glm/core/_swizzle.hpp | 1325 +++++++++++++++++----------------------- glm/core/type_vec2.hpp | 12 +- glm/core/type_vec3.hpp | 12 +- glm/core/type_vec4.hpp | 12 +- 4 files changed, 560 insertions(+), 801 deletions(-) diff --git a/glm/core/_swizzle.hpp b/glm/core/_swizzle.hpp index 007ca533..f1280596 100644 --- a/glm/core/_swizzle.hpp +++ b/glm/core/_swizzle.hpp @@ -51,6 +51,45 @@ namespace glm namespace glm{ namespace detail { + //! Internal class for implementing swizzle operators + template + struct _swizzle_base0 + { + typedef T value_type; + + protected: + value_type& elem (size_t i) { return (reinterpret_cast(_buffer))[i]; } + const value_type& elem (size_t i) const { return (reinterpret_cast(_buffer))[i]; } + + // Use an opaque buffer to *ensure* the compiler doesn't call a constructor. + // Otherwise, a vec4 containing all swizzles might end up with 1000s of + // constructor calls + char _buffer[sizeof(value_type) * N]; + }; + + template + struct _swizzle_base1 : public _swizzle_base0 + { + }; + + template + struct _swizzle_base1 : public _swizzle_base0 + { + V operator ()() const { return V(this->elem(E0), this->elem(E1)); } + }; + + template + struct _swizzle_base1 : public _swizzle_base0 + { + V operator ()() const { return V(this->elem(E0), this->elem(E1), this->elem(E2)); } + }; + + template + struct _swizzle_base1 : public _swizzle_base0 + { + V operator ()() const { return V(this->elem(E0), this->elem(E1), this->elem(E2), this->elem(E3)); } + }; + //! Internal class for implementing swizzle operators /*! Template parameters: @@ -63,21 +102,19 @@ namespace detail DUPLICATE_ELEMENTS = 1 if there is a repeated element, 0 otherwise (used to specialize swizzles containing duplicate elements so that they cannot be used as r-values). */ - template - struct swizzle_base + template + struct _swizzle_base2 : public _swizzle_base1 { - typedef DerivedType derived_type; - typedef VecType vec_type; - typedef ValueType value_type; + typedef VecType vec_type; - swizzle_base& operator= (const ValueType& t) + _swizzle_base2& operator= (const ValueType& t) { for (int i = 0; i < N; ++i) (*this)[i] = t; return *this; } - swizzle_base& operator= (const VecType& that) + _swizzle_base2& operator= (const VecType& that) { struct op { void operator() (value_type& e, value_type& t) { e = t; } @@ -128,7 +165,6 @@ namespace detail static const int offset_dst[4] = { E0, E1, E2, E3 }; return elem(offset_dst[i]); } - protected: template void _apply_op(const VecType& that, T op) @@ -143,156 +179,62 @@ namespace detail op( (*this)[i], t[i] ); } - value_type& elem (size_t i) { return (reinterpret_cast(_buffer))[i]; } - const value_type& elem (size_t i) const { return (reinterpret_cast(_buffer))[i]; } - // Use an opaque buffer to *ensure* the compiler doesn't call a constructor. - // Otherwise, a vec4 containing all swizzles might end up with 1000s of - // constructor calls - char _buffer[sizeof(value_type) * N]; }; //! Specialization for swizzles containing duplicate elements. These cannot be modified. - template - struct swizzle_base + template + struct _swizzle_base2 : public _swizzle_base1 { - typedef DerivedType derived_type; typedef VecType vec_type; typedef ValueType value_type; struct Stub {}; - swizzle_base& operator= (const Stub& that) {} + _swizzle_base2& operator= (const Stub& that) {} value_type operator[] (size_t) const { static const int offset_dst[4] = { E0, E1, E2, E3 }; return elem(offset_dst[i]); - } - - protected: - value_type& elem (size_t i) { return (reinterpret_cast(_buffer))[i]; } - const value_type& elem (size_t i) const { return (reinterpret_cast(_buffer))[i]; } - - char _buffer[sizeof(value_type) * N]; + } }; - //! Internal class for implementing swizzle operators - template - struct swizzle2 : public swizzle_base,T,P,2,E0,E1,0,0,(E0 == E1)> + template + struct swizzle : public _swizzle_base2 { - using swizzle_base,T,P,2,E0,E1,0,0,(E0 == E1)>::operator=; - P cast() const { return P(this->elem(E0), this->elem(E1)); } - P operator ()() const { return cast(); } - operator P () const { return cast(); } - }; + typedef _swizzle_base2 base_type; - //! Internal class for implementing swizzle operators - template - struct swizzle2_3 : public swizzle_base,T,P,2,E0,E1,E2,0,1> - { - using swizzle_base,T,P,2,E0,E1,E2,0,1>::operator=; - P cast() const { return P(this->elem(E0), this->elem(E1), this->elem(E2)); } - P operator ()() const { return cast(); } - operator P () const { return cast(); } - }; + using base_type::operator=; - //! Internal class for implementing swizzle operators - template - struct swizzle2_4 : public swizzle_base,T,P,2,E0,E1,E2,E3,1> - { - using swizzle_base,T,P,2,E0,E1,E2,E3,1>::operator=; - P cast() const { return P(this->elem(E0), this->elem(E1), this->elem(E2), this->elem(E3)); } - P operator ()() const { return cast(); } - operator P () const { return cast(); } - }; - - //! Internal class for implementing swizzle operators - template - struct swizzle3 : public swizzle_base,T,P,3,E0,E1,E2,0,(E0==E1||E0==E2||E1==E2)> - { - using swizzle_base,T,P,3,E0,E1,E2,0,(E0==E1||E0==E2||E1==E2)>::operator=; - P cast() const { return P(this->elem(E0), this->elem(E1), this->elem(E2)); } - P operator ()() const { return cast(); } - operator P () const { return cast(); } - }; - - //! Internal class for implementing swizzle operators - template - struct swizzle3_2 : public swizzle_base,T,P,2,E0,E1,0,0,(E0==E1)> - { - using swizzle_base,T,P,2,E0,E1,0,0,(E0==E1)>::operator=; - P cast() const { return P(this->elem(E0), this->elem(E1)); } - P operator ()() const { return cast(); } - operator P () const { return cast(); } - }; - - //! Internal class for implementing swizzle operators - template - struct swizzle3_4 : public swizzle_base,T,P,3,E0,E1,E2,E3,1> - { - using swizzle_base,T,P,3,E0,E1,E2,E3,1>::operator=; - P cast() const { return P(this->elem(E0), this->elem(E1), this->elem(E2), this->elem(E3)); } - P operator ()() const { return cast(); } - operator P () const { return cast(); } - }; - - //! Internal class for implementing swizzle operators - template - struct swizzle4 : public swizzle_base,T,P,4,E0,E1,E2,E3,(E0==E1||E0==E2||E0==E3||E1==E2||E1==E3||E2==E3)> - { - using swizzle_base,T,P,4,E0,E1,E2,E3,(E0==E1||E0==E2||E0==E3||E1==E2||E1==E3||E2==E3)>::operator=; - P cast() const { return P(this->elem(E0), this->elem(E1), this->elem(E2), this->elem(E3)); } - P operator ()() const { return cast(); } - operator P () const { return cast(); } - }; - - //! Internal class for implementing swizzle operators - template - struct swizzle4_2 : public swizzle_base,T,P,2,E0,E1,0,0,(E0==E1)> - { - using swizzle_base,T,P,2,E0,E1,0,0,(E0==E1)>::operator=; - P cast() const { return P(this->elem(E0), this->elem(E1)); } - P operator ()() const { return cast(); } - operator P () const { return cast(); } - }; - - - //! Internal class for implementing swizzle operators - template - struct swizzle4_3 : public swizzle_base,T,P,4,E0,E1,E2,0,(E0==E1||E0==E2||E1==E2)> - { - using swizzle_base,T,P,4,E0,E1,E2,0,(E0==E1||E0==E2||E1==E2)>::operator=; - P cast() const { return P(this->elem(E0), this->elem(E1), this->elem(E2)); } - P operator ()() const { return cast(); } - operator P () const { return cast(); } + operator VecType () const { return (*this)(); } }; // // To prevent the C++ syntax from getting entirely overwhelming, define some alias macros // -#define _GLM_SWIZZLE_TEMPLATE1 template -#define _GLM_SWIZZLE_TEMPLATE2 template -#define _GLM_SWIZZLE_TYPE1 glm::detail::swizzle_base -#define _GLM_SWIZZLE_TYPE2 glm::detail::swizzle_base +#define _GLM_SWIZZLE_TEMPLATE1 template +#define _GLM_SWIZZLE_TEMPLATE2 template +#define _GLM_SWIZZLE_TYPE1 glm::detail::swizzle +#define _GLM_SWIZZLE_TYPE2 glm::detail::swizzle // // Wrapper for a binary operator (e.g. u.yy + v.zy) // #define _GLM_SWIZZLE_VECTOR_BINARY_OPERATOR_IMPLEMENTATION(OPERAND)\ _GLM_SWIZZLE_TEMPLATE2 \ - typename P operator OPERAND ( const _GLM_SWIZZLE_TYPE1& a, const _GLM_SWIZZLE_TYPE2& b) \ + V operator OPERAND ( const _GLM_SWIZZLE_TYPE1& a, const _GLM_SWIZZLE_TYPE2& b) \ { \ - return static_cast(a).cast() OPERAND static_cast(b).cast(); \ + return a() OPERAND b(); \ } \ _GLM_SWIZZLE_TEMPLATE1 \ - typename P operator OPERAND ( const _GLM_SWIZZLE_TYPE1& a, const typename P& b) \ + V operator OPERAND ( const _GLM_SWIZZLE_TYPE1& a, const V& b) \ { \ - return static_cast(a).cast() OPERAND b; \ + return a() OPERAND b; \ } \ _GLM_SWIZZLE_TEMPLATE1 \ - typename P operator OPERAND ( const typename P& a, const _GLM_SWIZZLE_TYPE1& b) \ + V operator OPERAND ( const V& a, const _GLM_SWIZZLE_TYPE1& b) \ { \ - return a OPERAND static_cast(b).cast(); \ + return a OPERAND b(); \ } // @@ -300,212 +242,76 @@ namespace detail // #define _GLM_SWIZZLE_SCALAR_BINARY_OPERATOR_IMPLEMENTATION(OPERAND)\ _GLM_SWIZZLE_TEMPLATE1 \ - typename P operator OPERAND ( const _GLM_SWIZZLE_TYPE1& a, const typename T& b) \ + typename V operator OPERAND ( const _GLM_SWIZZLE_TYPE1& a, const typename T& b) \ { \ - return static_cast(a).cast() OPERAND b; \ + return a() OPERAND b; \ } \ _GLM_SWIZZLE_TEMPLATE1 \ - typename P operator OPERAND ( const typename T& a, const _GLM_SWIZZLE_TYPE1& b) \ + typename V operator OPERAND ( const typename T& a, const _GLM_SWIZZLE_TYPE1& b) \ { \ - return a OPERAND static_cast(b).cast(); \ + return a OPERAND b(); \ } // // Macro for wrapping a function taking one argument (e.g. abs()) -// Needs to wrap all 12 swizzle types. // #define _GLM_SWIZZLE_FUNCTION_1_ARGS(RETURN_TYPE,FUNCTION)\ - template \ - typename glm::detail::swizzle2::RETURN_TYPE FUNCTION(const glm::detail::swizzle2& a) \ - { \ - return FUNCTION(a.cast()); \ - } \ - template \ - typename glm::detail::swizzle2_3::RETURN_TYPE FUNCTION(const glm::detail::swizzle2_3& a) \ - { \ - return FUNCTION(a.cast()); \ - } \ - template \ - typename glm::detail::swizzle2_4::RETURN_TYPE FUNCTION(const glm::detail::swizzle2_4& a) \ - { \ - return FUNCTION(a.cast()); \ - } \ - template \ - typename glm::detail::swizzle3_2::RETURN_TYPE FUNCTION(const glm::detail::swizzle3_2& a) \ - { \ - return FUNCTION(a.cast()); \ - } \ - template \ - typename glm::detail::swizzle3::RETURN_TYPE FUNCTION(const glm::detail::swizzle3& a) \ - { \ - return FUNCTION(a.cast()); \ - } \ - template \ - typename glm::detail::swizzle3_4::RETURN_TYPE FUNCTION(const glm::detail::swizzle3_4& a) \ - { \ - return FUNCTION(a.cast()); \ - } \ - template \ - typename glm::detail::swizzle4_2::RETURN_TYPE FUNCTION(const glm::detail::swizzle4_2& a) \ - { \ - return FUNCTION(a.cast()); \ - } \ - template \ - typename glm::detail::swizzle4_3::RETURN_TYPE FUNCTION(const glm::detail::swizzle4_3& a) \ - { \ - return FUNCTION(a.cast()); \ - } \ - template \ - typename glm::detail::swizzle4::RETURN_TYPE FUNCTION(const glm::detail::swizzle4& a) \ - { \ - return FUNCTION(a.cast()); \ - } + _GLM_SWIZZLE_TEMPLATE1 \ + typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const _GLM_SWIZZLE_TYPE1& a) \ + { \ + return FUNCTION(a()); \ + } // // Macro for wrapping a function taking two vector arguments (e.g. dot()). // -// Needs to wrap all 12 swizzle types when the same type is passed as -// both arguments (u.xyz, v.xyz), wrappers for when the arguments are -// different types (u.xyz, v.yyx), and lastly wrappers for swizzle/unswizzled -// combinations (u.xyz, v). -// #define _GLM_SWIZZLE_FUNCTION_2_ARGS(RETURN_TYPE,FUNCTION)\ _GLM_SWIZZLE_TEMPLATE2\ - typename S0::RETURN_TYPE FUNCTION(const typename _GLM_SWIZZLE_TYPE1& a, const typename _GLM_SWIZZLE_TYPE2& b)\ + typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const typename _GLM_SWIZZLE_TYPE1& a, const typename _GLM_SWIZZLE_TYPE2& b)\ {\ - return FUNCTION(static_cast(a).cast(), static_cast(b).cast());\ + return FUNCTION(a(), b());\ }\ _GLM_SWIZZLE_TEMPLATE1\ - typename S0::RETURN_TYPE FUNCTION(const typename _GLM_SWIZZLE_TYPE1& a, const typename _GLM_SWIZZLE_TYPE1& b)\ + typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const _GLM_SWIZZLE_TYPE1& a, const typename _GLM_SWIZZLE_TYPE1& b)\ {\ - return FUNCTION(static_cast(a).cast(), static_cast(b).cast());\ + return FUNCTION(a(), b());\ }\ _GLM_SWIZZLE_TEMPLATE1\ - typename S0::RETURN_TYPE FUNCTION(const typename _GLM_SWIZZLE_TYPE1& a, const typename S0::vec_type& b)\ + typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const _GLM_SWIZZLE_TYPE1& a, const typename V& b)\ {\ - return FUNCTION(static_cast(a).cast(), b);\ + return FUNCTION(a(), b);\ }\ _GLM_SWIZZLE_TEMPLATE1\ - typename S0::RETURN_TYPE FUNCTION(const typename S0::vec_type& a, const typename _GLM_SWIZZLE_TYPE1& b)\ + typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const V& a, const _GLM_SWIZZLE_TYPE1& b)\ {\ - return FUNCTION(a, static_cast(b).cast());\ - } \ - template \ - typename glm::detail::swizzle2::RETURN_TYPE FUNCTION(const glm::detail::swizzle2& a, const glm::detail::swizzle2& b) \ - { \ - return FUNCTION(a.cast(), b.cast()); \ - } \ - template \ - typename glm::detail::swizzle2_3::RETURN_TYPE FUNCTION(const glm::detail::swizzle2_3& a, const glm::detail::swizzle2_3& b) \ - { \ - return FUNCTION(a.cast(), b.cast()); \ - } \ - template \ - typename glm::detail::swizzle2_4::RETURN_TYPE FUNCTION(const glm::detail::swizzle2_4& a, const glm::detail::swizzle2_4& b) \ - { \ - return FUNCTION(a.cast(), b.cast()); \ - } \ - template \ - typename glm::detail::swizzle3_2::RETURN_TYPE FUNCTION(const glm::detail::swizzle3_2& a, const glm::detail::swizzle3_2& b) \ - { \ - return FUNCTION(a.cast(), b.cast()); \ - } \ - template \ - typename glm::detail::swizzle3::RETURN_TYPE FUNCTION(const glm::detail::swizzle3& a, const glm::detail::swizzle3& b) \ - { \ - return FUNCTION(a.cast(), b.cast()); \ - } \ - template \ - typename glm::detail::swizzle3_4::RETURN_TYPE FUNCTION(const glm::detail::swizzle3_4& a, const glm::detail::swizzle3_4& b) \ - { \ - return FUNCTION(a.cast(), b.cast()); \ - } \ - template \ - typename glm::detail::swizzle4_2::RETURN_TYPE FUNCTION(const glm::detail::swizzle4_2& a, const glm::detail::swizzle4_2& b) \ - { \ - return FUNCTION(a.cast(), b.cast()); \ - } \ - template \ - typename glm::detail::swizzle4_3::RETURN_TYPE FUNCTION(const glm::detail::swizzle4_3& a, const glm::detail::swizzle4_3& b) \ - { \ - return FUNCTION(a.cast(), b.cast()); \ - } \ - template \ - typename glm::detail::swizzle4::RETURN_TYPE FUNCTION(const glm::detail::swizzle4& a, const glm::detail::swizzle4& b) \ - { \ - return FUNCTION(a.cast(), b.cast()); \ - } + return FUNCTION(a, b());\ + } // // Macro for wrapping a function take 2 vec arguments followed by a scalar (e.g. mix()). // #define _GLM_SWIZZLE_FUNCTION_2_ARGS_SCALAR(RETURN_TYPE,FUNCTION)\ _GLM_SWIZZLE_TEMPLATE2\ - typename S0::RETURN_TYPE FUNCTION(const typename _GLM_SWIZZLE_TYPE1& a, const typename _GLM_SWIZZLE_TYPE2& b, const typename S0::value_type& c)\ + typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const _GLM_SWIZZLE_TYPE1& a, const _GLM_SWIZZLE_TYPE2& b, const T& c)\ {\ - return FUNCTION(static_cast(a).cast(), static_cast(b).cast(), c);\ + return FUNCTION(a(), b(), c);\ }\ _GLM_SWIZZLE_TEMPLATE1\ - typename S0::RETURN_TYPE FUNCTION(const typename _GLM_SWIZZLE_TYPE1& a, const typename _GLM_SWIZZLE_TYPE1& b, const typename S0::value_type& c)\ + typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const _GLM_SWIZZLE_TYPE1& a, const _GLM_SWIZZLE_TYPE1& b, const T& c)\ {\ - return FUNCTION(static_cast(a).cast(), static_cast(b).cast(), c);\ + return FUNCTION(a(), b(), c);\ }\ _GLM_SWIZZLE_TEMPLATE1\ - typename S0::RETURN_TYPE FUNCTION(const typename _GLM_SWIZZLE_TYPE1& a, const typename S0::vec_type& b, const typename S0::value_type& c)\ + typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const _GLM_SWIZZLE_TYPE1& a, const typename S0::vec_type& b, const T& c)\ {\ - return FUNCTION(static_cast(a).cast(), b, c);\ + return FUNCTION(a(), b, c);\ }\ _GLM_SWIZZLE_TEMPLATE1\ - typename S0::RETURN_TYPE FUNCTION(const typename S0::vec_type& a, const typename _GLM_SWIZZLE_TYPE1& b, const typename S0::value_type& c)\ + typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const typename V& a, const _GLM_SWIZZLE_TYPE1& b, const T& c)\ {\ - return FUNCTION(a, static_cast(b).cast(), c);\ - } \ - template \ - typename glm::detail::swizzle2::RETURN_TYPE FUNCTION(const glm::detail::swizzle2& a, const glm::detail::swizzle2& b, const T& c) \ - { \ - return FUNCTION(a.cast(), b.cast(), c); \ - } \ - template \ - typename glm::detail::swizzle2_3::RETURN_TYPE FUNCTION(const glm::detail::swizzle2_3& a, const glm::detail::swizzle2_3& b, const T& c) \ - { \ - return FUNCTION(a.cast(), b.cast(), c); \ - } \ - template \ - typename glm::detail::swizzle2_4::RETURN_TYPE FUNCTION(const glm::detail::swizzle2_4& a, const glm::detail::swizzle2_4& b, const T& c) \ - { \ - return FUNCTION(a.cast(), b.cast(), c); \ - } \ - template \ - typename glm::detail::swizzle3_2::RETURN_TYPE FUNCTION(const glm::detail::swizzle3_2& a, const glm::detail::swizzle3_2& b, const T& c) \ - { \ - return FUNCTION(a.cast(), b.cast(), c); \ - } \ - template \ - typename glm::detail::swizzle3::RETURN_TYPE FUNCTION(const glm::detail::swizzle3& a, const glm::detail::swizzle3& b, const T& c) \ - { \ - return FUNCTION(a.cast(), b.cast(), c); \ - } - template \ - typename glm::detail::swizzle3_4::RETURN_TYPE FUNCTION(const glm::detail::swizzle3_4& a, const glm::detail::swizzle3_4& b, const T& c) \ - { \ - return FUNCTION(a.cast(), b.cast(), c); \ - } \ - template \ - typename glm::detail::swizzle4_2::RETURN_TYPE FUNCTION(const glm::detail::swizzle4_2& a, const glm::detail::swizzle4_2& b, const T& c) \ - { \ - return FUNCTION(a.cast(), b.cast(), c); \ - } \ - template \ - typename glm::detail::swizzle4_3::RETURN_TYPE FUNCTION(const glm::detail::swizzle4_3& a, const glm::detail::swizzle4_3& b, const T& c) \ - { \ - return FUNCTION(a.cast(), b.cast(), c); \ - } \ - template \ - typename glm::detail::swizzle4::RETURN_TYPE FUNCTION(const glm::detail::swizzle4& a, const glm::detail::swizzle4& b, const T& c) \ - { \ - return FUNCTION(a.cast(), b.cast(), c); \ - } - + return FUNCTION(a, b(), c);\ + } + }//namespace detail }//namespace glm @@ -515,7 +321,7 @@ namespace glm { _GLM_SWIZZLE_SCALAR_BINARY_OPERATOR_IMPLEMENTATION(-) _GLM_SWIZZLE_SCALAR_BINARY_OPERATOR_IMPLEMENTATION(*) - + _GLM_SWIZZLE_VECTOR_BINARY_OPERATOR_IMPLEMENTATION(+) _GLM_SWIZZLE_VECTOR_BINARY_OPERATOR_IMPLEMENTATION(-) _GLM_SWIZZLE_VECTOR_BINARY_OPERATOR_IMPLEMENTATION(*) @@ -546,515 +352,498 @@ namespace glm #define _GLM_SWIZZLE2_2_MEMBERS(T,P,E0,E1) \ - struct { glm::detail::swizzle2 E0 ## E0; }; \ - struct { glm::detail::swizzle2 E0 ## E1; }; \ - struct { glm::detail::swizzle2 E1 ## E0; }; \ - struct { glm::detail::swizzle2 E1 ## E1; }; + struct { glm::detail::swizzle<2,T,P,0,0,-1,-2> E0 ## E0; }; \ + struct { glm::detail::swizzle<2,T,P,0,1,-1,-2> E0 ## E1; }; \ + struct { glm::detail::swizzle<2,T,P,1,0,-1,-2> E1 ## E0; }; \ + struct { glm::detail::swizzle<2,T,P,1,1,-1,-2> E1 ## E1; }; #define _GLM_SWIZZLE2_3_MEMBERS(T,P2,E0,E1) \ - struct { glm::detail::swizzle2_3 E0 ## E0 ## E0; }; \ - struct { glm::detail::swizzle2_3 E0 ## E0 ## E1; }; \ - struct { glm::detail::swizzle2_3 E0 ## E1 ## E0; }; \ - struct { glm::detail::swizzle2_3 E0 ## E1 ## E1; }; \ - struct { glm::detail::swizzle2_3 E1 ## E0 ## E0; }; \ - struct { glm::detail::swizzle2_3 E1 ## E0 ## E1; }; \ - struct { glm::detail::swizzle2_3 E1 ## E1 ## E0; }; \ - struct { glm::detail::swizzle2_3 E1 ## E1 ## E1; }; + struct { glm::detail::swizzle<3,T,P2,0,0,0,-1> E0 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<3,T,P2,0,0,1,-1> E0 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<3,T,P2,0,1,0,-1> E0 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<3,T,P2,0,1,1,-1> E0 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<3,T,P2,1,0,0,-1> E1 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<3,T,P2,1,0,1,-1> E1 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<3,T,P2,1,1,0,-1> E1 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<3,T,P2,1,1,1,-1> E1 ## E1 ## E1; }; #define _GLM_SWIZZLE3_3_MEMBERS(T,P,E0,E1,E2) \ - struct { glm::detail::swizzle3 E0 ## E0 ## E0; }; \ - struct { glm::detail::swizzle3 E0 ## E0 ## E1; }; \ - struct { glm::detail::swizzle3 E0 ## E0 ## E2; }; \ - struct { glm::detail::swizzle3 E0 ## E1 ## E0; }; \ - struct { glm::detail::swizzle3 E0 ## E1 ## E1; }; \ - struct { glm::detail::swizzle3 E0 ## E1 ## E2; }; \ - struct { glm::detail::swizzle3 E0 ## E2 ## E0; }; \ - struct { glm::detail::swizzle3 E0 ## E2 ## E1; }; \ - struct { glm::detail::swizzle3 E0 ## E2 ## E2; }; \ + struct { glm::detail::swizzle<3,T,P,0,0,0,-1> E0 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<3,T,P,0,0,1,-1> E0 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<3,T,P,0,0,2,-1> E0 ## E0 ## E2; }; \ + struct { glm::detail::swizzle<3,T,P,0,1,0,-1> E0 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<3,T,P,0,1,1,-1> E0 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<3,T,P,0,1,2,-1> E0 ## E1 ## E2; }; \ + struct { glm::detail::swizzle<3,T,P,0,2,0,-1> E0 ## E2 ## E0; }; \ + struct { glm::detail::swizzle<3,T,P,0,2,1,-1> E0 ## E2 ## E1; }; \ + struct { glm::detail::swizzle<3,T,P,0,2,2,-1> E0 ## E2 ## E2; }; \ \ - struct { glm::detail::swizzle3 E1 ## E0 ## E0; }; \ - struct { glm::detail::swizzle3 E1 ## E0 ## E1; }; \ - struct { glm::detail::swizzle3 E1 ## E0 ## E2; }; \ - struct { glm::detail::swizzle3 E1 ## E1 ## E0; }; \ - struct { glm::detail::swizzle3 E1 ## E1 ## E1; }; \ - struct { glm::detail::swizzle3 E1 ## E1 ## E2; }; \ - struct { glm::detail::swizzle3 E1 ## E2 ## E0; }; \ - struct { glm::detail::swizzle3 E1 ## E2 ## E1; }; \ - struct { glm::detail::swizzle3 E1 ## E2 ## E2; }; \ + struct { glm::detail::swizzle<3,T,P,1,0,0,-1> E1 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<3,T,P,1,0,1,-1> E1 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<3,T,P,1,0,2,-1> E1 ## E0 ## E2; }; \ + struct { glm::detail::swizzle<3,T,P,1,1,0,-1> E1 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<3,T,P,1,1,1,-1> E1 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<3,T,P,1,1,2,-1> E1 ## E1 ## E2; }; \ + struct { glm::detail::swizzle<3,T,P,1,2,0,-1> E1 ## E2 ## E0; }; \ + struct { glm::detail::swizzle<3,T,P,1,2,1,-1> E1 ## E2 ## E1; }; \ + struct { glm::detail::swizzle<3,T,P,1,2,2,-1> E1 ## E2 ## E2; }; \ \ - struct { glm::detail::swizzle3 E2 ## E0 ## E0; }; \ - struct { glm::detail::swizzle3 E2 ## E0 ## E1; }; \ - struct { glm::detail::swizzle3 E2 ## E0 ## E2; }; \ - struct { glm::detail::swizzle3 E2 ## E1 ## E0; }; \ - struct { glm::detail::swizzle3 E2 ## E1 ## E1; }; \ - struct { glm::detail::swizzle3 E2 ## E1 ## E2; }; \ - struct { glm::detail::swizzle3 E2 ## E2 ## E0; }; \ - struct { glm::detail::swizzle3 E2 ## E2 ## E1; }; \ - struct { glm::detail::swizzle3 E2 ## E2 ## E2; }; + struct { glm::detail::swizzle<3,T,P,2,0,0,-1> E2 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<3,T,P,2,0,1,-1> E2 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<3,T,P,2,0,2,-1> E2 ## E0 ## E2; }; \ + struct { glm::detail::swizzle<3,T,P,2,1,0,-1> E2 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<3,T,P,2,1,1,-1> E2 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<3,T,P,2,1,2,-1> E2 ## E1 ## E2; }; \ + struct { glm::detail::swizzle<3,T,P,2,2,0,-1> E2 ## E2 ## E0; }; \ + struct { glm::detail::swizzle<3,T,P,2,2,1,-1> E2 ## E2 ## E1; }; \ + struct { glm::detail::swizzle<3,T,P,2,2,2,-1> E2 ## E2 ## E2; }; #define _GLM_SWIZZLE3_2_MEMBERS(T,P2,E0,E1,E2) \ - struct { glm::detail::swizzle3_2 E0 ## E0; }; \ - struct { glm::detail::swizzle3_2 E0 ## E1; }; \ - struct { glm::detail::swizzle3_2 E0 ## E2; }; \ - struct { glm::detail::swizzle3_2 E1 ## E0; }; \ - struct { glm::detail::swizzle3_2 E1 ## E1; }; \ - struct { glm::detail::swizzle3_2 E1 ## E2; }; \ - struct { glm::detail::swizzle3_2 E2 ## E0; }; \ - struct { glm::detail::swizzle3_2 E2 ## E1; }; \ - struct { glm::detail::swizzle3_2 E2 ## E2; }; + struct { glm::detail::swizzle<2,T,P2,0,0,-1,-2> E0 ## E0; }; \ + struct { glm::detail::swizzle<2,T,P2,0,1,-1,-2> E0 ## E1; }; \ + struct { glm::detail::swizzle<2,T,P2,0,2,-1,-2> E0 ## E2; }; \ + struct { glm::detail::swizzle<2,T,P2,1,0,-1,-2> E1 ## E0; }; \ + struct { glm::detail::swizzle<2,T,P2,1,1,-1,-2> E1 ## E1; }; \ + struct { glm::detail::swizzle<2,T,P2,1,2,-1,-2> E1 ## E2; }; \ + struct { glm::detail::swizzle<2,T,P2,2,0,-1,-2> E2 ## E0; }; \ + struct { glm::detail::swizzle<2,T,P2,2,1,-1,-2> E2 ## E1; }; \ + struct { glm::detail::swizzle<2,T,P2,2,2,-1,-2> E2 ## E2; }; #define _GLM_SWIZZLE3_4_MEMBERS(T,P2,E0,E1,E2) \ - struct { glm::detail::swizzle3_4 E0 ## E0 ## E0 ## E0; }; \ - struct { glm::detail::swizzle3_4 E0 ## E0 ## E0 ## E1; }; \ - struct { glm::detail::swizzle3_4 E0 ## E0 ## E0 ## E2; }; \ - struct { glm::detail::swizzle3_4 E0 ## E0 ## E1 ## E0; }; \ - struct { glm::detail::swizzle3_4 E0 ## E0 ## E1 ## E1; }; \ - struct { glm::detail::swizzle3_4 E0 ## E0 ## E1 ## E2; }; \ - struct { glm::detail::swizzle3_4 E0 ## E0 ## E2 ## E0; }; \ - struct { glm::detail::swizzle3_4 E0 ## E0 ## E2 ## E1; }; \ - struct { glm::detail::swizzle3_4 E0 ## E0 ## E2 ## E2; }; \ - struct { glm::detail::swizzle3_4 E0 ## E1 ## E0 ## E0; }; \ - struct { glm::detail::swizzle3_4 E0 ## E1 ## E0 ## E1; }; \ - struct { glm::detail::swizzle3_4 E0 ## E1 ## E0 ## E2; }; \ - struct { glm::detail::swizzle3_4 E0 ## E1 ## E1 ## E0; }; \ - struct { glm::detail::swizzle3_4 E0 ## E1 ## E1 ## E1; }; \ - struct { glm::detail::swizzle3_4 E0 ## E1 ## E1 ## E2; }; \ - struct { glm::detail::swizzle3_4 E0 ## E1 ## E2 ## E0; }; \ - struct { glm::detail::swizzle3_4 E0 ## E1 ## E2 ## E1; }; \ - struct { glm::detail::swizzle3_4 E0 ## E1 ## E2 ## E2; }; \ - struct { glm::detail::swizzle3_4 E0 ## E2 ## E0 ## E0; }; \ - struct { glm::detail::swizzle3_4 E0 ## E2 ## E0 ## E1; }; \ - struct { glm::detail::swizzle3_4 E0 ## E2 ## E0 ## E2; }; \ - struct { glm::detail::swizzle3_4 E0 ## E2 ## E1 ## E0; }; \ - struct { glm::detail::swizzle3_4 E0 ## E2 ## E1 ## E1; }; \ - struct { glm::detail::swizzle3_4 E0 ## E2 ## E1 ## E2; }; \ - struct { glm::detail::swizzle3_4 E0 ## E2 ## E2 ## E0; }; \ - struct { glm::detail::swizzle3_4 E0 ## E2 ## E2 ## E1; }; \ - struct { glm::detail::swizzle3_4 E0 ## E2 ## E2 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P2,0,0,0,0> E0 ## E0 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,0,0,0,1> E0 ## E0 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,0,0,0,2> E0 ## E0 ## E0 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P2,0,0,1,0> E0 ## E0 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,0,0,1,1> E0 ## E0 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,0,0,1,2> E0 ## E0 ## E1 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P2,0,0,2,0> E0 ## E0 ## E2 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,0,0,2,1> E0 ## E0 ## E2 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,0,0,2,2> E0 ## E0 ## E2 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P2,0,1,0,0> E0 ## E1 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,0,1,0,1> E0 ## E1 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,0,1,0,2> E0 ## E1 ## E0 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P2,0,1,1,0> E0 ## E1 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,0,1,1,1> E0 ## E1 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,0,1,1,2> E0 ## E1 ## E1 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P2,0,1,2,0> E0 ## E1 ## E2 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,0,1,2,1> E0 ## E1 ## E2 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,0,1,2,2> E0 ## E1 ## E2 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P2,0,2,0,0> E0 ## E2 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,0,2,0,1> E0 ## E2 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,0,2,0,2> E0 ## E2 ## E0 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P2,0,2,1,0> E0 ## E2 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,0,2,1,1> E0 ## E2 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,0,2,1,2> E0 ## E2 ## E1 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P2,0,2,2,0> E0 ## E2 ## E2 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,0,2,2,1> E0 ## E2 ## E2 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,0,2,2,2> E0 ## E2 ## E2 ## E2; }; \ \ - struct { glm::detail::swizzle3_4 E1 ## E0 ## E0 ## E0; }; \ - struct { glm::detail::swizzle3_4 E1 ## E0 ## E0 ## E1; }; \ - struct { glm::detail::swizzle3_4 E1 ## E0 ## E0 ## E2; }; \ - struct { glm::detail::swizzle3_4 E1 ## E0 ## E1 ## E0; }; \ - struct { glm::detail::swizzle3_4 E1 ## E0 ## E1 ## E1; }; \ - struct { glm::detail::swizzle3_4 E1 ## E0 ## E1 ## E2; }; \ - struct { glm::detail::swizzle3_4 E1 ## E0 ## E2 ## E0; }; \ - struct { glm::detail::swizzle3_4 E1 ## E0 ## E2 ## E1; }; \ - struct { glm::detail::swizzle3_4 E1 ## E0 ## E2 ## E2; }; \ - struct { glm::detail::swizzle3_4 E1 ## E1 ## E0 ## E0; }; \ - struct { glm::detail::swizzle3_4 E1 ## E1 ## E0 ## E1; }; \ - struct { glm::detail::swizzle3_4 E1 ## E1 ## E0 ## E2; }; \ - struct { glm::detail::swizzle3_4 E1 ## E1 ## E1 ## E0; }; \ - struct { glm::detail::swizzle3_4 E1 ## E1 ## E1 ## E1; }; \ - struct { glm::detail::swizzle3_4 E1 ## E1 ## E1 ## E2; }; \ - struct { glm::detail::swizzle3_4 E1 ## E1 ## E2 ## E0; }; \ - struct { glm::detail::swizzle3_4 E1 ## E1 ## E2 ## E1; }; \ - struct { glm::detail::swizzle3_4 E1 ## E1 ## E2 ## E2; }; \ - struct { glm::detail::swizzle3_4 E1 ## E2 ## E0 ## E0; }; \ - struct { glm::detail::swizzle3_4 E1 ## E2 ## E0 ## E1; }; \ - struct { glm::detail::swizzle3_4 E1 ## E2 ## E0 ## E2; }; \ - struct { glm::detail::swizzle3_4 E1 ## E2 ## E1 ## E0; }; \ - struct { glm::detail::swizzle3_4 E1 ## E2 ## E1 ## E1; }; \ - struct { glm::detail::swizzle3_4 E1 ## E2 ## E1 ## E2; }; \ - struct { glm::detail::swizzle3_4 E1 ## E2 ## E2 ## E0; }; \ - struct { glm::detail::swizzle3_4 E1 ## E2 ## E2 ## E1; }; \ - struct { glm::detail::swizzle3_4 E1 ## E2 ## E2 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P2,1,0,0,0> E1 ## E0 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,1,0,0,1> E1 ## E0 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,1,0,0,2> E1 ## E0 ## E0 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P2,1,0,1,0> E1 ## E0 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,1,0,1,1> E1 ## E0 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,1,0,1,2> E1 ## E0 ## E1 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P2,1,0,2,0> E1 ## E0 ## E2 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,1,0,2,1> E1 ## E0 ## E2 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,1,0,2,2> E1 ## E0 ## E2 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P2,1,1,0,0> E1 ## E1 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,1,1,0,1> E1 ## E1 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,1,1,0,2> E1 ## E1 ## E0 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P2,1,1,1,0> E1 ## E1 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,1,1,1,1> E1 ## E1 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,1,1,1,2> E1 ## E1 ## E1 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P2,1,1,2,0> E1 ## E1 ## E2 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,1,1,2,1> E1 ## E1 ## E2 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,1,1,2,2> E1 ## E1 ## E2 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P2,1,2,0,0> E1 ## E2 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,1,2,0,1> E1 ## E2 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,1,2,0,2> E1 ## E2 ## E0 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P2,1,2,1,0> E1 ## E2 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,1,2,1,1> E1 ## E2 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,1,2,1,2> E1 ## E2 ## E1 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P2,1,2,2,0> E1 ## E2 ## E2 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,1,2,2,1> E1 ## E2 ## E2 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,1,2,2,2> E1 ## E2 ## E2 ## E2; }; \ \ - struct { glm::detail::swizzle3_4 E2 ## E0 ## E0 ## E0; }; \ - struct { glm::detail::swizzle3_4 E2 ## E0 ## E0 ## E1; }; \ - struct { glm::detail::swizzle3_4 E2 ## E0 ## E0 ## E2; }; \ - struct { glm::detail::swizzle3_4 E2 ## E0 ## E1 ## E0; }; \ - struct { glm::detail::swizzle3_4 E2 ## E0 ## E1 ## E1; }; \ - struct { glm::detail::swizzle3_4 E2 ## E0 ## E1 ## E2; }; \ - struct { glm::detail::swizzle3_4 E2 ## E0 ## E2 ## E0; }; \ - struct { glm::detail::swizzle3_4 E2 ## E0 ## E2 ## E1; }; \ - struct { glm::detail::swizzle3_4 E2 ## E0 ## E2 ## E2; }; \ - struct { glm::detail::swizzle3_4 E2 ## E1 ## E0 ## E0; }; \ - struct { glm::detail::swizzle3_4 E2 ## E1 ## E0 ## E1; }; \ - struct { glm::detail::swizzle3_4 E2 ## E1 ## E0 ## E2; }; \ - struct { glm::detail::swizzle3_4 E2 ## E1 ## E1 ## E0; }; \ - struct { glm::detail::swizzle3_4 E2 ## E1 ## E1 ## E1; }; \ - struct { glm::detail::swizzle3_4 E2 ## E1 ## E1 ## E2; }; \ - struct { glm::detail::swizzle3_4 E2 ## E1 ## E2 ## E0; }; \ - struct { glm::detail::swizzle3_4 E2 ## E1 ## E2 ## E1; }; \ - struct { glm::detail::swizzle3_4 E2 ## E1 ## E2 ## E2; }; \ - struct { glm::detail::swizzle3_4 E2 ## E2 ## E0 ## E0; }; \ - struct { glm::detail::swizzle3_4 E2 ## E2 ## E0 ## E1; }; \ - struct { glm::detail::swizzle3_4 E2 ## E2 ## E0 ## E2; }; \ - struct { glm::detail::swizzle3_4 E2 ## E2 ## E1 ## E0; }; \ - struct { glm::detail::swizzle3_4 E2 ## E2 ## E1 ## E1; }; \ - struct { glm::detail::swizzle3_4 E2 ## E2 ## E1 ## E2; }; \ - struct { glm::detail::swizzle3_4 E2 ## E2 ## E2 ## E0; }; \ - struct { glm::detail::swizzle3_4 E2 ## E2 ## E2 ## E1; }; \ - struct { glm::detail::swizzle3_4 E2 ## E2 ## E2 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P2,2,0,0,0> E2 ## E0 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,2,0,0,1> E2 ## E0 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,2,0,0,2> E2 ## E0 ## E0 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P2,2,0,1,0> E2 ## E0 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,2,0,1,1> E2 ## E0 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,2,0,1,2> E2 ## E0 ## E1 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P2,2,0,2,0> E2 ## E0 ## E2 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,2,0,2,1> E2 ## E0 ## E2 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,2,0,2,2> E2 ## E0 ## E2 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P2,2,1,0,0> E2 ## E1 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,2,1,0,1> E2 ## E1 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,2,1,0,2> E2 ## E1 ## E0 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P2,2,1,1,0> E2 ## E1 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,2,1,1,1> E2 ## E1 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,2,1,1,2> E2 ## E1 ## E1 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P2,2,1,2,0> E2 ## E1 ## E2 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,2,1,2,1> E2 ## E1 ## E2 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,2,1,2,2> E2 ## E1 ## E2 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P2,2,2,0,0> E2 ## E2 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,2,2,0,1> E2 ## E2 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,2,2,0,2> E2 ## E2 ## E0 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P2,2,2,1,0> E2 ## E2 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,2,2,1,1> E2 ## E2 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,2,2,1,2> E2 ## E2 ## E1 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P2,2,2,2,0> E2 ## E2 ## E2 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,2,2,2,1> E2 ## E2 ## E2 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,2,2,2,2> E2 ## E2 ## E2 ## E2; }; \ #define _GLM_SWIZZLE2_4_MEMBERS(T,P2,E0,E1) \ - struct { glm::detail::swizzle2_4 E0 ## E0 ## E0 ## E0; }; \ - struct { glm::detail::swizzle2_4 E0 ## E0 ## E0 ## E1; }; \ - struct { glm::detail::swizzle2_4 E0 ## E0 ## E1 ## E0; }; \ - struct { glm::detail::swizzle2_4 E0 ## E0 ## E1 ## E1; }; \ - struct { glm::detail::swizzle2_4 E0 ## E1 ## E0 ## E0; }; \ - struct { glm::detail::swizzle2_4 E0 ## E1 ## E0 ## E1; }; \ - struct { glm::detail::swizzle2_4 E0 ## E1 ## E1 ## E0; }; \ - struct { glm::detail::swizzle2_4 E0 ## E1 ## E1 ## E1; }; \ - struct { glm::detail::swizzle2_4 E1 ## E0 ## E0 ## E0; }; \ - struct { glm::detail::swizzle2_4 E1 ## E0 ## E0 ## E1; }; \ - struct { glm::detail::swizzle2_4 E1 ## E0 ## E1 ## E0; }; \ - struct { glm::detail::swizzle2_4 E1 ## E0 ## E1 ## E1; }; \ - struct { glm::detail::swizzle2_4 E1 ## E1 ## E0 ## E0; }; \ - struct { glm::detail::swizzle2_4 E1 ## E1 ## E0 ## E1; }; \ - struct { glm::detail::swizzle2_4 E1 ## E1 ## E1 ## E0; }; \ - struct { glm::detail::swizzle2_4 E1 ## E1 ## E1 ## E1; }; + struct { glm::detail::swizzle<4,T,P2,0,0,0,0> E0 ## E0 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,0,0,0,1> E0 ## E0 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,0,0,1,0> E0 ## E0 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,0,0,1,1> E0 ## E0 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,0,1,0,0> E0 ## E1 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,0,1,0,1> E0 ## E1 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,0,1,1,0> E0 ## E1 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,0,1,1,1> E0 ## E1 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,1,0,0,0> E1 ## E0 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,1,0,0,1> E1 ## E0 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,1,0,1,0> E1 ## E0 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,1,0,1,1> E1 ## E0 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,1,1,0,0> E1 ## E1 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,1,1,0,1> E1 ## E1 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,1,1,1,0> E1 ## E1 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,1,1,1,1> E1 ## E1 ## E1 ## E1; }; #define _GLM_SWIZZLE4_2_MEMBERS(T,P,E0,E1,E2,E3) \ - struct { glm::detail::swizzle4_2 E0 ## E0; }; \ - struct { glm::detail::swizzle4_2 E0 ## E1; }; \ - struct { glm::detail::swizzle4_2 E0 ## E2; }; \ - struct { glm::detail::swizzle4_2 E0 ## E3; }; \ - struct { glm::detail::swizzle4_2 E1 ## E0; }; \ - struct { glm::detail::swizzle4_2 E1 ## E1; }; \ - struct { glm::detail::swizzle4_2 E1 ## E2; }; \ - struct { glm::detail::swizzle4_2 E1 ## E3; }; \ - struct { glm::detail::swizzle4_2 E2 ## E0; }; \ - struct { glm::detail::swizzle4_2 E2 ## E1; }; \ - struct { glm::detail::swizzle4_2 E2 ## E2; }; \ - struct { glm::detail::swizzle4_2 E2 ## E3; }; \ - struct { glm::detail::swizzle4_2 E3 ## E0; }; \ - struct { glm::detail::swizzle4_2 E3 ## E1; }; \ - struct { glm::detail::swizzle4_2 E3 ## E2; }; \ - struct { glm::detail::swizzle4_2 E3 ## E3; }; + struct { glm::detail::swizzle<2,T,P,0,0,-1,-2> E0 ## E0; }; \ + struct { glm::detail::swizzle<2,T,P,0,1,-1,-2> E0 ## E1; }; \ + struct { glm::detail::swizzle<2,T,P,0,2,-1,-2> E0 ## E2; }; \ + struct { glm::detail::swizzle<2,T,P,0,3,-1,-2> E0 ## E3; }; \ + struct { glm::detail::swizzle<2,T,P,1,0,-1,-2> E1 ## E0; }; \ + struct { glm::detail::swizzle<2,T,P,1,1,-1,-2> E1 ## E1; }; \ + struct { glm::detail::swizzle<2,T,P,1,2,-1,-2> E1 ## E2; }; \ + struct { glm::detail::swizzle<2,T,P,1,3,-1,-2> E1 ## E3; }; \ + struct { glm::detail::swizzle<2,T,P,2,0,-1,-2> E2 ## E0; }; \ + struct { glm::detail::swizzle<2,T,P,2,1,-1,-2> E2 ## E1; }; \ + struct { glm::detail::swizzle<2,T,P,2,2,-1,-2> E2 ## E2; }; \ + struct { glm::detail::swizzle<2,T,P,2,3,-1,-2> E2 ## E3; }; \ + struct { glm::detail::swizzle<2,T,P,3,0,-1,-2> E3 ## E0; }; \ + struct { glm::detail::swizzle<2,T,P,3,1,-1,-2> E3 ## E1; }; \ + struct { glm::detail::swizzle<2,T,P,3,2,-1,-2> E3 ## E2; }; \ + struct { glm::detail::swizzle<2,T,P,3,3,-1,-2> E3 ## E3; }; #define _GLM_SWIZZLE4_3_MEMBERS(T,P,E0,E1,E2,E3) \ - struct { glm::detail::swizzle4_3 E0 ## E0 ## E0; }; \ - struct { glm::detail::swizzle4_3 E0 ## E0 ## E1; }; \ - struct { glm::detail::swizzle4_3 E0 ## E0 ## E2; }; \ - struct { glm::detail::swizzle4_3 E0 ## E0 ## E3; }; \ - struct { glm::detail::swizzle4_3 E0 ## E1 ## E0; }; \ - struct { glm::detail::swizzle4_3 E0 ## E1 ## E1; }; \ - struct { glm::detail::swizzle4_3 E0 ## E1 ## E2; }; \ - struct { glm::detail::swizzle4_3 E0 ## E1 ## E3; }; \ - struct { glm::detail::swizzle4_3 E0 ## E2 ## E0; }; \ - struct { glm::detail::swizzle4_3 E0 ## E2 ## E1; }; \ - struct { glm::detail::swizzle4_3 E0 ## E2 ## E2; }; \ - struct { glm::detail::swizzle4_3 E0 ## E2 ## E3; }; \ - struct { glm::detail::swizzle4_3 E0 ## E3 ## E0; }; \ - struct { glm::detail::swizzle4_3 E0 ## E3 ## E1; }; \ - struct { glm::detail::swizzle4_3 E0 ## E3 ## E2; }; \ - struct { glm::detail::swizzle4_3 E0 ## E3 ## E3; }; \ + struct { glm::detail::swizzle<3,T,P,0,0,0,-1> E0 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<3,T,P,0,0,1,-1> E0 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<3,T,P,0,0,2,-1> E0 ## E0 ## E2; }; \ + struct { glm::detail::swizzle<3,T,P,0,0,3,-1> E0 ## E0 ## E3; }; \ + struct { glm::detail::swizzle<3,T,P,0,1,0,-1> E0 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<3,T,P,0,1,1,-1> E0 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<3,T,P,0,1,2,-1> E0 ## E1 ## E2; }; \ + struct { glm::detail::swizzle<3,T,P,0,1,3,-1> E0 ## E1 ## E3; }; \ + struct { glm::detail::swizzle<3,T,P,0,2,0,-1> E0 ## E2 ## E0; }; \ + struct { glm::detail::swizzle<3,T,P,0,2,1,-1> E0 ## E2 ## E1; }; \ + struct { glm::detail::swizzle<3,T,P,0,2,2,-1> E0 ## E2 ## E2; }; \ + struct { glm::detail::swizzle<3,T,P,0,2,3,-1> E0 ## E2 ## E3; }; \ + struct { glm::detail::swizzle<3,T,P,0,3,0,-1> E0 ## E3 ## E0; }; \ + struct { glm::detail::swizzle<3,T,P,0,3,1,-1> E0 ## E3 ## E1; }; \ + struct { glm::detail::swizzle<3,T,P,0,3,2,-1> E0 ## E3 ## E2; }; \ + struct { glm::detail::swizzle<3,T,P,0,3,3,-1> E0 ## E3 ## E3; }; \ \ - struct { glm::detail::swizzle4_3 E1 ## E0 ## E0; }; \ - struct { glm::detail::swizzle4_3 E1 ## E0 ## E1; }; \ - struct { glm::detail::swizzle4_3 E1 ## E0 ## E2; }; \ - struct { glm::detail::swizzle4_3 E1 ## E0 ## E3; }; \ - struct { glm::detail::swizzle4_3 E1 ## E1 ## E0; }; \ - struct { glm::detail::swizzle4_3 E1 ## E1 ## E1; }; \ - struct { glm::detail::swizzle4_3 E1 ## E1 ## E2; }; \ - struct { glm::detail::swizzle4_3 E1 ## E1 ## E3; }; \ - struct { glm::detail::swizzle4_3 E1 ## E2 ## E0; }; \ - struct { glm::detail::swizzle4_3 E1 ## E2 ## E1; }; \ - struct { glm::detail::swizzle4_3 E1 ## E2 ## E2; }; \ - struct { glm::detail::swizzle4_3 E1 ## E2 ## E3; }; \ - struct { glm::detail::swizzle4_3 E1 ## E3 ## E0; }; \ - struct { glm::detail::swizzle4_3 E1 ## E3 ## E1; }; \ - struct { glm::detail::swizzle4_3 E1 ## E3 ## E2; }; \ - struct { glm::detail::swizzle4_3 E1 ## E3 ## E3; }; \ + struct { glm::detail::swizzle<3,T,P,1,0,0,-1> E1 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<3,T,P,1,0,1,-1> E1 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<3,T,P,1,0,2,-1> E1 ## E0 ## E2; }; \ + struct { glm::detail::swizzle<3,T,P,1,0,3,-1> E1 ## E0 ## E3; }; \ + struct { glm::detail::swizzle<3,T,P,1,1,0,-1> E1 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<3,T,P,1,1,1,-1> E1 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<3,T,P,1,1,2,-1> E1 ## E1 ## E2; }; \ + struct { glm::detail::swizzle<3,T,P,1,1,3,-1> E1 ## E1 ## E3; }; \ + struct { glm::detail::swizzle<3,T,P,1,2,0,-1> E1 ## E2 ## E0; }; \ + struct { glm::detail::swizzle<3,T,P,1,2,1,-1> E1 ## E2 ## E1; }; \ + struct { glm::detail::swizzle<3,T,P,1,2,2,-1> E1 ## E2 ## E2; }; \ + struct { glm::detail::swizzle<3,T,P,1,2,3,-1> E1 ## E2 ## E3; }; \ + struct { glm::detail::swizzle<3,T,P,1,3,0,-1> E1 ## E3 ## E0; }; \ + struct { glm::detail::swizzle<3,T,P,1,3,1,-1> E1 ## E3 ## E1; }; \ + struct { glm::detail::swizzle<3,T,P,1,3,2,-1> E1 ## E3 ## E2; }; \ + struct { glm::detail::swizzle<3,T,P,1,3,3,-1> E1 ## E3 ## E3; }; \ \ - struct { glm::detail::swizzle4_3 E2 ## E0 ## E0; }; \ - struct { glm::detail::swizzle4_3 E2 ## E0 ## E1; }; \ - struct { glm::detail::swizzle4_3 E2 ## E0 ## E2; }; \ - struct { glm::detail::swizzle4_3 E2 ## E0 ## E3; }; \ - struct { glm::detail::swizzle4_3 E2 ## E1 ## E0; }; \ - struct { glm::detail::swizzle4_3 E2 ## E1 ## E1; }; \ - struct { glm::detail::swizzle4_3 E2 ## E1 ## E2; }; \ - struct { glm::detail::swizzle4_3 E2 ## E1 ## E3; }; \ - struct { glm::detail::swizzle4_3 E2 ## E2 ## E0; }; \ - struct { glm::detail::swizzle4_3 E2 ## E2 ## E1; }; \ - struct { glm::detail::swizzle4_3 E2 ## E2 ## E2; }; \ - struct { glm::detail::swizzle4_3 E2 ## E2 ## E3; }; \ - struct { glm::detail::swizzle4_3 E2 ## E3 ## E0; }; \ - struct { glm::detail::swizzle4_3 E2 ## E3 ## E1; }; \ - struct { glm::detail::swizzle4_3 E2 ## E3 ## E2; }; \ - struct { glm::detail::swizzle4_3 E2 ## E3 ## E3; }; \ + struct { glm::detail::swizzle<3,T,P,2,0,0,-1> E2 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<3,T,P,2,0,1,-1> E2 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<3,T,P,2,0,2,-1> E2 ## E0 ## E2; }; \ + struct { glm::detail::swizzle<3,T,P,2,0,3,-1> E2 ## E0 ## E3; }; \ + struct { glm::detail::swizzle<3,T,P,2,1,0,-1> E2 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<3,T,P,2,1,1,-1> E2 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<3,T,P,2,1,2,-1> E2 ## E1 ## E2; }; \ + struct { glm::detail::swizzle<3,T,P,2,1,3,-1> E2 ## E1 ## E3; }; \ + struct { glm::detail::swizzle<3,T,P,2,2,0,-1> E2 ## E2 ## E0; }; \ + struct { glm::detail::swizzle<3,T,P,2,2,1,-1> E2 ## E2 ## E1; }; \ + struct { glm::detail::swizzle<3,T,P,2,2,2,-1> E2 ## E2 ## E2; }; \ + struct { glm::detail::swizzle<3,T,P,2,2,3,-1> E2 ## E2 ## E3; }; \ + struct { glm::detail::swizzle<3,T,P,2,3,0,-1> E2 ## E3 ## E0; }; \ + struct { glm::detail::swizzle<3,T,P,2,3,1,-1> E2 ## E3 ## E1; }; \ + struct { glm::detail::swizzle<3,T,P,2,3,2,-1> E2 ## E3 ## E2; }; \ + struct { glm::detail::swizzle<3,T,P,2,3,3,-1> E2 ## E3 ## E3; }; \ \ - struct { glm::detail::swizzle4_3 E3 ## E0 ## E0; }; \ - struct { glm::detail::swizzle4_3 E3 ## E0 ## E1; }; \ - struct { glm::detail::swizzle4_3 E3 ## E0 ## E2; }; \ - struct { glm::detail::swizzle4_3 E3 ## E0 ## E3; }; \ - struct { glm::detail::swizzle4_3 E3 ## E1 ## E0; }; \ - struct { glm::detail::swizzle4_3 E3 ## E1 ## E1; }; \ - struct { glm::detail::swizzle4_3 E3 ## E1 ## E2; }; \ - struct { glm::detail::swizzle4_3 E3 ## E1 ## E3; }; \ - struct { glm::detail::swizzle4_3 E3 ## E2 ## E0; }; \ - struct { glm::detail::swizzle4_3 E3 ## E2 ## E1; }; \ - struct { glm::detail::swizzle4_3 E3 ## E2 ## E2; }; \ - struct { glm::detail::swizzle4_3 E3 ## E2 ## E3; }; \ - struct { glm::detail::swizzle4_3 E3 ## E3 ## E0; }; \ - struct { glm::detail::swizzle4_3 E3 ## E3 ## E1; }; \ - struct { glm::detail::swizzle4_3 E3 ## E3 ## E2; }; \ - struct { glm::detail::swizzle4_3 E3 ## E3 ## E3; }; + struct { glm::detail::swizzle<3,T,P,3,0,0,-1> E3 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<3,T,P,3,0,1,-1> E3 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<3,T,P,3,0,2,-1> E3 ## E0 ## E2; }; \ + struct { glm::detail::swizzle<3,T,P,3,0,3,-1> E3 ## E0 ## E3; }; \ + struct { glm::detail::swizzle<3,T,P,3,1,0,-1> E3 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<3,T,P,3,1,1,-1> E3 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<3,T,P,3,1,2,-1> E3 ## E1 ## E2; }; \ + struct { glm::detail::swizzle<3,T,P,3,1,3,-1> E3 ## E1 ## E3; }; \ + struct { glm::detail::swizzle<3,T,P,3,2,0,-1> E3 ## E2 ## E0; }; \ + struct { glm::detail::swizzle<3,T,P,3,2,1,-1> E3 ## E2 ## E1; }; \ + struct { glm::detail::swizzle<3,T,P,3,2,2,-1> E3 ## E2 ## E2; }; \ + struct { glm::detail::swizzle<3,T,P,3,2,3,-1> E3 ## E2 ## E3; }; \ + struct { glm::detail::swizzle<3,T,P,3,3,0,-1> E3 ## E3 ## E0; }; \ + struct { glm::detail::swizzle<3,T,P,3,3,1,-1> E3 ## E3 ## E1; }; \ + struct { glm::detail::swizzle<3,T,P,3,3,2,-1> E3 ## E3 ## E2; }; \ + struct { glm::detail::swizzle<3,T,P,3,3,3,-1> E3 ## E3 ## E3; }; #define _GLM_SWIZZLE4_4_MEMBERS(T,P,E0,E1,E2,E3) \ - struct { glm::detail::swizzle4 E0 ## E0 ## E0 ## E0; }; \ - struct { glm::detail::swizzle4 E0 ## E0 ## E0 ## E1; }; \ - struct { glm::detail::swizzle4 E0 ## E0 ## E0 ## E2; }; \ - struct { glm::detail::swizzle4 E0 ## E0 ## E0 ## E3; }; \ - struct { glm::detail::swizzle4 E0 ## E0 ## E1 ## E0; }; \ - struct { glm::detail::swizzle4 E0 ## E0 ## E1 ## E1; }; \ - struct { glm::detail::swizzle4 E0 ## E0 ## E1 ## E2; }; \ - struct { glm::detail::swizzle4 E0 ## E0 ## E1 ## E3; }; \ - struct { glm::detail::swizzle4 E0 ## E0 ## E2 ## E0; }; \ - struct { glm::detail::swizzle4 E0 ## E0 ## E2 ## E1; }; \ - struct { glm::detail::swizzle4 E0 ## E0 ## E2 ## E2; }; \ - struct { glm::detail::swizzle4 E0 ## E0 ## E2 ## E3; }; \ - struct { glm::detail::swizzle4 E0 ## E0 ## E3 ## E0; }; \ - struct { glm::detail::swizzle4 E0 ## E0 ## E3 ## E1; }; \ - struct { glm::detail::swizzle4 E0 ## E0 ## E3 ## E2; }; \ - struct { glm::detail::swizzle4 E0 ## E0 ## E3 ## E3; }; \ - \ - struct { glm::detail::swizzle4 E0 ## E1 ## E0 ## E0; }; \ - struct { glm::detail::swizzle4 E0 ## E1 ## E0 ## E1; }; \ - struct { glm::detail::swizzle4 E0 ## E1 ## E0 ## E2; }; \ - struct { glm::detail::swizzle4 E0 ## E1 ## E0 ## E3; }; \ - struct { glm::detail::swizzle4 E0 ## E1 ## E1 ## E0; }; \ - struct { glm::detail::swizzle4 E0 ## E1 ## E1 ## E1; }; \ - struct { glm::detail::swizzle4 E0 ## E1 ## E1 ## E2; }; \ - struct { glm::detail::swizzle4 E0 ## E1 ## E1 ## E3; }; \ - struct { glm::detail::swizzle4 E0 ## E1 ## E2 ## E0; }; \ - struct { glm::detail::swizzle4 E0 ## E1 ## E2 ## E1; }; \ - struct { glm::detail::swizzle4 E0 ## E1 ## E2 ## E2; }; \ - struct { glm::detail::swizzle4 E0 ## E1 ## E2 ## E3; }; \ - struct { glm::detail::swizzle4 E0 ## E1 ## E3 ## E0; }; \ - struct { glm::detail::swizzle4 E0 ## E1 ## E3 ## E1; }; \ - struct { glm::detail::swizzle4 E0 ## E1 ## E3 ## E2; }; \ - struct { glm::detail::swizzle4 E0 ## E1 ## E3 ## E3; }; \ - \ - struct { glm::detail::swizzle4 E0 ## E2 ## E0 ## E0; }; \ - struct { glm::detail::swizzle4 E0 ## E2 ## E0 ## E1; }; \ - struct { glm::detail::swizzle4 E0 ## E2 ## E0 ## E2; }; \ - struct { glm::detail::swizzle4 E0 ## E2 ## E0 ## E3; }; \ - struct { glm::detail::swizzle4 E0 ## E2 ## E1 ## E0; }; \ - struct { glm::detail::swizzle4 E0 ## E2 ## E1 ## E1; }; \ - struct { glm::detail::swizzle4 E0 ## E2 ## E1 ## E2; }; \ - struct { glm::detail::swizzle4 E0 ## E2 ## E1 ## E3; }; \ - struct { glm::detail::swizzle4 E0 ## E2 ## E2 ## E0; }; \ - struct { glm::detail::swizzle4 E0 ## E2 ## E2 ## E1; }; \ - struct { glm::detail::swizzle4 E0 ## E2 ## E2 ## E2; }; \ - struct { glm::detail::swizzle4 E0 ## E2 ## E2 ## E3; }; \ - struct { glm::detail::swizzle4 E0 ## E2 ## E3 ## E0; }; \ - struct { glm::detail::swizzle4 E0 ## E2 ## E3 ## E1; }; \ - struct { glm::detail::swizzle4 E0 ## E2 ## E3 ## E2; }; \ - struct { glm::detail::swizzle4 E0 ## E2 ## E3 ## E3; }; \ - \ - \ - struct { glm::detail::swizzle4 E1 ## E0 ## E0 ## E0; }; \ - struct { glm::detail::swizzle4 E1 ## E0 ## E0 ## E1; }; \ - struct { glm::detail::swizzle4 E1 ## E0 ## E0 ## E2; }; \ - struct { glm::detail::swizzle4 E1 ## E0 ## E0 ## E3; }; \ - struct { glm::detail::swizzle4 E1 ## E0 ## E1 ## E0; }; \ - struct { glm::detail::swizzle4 E1 ## E0 ## E1 ## E1; }; \ - struct { glm::detail::swizzle4 E1 ## E0 ## E1 ## E2; }; \ - struct { glm::detail::swizzle4 E1 ## E0 ## E1 ## E3; }; \ - struct { glm::detail::swizzle4 E1 ## E0 ## E2 ## E0; }; \ - struct { glm::detail::swizzle4 E1 ## E0 ## E2 ## E1; }; \ - struct { glm::detail::swizzle4 E1 ## E0 ## E2 ## E2; }; \ - struct { glm::detail::swizzle4 E1 ## E0 ## E2 ## E3; }; \ - struct { glm::detail::swizzle4 E1 ## E0 ## E3 ## E0; }; \ - struct { glm::detail::swizzle4 E1 ## E0 ## E3 ## E1; }; \ - struct { glm::detail::swizzle4 E1 ## E0 ## E3 ## E2; }; \ - struct { glm::detail::swizzle4 E1 ## E0 ## E3 ## E3; }; \ - \ - struct { glm::detail::swizzle4 E1 ## E1 ## E0 ## E0; }; \ - struct { glm::detail::swizzle4 E1 ## E1 ## E0 ## E1; }; \ - struct { glm::detail::swizzle4 E1 ## E1 ## E0 ## E2; }; \ - struct { glm::detail::swizzle4 E1 ## E1 ## E0 ## E3; }; \ - struct { glm::detail::swizzle4 E1 ## E1 ## E1 ## E0; }; \ - struct { glm::detail::swizzle4 E1 ## E1 ## E1 ## E1; }; \ - struct { glm::detail::swizzle4 E1 ## E1 ## E1 ## E2; }; \ - struct { glm::detail::swizzle4 E1 ## E1 ## E1 ## E3; }; \ - struct { glm::detail::swizzle4 E1 ## E1 ## E2 ## E0; }; \ - struct { glm::detail::swizzle4 E1 ## E1 ## E2 ## E1; }; \ - struct { glm::detail::swizzle4 E1 ## E1 ## E2 ## E2; }; \ - struct { glm::detail::swizzle4 E1 ## E1 ## E2 ## E3; }; \ - struct { glm::detail::swizzle4 E1 ## E1 ## E3 ## E0; }; \ - struct { glm::detail::swizzle4 E1 ## E1 ## E3 ## E1; }; \ - struct { glm::detail::swizzle4 E1 ## E1 ## E3 ## E2; }; \ - struct { glm::detail::swizzle4 E1 ## E1 ## E3 ## E3; }; \ - \ - struct { glm::detail::swizzle4 E1 ## E2 ## E0 ## E0; }; \ - struct { glm::detail::swizzle4 E1 ## E2 ## E0 ## E1; }; \ - struct { glm::detail::swizzle4 E1 ## E2 ## E0 ## E2; }; \ - struct { glm::detail::swizzle4 E1 ## E2 ## E0 ## E3; }; \ - struct { glm::detail::swizzle4 E1 ## E2 ## E1 ## E0; }; \ - struct { glm::detail::swizzle4 E1 ## E2 ## E1 ## E1; }; \ - struct { glm::detail::swizzle4 E1 ## E2 ## E1 ## E2; }; \ - struct { glm::detail::swizzle4 E1 ## E2 ## E1 ## E3; }; \ - struct { glm::detail::swizzle4 E1 ## E2 ## E2 ## E0; }; \ - struct { glm::detail::swizzle4 E1 ## E2 ## E2 ## E1; }; \ - struct { glm::detail::swizzle4 E1 ## E2 ## E2 ## E2; }; \ - struct { glm::detail::swizzle4 E1 ## E2 ## E2 ## E3; }; \ - struct { glm::detail::swizzle4 E1 ## E2 ## E3 ## E0; }; \ - struct { glm::detail::swizzle4 E1 ## E2 ## E3 ## E1; }; \ - struct { glm::detail::swizzle4 E1 ## E2 ## E3 ## E2; }; \ - struct { glm::detail::swizzle4 E1 ## E2 ## E3 ## E3; }; \ - \ - struct { glm::detail::swizzle4 E1 ## E3 ## E0 ## E0; }; \ - struct { glm::detail::swizzle4 E1 ## E3 ## E0 ## E1; }; \ - struct { glm::detail::swizzle4 E1 ## E3 ## E0 ## E2; }; \ - struct { glm::detail::swizzle4 E1 ## E3 ## E0 ## E3; }; \ - struct { glm::detail::swizzle4 E1 ## E3 ## E1 ## E0; }; \ - struct { glm::detail::swizzle4 E1 ## E3 ## E1 ## E1; }; \ - struct { glm::detail::swizzle4 E1 ## E3 ## E1 ## E2; }; \ - struct { glm::detail::swizzle4 E1 ## E3 ## E1 ## E3; }; \ - struct { glm::detail::swizzle4 E1 ## E3 ## E2 ## E0; }; \ - struct { glm::detail::swizzle4 E1 ## E3 ## E2 ## E1; }; \ - struct { glm::detail::swizzle4 E1 ## E3 ## E2 ## E2; }; \ - struct { glm::detail::swizzle4 E1 ## E3 ## E2 ## E3; }; \ - struct { glm::detail::swizzle4 E1 ## E3 ## E3 ## E0; }; \ - struct { glm::detail::swizzle4 E1 ## E3 ## E3 ## E1; }; \ - struct { glm::detail::swizzle4 E1 ## E3 ## E3 ## E2; }; \ - struct { glm::detail::swizzle4 E1 ## E3 ## E3 ## E3; }; \ - \ - \ - struct { glm::detail::swizzle4 E2 ## E0 ## E0 ## E0; }; \ - struct { glm::detail::swizzle4 E2 ## E0 ## E0 ## E1; }; \ - struct { glm::detail::swizzle4 E2 ## E0 ## E0 ## E2; }; \ - struct { glm::detail::swizzle4 E2 ## E0 ## E0 ## E3; }; \ - struct { glm::detail::swizzle4 E2 ## E0 ## E1 ## E0; }; \ - struct { glm::detail::swizzle4 E2 ## E0 ## E1 ## E1; }; \ - struct { glm::detail::swizzle4 E2 ## E0 ## E1 ## E2; }; \ - struct { glm::detail::swizzle4 E2 ## E0 ## E1 ## E3; }; \ - struct { glm::detail::swizzle4 E2 ## E0 ## E2 ## E0; }; \ - struct { glm::detail::swizzle4 E2 ## E0 ## E2 ## E1; }; \ - struct { glm::detail::swizzle4 E2 ## E0 ## E2 ## E2; }; \ - struct { glm::detail::swizzle4 E2 ## E0 ## E2 ## E3; }; \ - struct { glm::detail::swizzle4 E2 ## E0 ## E3 ## E0; }; \ - struct { glm::detail::swizzle4 E2 ## E0 ## E3 ## E1; }; \ - struct { glm::detail::swizzle4 E2 ## E0 ## E3 ## E2; }; \ - struct { glm::detail::swizzle4 E2 ## E0 ## E3 ## E3; }; \ - \ - struct { glm::detail::swizzle4 E2 ## E1 ## E0 ## E0; }; \ - struct { glm::detail::swizzle4 E2 ## E1 ## E0 ## E1; }; \ - struct { glm::detail::swizzle4 E2 ## E1 ## E0 ## E2; }; \ - struct { glm::detail::swizzle4 E2 ## E1 ## E0 ## E3; }; \ - struct { glm::detail::swizzle4 E2 ## E1 ## E1 ## E0; }; \ - struct { glm::detail::swizzle4 E2 ## E1 ## E1 ## E1; }; \ - struct { glm::detail::swizzle4 E2 ## E1 ## E1 ## E2; }; \ - struct { glm::detail::swizzle4 E2 ## E1 ## E1 ## E3; }; \ - struct { glm::detail::swizzle4 E2 ## E1 ## E2 ## E0; }; \ - struct { glm::detail::swizzle4 E2 ## E1 ## E2 ## E1; }; \ - struct { glm::detail::swizzle4 E2 ## E1 ## E2 ## E2; }; \ - struct { glm::detail::swizzle4 E2 ## E1 ## E2 ## E3; }; \ - struct { glm::detail::swizzle4 E2 ## E1 ## E3 ## E0; }; \ - struct { glm::detail::swizzle4 E2 ## E1 ## E3 ## E1; }; \ - struct { glm::detail::swizzle4 E2 ## E1 ## E3 ## E2; }; \ - struct { glm::detail::swizzle4 E2 ## E1 ## E3 ## E3; }; \ - \ - struct { glm::detail::swizzle4 E2 ## E2 ## E0 ## E0; }; \ - struct { glm::detail::swizzle4 E2 ## E2 ## E0 ## E1; }; \ - struct { glm::detail::swizzle4 E2 ## E2 ## E0 ## E2; }; \ - struct { glm::detail::swizzle4 E2 ## E2 ## E0 ## E3; }; \ - struct { glm::detail::swizzle4 E2 ## E2 ## E1 ## E0; }; \ - struct { glm::detail::swizzle4 E2 ## E2 ## E1 ## E1; }; \ - struct { glm::detail::swizzle4 E2 ## E2 ## E1 ## E2; }; \ - struct { glm::detail::swizzle4 E2 ## E2 ## E1 ## E3; }; \ - struct { glm::detail::swizzle4 E2 ## E2 ## E2 ## E0; }; \ - struct { glm::detail::swizzle4 E2 ## E2 ## E2 ## E1; }; \ - struct { glm::detail::swizzle4 E2 ## E2 ## E2 ## E2; }; \ - struct { glm::detail::swizzle4 E2 ## E2 ## E2 ## E3; }; \ - struct { glm::detail::swizzle4 E2 ## E2 ## E3 ## E0; }; \ - struct { glm::detail::swizzle4 E2 ## E2 ## E3 ## E1; }; \ - struct { glm::detail::swizzle4 E2 ## E2 ## E3 ## E2; }; \ - struct { glm::detail::swizzle4 E2 ## E2 ## E3 ## E3; }; \ - \ - struct { glm::detail::swizzle4 E2 ## E3 ## E0 ## E0; }; \ - struct { glm::detail::swizzle4 E2 ## E3 ## E0 ## E1; }; \ - struct { glm::detail::swizzle4 E2 ## E3 ## E0 ## E2; }; \ - struct { glm::detail::swizzle4 E2 ## E3 ## E0 ## E3; }; \ - struct { glm::detail::swizzle4 E2 ## E3 ## E1 ## E0; }; \ - struct { glm::detail::swizzle4 E2 ## E3 ## E1 ## E1; }; \ - struct { glm::detail::swizzle4 E2 ## E3 ## E1 ## E2; }; \ - struct { glm::detail::swizzle4 E2 ## E3 ## E1 ## E3; }; \ - struct { glm::detail::swizzle4 E2 ## E3 ## E2 ## E0; }; \ - struct { glm::detail::swizzle4 E2 ## E3 ## E2 ## E1; }; \ - struct { glm::detail::swizzle4 E2 ## E3 ## E2 ## E2; }; \ - struct { glm::detail::swizzle4 E2 ## E3 ## E2 ## E3; }; \ - struct { glm::detail::swizzle4 E2 ## E3 ## E3 ## E0; }; \ - struct { glm::detail::swizzle4 E2 ## E3 ## E3 ## E1; }; \ - struct { glm::detail::swizzle4 E2 ## E3 ## E3 ## E2; }; \ - struct { glm::detail::swizzle4 E2 ## E3 ## E3 ## E3; }; \ - \ - \ - struct { glm::detail::swizzle4 E3 ## E0 ## E0 ## E0; }; \ - struct { glm::detail::swizzle4 E3 ## E0 ## E0 ## E1; }; \ - struct { glm::detail::swizzle4 E3 ## E0 ## E0 ## E2; }; \ - struct { glm::detail::swizzle4 E3 ## E0 ## E0 ## E3; }; \ - struct { glm::detail::swizzle4 E3 ## E0 ## E1 ## E0; }; \ - struct { glm::detail::swizzle4 E3 ## E0 ## E1 ## E1; }; \ - struct { glm::detail::swizzle4 E3 ## E0 ## E1 ## E2; }; \ - struct { glm::detail::swizzle4 E3 ## E0 ## E1 ## E3; }; \ - struct { glm::detail::swizzle4 E3 ## E0 ## E2 ## E0; }; \ - struct { glm::detail::swizzle4 E3 ## E0 ## E2 ## E1; }; \ - struct { glm::detail::swizzle4 E3 ## E0 ## E2 ## E2; }; \ - struct { glm::detail::swizzle4 E3 ## E0 ## E2 ## E3; }; \ - struct { glm::detail::swizzle4 E3 ## E0 ## E3 ## E0; }; \ - struct { glm::detail::swizzle4 E3 ## E0 ## E3 ## E1; }; \ - struct { glm::detail::swizzle4 E3 ## E0 ## E3 ## E2; }; \ - struct { glm::detail::swizzle4 E3 ## E0 ## E3 ## E3; }; \ - \ - struct { glm::detail::swizzle4 E3 ## E1 ## E0 ## E0; }; \ - struct { glm::detail::swizzle4 E3 ## E1 ## E0 ## E1; }; \ - struct { glm::detail::swizzle4 E3 ## E1 ## E0 ## E2; }; \ - struct { glm::detail::swizzle4 E3 ## E1 ## E0 ## E3; }; \ - struct { glm::detail::swizzle4 E3 ## E1 ## E1 ## E0; }; \ - struct { glm::detail::swizzle4 E3 ## E1 ## E1 ## E1; }; \ - struct { glm::detail::swizzle4 E3 ## E1 ## E1 ## E2; }; \ - struct { glm::detail::swizzle4 E3 ## E1 ## E1 ## E3; }; \ - struct { glm::detail::swizzle4 E3 ## E1 ## E2 ## E0; }; \ - struct { glm::detail::swizzle4 E3 ## E1 ## E2 ## E1; }; \ - struct { glm::detail::swizzle4 E3 ## E1 ## E2 ## E2; }; \ - struct { glm::detail::swizzle4 E3 ## E1 ## E2 ## E3; }; \ - struct { glm::detail::swizzle4 E3 ## E1 ## E3 ## E0; }; \ - struct { glm::detail::swizzle4 E3 ## E1 ## E3 ## E1; }; \ - struct { glm::detail::swizzle4 E3 ## E1 ## E3 ## E2; }; \ - struct { glm::detail::swizzle4 E3 ## E1 ## E3 ## E3; }; \ - \ - struct { glm::detail::swizzle4 E3 ## E2 ## E0 ## E0; }; \ - struct { glm::detail::swizzle4 E3 ## E2 ## E0 ## E1; }; \ - struct { glm::detail::swizzle4 E3 ## E2 ## E0 ## E2; }; \ - struct { glm::detail::swizzle4 E3 ## E2 ## E0 ## E3; }; \ - struct { glm::detail::swizzle4 E3 ## E2 ## E1 ## E0; }; \ - struct { glm::detail::swizzle4 E3 ## E2 ## E1 ## E1; }; \ - struct { glm::detail::swizzle4 E3 ## E2 ## E1 ## E2; }; \ - struct { glm::detail::swizzle4 E3 ## E2 ## E1 ## E3; }; \ - struct { glm::detail::swizzle4 E3 ## E2 ## E2 ## E0; }; \ - struct { glm::detail::swizzle4 E3 ## E2 ## E2 ## E1; }; \ - struct { glm::detail::swizzle4 E3 ## E2 ## E2 ## E2; }; \ - struct { glm::detail::swizzle4 E3 ## E2 ## E2 ## E3; }; \ - struct { glm::detail::swizzle4 E3 ## E2 ## E3 ## E0; }; \ - struct { glm::detail::swizzle4 E3 ## E2 ## E3 ## E1; }; \ - struct { glm::detail::swizzle4 E3 ## E2 ## E3 ## E2; }; \ - struct { glm::detail::swizzle4 E3 ## E2 ## E3 ## E3; }; \ - \ - struct { glm::detail::swizzle4 E3 ## E3 ## E0 ## E0; }; \ - struct { glm::detail::swizzle4 E3 ## E3 ## E0 ## E1; }; \ - struct { glm::detail::swizzle4 E3 ## E3 ## E0 ## E2; }; \ - struct { glm::detail::swizzle4 E3 ## E3 ## E0 ## E3; }; \ - struct { glm::detail::swizzle4 E3 ## E3 ## E1 ## E0; }; \ - struct { glm::detail::swizzle4 E3 ## E3 ## E1 ## E1; }; \ - struct { glm::detail::swizzle4 E3 ## E3 ## E1 ## E2; }; \ - struct { glm::detail::swizzle4 E3 ## E3 ## E1 ## E3; }; \ - struct { glm::detail::swizzle4 E3 ## E3 ## E2 ## E0; }; \ - struct { glm::detail::swizzle4 E3 ## E3 ## E2 ## E1; }; \ - struct { glm::detail::swizzle4 E3 ## E3 ## E2 ## E2; }; \ - struct { glm::detail::swizzle4 E3 ## E3 ## E2 ## E3; }; \ - struct { glm::detail::swizzle4 E3 ## E3 ## E3 ## E0; }; \ - struct { glm::detail::swizzle4 E3 ## E3 ## E3 ## E1; }; \ - struct { glm::detail::swizzle4 E3 ## E3 ## E3 ## E2; }; \ - struct { glm::detail::swizzle4 E3 ## E3 ## E3 ## E3; }; + struct { glm::detail::swizzle<4,T,P,0,0,0,0> E0 ## E0 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,0,0,0,1> E0 ## E0 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,0,0,0,2> E0 ## E0 ## E0 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,0,0,0,3> E0 ## E0 ## E0 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,0,0,1,0> E0 ## E0 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,0,0,1,1> E0 ## E0 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,0,0,1,2> E0 ## E0 ## E1 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,0,0,1,3> E0 ## E0 ## E1 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,0,0,2,0> E0 ## E0 ## E2 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,0,0,2,1> E0 ## E0 ## E2 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,0,0,2,2> E0 ## E0 ## E2 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,0,0,2,3> E0 ## E0 ## E2 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,0,0,3,0> E0 ## E0 ## E3 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,0,0,3,1> E0 ## E0 ## E3 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,0,0,3,2> E0 ## E0 ## E3 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,0,0,3,3> E0 ## E0 ## E3 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,0,1,0,0> E0 ## E1 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,0,1,0,1> E0 ## E1 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,0,1,0,2> E0 ## E1 ## E0 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,0,1,0,3> E0 ## E1 ## E0 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,0,1,1,0> E0 ## E1 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,0,1,1,1> E0 ## E1 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,0,1,1,2> E0 ## E1 ## E1 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,0,1,1,3> E0 ## E1 ## E1 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,0,1,2,0> E0 ## E1 ## E2 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,0,1,2,1> E0 ## E1 ## E2 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,0,1,2,2> E0 ## E1 ## E2 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,0,1,2,3> E0 ## E1 ## E2 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,0,1,3,0> E0 ## E1 ## E3 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,0,1,3,1> E0 ## E1 ## E3 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,0,1,3,2> E0 ## E1 ## E3 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,0,1,3,3> E0 ## E1 ## E3 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,0,2,0,0> E0 ## E2 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,0,2,0,1> E0 ## E2 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,0,2,0,2> E0 ## E2 ## E0 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,0,2,0,3> E0 ## E2 ## E0 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,0,2,1,0> E0 ## E2 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,0,2,1,1> E0 ## E2 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,0,2,1,2> E0 ## E2 ## E1 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,0,2,1,3> E0 ## E2 ## E1 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,0,2,2,0> E0 ## E2 ## E2 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,0,2,2,1> E0 ## E2 ## E2 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,0,2,2,2> E0 ## E2 ## E2 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,0,2,2,3> E0 ## E2 ## E2 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,0,2,3,0> E0 ## E2 ## E3 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,0,2,3,1> E0 ## E2 ## E3 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,0,2,3,2> E0 ## E2 ## E3 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,0,2,3,3> E0 ## E2 ## E3 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,1,0,0,0> E1 ## E0 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,1,0,0,1> E1 ## E0 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,1,0,0,2> E1 ## E0 ## E0 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,1,0,0,3> E1 ## E0 ## E0 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,1,0,1,0> E1 ## E0 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,1,0,1,1> E1 ## E0 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,1,0,1,2> E1 ## E0 ## E1 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,1,0,1,3> E1 ## E0 ## E1 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,1,0,2,0> E1 ## E0 ## E2 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,1,0,2,1> E1 ## E0 ## E2 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,1,0,2,2> E1 ## E0 ## E2 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,1,0,2,3> E1 ## E0 ## E2 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,1,0,3,0> E1 ## E0 ## E3 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,1,0,3,1> E1 ## E0 ## E3 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,1,0,3,2> E1 ## E0 ## E3 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,1,0,3,3> E1 ## E0 ## E3 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,1,1,0,0> E1 ## E1 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,1,1,0,1> E1 ## E1 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,1,1,0,2> E1 ## E1 ## E0 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,1,1,0,3> E1 ## E1 ## E0 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,1,1,1,0> E1 ## E1 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,1,1,1,1> E1 ## E1 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,1,1,1,2> E1 ## E1 ## E1 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,1,1,1,3> E1 ## E1 ## E1 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,1,1,2,0> E1 ## E1 ## E2 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,1,1,2,1> E1 ## E1 ## E2 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,1,1,2,2> E1 ## E1 ## E2 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,1,1,2,3> E1 ## E1 ## E2 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,1,1,3,0> E1 ## E1 ## E3 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,1,1,3,1> E1 ## E1 ## E3 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,1,1,3,2> E1 ## E1 ## E3 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,1,1,3,3> E1 ## E1 ## E3 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,1,2,0,0> E1 ## E2 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,1,2,0,1> E1 ## E2 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,1,2,0,2> E1 ## E2 ## E0 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,1,2,0,3> E1 ## E2 ## E0 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,1,2,1,0> E1 ## E2 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,1,2,1,1> E1 ## E2 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,1,2,1,2> E1 ## E2 ## E1 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,1,2,1,3> E1 ## E2 ## E1 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,1,2,2,0> E1 ## E2 ## E2 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,1,2,2,1> E1 ## E2 ## E2 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,1,2,2,2> E1 ## E2 ## E2 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,1,2,2,3> E1 ## E2 ## E2 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,1,2,3,0> E1 ## E2 ## E3 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,1,2,3,1> E1 ## E2 ## E3 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,1,2,3,2> E1 ## E2 ## E3 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,1,2,3,3> E1 ## E2 ## E3 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,1,3,0,0> E1 ## E3 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,1,3,0,1> E1 ## E3 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,1,3,0,2> E1 ## E3 ## E0 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,1,3,0,3> E1 ## E3 ## E0 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,1,3,1,0> E1 ## E3 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,1,3,1,1> E1 ## E3 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,1,3,1,2> E1 ## E3 ## E1 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,1,3,1,3> E1 ## E3 ## E1 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,1,3,2,0> E1 ## E3 ## E2 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,1,3,2,1> E1 ## E3 ## E2 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,1,3,2,2> E1 ## E3 ## E2 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,1,3,2,3> E1 ## E3 ## E2 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,1,3,3,0> E1 ## E3 ## E3 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,1,3,3,1> E1 ## E3 ## E3 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,1,3,3,2> E1 ## E3 ## E3 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,1,3,3,3> E1 ## E3 ## E3 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,2,0,0,0> E2 ## E0 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,2,0,0,1> E2 ## E0 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,2,0,0,2> E2 ## E0 ## E0 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,2,0,0,3> E2 ## E0 ## E0 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,2,0,1,0> E2 ## E0 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,2,0,1,1> E2 ## E0 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,2,0,1,2> E2 ## E0 ## E1 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,2,0,1,3> E2 ## E0 ## E1 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,2,0,2,0> E2 ## E0 ## E2 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,2,0,2,1> E2 ## E0 ## E2 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,2,0,2,2> E2 ## E0 ## E2 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,2,0,2,3> E2 ## E0 ## E2 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,2,0,3,0> E2 ## E0 ## E3 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,2,0,3,1> E2 ## E0 ## E3 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,2,0,3,2> E2 ## E0 ## E3 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,2,0,3,3> E2 ## E0 ## E3 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,2,1,0,0> E2 ## E1 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,2,1,0,1> E2 ## E1 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,2,1,0,2> E2 ## E1 ## E0 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,2,1,0,3> E2 ## E1 ## E0 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,2,1,1,0> E2 ## E1 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,2,1,1,1> E2 ## E1 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,2,1,1,2> E2 ## E1 ## E1 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,2,1,1,3> E2 ## E1 ## E1 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,2,1,2,0> E2 ## E1 ## E2 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,2,1,2,1> E2 ## E1 ## E2 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,2,1,2,2> E2 ## E1 ## E2 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,2,1,2,3> E2 ## E1 ## E2 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,2,1,3,0> E2 ## E1 ## E3 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,2,1,3,1> E2 ## E1 ## E3 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,2,1,3,2> E2 ## E1 ## E3 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,2,1,3,3> E2 ## E1 ## E3 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,2,2,0,0> E2 ## E2 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,2,2,0,1> E2 ## E2 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,2,2,0,2> E2 ## E2 ## E0 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,2,2,0,3> E2 ## E2 ## E0 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,2,2,1,0> E2 ## E2 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,2,2,1,1> E2 ## E2 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,2,2,1,2> E2 ## E2 ## E1 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,2,2,1,3> E2 ## E2 ## E1 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,2,2,2,0> E2 ## E2 ## E2 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,2,2,2,1> E2 ## E2 ## E2 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,2,2,2,2> E2 ## E2 ## E2 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,2,2,2,3> E2 ## E2 ## E2 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,2,2,3,0> E2 ## E2 ## E3 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,2,2,3,1> E2 ## E2 ## E3 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,2,2,3,2> E2 ## E2 ## E3 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,2,2,3,3> E2 ## E2 ## E3 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,2,3,0,0> E2 ## E3 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,2,3,0,1> E2 ## E3 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,2,3,0,2> E2 ## E3 ## E0 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,2,3,0,3> E2 ## E3 ## E0 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,2,3,1,0> E2 ## E3 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,2,3,1,1> E2 ## E3 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,2,3,1,2> E2 ## E3 ## E1 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,2,3,1,3> E2 ## E3 ## E1 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,2,3,2,0> E2 ## E3 ## E2 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,2,3,2,1> E2 ## E3 ## E2 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,2,3,2,2> E2 ## E3 ## E2 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,2,3,2,3> E2 ## E3 ## E2 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,2,3,3,0> E2 ## E3 ## E3 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,2,3,3,1> E2 ## E3 ## E3 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,2,3,3,2> E2 ## E3 ## E3 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,2,3,3,3> E2 ## E3 ## E3 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,3,0,0,0> E3 ## E0 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,3,0,0,1> E3 ## E0 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,3,0,0,2> E3 ## E0 ## E0 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,3,0,0,3> E3 ## E0 ## E0 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,3,0,1,0> E3 ## E0 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,3,0,1,1> E3 ## E0 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,3,0,1,2> E3 ## E0 ## E1 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,3,0,1,3> E3 ## E0 ## E1 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,3,0,2,0> E3 ## E0 ## E2 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,3,0,2,1> E3 ## E0 ## E2 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,3,0,2,2> E3 ## E0 ## E2 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,3,0,2,3> E3 ## E0 ## E2 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,3,0,3,0> E3 ## E0 ## E3 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,3,0,3,1> E3 ## E0 ## E3 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,3,0,3,2> E3 ## E0 ## E3 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,3,0,3,3> E3 ## E0 ## E3 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,3,1,0,0> E3 ## E1 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,3,1,0,1> E3 ## E1 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,3,1,0,2> E3 ## E1 ## E0 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,3,1,0,3> E3 ## E1 ## E0 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,3,1,1,0> E3 ## E1 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,3,1,1,1> E3 ## E1 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,3,1,1,2> E3 ## E1 ## E1 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,3,1,1,3> E3 ## E1 ## E1 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,3,1,2,0> E3 ## E1 ## E2 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,3,1,2,1> E3 ## E1 ## E2 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,3,1,2,2> E3 ## E1 ## E2 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,3,1,2,3> E3 ## E1 ## E2 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,3,1,3,0> E3 ## E1 ## E3 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,3,1,3,1> E3 ## E1 ## E3 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,3,1,3,2> E3 ## E1 ## E3 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,3,1,3,3> E3 ## E1 ## E3 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,3,2,0,0> E3 ## E2 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,3,2,0,1> E3 ## E2 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,3,2,0,2> E3 ## E2 ## E0 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,3,2,0,3> E3 ## E2 ## E0 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,3,2,1,0> E3 ## E2 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,3,2,1,1> E3 ## E2 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,3,2,1,2> E3 ## E2 ## E1 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,3,2,1,3> E3 ## E2 ## E1 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,3,2,2,0> E3 ## E2 ## E2 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,3,2,2,1> E3 ## E2 ## E2 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,3,2,2,2> E3 ## E2 ## E2 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,3,2,2,3> E3 ## E2 ## E2 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,3,2,3,0> E3 ## E2 ## E3 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,3,2,3,1> E3 ## E2 ## E3 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,3,2,3,2> E3 ## E2 ## E3 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,3,2,3,3> E3 ## E2 ## E3 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,3,3,0,0> E3 ## E3 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,3,3,0,1> E3 ## E3 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,3,3,0,2> E3 ## E3 ## E0 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,3,3,0,3> E3 ## E3 ## E0 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,3,3,1,0> E3 ## E3 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,3,3,1,1> E3 ## E3 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,3,3,1,2> E3 ## E3 ## E1 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,3,3,1,3> E3 ## E3 ## E1 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,3,3,2,0> E3 ## E3 ## E2 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,3,3,2,1> E3 ## E3 ## E2 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,3,3,2,2> E3 ## E3 ## E2 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,3,3,2,3> E3 ## E3 ## E2 ## E3; }; \ + struct { glm::detail::swizzle<4,T,P,3,3,3,0> E3 ## E3 ## E3 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P,3,3,3,1> E3 ## E3 ## E3 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P,3,3,3,2> E3 ## E3 ## E3 ## E2; }; \ + struct { glm::detail::swizzle<4,T,P,3,3,3,3> E3 ## E3 ## E3 ## E3; }; diff --git a/glm/core/type_vec2.hpp b/glm/core/type_vec2.hpp index c93157bb..e1256bb6 100644 --- a/glm/core/type_vec2.hpp +++ b/glm/core/type_vec2.hpp @@ -115,17 +115,7 @@ namespace detail tvec2(tref2 const & r); template - GLM_FUNC_DECL tvec2(glm::detail::swizzle2,E0,E1>& that) - { - *this = that(); - } - template - GLM_FUNC_DECL tvec2(glm::detail::swizzle3_2,E0,E1>& that) - { - *this = that(); - } - template - GLM_FUNC_DECL tvec2(glm::detail::swizzle4_2,E0,E1>& that) + GLM_FUNC_DECL tvec2(const glm::detail::swizzle<2,T,tvec2,E0,E1,-1,-2>& that) { *this = that(); } diff --git a/glm/core/type_vec3.hpp b/glm/core/type_vec3.hpp index e65463f2..6d2376aa 100644 --- a/glm/core/type_vec3.hpp +++ b/glm/core/type_vec3.hpp @@ -117,17 +117,7 @@ namespace detail GLM_FUNC_DECL tvec3(tref3 const & r); template - GLM_FUNC_DECL tvec3(glm::detail::swizzle2_3,E0,E1,E2>& that) - { - *this = that(); - } - template - GLM_FUNC_DECL tvec3(glm::detail::swizzle3,E0,E1,E2>& that) - { - *this = that(); - } - template - GLM_FUNC_DECL tvec3(glm::detail::swizzle4_3,E0,E1,E2>& that) + GLM_FUNC_DECL tvec3(const glm::detail::swizzle<3,T,tvec3,E0,E1,E2,-1>& that) { *this = that(); } diff --git a/glm/core/type_vec4.hpp b/glm/core/type_vec4.hpp index 296e1641..bf34fb31 100644 --- a/glm/core/type_vec4.hpp +++ b/glm/core/type_vec4.hpp @@ -119,17 +119,7 @@ namespace detail GLM_FUNC_DECL tvec4(tref4 const & r); template - GLM_FUNC_DECL tvec4(glm::detail::swizzle2_4,E0,E1,E2,E3>& that) - { - *this = that(); - } - template - GLM_FUNC_DECL tvec4(glm::detail::swizzle3_4,E0,E1,E2,E3>& that) - { - *this = that(); - } - template - GLM_FUNC_DECL tvec4(glm::detail::swizzle4,E0,E1,E2,E3>& that) + GLM_FUNC_DECL tvec4(const glm::detail::swizzle<4,T,tvec4,E0,E1,E2,E3>& that) { *this = that(); } From 124923154ba3fd12bb21fe0f28b17a51c059744c Mon Sep 17 00:00:00 2001 From: athile Date: Fri, 23 Sep 2011 14:08:52 -0400 Subject: [PATCH 6/6] Fix swizzle size defect and further clean-up --- glm/core/_swizzle.hpp | 252 ++++++++++++++++++++---------------------- 1 file changed, 119 insertions(+), 133 deletions(-) diff --git a/glm/core/_swizzle.hpp b/glm/core/_swizzle.hpp index f1280596..2ca69d58 100644 --- a/glm/core/_swizzle.hpp +++ b/glm/core/_swizzle.hpp @@ -62,9 +62,9 @@ namespace detail const value_type& elem (size_t i) const { return (reinterpret_cast(_buffer))[i]; } // Use an opaque buffer to *ensure* the compiler doesn't call a constructor. - // Otherwise, a vec4 containing all swizzles might end up with 1000s of - // constructor calls - char _buffer[sizeof(value_type) * N]; + // The size 1 buffer is assumed to aligned to the actual members so that the + // elem() + char _buffer[1]; }; template @@ -220,96 +220,96 @@ namespace detail // // Wrapper for a binary operator (e.g. u.yy + v.zy) // -#define _GLM_SWIZZLE_VECTOR_BINARY_OPERATOR_IMPLEMENTATION(OPERAND)\ - _GLM_SWIZZLE_TEMPLATE2 \ - V operator OPERAND ( const _GLM_SWIZZLE_TYPE1& a, const _GLM_SWIZZLE_TYPE2& b) \ - { \ - return a() OPERAND b(); \ - } \ - _GLM_SWIZZLE_TEMPLATE1 \ - V operator OPERAND ( const _GLM_SWIZZLE_TYPE1& a, const V& b) \ - { \ - return a() OPERAND b; \ - } \ - _GLM_SWIZZLE_TEMPLATE1 \ - V operator OPERAND ( const V& a, const _GLM_SWIZZLE_TYPE1& b) \ - { \ - return a OPERAND b(); \ +#define _GLM_SWIZZLE_VECTOR_BINARY_OPERATOR_IMPLEMENTATION(OPERAND) \ + _GLM_SWIZZLE_TEMPLATE2 \ + V operator OPERAND ( const _GLM_SWIZZLE_TYPE1& a, const _GLM_SWIZZLE_TYPE2& b) \ + { \ + return a() OPERAND b(); \ + } \ + _GLM_SWIZZLE_TEMPLATE1 \ + V operator OPERAND ( const _GLM_SWIZZLE_TYPE1& a, const V& b) \ + { \ + return a() OPERAND b; \ + } \ + _GLM_SWIZZLE_TEMPLATE1 \ + V operator OPERAND ( const V& a, const _GLM_SWIZZLE_TYPE1& b) \ + { \ + return a OPERAND b(); \ } // // Wrapper for a operand between a swizzle and a binary (e.g. 1.0f - u.xyz) // -#define _GLM_SWIZZLE_SCALAR_BINARY_OPERATOR_IMPLEMENTATION(OPERAND)\ - _GLM_SWIZZLE_TEMPLATE1 \ - typename V operator OPERAND ( const _GLM_SWIZZLE_TYPE1& a, const typename T& b) \ - { \ - return a() OPERAND b; \ - } \ - _GLM_SWIZZLE_TEMPLATE1 \ - typename V operator OPERAND ( const typename T& a, const _GLM_SWIZZLE_TYPE1& b) \ - { \ - return a OPERAND b(); \ +#define _GLM_SWIZZLE_SCALAR_BINARY_OPERATOR_IMPLEMENTATION(OPERAND) \ + _GLM_SWIZZLE_TEMPLATE1 \ + V operator OPERAND ( const _GLM_SWIZZLE_TYPE1& a, const T& b) \ + { \ + return a() OPERAND b; \ + } \ + _GLM_SWIZZLE_TEMPLATE1 \ + V operator OPERAND ( const T& a, const _GLM_SWIZZLE_TYPE1& b) \ + { \ + return a OPERAND b(); \ } // // Macro for wrapping a function taking one argument (e.g. abs()) // -#define _GLM_SWIZZLE_FUNCTION_1_ARGS(RETURN_TYPE,FUNCTION)\ - _GLM_SWIZZLE_TEMPLATE1 \ - typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const _GLM_SWIZZLE_TYPE1& a) \ - { \ - return FUNCTION(a()); \ +#define _GLM_SWIZZLE_FUNCTION_1_ARGS(RETURN_TYPE,FUNCTION) \ + _GLM_SWIZZLE_TEMPLATE1 \ + typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const _GLM_SWIZZLE_TYPE1& a) \ + { \ + return FUNCTION(a()); \ } // // Macro for wrapping a function taking two vector arguments (e.g. dot()). // -#define _GLM_SWIZZLE_FUNCTION_2_ARGS(RETURN_TYPE,FUNCTION)\ - _GLM_SWIZZLE_TEMPLATE2\ - typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const typename _GLM_SWIZZLE_TYPE1& a, const typename _GLM_SWIZZLE_TYPE2& b)\ - {\ - return FUNCTION(a(), b());\ - }\ - _GLM_SWIZZLE_TEMPLATE1\ - typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const _GLM_SWIZZLE_TYPE1& a, const typename _GLM_SWIZZLE_TYPE1& b)\ - {\ - return FUNCTION(a(), b());\ - }\ - _GLM_SWIZZLE_TEMPLATE1\ - typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const _GLM_SWIZZLE_TYPE1& a, const typename V& b)\ - {\ - return FUNCTION(a(), b);\ - }\ - _GLM_SWIZZLE_TEMPLATE1\ - typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const V& a, const _GLM_SWIZZLE_TYPE1& b)\ - {\ - return FUNCTION(a, b());\ +#define _GLM_SWIZZLE_FUNCTION_2_ARGS(RETURN_TYPE,FUNCTION) \ + _GLM_SWIZZLE_TEMPLATE2 \ + typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const _GLM_SWIZZLE_TYPE1& a, const _GLM_SWIZZLE_TYPE2& b) \ + { \ + return FUNCTION(a(), b()); \ + } \ + _GLM_SWIZZLE_TEMPLATE1 \ + typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const _GLM_SWIZZLE_TYPE1& a, const _GLM_SWIZZLE_TYPE1& b) \ + { \ + return FUNCTION(a(), b()); \ + } \ + _GLM_SWIZZLE_TEMPLATE1 \ + typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const _GLM_SWIZZLE_TYPE1& a, const typename V& b) \ + { \ + return FUNCTION(a(), b); \ + } \ + _GLM_SWIZZLE_TEMPLATE1 \ + typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const V& a, const _GLM_SWIZZLE_TYPE1& b) \ + { \ + return FUNCTION(a, b()); \ } // // Macro for wrapping a function take 2 vec arguments followed by a scalar (e.g. mix()). // -#define _GLM_SWIZZLE_FUNCTION_2_ARGS_SCALAR(RETURN_TYPE,FUNCTION)\ - _GLM_SWIZZLE_TEMPLATE2\ - typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const _GLM_SWIZZLE_TYPE1& a, const _GLM_SWIZZLE_TYPE2& b, const T& c)\ - {\ - return FUNCTION(a(), b(), c);\ - }\ - _GLM_SWIZZLE_TEMPLATE1\ - typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const _GLM_SWIZZLE_TYPE1& a, const _GLM_SWIZZLE_TYPE1& b, const T& c)\ - {\ - return FUNCTION(a(), b(), c);\ - }\ - _GLM_SWIZZLE_TEMPLATE1\ +#define _GLM_SWIZZLE_FUNCTION_2_ARGS_SCALAR(RETURN_TYPE,FUNCTION) \ + _GLM_SWIZZLE_TEMPLATE2 \ + typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const _GLM_SWIZZLE_TYPE1& a, const _GLM_SWIZZLE_TYPE2& b, const T& c) \ + { \ + return FUNCTION(a(), b(), c); \ + } \ + _GLM_SWIZZLE_TEMPLATE1 \ + typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const _GLM_SWIZZLE_TYPE1& a, const _GLM_SWIZZLE_TYPE1& b, const T& c) \ + { \ + return FUNCTION(a(), b(), c); \ + } \ + _GLM_SWIZZLE_TEMPLATE1 \ typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const _GLM_SWIZZLE_TYPE1& a, const typename S0::vec_type& b, const T& c)\ - {\ - return FUNCTION(a(), b, c);\ - }\ - _GLM_SWIZZLE_TEMPLATE1\ - typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const typename V& a, const _GLM_SWIZZLE_TYPE1& b, const T& c)\ - {\ - return FUNCTION(a, b(), c);\ + { \ + return FUNCTION(a(), b, c); \ + } \ + _GLM_SWIZZLE_TEMPLATE1 \ + typename _GLM_SWIZZLE_TYPE1::RETURN_TYPE FUNCTION(const typename V& a, const _GLM_SWIZZLE_TYPE1& b, const T& c) \ + { \ + return FUNCTION(a, b(), c); \ } }//namespace detail @@ -350,7 +350,6 @@ namespace glm //_GLM_SWIZZLE_FUNCTION_2_ARGS_SCALAR(vec_type, mix); } - #define _GLM_SWIZZLE2_2_MEMBERS(T,P,E0,E1) \ struct { glm::detail::swizzle<2,T,P,0,0,-1,-2> E0 ## E0; }; \ struct { glm::detail::swizzle<2,T,P,0,1,-1,-2> E0 ## E1; }; \ @@ -367,37 +366,23 @@ namespace glm struct { glm::detail::swizzle<3,T,P2,1,1,0,-1> E1 ## E1 ## E0; }; \ struct { glm::detail::swizzle<3,T,P2,1,1,1,-1> E1 ## E1 ## E1; }; - -#define _GLM_SWIZZLE3_3_MEMBERS(T,P,E0,E1,E2) \ - struct { glm::detail::swizzle<3,T,P,0,0,0,-1> E0 ## E0 ## E0; }; \ - struct { glm::detail::swizzle<3,T,P,0,0,1,-1> E0 ## E0 ## E1; }; \ - struct { glm::detail::swizzle<3,T,P,0,0,2,-1> E0 ## E0 ## E2; }; \ - struct { glm::detail::swizzle<3,T,P,0,1,0,-1> E0 ## E1 ## E0; }; \ - struct { glm::detail::swizzle<3,T,P,0,1,1,-1> E0 ## E1 ## E1; }; \ - struct { glm::detail::swizzle<3,T,P,0,1,2,-1> E0 ## E1 ## E2; }; \ - struct { glm::detail::swizzle<3,T,P,0,2,0,-1> E0 ## E2 ## E0; }; \ - struct { glm::detail::swizzle<3,T,P,0,2,1,-1> E0 ## E2 ## E1; }; \ - struct { glm::detail::swizzle<3,T,P,0,2,2,-1> E0 ## E2 ## E2; }; \ - \ - struct { glm::detail::swizzle<3,T,P,1,0,0,-1> E1 ## E0 ## E0; }; \ - struct { glm::detail::swizzle<3,T,P,1,0,1,-1> E1 ## E0 ## E1; }; \ - struct { glm::detail::swizzle<3,T,P,1,0,2,-1> E1 ## E0 ## E2; }; \ - struct { glm::detail::swizzle<3,T,P,1,1,0,-1> E1 ## E1 ## E0; }; \ - struct { glm::detail::swizzle<3,T,P,1,1,1,-1> E1 ## E1 ## E1; }; \ - struct { glm::detail::swizzle<3,T,P,1,1,2,-1> E1 ## E1 ## E2; }; \ - struct { glm::detail::swizzle<3,T,P,1,2,0,-1> E1 ## E2 ## E0; }; \ - struct { glm::detail::swizzle<3,T,P,1,2,1,-1> E1 ## E2 ## E1; }; \ - struct { glm::detail::swizzle<3,T,P,1,2,2,-1> E1 ## E2 ## E2; }; \ - \ - struct { glm::detail::swizzle<3,T,P,2,0,0,-1> E2 ## E0 ## E0; }; \ - struct { glm::detail::swizzle<3,T,P,2,0,1,-1> E2 ## E0 ## E1; }; \ - struct { glm::detail::swizzle<3,T,P,2,0,2,-1> E2 ## E0 ## E2; }; \ - struct { glm::detail::swizzle<3,T,P,2,1,0,-1> E2 ## E1 ## E0; }; \ - struct { glm::detail::swizzle<3,T,P,2,1,1,-1> E2 ## E1 ## E1; }; \ - struct { glm::detail::swizzle<3,T,P,2,1,2,-1> E2 ## E1 ## E2; }; \ - struct { glm::detail::swizzle<3,T,P,2,2,0,-1> E2 ## E2 ## E0; }; \ - struct { glm::detail::swizzle<3,T,P,2,2,1,-1> E2 ## E2 ## E1; }; \ - struct { glm::detail::swizzle<3,T,P,2,2,2,-1> E2 ## E2 ## E2; }; +#define _GLM_SWIZZLE2_4_MEMBERS(T,P2,E0,E1) \ + struct { glm::detail::swizzle<4,T,P2,0,0,0,0> E0 ## E0 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,0,0,0,1> E0 ## E0 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,0,0,1,0> E0 ## E0 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,0,0,1,1> E0 ## E0 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,0,1,0,0> E0 ## E1 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,0,1,0,1> E0 ## E1 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,0,1,1,0> E0 ## E1 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,0,1,1,1> E0 ## E1 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,1,0,0,0> E1 ## E0 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,1,0,0,1> E1 ## E0 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,1,0,1,0> E1 ## E0 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,1,0,1,1> E1 ## E0 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,1,1,0,0> E1 ## E1 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,1,1,0,1> E1 ## E1 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<4,T,P2,1,1,1,0> E1 ## E1 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<4,T,P2,1,1,1,1> E1 ## E1 ## E1 ## E1; }; #define _GLM_SWIZZLE3_2_MEMBERS(T,P2,E0,E1,E2) \ struct { glm::detail::swizzle<2,T,P2,0,0,-1,-2> E0 ## E0; }; \ @@ -410,6 +395,35 @@ namespace glm struct { glm::detail::swizzle<2,T,P2,2,1,-1,-2> E2 ## E1; }; \ struct { glm::detail::swizzle<2,T,P2,2,2,-1,-2> E2 ## E2; }; +#define _GLM_SWIZZLE3_3_MEMBERS(T,P,E0,E1,E2) \ + struct { glm::detail::swizzle<3,T,P,0,0,0,-1> E0 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<3,T,P,0,0,1,-1> E0 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<3,T,P,0,0,2,-1> E0 ## E0 ## E2; }; \ + struct { glm::detail::swizzle<3,T,P,0,1,0,-1> E0 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<3,T,P,0,1,1,-1> E0 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<3,T,P,0,1,2,-1> E0 ## E1 ## E2; }; \ + struct { glm::detail::swizzle<3,T,P,0,2,0,-1> E0 ## E2 ## E0; }; \ + struct { glm::detail::swizzle<3,T,P,0,2,1,-1> E0 ## E2 ## E1; }; \ + struct { glm::detail::swizzle<3,T,P,0,2,2,-1> E0 ## E2 ## E2; }; \ + struct { glm::detail::swizzle<3,T,P,1,0,0,-1> E1 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<3,T,P,1,0,1,-1> E1 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<3,T,P,1,0,2,-1> E1 ## E0 ## E2; }; \ + struct { glm::detail::swizzle<3,T,P,1,1,0,-1> E1 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<3,T,P,1,1,1,-1> E1 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<3,T,P,1,1,2,-1> E1 ## E1 ## E2; }; \ + struct { glm::detail::swizzle<3,T,P,1,2,0,-1> E1 ## E2 ## E0; }; \ + struct { glm::detail::swizzle<3,T,P,1,2,1,-1> E1 ## E2 ## E1; }; \ + struct { glm::detail::swizzle<3,T,P,1,2,2,-1> E1 ## E2 ## E2; }; \ + struct { glm::detail::swizzle<3,T,P,2,0,0,-1> E2 ## E0 ## E0; }; \ + struct { glm::detail::swizzle<3,T,P,2,0,1,-1> E2 ## E0 ## E1; }; \ + struct { glm::detail::swizzle<3,T,P,2,0,2,-1> E2 ## E0 ## E2; }; \ + struct { glm::detail::swizzle<3,T,P,2,1,0,-1> E2 ## E1 ## E0; }; \ + struct { glm::detail::swizzle<3,T,P,2,1,1,-1> E2 ## E1 ## E1; }; \ + struct { glm::detail::swizzle<3,T,P,2,1,2,-1> E2 ## E1 ## E2; }; \ + struct { glm::detail::swizzle<3,T,P,2,2,0,-1> E2 ## E2 ## E0; }; \ + struct { glm::detail::swizzle<3,T,P,2,2,1,-1> E2 ## E2 ## E1; }; \ + struct { glm::detail::swizzle<3,T,P,2,2,2,-1> E2 ## E2 ## E2; }; + #define _GLM_SWIZZLE3_4_MEMBERS(T,P2,E0,E1,E2) \ struct { glm::detail::swizzle<4,T,P2,0,0,0,0> E0 ## E0 ## E0 ## E0; }; \ struct { glm::detail::swizzle<4,T,P2,0,0,0,1> E0 ## E0 ## E0 ## E1; }; \ @@ -438,7 +452,6 @@ namespace glm struct { glm::detail::swizzle<4,T,P2,0,2,2,0> E0 ## E2 ## E2 ## E0; }; \ struct { glm::detail::swizzle<4,T,P2,0,2,2,1> E0 ## E2 ## E2 ## E1; }; \ struct { glm::detail::swizzle<4,T,P2,0,2,2,2> E0 ## E2 ## E2 ## E2; }; \ - \ struct { glm::detail::swizzle<4,T,P2,1,0,0,0> E1 ## E0 ## E0 ## E0; }; \ struct { glm::detail::swizzle<4,T,P2,1,0,0,1> E1 ## E0 ## E0 ## E1; }; \ struct { glm::detail::swizzle<4,T,P2,1,0,0,2> E1 ## E0 ## E0 ## E2; }; \ @@ -466,7 +479,6 @@ namespace glm struct { glm::detail::swizzle<4,T,P2,1,2,2,0> E1 ## E2 ## E2 ## E0; }; \ struct { glm::detail::swizzle<4,T,P2,1,2,2,1> E1 ## E2 ## E2 ## E1; }; \ struct { glm::detail::swizzle<4,T,P2,1,2,2,2> E1 ## E2 ## E2 ## E2; }; \ - \ struct { glm::detail::swizzle<4,T,P2,2,0,0,0> E2 ## E0 ## E0 ## E0; }; \ struct { glm::detail::swizzle<4,T,P2,2,0,0,1> E2 ## E0 ## E0 ## E1; }; \ struct { glm::detail::swizzle<4,T,P2,2,0,0,2> E2 ## E0 ## E0 ## E2; }; \ @@ -493,27 +505,7 @@ namespace glm struct { glm::detail::swizzle<4,T,P2,2,2,1,2> E2 ## E2 ## E1 ## E2; }; \ struct { glm::detail::swizzle<4,T,P2,2,2,2,0> E2 ## E2 ## E2 ## E0; }; \ struct { glm::detail::swizzle<4,T,P2,2,2,2,1> E2 ## E2 ## E2 ## E1; }; \ - struct { glm::detail::swizzle<4,T,P2,2,2,2,2> E2 ## E2 ## E2 ## E2; }; \ - - -#define _GLM_SWIZZLE2_4_MEMBERS(T,P2,E0,E1) \ - struct { glm::detail::swizzle<4,T,P2,0,0,0,0> E0 ## E0 ## E0 ## E0; }; \ - struct { glm::detail::swizzle<4,T,P2,0,0,0,1> E0 ## E0 ## E0 ## E1; }; \ - struct { glm::detail::swizzle<4,T,P2,0,0,1,0> E0 ## E0 ## E1 ## E0; }; \ - struct { glm::detail::swizzle<4,T,P2,0,0,1,1> E0 ## E0 ## E1 ## E1; }; \ - struct { glm::detail::swizzle<4,T,P2,0,1,0,0> E0 ## E1 ## E0 ## E0; }; \ - struct { glm::detail::swizzle<4,T,P2,0,1,0,1> E0 ## E1 ## E0 ## E1; }; \ - struct { glm::detail::swizzle<4,T,P2,0,1,1,0> E0 ## E1 ## E1 ## E0; }; \ - struct { glm::detail::swizzle<4,T,P2,0,1,1,1> E0 ## E1 ## E1 ## E1; }; \ - struct { glm::detail::swizzle<4,T,P2,1,0,0,0> E1 ## E0 ## E0 ## E0; }; \ - struct { glm::detail::swizzle<4,T,P2,1,0,0,1> E1 ## E0 ## E0 ## E1; }; \ - struct { glm::detail::swizzle<4,T,P2,1,0,1,0> E1 ## E0 ## E1 ## E0; }; \ - struct { glm::detail::swizzle<4,T,P2,1,0,1,1> E1 ## E0 ## E1 ## E1; }; \ - struct { glm::detail::swizzle<4,T,P2,1,1,0,0> E1 ## E1 ## E0 ## E0; }; \ - struct { glm::detail::swizzle<4,T,P2,1,1,0,1> E1 ## E1 ## E0 ## E1; }; \ - struct { glm::detail::swizzle<4,T,P2,1,1,1,0> E1 ## E1 ## E1 ## E0; }; \ - struct { glm::detail::swizzle<4,T,P2,1,1,1,1> E1 ## E1 ## E1 ## E1; }; - + struct { glm::detail::swizzle<4,T,P2,2,2,2,2> E2 ## E2 ## E2 ## E2; }; #define _GLM_SWIZZLE4_2_MEMBERS(T,P,E0,E1,E2,E3) \ struct { glm::detail::swizzle<2,T,P,0,0,-1,-2> E0 ## E0; }; \ @@ -550,7 +542,6 @@ namespace glm struct { glm::detail::swizzle<3,T,P,0,3,1,-1> E0 ## E3 ## E1; }; \ struct { glm::detail::swizzle<3,T,P,0,3,2,-1> E0 ## E3 ## E2; }; \ struct { glm::detail::swizzle<3,T,P,0,3,3,-1> E0 ## E3 ## E3; }; \ - \ struct { glm::detail::swizzle<3,T,P,1,0,0,-1> E1 ## E0 ## E0; }; \ struct { glm::detail::swizzle<3,T,P,1,0,1,-1> E1 ## E0 ## E1; }; \ struct { glm::detail::swizzle<3,T,P,1,0,2,-1> E1 ## E0 ## E2; }; \ @@ -567,7 +558,6 @@ namespace glm struct { glm::detail::swizzle<3,T,P,1,3,1,-1> E1 ## E3 ## E1; }; \ struct { glm::detail::swizzle<3,T,P,1,3,2,-1> E1 ## E3 ## E2; }; \ struct { glm::detail::swizzle<3,T,P,1,3,3,-1> E1 ## E3 ## E3; }; \ - \ struct { glm::detail::swizzle<3,T,P,2,0,0,-1> E2 ## E0 ## E0; }; \ struct { glm::detail::swizzle<3,T,P,2,0,1,-1> E2 ## E0 ## E1; }; \ struct { glm::detail::swizzle<3,T,P,2,0,2,-1> E2 ## E0 ## E2; }; \ @@ -584,7 +574,6 @@ namespace glm struct { glm::detail::swizzle<3,T,P,2,3,1,-1> E2 ## E3 ## E1; }; \ struct { glm::detail::swizzle<3,T,P,2,3,2,-1> E2 ## E3 ## E2; }; \ struct { glm::detail::swizzle<3,T,P,2,3,3,-1> E2 ## E3 ## E3; }; \ - \ struct { glm::detail::swizzle<3,T,P,3,0,0,-1> E3 ## E0 ## E0; }; \ struct { glm::detail::swizzle<3,T,P,3,0,1,-1> E3 ## E0 ## E1; }; \ struct { glm::detail::swizzle<3,T,P,3,0,2,-1> E3 ## E0 ## E2; }; \ @@ -846,9 +835,6 @@ namespace glm struct { glm::detail::swizzle<4,T,P,3,3,3,3> E3 ## E3 ## E3 ## E3; }; - - - #if(defined(GLM_SWIZZLE_XYZW) || defined(GLM_SWIZZLE)) #define xx swizzle(glm::X, glm::X)