mirror of
https://github.com/g-truc/glm.git
synced 2024-11-16 06:44:35 +00:00
Add metaprogramming constructors to tvec3
- Tests, too
This commit is contained in:
parent
63a087a2e6
commit
c2b31a8831
@ -150,6 +150,15 @@ namespace glm
|
||||
template <typename U, precision Q>
|
||||
GLM_FUNC_DECL GLM_EXPLICIT tvec3(tvec3<U, Q> const & v);
|
||||
|
||||
/// Extra helper constructors for metaprogramming
|
||||
# ifdef GLM_META_PROG_HELPERS
|
||||
template <typename X, typename Y, typename Z, typename W>
|
||||
GLM_FUNC_DECL tvec3(X const& x, Y const& y, Z const& z, W const&);
|
||||
|
||||
template <typename X, typename Y>
|
||||
GLM_FUNC_DECL tvec3(X const& x, Y const& y);
|
||||
# endif
|
||||
|
||||
// -- Swizzle constructors --
|
||||
|
||||
# if GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)
|
||||
|
@ -140,6 +140,21 @@ namespace glm
|
||||
z(static_cast<T>(v.z))
|
||||
{}
|
||||
|
||||
// -- Metaprogramming helper constructors --
|
||||
# ifdef GLM_META_PROG_HELPERS
|
||||
template <typename T, precision P>
|
||||
template <typename X, typename Y, typename Z, typename W>
|
||||
GLM_FUNC_QUALIFIER tvec3<T, P>::tvec3(X const& x, Y const& y, Z const& z, W const&)
|
||||
: x(static_cast<T>(x)), y(static_cast<T>(y)), z(static_cast<T>(z))
|
||||
{}
|
||||
|
||||
template <typename T, precision P>
|
||||
template <typename X, typename Y>
|
||||
GLM_FUNC_QUALIFIER tvec3<T, P>::tvec3(X const& x, Y const& y)
|
||||
: x(static_cast<T>(x)), y(static_cast<T>(y)), z(static_cast<T>(0))
|
||||
{}
|
||||
# endif
|
||||
|
||||
// -- Component accesses --
|
||||
|
||||
# ifdef GLM_FORCE_SIZE_FUNC
|
||||
|
@ -45,6 +45,16 @@ int test_vec3_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# ifdef GLM_META_PROG_HELPERS
|
||||
{
|
||||
glm::vec3 a(1, 2, 0), b(1, 2, 0, 4), c(1, 2);
|
||||
|
||||
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::vec3>::value ? 0 : 1;
|
||||
// Error += std::is_trivially_copy_assignable<glm::vec3>::value ? 0 : 1;
|
||||
|
Loading…
Reference in New Issue
Block a user