Clean up formatting for components and swizzle code

This commit is contained in:
Christophe Riccio 2014-10-12 19:58:46 +02:00
parent 093b8042f7
commit b2ce1a726b
4 changed files with 94 additions and 63 deletions

View File

@ -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

View File

@ -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
//////////////////////////////////////

View File

@ -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
//////////////////////////////////////

View File

@ -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<T>::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<T>::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
//////////////////////////////////////