mirror of
https://github.com/g-truc/glm.git
synced 2024-11-30 03:44:38 +00:00
Removed multiple component selection code
This commit is contained in:
parent
4dd2b6893e
commit
bc72fafdd9
@ -605,49 +605,6 @@
|
||||
# endif//GLM_ARCH
|
||||
#endif//GLM_MESSAGE
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Support check macros
|
||||
|
||||
#define GLM_SUPPORT_ANONYMOUS_UNION() \
|
||||
(GLM_LANG & GLM_LANG_CXX98_FLAG)
|
||||
|
||||
#define GLM_SUPPORT_ANONYMOUS_UNION_OF_STRUCTURE() \
|
||||
((GLM_LANG & GLM_LANG_CXXMS_FLAG) && (GLM_COMPILER & GLM_COMPILER_VC))
|
||||
|
||||
#define GLM_SUPPORT_SWIZZLE_OPERATOR() \
|
||||
(defined(GLM_SWIZZLE) && GLM_SUPPORT_ANONYMOUS_UNION_OF_STRUCTURE())
|
||||
|
||||
#define GLM_SUPPORT_SWIZZLE_FUNCTION() defined(GLM_SWIZZLE)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Components
|
||||
|
||||
//#define GLM_FORCE_ONLY_XYZW
|
||||
#define GLM_COMPONENT_ONLY_XYZW 0 // To disable multiple vector component names access.
|
||||
#define GLM_COMPONENT_CXX98 1 //
|
||||
#define GLM_COMPONENT_CXXMS 2 // To use anonymous union to provide multiple component names access for class valType. Visual C++ only.
|
||||
|
||||
#if(GLM_SUPPORT_ANONYMOUS_UNION_OF_STRUCTURE() && !defined(GLM_FORCE_ONLY_XYZW))
|
||||
# define GLM_COMPONENT GLM_COMPONENT_CXXMS
|
||||
#elif(GLM_SUPPORT_ANONYMOUS_UNION() && !defined(GLM_FORCE_ONLY_XYZW))
|
||||
# define GLM_COMPONENT GLM_COMPONENT_CXX98
|
||||
#else
|
||||
# define GLM_COMPONENT GLM_COMPONENT_ONLY_XYZW
|
||||
#endif
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_COMPONENT_DISPLAYED))
|
||||
# define GLM_MESSAGE_COMPONENT_DISPLAYED
|
||||
# if(GLM_COMPONENT == GLM_COMPONENT_CXX98)
|
||||
# pragma message("GLM: x,y,z,w; r,g,b,a; s,t,p,q component names except of half based vector types")
|
||||
# elif(GLM_COMPONENT == GLM_COMPONENT_ONLY_XYZW)
|
||||
# pragma message("GLM: x,y,z,w component names for all vector types")
|
||||
# elif(GLM_COMPONENT == GLM_COMPONENT_CXXMS)
|
||||
# pragma message("GLM: x,y,z,w; r,g,b,a; s,t,p,q component names for all vector types")
|
||||
# else
|
||||
# error "GLM: GLM_COMPONENT value unknown"
|
||||
# endif//GLM_MESSAGE_COMPONENT_DISPLAYED
|
||||
#endif//GLM_MESSAGE
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Radians
|
||||
|
||||
@ -710,10 +667,8 @@
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_SWIZZLE_DISPLAYED))
|
||||
# define GLM_MESSAGE_SWIZZLE_DISPLAYED
|
||||
# if(GLM_SUPPORT_SWIZZLE_OPERATOR())
|
||||
# if defined(GLM_SWIZZLE)
|
||||
# pragma message("GLM: Swizzling operators enabled")
|
||||
# elif(GLM_SUPPORT_SWIZZLE_FUNCTION())
|
||||
# pragma message("GLM: Swizzling operators supported through swizzling functions")
|
||||
# else
|
||||
# pragma message("GLM: Swizzling operators disabled")
|
||||
# endif
|
||||
@ -736,7 +691,7 @@
|
||||
# define GLM_RESTRICT
|
||||
# define GLM_RESTRICT_VAR __restrict
|
||||
# define GLM_CONSTEXPR
|
||||
#elif(((GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_LLVM_GCC)) && (GLM_COMPILER >= GLM_COMPILER_GCC31)) || (GLM_COMPILER & GLM_COMPILER_CLANG))
|
||||
#elif(((GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_LLVM_GCC)) && (GLM_COMPILER >= GLM_COMPILER_GCC34)) || (GLM_COMPILER & GLM_COMPILER_CLANG))
|
||||
# define GLM_DEPRECATED __attribute__((__deprecated__))
|
||||
# define GLM_ALIGN(x) __attribute__((aligned(x)))
|
||||
# define GLM_ALIGNED_STRUCT(x) struct __attribute__((aligned(x)))
|
||||
|
@ -22,7 +22,7 @@
|
||||
///
|
||||
/// @ref core
|
||||
/// @file glm/core/type_vec2.hpp
|
||||
/// @date 2008-08-18 / 2011-06-15
|
||||
/// @date 2008-08-18 / 2013-08-27
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -54,11 +54,10 @@ namespace detail
|
||||
union {value_type x, r, s;};
|
||||
union {value_type y, g, t;};
|
||||
|
||||
# if(defined(GLM_SWIZZLE))
|
||||
// Defines all he swizzle operator as functions
|
||||
# ifdef GLM_SWIZZLE
|
||||
GLM_SWIZZLE_GEN_REF_FROM_VEC2(value_type, P, detail::tvec2, detail::tref2)
|
||||
GLM_SWIZZLE_GEN_VEC_FROM_VEC2(value_type, P, detail::tvec2, detail::tvec2, detail::tvec3, detail::tvec4)
|
||||
# endif//(defined(GLM_SWIZZLE))
|
||||
# endif//GLM_SWIZZLE
|
||||
|
||||
//////////////////////////////////////
|
||||
// Accesses
|
||||
|
@ -56,7 +56,6 @@ namespace detail
|
||||
union {value_type z, b, p;};
|
||||
|
||||
# if(defined(GLM_SWIZZLE))
|
||||
// Defines all he swizzle operator as functions
|
||||
GLM_SWIZZLE_GEN_REF_FROM_VEC3(T, P, detail::tvec3, detail::tref2, detail::tref3)
|
||||
GLM_SWIZZLE_GEN_VEC_FROM_VEC3(T, P, detail::tvec3, detail::tvec2, detail::tvec3, detail::tvec4)
|
||||
# endif//(defined(GLM_SWIZZLE))
|
||||
|
@ -57,7 +57,6 @@ namespace detail
|
||||
union {value_type w, a, q;};
|
||||
|
||||
# if(defined(GLM_SWIZZLE))
|
||||
// Defines all he swizzle operator as functions
|
||||
GLM_SWIZZLE_GEN_REF_FROM_VEC4(T, P, detail::tvec4, detail::tref2, detail::tref3, detail::tref4)
|
||||
GLM_SWIZZLE_GEN_VEC_FROM_VEC4(T, P, detail::tvec4, detail::tvec2, detail::tvec3, detail::tvec4)
|
||||
# endif//(defined(GLM_SWIZZLE))
|
||||
|
@ -134,7 +134,6 @@
|
||||
////////////////////
|
||||
// check type sizes
|
||||
#ifndef GLM_STATIC_ASSERT_NULL
|
||||
GLM_STATIC_ASSERT(sizeof(glm::float16) == 2, "float16 size isn't 2 bytes on this platform");
|
||||
GLM_STATIC_ASSERT(sizeof(glm::float32) == 4, "float32 size isn't 4 bytes on this platform");
|
||||
GLM_STATIC_ASSERT(sizeof(glm::float64) == 8, "float64 size isn't 8 bytes on this platform");
|
||||
#endif//GLM_STATIC_ASSERT_NULL
|
||||
|
@ -197,7 +197,6 @@ int test_vec3_swizzle3_2()
|
||||
//u = v.rgb; //Illegal
|
||||
//u = v.stp; //Illegal
|
||||
|
||||
#if(GLM_SUPPORT_SWIZZLE_OPERATOR())
|
||||
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;
|
||||
@ -243,7 +242,6 @@ int test_vec3_swizzle3_2()
|
||||
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
|
||||
#endif//(GLM_SUPPORT_SWIZZLE_OPERATOR())
|
||||
|
||||
return Error;
|
||||
}
|
||||
@ -257,7 +255,6 @@ int test_vec3_swizzle3_3()
|
||||
|
||||
u = v; Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.0f) ? 0 : 1;
|
||||
|
||||
#if(GLM_SUPPORT_SWIZZLE_OPERATOR())
|
||||
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;
|
||||
@ -269,7 +266,7 @@ int test_vec3_swizzle3_3()
|
||||
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;
|
||||
#endif//(GLM_SUPPORT_SWIZZLE_OPERATOR())
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
@ -282,7 +279,6 @@ int test_vec3_swizzle_operators()
|
||||
u = glm::vec3(1, 2, 3);
|
||||
v = glm::vec3(10, 20, 30);
|
||||
|
||||
#if(GLM_SUPPORT_SWIZZLE_OPERATOR())
|
||||
// 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;
|
||||
@ -304,7 +300,6 @@ int test_vec3_swizzle_operators()
|
||||
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;
|
||||
#endif//(GLM_SUPPORT_SWIZZLE_OPERATOR())
|
||||
|
||||
// Compile errors
|
||||
//q = (u.yz * v.xyz);
|
||||
@ -324,7 +319,6 @@ int test_vec3_swizzle_functions()
|
||||
// glm::dot(u.xy, v.xy); <--- Compile error
|
||||
// glm::dot(u.xy(), v.xy()); <--- Compiles correctly
|
||||
|
||||
#if(GLM_SUPPORT_SWIZZLE_OPERATOR())
|
||||
float r;
|
||||
|
||||
// vec2
|
||||
@ -351,7 +345,6 @@ int test_vec3_swizzle_functions()
|
||||
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;
|
||||
#endif//(GLM_SUPPORT_SWIZZLE_OPERATOR())
|
||||
|
||||
return Error;
|
||||
}
|
||||
@ -360,7 +353,6 @@ int test_vec3_swizzle_partial()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
#if(GLM_SUPPORT_SWIZZLE_OPERATOR())
|
||||
glm::vec3 A(1, 2, 3);
|
||||
|
||||
{
|
||||
@ -377,7 +369,6 @@ int test_vec3_swizzle_partial()
|
||||
glm::vec3 B(A.xyz);
|
||||
Error += A == B ? 0 : 1;
|
||||
}
|
||||
#endif//(GLM_SUPPORT_SWIZZLE_OPERATOR())
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
@ -216,7 +216,6 @@ int test_vec4_swizzle_partial()
|
||||
|
||||
glm::vec4 A(1, 2, 3, 4);
|
||||
|
||||
#if(GLM_SUPPORT_SWIZZLE_OPERATOR())
|
||||
{
|
||||
glm::vec4 B(A.xy, A.zw);
|
||||
Error += A == B ? 0 : 1;
|
||||
@ -242,7 +241,6 @@ int test_vec4_swizzle_partial()
|
||||
glm::vec4 B(1.0f, A.yzw);
|
||||
Error += A == B ? 0 : 1;
|
||||
}
|
||||
#endif//(GLM_SUPPORT_SWIZZLE_OPERATOR())
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user