Added vec1 based constructors to vec2 zith tests and started vec3

This commit is contained in:
Groove 2018-07-05 15:21:34 +02:00
parent 0d973b40a4
commit 97ad14cf82
5 changed files with 104 additions and 0 deletions

View File

@ -94,6 +94,7 @@ namespace glm
// -- Explicit basic constructors -- // -- Explicit basic constructors --
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR explicit vec(T scalar); GLM_FUNC_DECL GLM_CONSTEXPR_CTOR explicit vec(T scalar);
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR explicit vec(vec<1, T, P> const& v);
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(T x, T y); GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(T x, T y);
// -- Conversion constructors -- // -- Conversion constructors --
@ -102,6 +103,10 @@ namespace glm
template<typename A, typename B> template<typename A, typename B>
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(A x, B y); GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(A x, B y);
template<typename A, typename B> template<typename A, typename B>
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<1, A, Q> const& x, B y);
template<typename A, typename B>
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(A x, vec<1, B, Q> const& y);
template<typename A, typename B>
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<1, A, Q> const& x, vec<1, B, Q> const& y); GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<1, A, Q> const& x, vec<1, B, Q> const& y);
// -- Conversion vector constructors -- // -- Conversion vector constructors --

View File

@ -34,6 +34,11 @@ namespace glm
: x(scalar), y(scalar) : x(scalar), y(scalar)
{} {}
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR vec<2, T, Q>::vec(vec<1, T, P> const& v)
: x(v.x), y(v.x)
{}
template<typename T, qualifier Q> template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR vec<2, T, Q>::vec(T _x, T _y) GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR vec<2, T, Q>::vec(T _x, T _y)
: x(_x), y(_y) : x(_x), y(_y)
@ -48,6 +53,20 @@ namespace glm
, y(static_cast<T>(_y)) , y(static_cast<T>(_y))
{} {}
template<typename T, qualifier Q>
template<typename A, typename B>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR vec<2, T, Q>::vec(vec<1, A, Q> const& _x, B _y)
: x(static_cast<T>(_x.x))
, y(static_cast<T>(_y))
{}
template<typename T, qualifier Q>
template<typename A, typename B>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR vec<2, T, Q>::vec(A _x, vec<1, B, Q> const& _y)
: x(static_cast<T>(_x))
, y(static_cast<T>(_y.x))
{}
template<typename T, qualifier Q> template<typename T, qualifier Q>
template<typename A, typename B> template<typename A, typename B>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR vec<2, T, Q>::vec(vec<1, A, Q> const& _x, vec<1, B, Q> const& _y) GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR vec<2, T, Q>::vec(vec<1, A, Q> const& _x, vec<1, B, Q> const& _y)

View File

@ -102,6 +102,18 @@ namespace glm
template<typename X, typename Y, typename Z> template<typename X, typename Y, typename Z>
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(X x, Y y, Z z); GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(X x, Y y, Z z);
template<typename X, typename Y, typename Z> template<typename X, typename Y, typename Z>
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<1, X, Q> const& _x, Y _y, Z _z);
template<typename X, typename Y, typename Z>
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(X _x, vec<1, Y, Q> const& _y, Z _z);
template<typename X, typename Y, typename Z>
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<1, X, Q> const& _x, vec<1, Y, Q> const& _y, Z _z);
template<typename X, typename Y, typename Z>
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(X _x, Y _y, vec<1, Z, Q> const& _z);
template<typename X, typename Y, typename Z>
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(vec<1, X, Q> const& _x, Y _y, vec<1, Z, Q> const& _z);
template<typename X, typename Y, typename Z>
GLM_FUNC_DECL GLM_CONSTEXPR_CTOR vec(X _x, vec<1, Y, Q> const& _y, vec<1, Z, Q> const& _z);
template<typename X, typename Y, typename Z>
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); 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);
// -- Conversion vector constructors -- // -- Conversion vector constructors --

View File

@ -49,6 +49,54 @@ namespace glm
, z(static_cast<T>(_z)) , z(static_cast<T>(_z))
{} {}
template<typename T, qualifier Q>
template<typename X, typename Y, typename Z>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR vec<3, T, Q>::vec(vec<1, X, Q> const& _x, Y _y, Z _z)
: x(static_cast<T>(_x))
, y(static_cast<T>(_y))
, z(static_cast<T>(_z))
{}
template<typename T, qualifier Q>
template<typename X, typename Y, typename Z>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR vec<3, T, Q>::vec(X _x, vec<1, Y, Q> const& _y, Z _z)
: x(static_cast<T>(_x))
, y(static_cast<T>(_y))
, z(static_cast<T>(_z))
{}
template<typename T, qualifier Q>
template<typename X, typename Y, typename Z>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR vec<3, T, Q>::vec(vec<1, X, Q> const& _x, vec<1, Y, Q> const& _y, Z _z)
: x(static_cast<T>(_x))
, y(static_cast<T>(_y))
, z(static_cast<T>(_z))
{}
template<typename T, qualifier Q>
template<typename X, typename Y, typename Z>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR vec<3, T, Q>::vec(X _x, Y _y, vec<1, Z, Q> const& _z)
: x(static_cast<T>(_x))
, y(static_cast<T>(_y))
, z(static_cast<T>(_z))
{}
template<typename T, qualifier Q>
template<typename X, typename Y, typename Z>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR vec<3, T, Q>::vec(vec<1, X, Q> const& _x, Y _y, vec<1, Z, Q> const& _z)
: x(static_cast<T>(_x))
, y(static_cast<T>(_y))
, z(static_cast<T>(_z))
{}
template<typename T, qualifier Q>
template<typename X, typename Y, typename Z>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR vec<3, T, Q>::vec(X _x, vec<1, Y, Q> const& _y, vec<1, Z, Q> const& _z)
: x(static_cast<T>(_x))
, y(static_cast<T>(_y))
, z(static_cast<T>(_z))
{}
template<typename T, qualifier Q> template<typename T, qualifier Q>
template<typename X, typename Y, typename Z> template<typename X, typename Y, typename Z>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR vec<3, T, Q>::vec(vec<1, X, Q> const& _x, vec<1, Y, Q> const& _y, vec<1, Z, Q> const& _z) GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR vec<3, T, Q>::vec(vec<1, X, Q> const& _x, vec<1, Y, Q> const& _y, vec<1, Z, Q> const& _z)

View File

@ -2,6 +2,7 @@
#include <glm/gtc/epsilon.hpp> #include <glm/gtc/epsilon.hpp>
#include <glm/vector_relational.hpp> #include <glm/vector_relational.hpp>
#include <glm/vec2.hpp> #include <glm/vec2.hpp>
#include <glm/ext/vec1.hpp>
#include <vector> #include <vector>
#if GLM_HAS_TRIVIAL_QUERIES #if GLM_HAS_TRIVIAL_QUERIES
# include <type_traits> # include <type_traits>
@ -257,6 +258,25 @@ int test_vec2_ctor()
glm::vec2 F(glm::ivec2(2)); glm::vec2 F(glm::ivec2(2));
} }
{
glm::vec1 const R(1.0f);
glm::vec1 const S(2.0f);
glm::vec2 const O(1.0f, 2.0f);
glm::vec2 const A(R);
glm::vec2 const B(1.0f);
Error += glm::all(glm::equal(A, B)) ? 0 : 1;
glm::vec2 const C(R, S);
Error += glm::all(glm::equal(C, O)) ? 0 : 1;
glm::vec2 const D(R, 2.0f);
Error += glm::all(glm::equal(D, O)) ? 0 : 1;
glm::vec2 const E(1.0f, S);
Error += glm::all(glm::equal(E, O)) ? 0 : 1;
}
return Error; return Error;
} }