mirror of
https://github.com/g-truc/glm.git
synced 2024-11-15 22:34:35 +00:00
Add metaprogramming helper constructors for tvec4 and fvec4SIMD
- Tests, too - Also, removed a line from the simdVec4 test (there's no operator+, apparently)
This commit is contained in:
parent
c2b31a8831
commit
94eff6f642
@ -225,6 +225,11 @@ namespace detail
|
||||
template <typename U, precision Q>
|
||||
GLM_FUNC_DECL GLM_EXPLICIT tvec4(tvec4<U, Q> const & v);
|
||||
|
||||
# ifdef GLM_META_PROG_HELPERS
|
||||
template <typename X, typename Y, typename Z = Y>
|
||||
GLM_FUNC_DECL tvec4(X const& x, Y const& y, Z const& z = Z(0));
|
||||
# endif
|
||||
|
||||
// -- Swizzle constructors --
|
||||
|
||||
# if GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)
|
||||
|
@ -202,6 +202,14 @@ namespace glm
|
||||
w(static_cast<T>(v.w))
|
||||
{}
|
||||
|
||||
# ifdef GLM_META_PROG_HELPERS
|
||||
template <typename T, precision P>
|
||||
template <typename X, typename Y, typename Z>
|
||||
GLM_FUNC_QUALIFIER tvec4<T, P>::tvec4(X const& x, Y const& y, Z const& z)
|
||||
: x(static_cast<T>(x)), y(static_cast<T>(y)), z(static_cast<T>(z)), w(static_cast<T>(0))
|
||||
{}
|
||||
# endif
|
||||
|
||||
// -- Component accesses --
|
||||
|
||||
# ifdef GLM_FORCE_SIZE_FUNC
|
||||
|
@ -136,6 +136,11 @@ namespace detail
|
||||
explicit fvec4SIMD(
|
||||
vec4 const & v);
|
||||
|
||||
# ifdef GLM_META_PROG_HELPERS
|
||||
template <typename X, typename Y, typename Z = Y>
|
||||
GLM_FUNC_DECL fvec4SIMD(X const& x, Y const& y, Z const& z = Z(0));
|
||||
# endif
|
||||
|
||||
////////////////////////////////////////
|
||||
//// Conversion vector constructors
|
||||
|
||||
|
@ -89,6 +89,12 @@ GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(vec2 const & v1, vec2 const & v2) :
|
||||
Data(_mm_set_ps(v2.y, v2.x, v1.y, v1.x))
|
||||
{}
|
||||
|
||||
# ifdef GLM_META_PROG_HELPERS
|
||||
template <typename X, typename Y, typename Z>
|
||||
GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(X const& x, Y const& y, Z const& z)
|
||||
: fvec4SIMD(static_cast<float>(x), static_cast<float>(y), static_cast<float>(z), 0.0f)
|
||||
{}
|
||||
# endif
|
||||
//GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(ivec4SIMD const & v) :
|
||||
// Data(_mm_cvtepi32_ps(v.Data))
|
||||
//{}
|
||||
|
@ -73,6 +73,16 @@ int test_vec4_ctor()
|
||||
Error += glm::all(glm::equal(A, B)) ? 0 : 1;
|
||||
}
|
||||
|
||||
# ifdef GLM_META_PROG_HELPERS
|
||||
{
|
||||
glm::vec4 a(1, 2, 0, 0), b(1, 2), c(1, 2, 0);
|
||||
|
||||
Error += (a == b) ? 0 : 1;
|
||||
Error += (b == c) ? 0 : 1;
|
||||
Error += (a == c) ? 0 : 1;
|
||||
}
|
||||
# endif
|
||||
|
||||
# if GLM_HAS_TRIVIAL_QUERIES
|
||||
// Error += std::is_trivially_default_constructible<glm::vec4>::value ? 0 : 1;
|
||||
// Error += std::is_trivially_copy_assignable<glm::vec4>::value ? 0 : 1;
|
||||
|
@ -29,22 +29,32 @@
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define GLM_META_PROG_HELPERS
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtx/simd_vec4.hpp>
|
||||
#include <cstdio>
|
||||
|
||||
|
||||
#if(GLM_ARCH != GLM_ARCH_PURE)
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
#ifdef GLM_META_PROG_HELPERS
|
||||
assert(glm::simdVec4::components == glm::simdVec4::pure_type::components);
|
||||
{
|
||||
glm::simdVec4 a(1, 2, 0, 0), b(1, 2), c(1, 2, 0);
|
||||
|
||||
Error += (glm::vec4_cast(a) == glm::vec4_cast(b)) ? 0 : 1;
|
||||
Error += (glm::vec4_cast(b) == glm::vec4_cast(c)) ? 0 : 1;
|
||||
Error += (glm::vec4_cast(c) == glm::vec4_cast(a)) ? 0 : 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
glm::simdVec4 A1(0.0f, 0.1f, 0.2f, 0.3f);
|
||||
glm::simdVec4 B1(0.4f, 0.5f, 0.6f, 0.7f);
|
||||
glm::simdVec4 C1 = A1 + B1;
|
||||
//glm::simdVec4 C1 = A1 + B1;
|
||||
glm::simdVec4 D1 = A1.swizzle<glm::X, glm::Z, glm::Y, glm::W>();
|
||||
glm::simdVec4 E1(glm::vec4(1.0f));
|
||||
glm::vec4 F1 = glm::vec4_cast(E1);
|
||||
@ -61,7 +71,7 @@ int main()
|
||||
|
||||
glm::simdVec4 GNI(add0);
|
||||
|
||||
return 0;
|
||||
return Error;
|
||||
}
|
||||
|
||||
#else
|
||||
|
Loading…
Reference in New Issue
Block a user