mirror of
https://github.com/g-truc/glm.git
synced 2024-11-26 18:24:35 +00:00
Fixed issues with ref types for l-value swizzle operators
This commit is contained in:
parent
b3d70c635b
commit
4b7862b314
@ -51,24 +51,22 @@ namespace detail
|
||||
//////////////////////////////////////
|
||||
// Data
|
||||
|
||||
# if(GLM_LANG & GLM_LANG_CXXMS_FLAG)
|
||||
# if((GLM_LANG & GLM_LANG_CXXMS_FLAG) && defined(GLM_SWIZZLE))
|
||||
union
|
||||
{
|
||||
struct{ value_type x, y; };
|
||||
struct{ value_type r, g; };
|
||||
struct{ value_type s, t; };
|
||||
|
||||
# if(defined(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//(defined(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)
|
||||
};
|
||||
# else
|
||||
union {value_type x, r, s;};
|
||||
|
@ -51,24 +51,22 @@ namespace detail
|
||||
//////////////////////////////////////
|
||||
// Data
|
||||
|
||||
# if(GLM_LANG & GLM_LANG_CXXMS_FLAG)
|
||||
# if((GLM_LANG & GLM_LANG_CXXMS_FLAG) && defined(GLM_SWIZZLE))
|
||||
union
|
||||
{
|
||||
struct{ value_type x, y, z; };
|
||||
struct{ value_type r, g, b; };
|
||||
struct{ value_type s, t, p; };
|
||||
|
||||
# if(defined(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//(defined(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)
|
||||
};
|
||||
# else
|
||||
union { value_type x, r, s; };
|
||||
|
@ -51,24 +51,22 @@ namespace detail
|
||||
//////////////////////////////////////
|
||||
// Data
|
||||
|
||||
# if(GLM_LANG & GLM_LANG_CXXMS_FLAG)
|
||||
# if((GLM_LANG & GLM_LANG_CXXMS_FLAG) && defined(GLM_SWIZZLE))
|
||||
union
|
||||
{
|
||||
struct { value_type r, g, b, a; };
|
||||
struct { value_type s, t, p, q; };
|
||||
struct { value_type x, y, z, w;};
|
||||
|
||||
# if(defined(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//(defined(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)
|
||||
};
|
||||
# else
|
||||
union { value_type x, r, s; };
|
||||
|
@ -91,16 +91,26 @@ namespace glm
|
||||
vecType<T, P> & v,
|
||||
comp x, comp y, comp z, comp w);
|
||||
|
||||
# define static_swizzle1_const(TYPE, SIZE) \
|
||||
# define static_swizzle1_const_precision(TYPE, SIZE, PRECISION) \
|
||||
template <comp x> \
|
||||
GLM_FUNC_QUALIFIER TYPE swizzle(detail::tvec##SIZE<TYPE, defaultp> const & v) \
|
||||
GLM_FUNC_QUALIFIER TYPE swizzle(detail::tvec##SIZE<TYPE, PRECISION> const & v) \
|
||||
{return v[x];}
|
||||
|
||||
# define static_swizzle1_ref(TYPE, SIZE) \
|
||||
# define static_swizzle1_ref_precision(TYPE, SIZE, PRECISION) \
|
||||
template <comp x> \
|
||||
GLM_FUNC_QUALIFIER TYPE& swizzle(detail::tvec##SIZE<TYPE, defaultp> & v) \
|
||||
GLM_FUNC_QUALIFIER TYPE& swizzle(detail::tvec##SIZE<TYPE, PRECISION> & v) \
|
||||
{return v[x];}
|
||||
|
||||
# define static_swizzle1_const(TYPE, SIZE) \
|
||||
static_swizzle1_const_precision(TYPE, SIZE, glm::highp) \
|
||||
static_swizzle1_const_precision(TYPE, SIZE, glm::mediump) \
|
||||
static_swizzle1_const_precision(TYPE, SIZE, glm::lowp)
|
||||
|
||||
# define static_swizzle1_ref(TYPE, SIZE) \
|
||||
static_swizzle1_ref_precision(TYPE, SIZE, glm::highp) \
|
||||
static_swizzle1_ref_precision(TYPE, SIZE, glm::mediump) \
|
||||
static_swizzle1_ref_precision(TYPE, SIZE, glm::lowp)
|
||||
|
||||
static_swizzle1_ref(detail::float32, 2)
|
||||
static_swizzle1_ref(detail::float32, 3)
|
||||
static_swizzle1_ref(detail::float32, 4)
|
||||
@ -150,24 +160,38 @@ namespace glm
|
||||
{return TYPE(v[x], v[y], v[z], v[w]);}
|
||||
*/
|
||||
|
||||
# define static_swizzle2_const(TYPE, SIZE) \
|
||||
# define static_swizzle2_const_precision(TYPE, SIZE, PRECISION) \
|
||||
template <comp x, comp y> \
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<TYPE, defaultp> swizzle( \
|
||||
detail::tvec##SIZE<TYPE, defaultp> const & v) \
|
||||
{return detail::tvec2<TYPE, defaultp>(v[x], v[y]);}
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<TYPE, PRECISION> swizzle( \
|
||||
detail::tvec##SIZE<TYPE, PRECISION> const & v) \
|
||||
{return detail::tvec2<TYPE, PRECISION>(v[x], v[y]); }
|
||||
|
||||
# define static_swizzle3_const_precision(TYPE, SIZE, PRECISION) \
|
||||
template <comp x, comp y, comp z> \
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<TYPE, PRECISION> swizzle( \
|
||||
detail::tvec##SIZE<TYPE, PRECISION> const & v) \
|
||||
{return detail::tvec3<TYPE, PRECISION>(v[x], v[y], v[z]); }
|
||||
|
||||
# define static_swizzle4_const_precision(TYPE, SIZE, PRECISION) \
|
||||
template <comp x, comp y, comp z, comp w> \
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<TYPE, PRECISION> swizzle( \
|
||||
detail::tvec##SIZE<TYPE, PRECISION> const & v) \
|
||||
{return detail::tvec4<TYPE, PRECISION>(v[x], v[y], v[z], v[w]); }
|
||||
|
||||
# define static_swizzle2_const(TYPE, SIZE) \
|
||||
static_swizzle2_const_precision(TYPE, SIZE, glm::highp) \
|
||||
static_swizzle2_const_precision(TYPE, SIZE, glm::mediump) \
|
||||
static_swizzle2_const_precision(TYPE, SIZE, glm::lowp)
|
||||
|
||||
# define static_swizzle3_const(TYPE, SIZE) \
|
||||
template <comp x, comp y, comp z> \
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<TYPE, defaultp> swizzle( \
|
||||
detail::tvec##SIZE<TYPE, defaultp> const & v) \
|
||||
{return detail::tvec3<TYPE, defaultp>(v[x], v[y], v[z]);}
|
||||
static_swizzle3_const_precision(TYPE, SIZE, glm::highp) \
|
||||
static_swizzle3_const_precision(TYPE, SIZE, glm::mediump) \
|
||||
static_swizzle3_const_precision(TYPE, SIZE, glm::lowp)
|
||||
|
||||
# define static_swizzle4_const(TYPE, SIZE) \
|
||||
template <comp x, comp y, comp z, comp w> \
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<TYPE, defaultp> swizzle( \
|
||||
detail::tvec##SIZE<TYPE, defaultp> const & v) \
|
||||
{return detail::tvec4<TYPE, defaultp>(v[x], v[y], v[z], v[w]);}
|
||||
|
||||
static_swizzle4_const_precision(TYPE, SIZE, glm::highp) \
|
||||
static_swizzle4_const_precision(TYPE, SIZE, glm::mediump) \
|
||||
static_swizzle4_const_precision(TYPE, SIZE, glm::lowp)
|
||||
|
||||
static_swizzle2_const(glm::f32, 2)
|
||||
static_swizzle2_const(glm::f32, 3)
|
||||
@ -268,23 +292,38 @@ namespace glm
|
||||
static_swizzle4_const(glm::u64, 3)
|
||||
static_swizzle4_const(glm::u64, 4)
|
||||
|
||||
# define static_swizzle2_ref(TYPE, SIZE) \
|
||||
template <glm::comp x, glm::comp y> \
|
||||
GLM_FUNC_QUALIFIER glm::detail::tref2<TYPE, defaultp> swizzle( \
|
||||
detail::tvec##SIZE<TYPE, defaultp> & v) \
|
||||
{return glm::detail::tref2<TYPE, defaultp>(v[x], v[y]);}
|
||||
# define static_swizzle2_ref_precision(TYPE, SIZE, PRECISION) \
|
||||
template <glm::comp x, glm::comp y> \
|
||||
GLM_FUNC_QUALIFIER glm::detail::tref2<TYPE, PRECISION> swizzle( \
|
||||
detail::tvec##SIZE<TYPE, PRECISION> & v) \
|
||||
{return glm::detail::tref2<TYPE, PRECISION>(v[x], v[y]); }
|
||||
|
||||
# define static_swizzle3_ref(TYPE, SIZE) \
|
||||
template <glm::comp x, glm::comp y, glm::comp z> \
|
||||
GLM_FUNC_QUALIFIER glm::detail::tref3<TYPE, defaultp> swizzle( \
|
||||
detail::tvec##SIZE<TYPE, defaultp> & v) \
|
||||
{return glm::detail::tref3<TYPE, defaultp>(v[x], v[y], v[z]);}
|
||||
# define static_swizzle3_ref_precision(TYPE, SIZE, PRECISION) \
|
||||
template <glm::comp x, glm::comp y, glm::comp z> \
|
||||
GLM_FUNC_QUALIFIER glm::detail::tref3<TYPE, PRECISION> swizzle( \
|
||||
detail::tvec##SIZE<TYPE, PRECISION> & v) \
|
||||
{return glm::detail::tref3<TYPE, PRECISION>(v[x], v[y], v[z]); }
|
||||
|
||||
# define static_swizzle4_ref(TYPE, SIZE) \
|
||||
template <glm::comp x, glm::comp y, glm::comp z, glm::comp w> \
|
||||
GLM_FUNC_QUALIFIER glm::detail::tref4<TYPE, defaultp> swizzle( \
|
||||
detail::tvec##SIZE<TYPE, defaultp> & v) \
|
||||
{return glm::detail::tref4<TYPE, defaultp>(v[x], v[y], v[z], v[w]);}
|
||||
# define static_swizzle4_ref_precision(TYPE, SIZE, PRECISION) \
|
||||
template <glm::comp x, glm::comp y, glm::comp z, glm::comp w> \
|
||||
GLM_FUNC_QUALIFIER glm::detail::tref4<TYPE, PRECISION> swizzle( \
|
||||
detail::tvec##SIZE<TYPE, PRECISION> & v) \
|
||||
{return glm::detail::tref4<TYPE, PRECISION>(v[x], v[y], v[z], v[w]); }
|
||||
|
||||
# define static_swizzle2_ref(TYPE, SIZE) \
|
||||
static_swizzle2_ref_precision(TYPE, SIZE, glm::highp) \
|
||||
static_swizzle2_ref_precision(TYPE, SIZE, glm::mediump) \
|
||||
static_swizzle2_ref_precision(TYPE, SIZE, glm::lowp)
|
||||
|
||||
# define static_swizzle3_ref(TYPE, SIZE) \
|
||||
static_swizzle3_ref_precision(TYPE, SIZE, glm::highp) \
|
||||
static_swizzle3_ref_precision(TYPE, SIZE, glm::mediump) \
|
||||
static_swizzle3_ref_precision(TYPE, SIZE, glm::lowp)
|
||||
|
||||
# define static_swizzle4_ref(TYPE, SIZE) \
|
||||
static_swizzle4_ref_precision(TYPE, SIZE, glm::highp) \
|
||||
static_swizzle4_ref_precision(TYPE, SIZE, glm::mediump) \
|
||||
static_swizzle4_ref_precision(TYPE, SIZE, glm::lowp)
|
||||
|
||||
static_swizzle2_ref(glm::f32, 2)
|
||||
static_swizzle2_ref(glm::f32, 3)
|
||||
|
@ -2,7 +2,7 @@
|
||||
// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2008-08-31
|
||||
// Updated : 2011-09-19
|
||||
// Updated : 2013-08-27
|
||||
// Licence : This source is under MIT License
|
||||
// File : test/core/type_vec3.cpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -187,125 +187,131 @@ int test_vec3_size()
|
||||
|
||||
int test_vec3_swizzle3_2()
|
||||
{
|
||||
int Error = 0;
|
||||
int Error = 0;
|
||||
|
||||
glm::vec3 v(1, 2, 3);
|
||||
glm::vec2 u;
|
||||
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
|
||||
# if(GLM_LANG & GLM_LANG_CXXMS_FLAG)
|
||||
// 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.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.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 = 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
|
||||
|
||||
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
|
||||
# endif//GLM_LANG
|
||||
|
||||
return Error;
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_vec3_swizzle3_3()
|
||||
{
|
||||
int Error = 0;
|
||||
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;
|
||||
glm::vec3 v(1, 2, 3);
|
||||
glm::vec3 u;
|
||||
|
||||
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;
|
||||
# if(GLM_LANG & GLM_LANG_CXXMS_FLAG)
|
||||
u = v; Error += (u.x == 1.0f && u.y == 2.0f && u.z == 3.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;
|
||||
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;
|
||||
|
||||
return Error;
|
||||
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;
|
||||
# endif//GLM_LANG
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_vec3_swizzle_operators()
|
||||
{
|
||||
int Error = 0;
|
||||
int Error = 0;
|
||||
|
||||
glm::vec3 q, u, v;
|
||||
glm::vec3 q, u, v;
|
||||
|
||||
u = glm::vec3(1, 2, 3);
|
||||
v = glm::vec3(10, 20, 30);
|
||||
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;
|
||||
# if(GLM_LANG & GLM_LANG_CXXMS_FLAG)
|
||||
// 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;
|
||||
// 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;
|
||||
// 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;
|
||||
# endif//GLM_LANG
|
||||
|
||||
// Compile errors
|
||||
//q = (u.yz * v.xyz);
|
||||
//q = (u * v.xy);
|
||||
// Compile errors
|
||||
//q = (u.yz * v.xyz);
|
||||
//q = (u * v.xy);
|
||||
|
||||
return Error;
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_vec3_swizzle_functions()
|
||||
@ -355,6 +361,7 @@ int test_vec3_swizzle_partial()
|
||||
|
||||
glm::vec3 A(1, 2, 3);
|
||||
|
||||
# if(GLM_LANG & GLM_LANG_CXXMS_FLAG)
|
||||
{
|
||||
glm::vec3 B(A.xy, 3.0f);
|
||||
Error += A == B ? 0 : 1;
|
||||
@ -369,6 +376,7 @@ int test_vec3_swizzle_partial()
|
||||
glm::vec3 B(A.xyz);
|
||||
Error += A == B ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_LANG
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
@ -216,6 +216,7 @@ int test_vec4_swizzle_partial()
|
||||
|
||||
glm::vec4 A(1, 2, 3, 4);
|
||||
|
||||
# if((GLM_LANG & GLM_LANG_CXXMS_FLAG) && defined(GLM_SWIZZLE))
|
||||
{
|
||||
glm::vec4 B(A.xy, A.zw);
|
||||
Error += A == B ? 0 : 1;
|
||||
@ -241,6 +242,7 @@ int test_vec4_swizzle_partial()
|
||||
glm::vec4 B(1.0f, A.yzw);
|
||||
Error += A == B ? 0 : 1;
|
||||
}
|
||||
# endif//GLM_LANG
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user