diff --git a/glm/core/type_vec3.hpp b/glm/core/type_vec3.hpp index 95626cb8..43cdcf40 100644 --- a/glm/core/type_vec3.hpp +++ b/glm/core/type_vec3.hpp @@ -158,6 +158,18 @@ namespace detail *this = that(); } + template + GLM_FUNC_DECL tvec3(glm::detail::swizzle<2, T, tvec2, E0, E1, -1, -2> const & v, T const & s) + { + *this = tvec3(v(), s); + } + + template + GLM_FUNC_DECL tvec3(T const & s, glm::detail::swizzle<2, T, tvec2, E0, E1, -1, -2> const & v) + { + *this = tvec3(s, v()); + } + ////////////////////////////////////// // Unary arithmetic operators diff --git a/glm/core/type_vec4.hpp b/glm/core/type_vec4.hpp index 9b47383d..8c343aa0 100644 --- a/glm/core/type_vec4.hpp +++ b/glm/core/type_vec4.hpp @@ -159,6 +159,42 @@ namespace detail *this = that(); } + template + GLM_FUNC_DECL tvec4(glm::detail::swizzle<2, T, tvec2, E0, E1, -1, -2> const & v, glm::detail::swizzle<2, T, tvec2, F0, F1, -1, -2> const & u) + { + *this = tvec4(v(), u()); + } + + template + GLM_FUNC_DECL tvec4(T const & x, T const & y, glm::detail::swizzle<2, T, tvec2, E0, E1, -1, -2> const & v) + { + *this = tvec4(x, y, v()); + } + + template + GLM_FUNC_DECL tvec4(T const & x, glm::detail::swizzle<2, T, tvec2, E0, E1, -1, -2> const & v, T const & w) + { + *this = tvec4(x, v(), w); + } + + template + GLM_FUNC_DECL tvec4(glm::detail::swizzle<2, T, tvec2, E0, E1, -1, -2> const & v, T const & z, T const & w) + { + *this = tvec4(v(), z, w); + } + + template + GLM_FUNC_DECL tvec4(glm::detail::swizzle<3, T, tvec3, E0, E1, E2, -1> const & v, T const & w) + { + *this = tvec4(v(), w); + } + + template + GLM_FUNC_DECL tvec4(T const & x, glm::detail::swizzle<3, T, tvec3, E0, E1, E2, -1> const & v) + { + *this = tvec4(x, v()); + } + ////////////////////////////////////// // Swizzle constructors diff --git a/test/core/core_type_vec3.cpp b/test/core/core_type_vec3.cpp index 2afe97d4..b872b40a 100644 --- a/test/core/core_type_vec3.cpp +++ b/test/core/core_type_vec3.cpp @@ -391,19 +391,16 @@ int test_vec3_swizzle_partial() { glm::vec3 B(A.xy, 3.0f); - Error += A == B ? 0 : 1; } { glm::vec3 B(1.0f, A.yz); - Error += A == B ? 0 : 1; } { glm::vec3 B(A.xyz); - Error += A == B ? 0 : 1; } diff --git a/test/core/core_type_vec4.cpp b/test/core/core_type_vec4.cpp index 99410fa0..8078c473 100644 --- a/test/core/core_type_vec4.cpp +++ b/test/core/core_type_vec4.cpp @@ -213,6 +213,41 @@ int test_vec4_size() return Error; } +int test_vec4_swizzle_partial() +{ + int Error = 0; + + glm::vec4 A(1, 2, 3, 4); + + { + glm::vec4 B(A.xy, A.zw); + Error += A == B ? 0 : 1; + } + { + glm::vec4 B(A.xy, 3.0f, 4.0f); + Error += A == B ? 0 : 1; + } + { + glm::vec4 B(1.0f, A.yz, 4.0f); + Error += A == B ? 0 : 1; + } + { + glm::vec4 B(1.0f, 2.0f, A.zw); + Error += A == B ? 0 : 1; + } + + { + glm::vec4 B(A.xyz, 4.0f); + Error += A == B ? 0 : 1; + } + { + glm::vec4 B(1.0f, A.yzw); + Error += A == B ? 0 : 1; + } + + return Error; +} + int main() { //__m128 DataA = swizzle(glm::vec4(1.0f, 2.0f, 3.0f, 4.0f)); @@ -223,6 +258,7 @@ int main() Error += test_vec4_size(); Error += test_vec4_operators(); Error += test_hvec4(); + Error += test_vec4_swizzle_partial(); return Error; }