From 7ed3456ca32fdfe88f04307029741f850b934b74 Mon Sep 17 00:00:00 2001 From: Jesse Talavera-Greenberg Date: Sun, 6 Mar 2016 19:42:35 -0500 Subject: [PATCH] Add templated conversions from smaller vector types to larger ones --- glm/detail/type_vec3.hpp | 4 ++++ glm/detail/type_vec3.inl | 8 ++++++++ glm/detail/type_vec4.hpp | 7 +++++++ glm/detail/type_vec4.inl | 18 ++++++++++++++++++ 4 files changed, 37 insertions(+) diff --git a/glm/detail/type_vec3.hpp b/glm/detail/type_vec3.hpp index 72d32286..808b6da4 100644 --- a/glm/detail/type_vec3.hpp +++ b/glm/detail/type_vec3.hpp @@ -161,6 +161,10 @@ namespace glm template GLM_FUNC_DECL GLM_EXPLICIT tvec3(tvec3 const & v); + /// Other explicit conversions + template + GLM_FUNC_DECL GLM_EXPLICIT tvec3(tvec2 const & v); + // -- Swizzle constructors -- # if GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE) diff --git a/glm/detail/type_vec3.inl b/glm/detail/type_vec3.inl index 38104a3a..92ff3aff 100644 --- a/glm/detail/type_vec3.inl +++ b/glm/detail/type_vec3.inl @@ -166,6 +166,14 @@ namespace glm z(static_cast(v.z)) {} + template + template + GLM_FUNC_QUALIFIER tvec3::tvec3(tvec2 const & v) : + x(static_cast(v.x)), + y(static_cast(v.y)), + z(static_cast(0)) + {} + // -- Component accesses -- # ifdef GLM_FORCE_SIZE_FUNC diff --git a/glm/detail/type_vec4.hpp b/glm/detail/type_vec4.hpp index fe7235ac..396212a0 100644 --- a/glm/detail/type_vec4.hpp +++ b/glm/detail/type_vec4.hpp @@ -244,6 +244,13 @@ namespace detail template GLM_FUNC_DECL GLM_EXPLICIT tvec4(tvec4 const & v); + /// Other explicit conversions + template + GLM_FUNC_DECL GLM_EXPLICIT tvec4(tvec2 const & v); + + template + GLM_FUNC_DECL GLM_EXPLICIT tvec4(tvec3 const & v); + // -- Swizzle constructors -- # if GLM_HAS_ANONYMOUS_UNION && defined(GLM_SWIZZLE) diff --git a/glm/detail/type_vec4.inl b/glm/detail/type_vec4.inl index 6712ce33..0685dde2 100644 --- a/glm/detail/type_vec4.inl +++ b/glm/detail/type_vec4.inl @@ -268,6 +268,24 @@ namespace glm w(static_cast(v.w)) {} + template + template + GLM_FUNC_QUALIFIER tvec4::tvec4(tvec2 const & v) : + x(static_cast(v.x)), + y(static_cast(v.y)), + z(static_cast(0)), + w(static_cast(0)) + {} + + template + template + GLM_FUNC_QUALIFIER tvec4::tvec4(tvec3 const & v) : + x(static_cast(v.x)), + y(static_cast(v.y)), + z(static_cast(v.z)), + w(static_cast(0)) + {} + // -- Component accesses -- # ifdef GLM_FORCE_SIZE_FUNC