mirror of
https://github.com/g-truc/glm.git
synced 2024-11-10 04:31:47 +00:00
Added constructor taking partial swizzle operation parameter
This commit is contained in:
parent
f1975617c0
commit
e8ee34e397
@ -82,11 +82,6 @@ namespace detail
|
||||
value_type const & s2,
|
||||
value_type const & s3);
|
||||
|
||||
//////////////////////////////////////
|
||||
// Swizzle constructors
|
||||
|
||||
GLM_FUNC_DECL tvec3(tref3<T> const & r);
|
||||
|
||||
//////////////////////////////////////
|
||||
// Convertion scalar constructors
|
||||
|
||||
@ -117,6 +112,17 @@ namespace detail
|
||||
template <typename U>
|
||||
GLM_FUNC_DECL explicit tvec3(tvec4<U> const & v);
|
||||
|
||||
//////////////////////////////////////
|
||||
// Swizzle constructors
|
||||
|
||||
GLM_FUNC_DECL tvec3(tref3<T> const & r);
|
||||
|
||||
template <typename A, typename B>
|
||||
GLM_FUNC_DECL explicit tvec3(tref2<A> const & v, B const & s);
|
||||
|
||||
template <typename A, typename B>
|
||||
GLM_FUNC_DECL explicit tvec3(A const & s, tref2<B> const & v);
|
||||
|
||||
//////////////////////////////////////
|
||||
// Unary arithmetic operators
|
||||
|
||||
|
@ -112,6 +112,30 @@ namespace detail
|
||||
z(r.z)
|
||||
{}
|
||||
|
||||
template <typename T>
|
||||
template <typename A, typename B>
|
||||
GLM_FUNC_QUALIFIER tvec3<T>::tvec3
|
||||
(
|
||||
tref2<A> const & v,
|
||||
B const & s
|
||||
) :
|
||||
x(value_type(v.x)),
|
||||
y(value_type(v.y)),
|
||||
z(value_type(s))
|
||||
{}
|
||||
|
||||
template <typename T>
|
||||
template <typename A, typename B>
|
||||
GLM_FUNC_QUALIFIER tvec3<T>::tvec3
|
||||
(
|
||||
A const & s,
|
||||
tref2<B> const & v
|
||||
) :
|
||||
x(value_type(s)),
|
||||
y(value_type(v.x)),
|
||||
z(value_type(v.y))
|
||||
{}
|
||||
|
||||
//////////////////////////////////////
|
||||
// Convertion scalar constructors
|
||||
|
||||
|
@ -84,11 +84,6 @@ namespace detail
|
||||
value_type const & s2,
|
||||
value_type const & s3);
|
||||
|
||||
//////////////////////////////////////
|
||||
// Swizzle constructors
|
||||
|
||||
GLM_FUNC_DECL tvec4(tref4<T> const & r);
|
||||
|
||||
//////////////////////////////////////
|
||||
// Convertion scalar constructors
|
||||
|
||||
@ -129,6 +124,36 @@ namespace detail
|
||||
template <typename U>
|
||||
GLM_FUNC_DECL explicit tvec4(tvec4<U> const & v);
|
||||
|
||||
//////////////////////////////////////
|
||||
// Swizzle constructors
|
||||
|
||||
GLM_FUNC_DECL tvec4(tref4<T> const & r);
|
||||
|
||||
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
|
||||
template <typename A, typename B, typename C>
|
||||
GLM_FUNC_DECL explicit tvec4(tref2<A> const & v, B const & s1, C const & s2);
|
||||
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
|
||||
template <typename A, typename B, typename C>
|
||||
GLM_FUNC_DECL explicit tvec4(A const & s1, tref2<B> const & v, C const & s2);
|
||||
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
|
||||
template <typename A, typename B, typename C>
|
||||
GLM_FUNC_DECL explicit tvec4(A const & s1, B const & s2, tref2<C> const & v);
|
||||
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
|
||||
template <typename A, typename B>
|
||||
GLM_FUNC_DECL explicit tvec4(tref3<A> const & v, B const & s);
|
||||
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
|
||||
template <typename A, typename B>
|
||||
GLM_FUNC_DECL explicit tvec4(A const & s, tref3<B> const & v);
|
||||
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
|
||||
template <typename A, typename B>
|
||||
GLM_FUNC_DECL explicit tvec4(tref2<A> const & v1, tref2<B> const & v2);
|
||||
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
|
||||
template <typename A, typename B>
|
||||
GLM_FUNC_DECL explicit tvec4(tvec2<A> const & v1, tref2<B> const & v2);
|
||||
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
|
||||
template <typename A, typename B>
|
||||
GLM_FUNC_DECL explicit tvec4(tref2<A> const & v1, tvec2<B> const & v2);
|
||||
|
||||
//////////////////////////////////////
|
||||
// Unary arithmetic operators
|
||||
|
||||
|
@ -118,6 +118,113 @@ namespace detail
|
||||
w(r.w)
|
||||
{}
|
||||
|
||||
template <typename T>
|
||||
template <typename A, typename B, typename C>
|
||||
GLM_FUNC_QUALIFIER tvec4<T>::tvec4
|
||||
(
|
||||
tref2<A> const & v,
|
||||
B const & s1,
|
||||
C const & s2
|
||||
) :
|
||||
x(value_type(v.x)),
|
||||
y(value_type(v.y)),
|
||||
z(value_type(s1)),
|
||||
w(value_type(s2))
|
||||
{}
|
||||
|
||||
template <typename T>
|
||||
template <typename A, typename B, typename C>
|
||||
GLM_FUNC_QUALIFIER tvec4<T>::tvec4
|
||||
(
|
||||
A const & s1,
|
||||
tref2<B> const & v,
|
||||
C const & s2
|
||||
) :
|
||||
x(value_type(s1)),
|
||||
y(value_type(v.x)),
|
||||
z(value_type(v.y)),
|
||||
w(value_type(s2))
|
||||
{}
|
||||
|
||||
template <typename T>
|
||||
template <typename A, typename B, typename C>
|
||||
GLM_FUNC_QUALIFIER tvec4<T>::tvec4
|
||||
(
|
||||
A const & s1,
|
||||
B const & s2,
|
||||
tref2<C> const & v
|
||||
) :
|
||||
x(value_type(s1)),
|
||||
y(value_type(s2)),
|
||||
z(value_type(v.x)),
|
||||
w(value_type(v.y))
|
||||
{}
|
||||
|
||||
template <typename T>
|
||||
template <typename A, typename B>
|
||||
GLM_FUNC_QUALIFIER tvec4<T>::tvec4
|
||||
(
|
||||
tref3<A> const & v,
|
||||
B const & s
|
||||
) :
|
||||
x(value_type(v.x)),
|
||||
y(value_type(v.y)),
|
||||
z(value_type(v.z)),
|
||||
w(value_type(s))
|
||||
{}
|
||||
|
||||
template <typename T>
|
||||
template <typename A, typename B>
|
||||
GLM_FUNC_QUALIFIER tvec4<T>::tvec4
|
||||
(
|
||||
A const & s,
|
||||
tref3<B> const & v
|
||||
) :
|
||||
x(value_type(s)),
|
||||
y(value_type(v.x)),
|
||||
z(value_type(v.y)),
|
||||
w(value_type(v.z))
|
||||
{}
|
||||
|
||||
template <typename T>
|
||||
template <typename A, typename B>
|
||||
GLM_FUNC_QUALIFIER tvec4<T>::tvec4
|
||||
(
|
||||
tref2<A> const & v1,
|
||||
tref2<B> const & v2
|
||||
) :
|
||||
x(value_type(v1.x)),
|
||||
y(value_type(v1.y)),
|
||||
z(value_type(v2.x)),
|
||||
w(value_type(v2.y))
|
||||
{}
|
||||
|
||||
template <typename T>
|
||||
template <typename A, typename B>
|
||||
GLM_FUNC_QUALIFIER tvec4<T>::tvec4
|
||||
(
|
||||
tvec2<A> const & v1,
|
||||
tref2<B> const & v2
|
||||
) :
|
||||
x(value_type(v1.x)),
|
||||
y(value_type(v1.y)),
|
||||
z(value_type(v2.x)),
|
||||
w(value_type(v2.y))
|
||||
{}
|
||||
|
||||
template <typename T>
|
||||
template <typename A, typename B>
|
||||
GLM_FUNC_QUALIFIER tvec4<T>::tvec4
|
||||
(
|
||||
tref2<A> const & v1,
|
||||
tvec2<B> const & v2
|
||||
) :
|
||||
x(value_type(v1.x)),
|
||||
y(value_type(v1.y)),
|
||||
z(value_type(v2.x)),
|
||||
w(value_type(v2.y))
|
||||
{}
|
||||
|
||||
//////////////////////////////////////
|
||||
// Convertion scalar constructors
|
||||
|
||||
|
@ -121,13 +121,83 @@ int test_swizzle_vec4_const_static()
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_swizzle_vec3_partial()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::ivec3 A(0, 1, 2);
|
||||
|
||||
{
|
||||
glm::ivec3 B(A.swizzle(glm::R, glm::G, glm::B));
|
||||
Error += (A == B) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec3 B(A.swizzle(glm::R, glm::G), 2);
|
||||
Error += (A == B) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec3 B(0, A.swizzle(glm::G, glm::B));
|
||||
Error += (A == B) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_swizzle_vec4_partial()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::ivec4 A(0, 1, 2, 3);
|
||||
|
||||
{
|
||||
glm::ivec4 B(A.swizzle(glm::R, glm::G, glm::B), 3);
|
||||
Error += (A == B) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec4 B(A.swizzle(glm::R, glm::G), 2, 3);
|
||||
Error += (A == B) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec4 B(0, A.swizzle(glm::G, glm::B), 3);
|
||||
Error += (A == B) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec4 B(0, 1, A.swizzle(glm::B, glm::A));
|
||||
Error += (A == B) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec4 B(A.swizzle(glm::X, glm::Y), A.swizzle(glm::Z, glm::W));
|
||||
Error += (A == B) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec4 B(A.swizzle(glm::X, glm::Y), glm::vec2(2, 3));
|
||||
Error += (A == B) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::ivec4 B(glm::vec2(0, 1), A.swizzle(glm::Z, glm::W));
|
||||
Error += (A == B) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
Error += test_swizzle_vec3_partial();
|
||||
Error += test_swizzle_vec4_ref_dynamic();
|
||||
Error += test_swizzle_vec4_ref_static();
|
||||
Error += test_swizzle_vec4_const_dynamic();
|
||||
Error += test_swizzle_vec4_const_static();
|
||||
Error += test_swizzle_vec4_partial();
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user