From 1af1bea83707112e80c12d9733aaf37be94246be Mon Sep 17 00:00:00 2001 From: Dave Reid Date: Sat, 22 Dec 2012 13:16:37 +1000 Subject: [PATCH] Add static xpos, xneg, ypos, etc constants to tvec3 as requested in issue #21. I've also included corresponding right, left, up, down, backward and forward constants. The z coordinate for 'forward' is set to -1, as one would expect with OpenGL. --- glm/core/type_vec3.hpp | 18 ++++++++++++++++++ glm/core/type_vec3.inl | 20 ++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/glm/core/type_vec3.hpp b/glm/core/type_vec3.hpp index fa6e357c..8e38b6b4 100644 --- a/glm/core/type_vec3.hpp +++ b/glm/core/type_vec3.hpp @@ -244,6 +244,24 @@ namespace detail GLM_FUNC_DECL tvec4 swizzle(comp X, comp Y, comp Z, comp W) const; GLM_FUNC_DECL tref2 swizzle(comp X, comp Y); GLM_FUNC_DECL tref3 swizzle(comp X, comp Y, comp Z); + + + ////////////////////////////////////// + // Static constants + + static const tvec3 xpos; + static const tvec3 xneg; + static const tvec3 ypos; + static const tvec3 yneg; + static const tvec3 zpos; + static const tvec3 zneg; + + static const tvec3 right; + static const tvec3 left; + static const tvec3 up; + static const tvec3 down; + static const tvec3 backward; + static const tvec3 forward; }; template diff --git a/glm/core/type_vec3.inl b/glm/core/type_vec3.inl index 566266a9..ed41f9ab 100644 --- a/glm/core/type_vec3.inl +++ b/glm/core/type_vec3.inl @@ -1148,5 +1148,25 @@ namespace detail return tvec3(this->x, this->y, this->z); } + + + ////////////////////////////////////// + // Static constants + + template const tvec3 tvec3::xpos = tvec3(T( 1), T( 0), T (0)); + template const tvec3 tvec3::xneg = tvec3(T(-1), T( 0), T( 0)); + template const tvec3 tvec3::ypos = tvec3(T( 0), T( 1), T( 0)); + template const tvec3 tvec3::yneg = tvec3(T( 0), T(-1), T( 0)); + template const tvec3 tvec3::zpos = tvec3(T( 0), T( 0), T( 1)); + template const tvec3 tvec3::zneg = tvec3(T( 0), T( 0), T(-1)); + + template const tvec3 tvec3::right = tvec3(T( 1), T( 0), T( 0)); + template const tvec3 tvec3::left = tvec3(T(-1), T( 0), T( 0)); + template const tvec3 tvec3::up = tvec3(T( 0), T( 1), T( 0)); + template const tvec3 tvec3::down = tvec3(T( 0), T(-1), T( 0)); + template const tvec3 tvec3::backward = tvec3(T( 0), T( 0), T( 1)); + template const tvec3 tvec3::forward = tvec3(T( 0), T( 0), T(-1)); + + }//namespace detail }//namespace glm