- Added identity functions #765
This commit is contained in:
@@ -152,5 +152,45 @@ namespace detail
|
||||
typedef glm_u64vec4 type;
|
||||
};
|
||||
# endif
|
||||
|
||||
enum genTypeEnum
|
||||
{
|
||||
GENTYPE_VEC,
|
||||
GENTYPE_MAT,
|
||||
GENTYPE_QUAT
|
||||
};
|
||||
|
||||
template <typename genType>
|
||||
struct genTypeTrait
|
||||
{};
|
||||
|
||||
template <length_t C, length_t R, typename T>
|
||||
struct genTypeTrait<mat<C, R, T> >
|
||||
{
|
||||
static const genTypeEnum GENTYPE = GENTYPE_MAT;
|
||||
};
|
||||
|
||||
template<typename genType, genTypeEnum type>
|
||||
struct init_gentype
|
||||
{
|
||||
};
|
||||
|
||||
template<typename genType>
|
||||
struct init_gentype<genType, GENTYPE_QUAT>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static genType identity()
|
||||
{
|
||||
return genType(1, 0, 0, 0);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename genType>
|
||||
struct init_gentype<genType, GENTYPE_MAT>
|
||||
{
|
||||
GLM_FUNC_QUALIFIER static genType identity()
|
||||
{
|
||||
return genType(1);
|
||||
}
|
||||
};
|
||||
}//namespace detail
|
||||
}//namespace glm
|
||||
|
||||
@@ -36,6 +36,10 @@ namespace glm
|
||||
/// @addtogroup gtc_matrix_transform
|
||||
/// @{
|
||||
|
||||
/// Builds an identity matrix.
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL genType identity();
|
||||
|
||||
/// Builds a translation 4 * 4 matrix created from a vector of 3 components.
|
||||
///
|
||||
/// @param m Input matrix multiplied by this translation matrix.
|
||||
|
||||
@@ -7,6 +7,12 @@
|
||||
|
||||
namespace glm
|
||||
{
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER genType identity()
|
||||
{
|
||||
return detail::init_gentype<genType, detail::genTypeTrait<genType>::GENTYPE>::identity();
|
||||
}
|
||||
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER mat<4, 4, T, Q> translate(mat<4, 4, T, Q> const& m, vec<3, T, Q> const& v)
|
||||
{
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "../vec3.hpp"
|
||||
#include "../vec4.hpp"
|
||||
#include "../gtc/constants.hpp"
|
||||
#include "../gtc/matrix_transform.hpp"
|
||||
|
||||
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
|
||||
# pragma message("GLM: GLM_GTC_quaternion extension included")
|
||||
@@ -159,6 +160,10 @@ namespace glm
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL bool operator!=(tquat<T, Q> const& q1, tquat<T, Q> const& q2);
|
||||
|
||||
/// Builds an identity quaternion.
|
||||
template<typename genType>
|
||||
GLM_FUNC_DECL genType identity();
|
||||
|
||||
/// Returns the length of the quaternion.
|
||||
///
|
||||
/// @tparam T Floating-point scalar types.
|
||||
|
||||
@@ -10,6 +10,12 @@
|
||||
namespace glm{
|
||||
namespace detail
|
||||
{
|
||||
template <typename T>
|
||||
struct genTypeTrait<tquat<T> >
|
||||
{
|
||||
static const genTypeEnum GENTYPE = GENTYPE_QUAT;
|
||||
};
|
||||
|
||||
template<typename T, qualifier Q, bool Aligned>
|
||||
struct compute_dot<tquat<T, Q>, T, Aligned>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user