From b2ce1a726b233689961b7e4775de90504360cd2c Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Sun, 12 Oct 2014 19:58:46 +0200 Subject: [PATCH] Clean up formatting for components and swizzle code --- glm/detail/type_vec1.hpp | 41 ++++++++++++++++++++++++++++++++-------- glm/detail/type_vec2.hpp | 38 +++++++++++++++++++------------------ glm/detail/type_vec3.hpp | 38 +++++++++++++++++++------------------ glm/detail/type_vec4.hpp | 40 ++++++++++++++++++++------------------- 4 files changed, 94 insertions(+), 63 deletions(-) diff --git a/glm/detail/type_vec1.hpp b/glm/detail/type_vec1.hpp index e12dc56d..8389b6b7 100644 --- a/glm/detail/type_vec1.hpp +++ b/glm/detail/type_vec1.hpp @@ -56,18 +56,43 @@ namespace glm ////////////////////////////////////// // Helper -#if GLM_FORCE_SIZE_FUNC - /// Return the count of components of the vector - GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const; -#else - /// Return the count of components of the vector - GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; -#endif//GLM_FORCE_SIZE_FUNC +# if GLM_FORCE_SIZE_FUNC + /// Return the count of components of the vector + GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const; +# else + /// Return the count of components of the vector + GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; +# endif//GLM_FORCE_SIZE_FUNC ////////////////////////////////////// // Data - union {T x, r, s;}; +# if GLM_HAS_ANONYMOUS_UNION + union + { + T x; + T r; + T s; +/* +# ifdef GLM_SWIZZLE + _GLM_SWIZZLE1_2_MEMBERS(T, P, tvec2, x) + _GLM_SWIZZLE1_2_MEMBERS(T, P, tvec2, r) + _GLM_SWIZZLE1_2_MEMBERS(T, P, tvec2, s) + _GLM_SWIZZLE1_3_MEMBERS(T, P, tvec3, x) + _GLM_SWIZZLE1_3_MEMBERS(T, P, tvec3, r) + _GLM_SWIZZLE1_3_MEMBERS(T, P, tvec3, s) + _GLM_SWIZZLE1_4_MEMBERS(T, P, tvec4, x) + _GLM_SWIZZLE1_4_MEMBERS(T, P, tvec4, r) + _GLM_SWIZZLE1_4_MEMBERS(T, P, tvec4, s) +# endif//GLM_SWIZZLE*/ + }; +# else + union {T x, r, s;}; +/* +# ifdef GLM_SWIZZLE + GLM_SWIZZLE_GEN_VEC_FROM_VEC1(T, P, tvec2, tvec2, tvec3, tvec4) +# endif//GLM_SWIZZLE*/ +# endif ////////////////////////////////////// // Accesses diff --git a/glm/detail/type_vec2.hpp b/glm/detail/type_vec2.hpp index aada46e1..5c63a8a3 100644 --- a/glm/detail/type_vec2.hpp +++ b/glm/detail/type_vec2.hpp @@ -57,33 +57,35 @@ namespace glm ////////////////////////////////////// // Helper -#if GLM_FORCE_SIZE_FUNC - /// Return the count of components of the vector - GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const; -#else - /// Return the count of components of the vector - GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; -#endif//GLM_FORCE_SIZE_FUNC +# if GLM_FORCE_SIZE_FUNC + /// Return the count of components of the vector + GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const; +# else + /// Return the count of components of the vector + GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; +# endif//GLM_FORCE_SIZE_FUNC ////////////////////////////////////// // Data -# if(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)) +# if GLM_HAS_ANONYMOUS_UNION union { struct{ T x, y; }; struct{ T r, g; }; struct{ T s, t; }; - _GLM_SWIZZLE2_2_MEMBERS(T, P, tvec2, x, y) - _GLM_SWIZZLE2_2_MEMBERS(T, P, tvec2, r, g) - _GLM_SWIZZLE2_2_MEMBERS(T, P, tvec2, s, t) - _GLM_SWIZZLE2_3_MEMBERS(T, P, tvec3, x, y) - _GLM_SWIZZLE2_3_MEMBERS(T, P, tvec3, r, g) - _GLM_SWIZZLE2_3_MEMBERS(T, P, tvec3, s, t) - _GLM_SWIZZLE2_4_MEMBERS(T, P, tvec4, x, y) - _GLM_SWIZZLE2_4_MEMBERS(T, P, tvec4, r, g) - _GLM_SWIZZLE2_4_MEMBERS(T, P, tvec4, s, t) +# ifdef GLM_SWIZZLE + _GLM_SWIZZLE2_2_MEMBERS(T, P, tvec2, x, y) + _GLM_SWIZZLE2_2_MEMBERS(T, P, tvec2, r, g) + _GLM_SWIZZLE2_2_MEMBERS(T, P, tvec2, s, t) + _GLM_SWIZZLE2_3_MEMBERS(T, P, tvec3, x, y) + _GLM_SWIZZLE2_3_MEMBERS(T, P, tvec3, r, g) + _GLM_SWIZZLE2_3_MEMBERS(T, P, tvec3, s, t) + _GLM_SWIZZLE2_4_MEMBERS(T, P, tvec4, x, y) + _GLM_SWIZZLE2_4_MEMBERS(T, P, tvec4, r, g) + _GLM_SWIZZLE2_4_MEMBERS(T, P, tvec4, s, t) +# endif//GLM_SWIZZLE }; # else union {T x, r, s;}; @@ -91,7 +93,7 @@ namespace glm # ifdef GLM_SWIZZLE GLM_SWIZZLE_GEN_VEC_FROM_VEC2(T, P, tvec2, tvec2, tvec3, tvec4) -# endif +# endif//GLM_SWIZZLE # endif ////////////////////////////////////// diff --git a/glm/detail/type_vec3.hpp b/glm/detail/type_vec3.hpp index d073ba3c..a51b6d4e 100644 --- a/glm/detail/type_vec3.hpp +++ b/glm/detail/type_vec3.hpp @@ -57,33 +57,35 @@ namespace glm ////////////////////////////////////// // Helper -#if GLM_FORCE_SIZE_FUNC - /// Return the count of components of the vector - GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const; -#else - /// Return the count of components of the vector - GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; -#endif//GLM_FORCE_SIZE_FUNC +# if GLM_FORCE_SIZE_FUNC + /// Return the count of components of the vector + GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const; +# else + /// Return the count of components of the vector + GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; +# endif//GLM_FORCE_SIZE_FUNC ////////////////////////////////////// // Data -# if(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)) +# if GLM_HAS_ANONYMOUS_UNION union { struct{ T x, y, z; }; struct{ T r, g, b; }; struct{ T s, t, p; }; - _GLM_SWIZZLE3_2_MEMBERS(T, P, tvec2, x, y, z) - _GLM_SWIZZLE3_2_MEMBERS(T, P, tvec2, r, g, b) - _GLM_SWIZZLE3_2_MEMBERS(T, P, tvec2, s, t, p) - _GLM_SWIZZLE3_3_MEMBERS(T, P, tvec3, x, y, z) - _GLM_SWIZZLE3_3_MEMBERS(T, P, tvec3, r, g, b) - _GLM_SWIZZLE3_3_MEMBERS(T, P, tvec3, s, t, p) - _GLM_SWIZZLE3_4_MEMBERS(T, P, tvec4, x, y, z) - _GLM_SWIZZLE3_4_MEMBERS(T, P, tvec4, r, g, b) - _GLM_SWIZZLE3_4_MEMBERS(T, P, tvec4, s, t, p) +# ifdef GLM_SWIZZLE + _GLM_SWIZZLE3_2_MEMBERS(T, P, tvec2, x, y, z) + _GLM_SWIZZLE3_2_MEMBERS(T, P, tvec2, r, g, b) + _GLM_SWIZZLE3_2_MEMBERS(T, P, tvec2, s, t, p) + _GLM_SWIZZLE3_3_MEMBERS(T, P, tvec3, x, y, z) + _GLM_SWIZZLE3_3_MEMBERS(T, P, tvec3, r, g, b) + _GLM_SWIZZLE3_3_MEMBERS(T, P, tvec3, s, t, p) + _GLM_SWIZZLE3_4_MEMBERS(T, P, tvec4, x, y, z) + _GLM_SWIZZLE3_4_MEMBERS(T, P, tvec4, r, g, b) + _GLM_SWIZZLE3_4_MEMBERS(T, P, tvec4, s, t, p) +# endif//GLM_SWIZZLE }; # else union { T x, r, s; }; @@ -92,7 +94,7 @@ namespace glm # ifdef GLM_SWIZZLE GLM_SWIZZLE_GEN_VEC_FROM_VEC3(T, P, tvec3, tvec2, tvec3, tvec4) -# endif +# endif//GLM_SWIZZLE # endif//GLM_LANG ////////////////////////////////////// diff --git a/glm/detail/type_vec4.hpp b/glm/detail/type_vec4.hpp index 6f8b94ef..1bb565f3 100644 --- a/glm/detail/type_vec4.hpp +++ b/glm/detail/type_vec4.hpp @@ -80,18 +80,18 @@ namespace glm ////////////////////////////////////// // Helper -#if GLM_FORCE_SIZE_FUNC - /// Return the count of components of the vector - GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const; -#else - /// Return the count of components of the vector - GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; -#endif//GLM_FORCE_SIZE_FUNC +# if GLM_FORCE_SIZE_FUNC + /// Return the count of components of the vector + GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const; +# else + /// Return the count of components of the vector + GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const; +# endif//GLM_FORCE_SIZE_FUNC ////////////////////////////////////// // Data -# if(GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)) +# if GLM_HAS_ANONYMOUS_UNION union { typename simd::type data; @@ -99,18 +99,20 @@ namespace glm struct { T s, t, p, q; }; struct { T x, y, z, w;}; - _GLM_SWIZZLE4_2_MEMBERS(T, P, tvec2, x, y, z, w) - _GLM_SWIZZLE4_2_MEMBERS(T, P, tvec2, r, g, b, a) - _GLM_SWIZZLE4_2_MEMBERS(T, P, tvec2, s, t, p, q) - _GLM_SWIZZLE4_3_MEMBERS(T, P, tvec3, x, y, z, w) - _GLM_SWIZZLE4_3_MEMBERS(T, P, tvec3, r, g, b, a) - _GLM_SWIZZLE4_3_MEMBERS(T, P, tvec3, s, t, p, q) - _GLM_SWIZZLE4_4_MEMBERS(T, P, tvec4, x, y, z, w) - _GLM_SWIZZLE4_4_MEMBERS(T, P, tvec4, r, g, b, a) - _GLM_SWIZZLE4_4_MEMBERS(T, P, tvec4, s, t, p, q) +# ifdef GLM_SWIZZLE + _GLM_SWIZZLE4_2_MEMBERS(T, P, tvec2, x, y, z, w) + _GLM_SWIZZLE4_2_MEMBERS(T, P, tvec2, r, g, b, a) + _GLM_SWIZZLE4_2_MEMBERS(T, P, tvec2, s, t, p, q) + _GLM_SWIZZLE4_3_MEMBERS(T, P, tvec3, x, y, z, w) + _GLM_SWIZZLE4_3_MEMBERS(T, P, tvec3, r, g, b, a) + _GLM_SWIZZLE4_3_MEMBERS(T, P, tvec3, s, t, p, q) + _GLM_SWIZZLE4_4_MEMBERS(T, P, tvec4, x, y, z, w) + _GLM_SWIZZLE4_4_MEMBERS(T, P, tvec4, r, g, b, a) + _GLM_SWIZZLE4_4_MEMBERS(T, P, tvec4, s, t, p, q) +# endif//GLM_SWIZZLE }; # else -# if(GLM_HAS_UNRESTRICTED_UNIONS) +# if GLM_HAS_UNRESTRICTED_UNIONS union { typename simd::type data; @@ -131,7 +133,7 @@ namespace glm # ifdef GLM_SWIZZLE GLM_SWIZZLE_GEN_VEC_FROM_VEC4(T, P, tvec4, tvec2, tvec3, tvec4) -# endif +# endif//GLM_SWIZZLE # endif//GLM_LANG //////////////////////////////////////