Add templated conversions from smaller vector types to larger ones

This commit is contained in:
Jesse Talavera-Greenberg 2016-03-06 19:42:35 -05:00
parent 185e9e257b
commit 7ed3456ca3
4 changed files with 37 additions and 0 deletions

View File

@ -161,6 +161,10 @@ namespace glm
template <typename U, precision Q>
GLM_FUNC_DECL GLM_EXPLICIT tvec3(tvec3<U, Q> const & v);
/// Other explicit conversions
template <typename U, precision Q>
GLM_FUNC_DECL GLM_EXPLICIT tvec3(tvec2<U, Q> const & v);
// -- Swizzle constructors --
# if GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)

View File

@ -166,6 +166,14 @@ namespace glm
z(static_cast<T>(v.z))
{}
template <typename T, precision P>
template <typename U, precision Q>
GLM_FUNC_QUALIFIER tvec3<T, P>::tvec3(tvec2<U, Q> const & v) :
x(static_cast<T>(v.x)),
y(static_cast<T>(v.y)),
z(static_cast<T>(0))
{}
// -- Component accesses --
# ifdef GLM_FORCE_SIZE_FUNC

View File

@ -244,6 +244,13 @@ namespace detail
template <typename U, precision Q>
GLM_FUNC_DECL GLM_EXPLICIT tvec4(tvec4<U, Q> const & v);
/// Other explicit conversions
template <typename U, precision Q>
GLM_FUNC_DECL GLM_EXPLICIT tvec4(tvec2<U, Q> const & v);
template <typename U, precision Q>
GLM_FUNC_DECL GLM_EXPLICIT tvec4(tvec3<U, Q> const & v);
// -- Swizzle constructors --
# if GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE)

View File

@ -268,6 +268,24 @@ namespace glm
w(static_cast<T>(v.w))
{}
template <typename T, precision P>
template <typename U, precision Q>
GLM_FUNC_QUALIFIER tvec4<T, P>::tvec4(tvec2<U, Q> const & v) :
x(static_cast<T>(v.x)),
y(static_cast<T>(v.y)),
z(static_cast<T>(0)),
w(static_cast<T>(0))
{}
template <typename T, precision P>
template <typename U, precision Q>
GLM_FUNC_QUALIFIER tvec4<T, P>::tvec4(tvec3<U, Q> const & v) :
x(static_cast<T>(v.x)),
y(static_cast<T>(v.y)),
z(static_cast<T>(v.z)),
w(static_cast<T>(0))
{}
// -- Component accesses --
# ifdef GLM_FORCE_SIZE_FUNC