From 8df8569563fefb233135c1e0069a95ae1fbddb0d Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Mon, 3 Oct 2011 12:39:56 +0100 Subject: [PATCH] Added () operator for swizzling --- glm/core/type_vec2.hpp | 6 ++++-- glm/core/type_vec2.inl | 6 ++++++ glm/core/type_vec3.hpp | 2 ++ glm/core/type_vec3.inl | 6 ++++++ glm/core/type_vec4.hpp | 2 ++ glm/core/type_vec4.inl | 6 ++++++ 6 files changed, 26 insertions(+), 2 deletions(-) diff --git a/glm/core/type_vec2.hpp b/glm/core/type_vec2.hpp index ae266e15..2cd87074 100644 --- a/glm/core/type_vec2.hpp +++ b/glm/core/type_vec2.hpp @@ -185,8 +185,10 @@ namespace detail GLM_FUNC_DECL tref2 & operator= (tref2 const & r); GLM_FUNC_DECL tref2 & operator= (tvec2 const & v); - T& x; - T& y; + GLM_FUNC_DECL tvec2 operator() (); + + T & x; + T & y; }; GLM_DETAIL_IS_VECTOR(tvec2); diff --git a/glm/core/type_vec2.inl b/glm/core/type_vec2.inl index 28f8edbe..d3278bf2 100644 --- a/glm/core/type_vec2.inl +++ b/glm/core/type_vec2.inl @@ -1006,5 +1006,11 @@ namespace detail return *this; } + template + GLM_FUNC_QUALIFIER tvec2 tref2::operator() () + { + return tvec2(this->x, this->y); + } + }//namespace detail }//namespace glm diff --git a/glm/core/type_vec3.hpp b/glm/core/type_vec3.hpp index 1b661ad8..2d8d2a29 100644 --- a/glm/core/type_vec3.hpp +++ b/glm/core/type_vec3.hpp @@ -198,6 +198,8 @@ namespace detail GLM_FUNC_DECL tref3 & operator= (tref3 const & r); GLM_FUNC_DECL tref3 & operator= (tvec3 const & v); + GLM_FUNC_DECL tvec3 operator() (); + T & x; T & y; T & z; diff --git a/glm/core/type_vec3.inl b/glm/core/type_vec3.inl index ab308c06..0a587f24 100644 --- a/glm/core/type_vec3.inl +++ b/glm/core/type_vec3.inl @@ -1129,5 +1129,11 @@ namespace detail return *this; } + template + GLM_FUNC_QUALIFIER tvec3 tref3::operator() () + { + return tvec3(this->x, this->y, this->z); + } + }//namespace detail }//namespace glm diff --git a/glm/core/type_vec4.hpp b/glm/core/type_vec4.hpp index 3fe2fa21..17b029a8 100644 --- a/glm/core/type_vec4.hpp +++ b/glm/core/type_vec4.hpp @@ -230,6 +230,8 @@ namespace detail GLM_FUNC_DECL tref4 & operator= (tref4 const & r); GLM_FUNC_DECL tref4 & operator= (tvec4 const & v); + GLM_FUNC_DECL tvec4 operator() (); + T & x; T & y; T & z; diff --git a/glm/core/type_vec4.inl b/glm/core/type_vec4.inl index 9e5d2eea..74ad1da7 100644 --- a/glm/core/type_vec4.inl +++ b/glm/core/type_vec4.inl @@ -1355,5 +1355,11 @@ namespace detail return *this; } + template + GLM_FUNC_QUALIFIER tvec4 tref4::operator() () + { + return tvec4(this->x, this->y, this->z, this->w); + } + }//namespace detail }//namespace glm