Added vec1 based constructors to vec4 with tests and fixed build

This commit is contained in:
Groove 2018-07-06 22:22:09 +02:00
parent f5e27805af
commit ec261bd21b
3 changed files with 271 additions and 1 deletions

View File

@ -101,10 +101,39 @@ namespace glm
// -- Conversion scalar constructors --
template<typename U, qualifier P>
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR explicit vec(vec<1, U, P> const& v);
/// Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template<typename X, typename Y, typename Z, typename W>
GLM_FUNC_DECL GLM_CONSTEXPR_SIMD vec(X _x, Y _y, Z _z, W _w);
template<typename X, typename Y, typename Z, typename W>
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<1, X, Q> const& _x, Y _y, Z _z, W _w);
template<typename X, typename Y, typename Z, typename W>
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(X _x, vec<1, Y, Q> const& _y, Z _z, W _w);
template<typename X, typename Y, typename Z, typename W>
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<1, X, Q> const& _x, vec<1, Y, Q> const& _y, Z _z, W _w);
template<typename X, typename Y, typename Z, typename W>
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(X _x, Y _y, vec<1, Z, Q> const& _z, W _w);
template<typename X, typename Y, typename Z, typename W>
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<1, X, Q> const& _x, Y _y, vec<1, Z, Q> const& _z, W _w);
template<typename X, typename Y, typename Z, typename W>
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(X _x, vec<1, Y, Q> const& _y, vec<1, Z, Q> const& _z, W _w);
template<typename X, typename Y, typename Z, typename W>
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<1, X, Q> const& _x, vec<1, Y, Q> const& _y, vec<1, Z, Q> const& _z, W _w);
template<typename X, typename Y, typename Z, typename W>
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<1, X, Q> const& _x, Y _y, Z _z, vec<1, W, Q> const& _w);
template<typename X, typename Y, typename Z, typename W>
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(X _x, vec<1, Y, Q> const& _y, Z _z, vec<1, W, Q> const& _w);
template<typename X, typename Y, typename Z, typename W>
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<1, X, Q> const& _x, vec<1, Y, Q> const& _y, Z _z, vec<1, W, Q> const& _w);
template<typename X, typename Y, typename Z, typename W>
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(X _x, Y _y, vec<1, Z, Q> const& _z, vec<1, W, Q> const& _w);
template<typename X, typename Y, typename Z, typename W>
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<1, X, Q> const& _x, Y _y, vec<1, Z, Q> const& _z, vec<1, W, Q> const& _w);
template<typename X, typename Y, typename Z, typename W>
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(X _x, vec<1, Y, Q> const& _y, vec<1, Z, Q> const& _z, vec<1, W, Q> const& _w);
template<typename X, typename Y, typename Z, typename W>
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<1, X, Q> const& _x, vec<1, Y, Q> const& _Y, vec<1, Z, Q> const& _z, vec<1, W, Q> const& _w);
// -- Conversion vector constructors --

View File

@ -194,6 +194,15 @@ namespace detail
// -- Conversion scalar constructors --
template<typename T, qualifier Q>
template<typename U, qualifier P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR vec<4, T, Q>::vec(vec<1, U, P> const& v)
: x(static_cast<T>(v.x))
, y(static_cast<T>(v.x))
, z(static_cast<T>(v.x))
, w(static_cast<T>(v.x))
{}
template<typename T, qualifier Q>
template<typename X, typename Y, typename Z, typename W>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD vec<4, T, Q>::vec(X _x, Y _y, Z _z, W _w)
@ -203,6 +212,123 @@ namespace detail
, w(static_cast<T>(_w))
{}
template<typename T, qualifier Q>
template<typename X, typename Y, typename Z, typename W>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR vec<4, T, Q>::vec(vec<1, X, Q> const& _x, Y _y, Z _z, W _w)
: x(static_cast<T>(_x.x))
, y(static_cast<T>(_y))
, z(static_cast<T>(_z))
, w(static_cast<T>(_w))
{}
template<typename T, qualifier Q>
template<typename X, typename Y, typename Z, typename W>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR vec<4, T, Q>::vec(X _x, vec<1, Y, Q> const& _y, Z _z, W _w)
: x(static_cast<T>(_x))
, y(static_cast<T>(_y.x))
, z(static_cast<T>(_z))
, w(static_cast<T>(_w))
{}
template<typename T, qualifier Q>
template<typename X, typename Y, typename Z, typename W>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR vec<4, T, Q>::vec(vec<1, X, Q> const& _x, vec<1, Y, Q> const& _y, Z _z, W _w)
: x(static_cast<T>(_x.x))
, y(static_cast<T>(_y.x))
, z(static_cast<T>(_z))
, w(static_cast<T>(_w))
{}
template<typename T, qualifier Q>
template<typename X, typename Y, typename Z, typename W>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR vec<4, T, Q>::vec(X _x, Y _y, vec<1, Z, Q> const& _z, W _w)
: x(static_cast<T>(_x))
, y(static_cast<T>(_y))
, z(static_cast<T>(_z.x))
, w(static_cast<T>(_w))
{}
template<typename T, qualifier Q>
template<typename X, typename Y, typename Z, typename W>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR vec<4, T, Q>::vec(vec<1, X, Q> const& _x, Y _y, vec<1, Z, Q> const& _z, W _w)
: x(static_cast<T>(_x.x))
, y(static_cast<T>(_y))
, z(static_cast<T>(_z.x))
, w(static_cast<T>(_w))
{}
template<typename T, qualifier Q>
template<typename X, typename Y, typename Z, typename W>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR vec<4, T, Q>::vec(X _x, vec<1, Y, Q> const& _y, vec<1, Z, Q> const& _z, W _w)
: x(static_cast<T>(_x))
, y(static_cast<T>(_y.x))
, z(static_cast<T>(_z.x))
, w(static_cast<T>(_w))
{}
template<typename T, qualifier Q>
template<typename X, typename Y, typename Z, typename W>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR vec<4, T, Q>::vec(vec<1, X, Q> const& _x, vec<1, Y, Q> const& _y, vec<1, Z, Q> const& _z, W _w)
: x(static_cast<T>(_x.x))
, y(static_cast<T>(_y.x))
, z(static_cast<T>(_z.x))
, w(static_cast<T>(_w))
{}
template<typename T, qualifier Q>
template<typename X, typename Y, typename Z, typename W>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR vec<4, T, Q>::vec(vec<1, X, Q> const& _x, Y _y, Z _z, vec<1, W, Q> const& _w)
: x(static_cast<T>(_x.x))
, y(static_cast<T>(_y))
, z(static_cast<T>(_z))
, w(static_cast<T>(_w.x))
{}
template<typename T, qualifier Q>
template<typename X, typename Y, typename Z, typename W>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR vec<4, T, Q>::vec(X _x, vec<1, Y, Q> const& _y, Z _z, vec<1, W, Q> const& _w)
: x(static_cast<T>(_x))
, y(static_cast<T>(_y.x))
, z(static_cast<T>(_z))
, w(static_cast<T>(_w.x))
{}
template<typename T, qualifier Q>
template<typename X, typename Y, typename Z, typename W>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR vec<4, T, Q>::vec(vec<1, X, Q> const& _x, vec<1, Y, Q> const& _y, Z _z, vec<1, W, Q> const& _w)
: x(static_cast<T>(_x.x))
, y(static_cast<T>(_y.x))
, z(static_cast<T>(_z))
, w(static_cast<T>(_w.x))
{}
template<typename T, qualifier Q>
template<typename X, typename Y, typename Z, typename W>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR vec<4, T, Q>::vec(X _x, Y _y, vec<1, Z, Q> const& _z, vec<1, W, Q> const& _w)
: x(static_cast<T>(_x))
, y(static_cast<T>(_y))
, z(static_cast<T>(_z.x))
, w(static_cast<T>(_w.x))
{}
template<typename T, qualifier Q>
template<typename X, typename Y, typename Z, typename W>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR vec<4, T, Q>::vec(vec<1, X, Q> const& _x, Y _y, vec<1, Z, Q> const& _z, vec<1, W, Q> const& _w)
: x(static_cast<T>(_x.x))
, y(static_cast<T>(_y))
, z(static_cast<T>(_z.x))
, w(static_cast<T>(_w.x))
{}
template<typename T, qualifier Q>
template<typename X, typename Y, typename Z, typename W>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR vec<4, T, Q>::vec(X _x, vec<1, Y, Q> const& _y, vec<1, Z, Q> const& _z, vec<1, W, Q> const& _w)
: x(static_cast<T>(_x))
, y(static_cast<T>(_y.x))
, z(static_cast<T>(_z.x))
, w(static_cast<T>(_w.x))
{}
template<typename T, qualifier Q>
template<typename X, typename Y, typename Z, typename W>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR vec<4, T, Q>::vec(vec<1, X, Q> const& _x, vec<1, Y, Q> const& _y, vec<1, Z, Q> const& _z, vec<1, W, Q> const& _w)

View File

@ -1,6 +1,7 @@
#define GLM_FORCE_ALIGNED
#define GLM_FORCE_SWIZZLE
#include <glm/gtc/epsilon.hpp>
#include <glm/ext/vec1.hpp>
#include <glm/vector_relational.hpp>
#include <glm/vec2.hpp>
#include <glm/vec3.hpp>
@ -136,7 +137,121 @@ static int test_vec4_ctor()
for(std::size_t i = 0; i < Tests.size(); ++i)
Error += Tests[i] == glm::vec4(1, 2, 3, 4) ? 0 : 1;
}
{
glm::vec1 const R(1.0f);
glm::vec1 const S(2.0f);
glm::vec1 const T(3.0f);
glm::vec1 const U(4.0f);
glm::vec4 const O(1.0f, 2.0f, 3.0f, 4.0f);
glm::vec4 const A(R);
glm::vec4 const B(1.0f);
Error += glm::all(glm::equal(A, B)) ? 0 : 1;
glm::vec4 const C(R, S, T, U);
Error += glm::all(glm::equal(C, O)) ? 0 : 1;
glm::vec4 const D(R, 2.0f, 3.0f, 4.0f);
Error += glm::all(glm::equal(D, O)) ? 0 : 1;
glm::vec4 const E(1.0f, S, 3.0f, 4.0f);
Error += glm::all(glm::equal(E, O)) ? 0 : 1;
glm::vec4 const F(R, S, 3.0f, 4.0f);
Error += glm::all(glm::equal(F, O)) ? 0 : 1;
glm::vec4 const G(1.0f, 2.0f, T, 4.0f);
Error += glm::all(glm::equal(G, O)) ? 0 : 1;
glm::vec4 const H(R, 2.0f, T, 4.0f);
Error += glm::all(glm::equal(H, O)) ? 0 : 1;
glm::vec4 const I(1.0f, S, T, 4.0f);
Error += glm::all(glm::equal(I, O)) ? 0 : 1;
glm::vec4 const J(R, S, T, 4.0f);
Error += glm::all(glm::equal(J, O)) ? 0 : 1;
glm::vec4 const K(R, 2.0f, 3.0f, U);
Error += glm::all(glm::equal(K, O)) ? 0 : 1;
glm::vec4 const L(1.0f, S, 3.0f, U);
Error += glm::all(glm::equal(L, O)) ? 0 : 1;
glm::vec4 const M(R, S, 3.0f, U);
Error += glm::all(glm::equal(M, O)) ? 0 : 1;
glm::vec4 const N(1.0f, 2.0f, T, U);
Error += glm::all(glm::equal(N, O)) ? 0 : 1;
glm::vec4 const P(R, 2.0f, T, U);
Error += glm::all(glm::equal(P, O)) ? 0 : 1;
glm::vec4 const Q(1.0f, S, T, U);
Error += glm::all(glm::equal(Q, O)) ? 0 : 1;
glm::vec4 const V(R, S, T, U);
Error += glm::all(glm::equal(V, O)) ? 0 : 1;
}
{
glm::vec1 const R(1.0f);
glm::dvec1 const S(2.0f);
glm::vec1 const T(3.0);
glm::dvec1 const U(4.0);
glm::vec4 const O(1.0f, 2.0, 3.0f, 4.0);
glm::vec4 const A(R);
glm::vec4 const B(1.0);
Error += glm::all(glm::equal(A, B)) ? 0 : 1;
glm::vec4 const C(R, S, T, U);
Error += glm::all(glm::equal(C, O)) ? 0 : 1;
glm::vec4 const D(R, 2.0f, 3.0, 4.0f);
Error += glm::all(glm::equal(D, O)) ? 0 : 1;
glm::vec4 const E(1.0, S, 3.0f, 4.0);
Error += glm::all(glm::equal(E, O)) ? 0 : 1;
glm::vec4 const F(R, S, 3.0, 4.0f);
Error += glm::all(glm::equal(F, O)) ? 0 : 1;
glm::vec4 const G(1.0f, 2.0, T, 4.0);
Error += glm::all(glm::equal(G, O)) ? 0 : 1;
glm::vec4 const H(R, 2.0, T, 4.0);
Error += glm::all(glm::equal(H, O)) ? 0 : 1;
glm::vec4 const I(1.0, S, T, 4.0f);
Error += glm::all(glm::equal(I, O)) ? 0 : 1;
glm::vec4 const J(R, S, T, 4.0f);
Error += glm::all(glm::equal(J, O)) ? 0 : 1;
glm::vec4 const K(R, 2.0f, 3.0, U);
Error += glm::all(glm::equal(K, O)) ? 0 : 1;
glm::vec4 const L(1.0f, S, 3.0, U);
Error += glm::all(glm::equal(L, O)) ? 0 : 1;
glm::vec4 const M(R, S, 3.0, U);
Error += glm::all(glm::equal(M, O)) ? 0 : 1;
glm::vec4 const N(1.0f, 2.0, T, U);
Error += glm::all(glm::equal(N, O)) ? 0 : 1;
glm::vec4 const P(R, 2.0, T, U);
Error += glm::all(glm::equal(P, O)) ? 0 : 1;
glm::vec4 const Q(1.0f, S, T, U);
Error += glm::all(glm::equal(Q, O)) ? 0 : 1;
glm::vec4 const V(R, S, T, U);
Error += glm::all(glm::equal(V, O)) ? 0 : 1;
}
return Error;
}