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.
This commit is contained in:
Dave Reid 2012-12-22 13:16:37 +10:00
parent ac59f0e4c5
commit 1af1bea837
2 changed files with 38 additions and 0 deletions

View File

@ -244,6 +244,24 @@ namespace detail
GLM_FUNC_DECL tvec4<T> swizzle(comp X, comp Y, comp Z, comp W) const; GLM_FUNC_DECL tvec4<T> swizzle(comp X, comp Y, comp Z, comp W) const;
GLM_FUNC_DECL tref2<T> swizzle(comp X, comp Y); GLM_FUNC_DECL tref2<T> swizzle(comp X, comp Y);
GLM_FUNC_DECL tref3<T> swizzle(comp X, comp Y, comp Z); GLM_FUNC_DECL tref3<T> swizzle(comp X, comp Y, comp Z);
//////////////////////////////////////
// Static constants
static const tvec3<T> xpos;
static const tvec3<T> xneg;
static const tvec3<T> ypos;
static const tvec3<T> yneg;
static const tvec3<T> zpos;
static const tvec3<T> zneg;
static const tvec3<T> right;
static const tvec3<T> left;
static const tvec3<T> up;
static const tvec3<T> down;
static const tvec3<T> backward;
static const tvec3<T> forward;
}; };
template <typename T> template <typename T>

View File

@ -1148,5 +1148,25 @@ namespace detail
return tvec3<T>(this->x, this->y, this->z); return tvec3<T>(this->x, this->y, this->z);
} }
//////////////////////////////////////
// Static constants
template <typename T> const tvec3<T> tvec3<T>::xpos = tvec3<T>(T( 1), T( 0), T (0));
template <typename T> const tvec3<T> tvec3<T>::xneg = tvec3<T>(T(-1), T( 0), T( 0));
template <typename T> const tvec3<T> tvec3<T>::ypos = tvec3<T>(T( 0), T( 1), T( 0));
template <typename T> const tvec3<T> tvec3<T>::yneg = tvec3<T>(T( 0), T(-1), T( 0));
template <typename T> const tvec3<T> tvec3<T>::zpos = tvec3<T>(T( 0), T( 0), T( 1));
template <typename T> const tvec3<T> tvec3<T>::zneg = tvec3<T>(T( 0), T( 0), T(-1));
template <typename T> const tvec3<T> tvec3<T>::right = tvec3<T>(T( 1), T( 0), T( 0));
template <typename T> const tvec3<T> tvec3<T>::left = tvec3<T>(T(-1), T( 0), T( 0));
template <typename T> const tvec3<T> tvec3<T>::up = tvec3<T>(T( 0), T( 1), T( 0));
template <typename T> const tvec3<T> tvec3<T>::down = tvec3<T>(T( 0), T(-1), T( 0));
template <typename T> const tvec3<T> tvec3<T>::backward = tvec3<T>(T( 0), T( 0), T( 1));
template <typename T> const tvec3<T> tvec3<T>::forward = tvec3<T>(T( 0), T( 0), T(-1));
}//namespace detail }//namespace detail
}//namespace glm }//namespace glm