Merge pull request #350 from JesseTG/jtg/template-convenience

Add static components and prec members to all vector and quat types #350
This commit is contained in:
Christophe Riccio 2015-07-18 23:49:29 +02:00
commit 47deb9709c
23 changed files with 482 additions and 294 deletions

View File

@ -54,6 +54,18 @@ namespace glm
template <typename U, precision Q>
friend tvec2<U, Q> operator/(tvec2<U, Q> const & v, tmat2x2<U, Q> const & m);
# if GLM_HAS_CONSTEXPR
static GLM_CONSTEXPR length_t components = 2;
static GLM_CONSTEXPR length_t cols = 2;
static GLM_CONSTEXPR length_t rows = 2;
static GLM_CONSTEXPR precision prec = P;
# else
static const length_t components = 2;
static const length_t cols = 2;
static const length_t rows = 2;
static const precision prec = P;
# endif
private:
/// @cond DETAIL
col_type value[2];

View File

@ -50,6 +50,18 @@ namespace glm
typedef tmat3x2<T, P> transpose_type;
typedef T value_type;
# if GLM_HAS_CONSTEXPR
static GLM_CONSTEXPR length_t components = 2;
static GLM_CONSTEXPR length_t cols = 3;
static GLM_CONSTEXPR length_t rows = 2;
static GLM_CONSTEXPR precision prec = P;
# else
static const length_t components = 2;
static const length_t cols = 3;
static const length_t rows = 2;
static const precision prec = P;
# endif
private:
/// @cond DETAIL
col_type value[2];

View File

@ -50,6 +50,18 @@ namespace glm
typedef tmat4x2<T, P> transpose_type;
typedef T value_type;
# if GLM_HAS_CONSTEXPR
static GLM_CONSTEXPR length_t components = 2;
static GLM_CONSTEXPR length_t cols = 4;
static GLM_CONSTEXPR length_t rows = 2;
static GLM_CONSTEXPR precision prec = P;
# else
static const length_t components = 2;
static const length_t cols = 4;
static const length_t rows = 2;
static const precision prec = P;
# endif
private:
/// @cond DETAIL
col_type value[2];

View File

@ -50,6 +50,18 @@ namespace glm
typedef tmat2x3<T, P> transpose_type;
typedef T value_type;
# if GLM_HAS_CONSTEXPR
static GLM_CONSTEXPR length_t components = 3;
static GLM_CONSTEXPR length_t cols = 2;
static GLM_CONSTEXPR length_t rows = 3;
static GLM_CONSTEXPR precision prec = P;
# else
static const length_t components = 3;
static const length_t cols = 2;
static const length_t rows = 3;
static const precision prec = P;
# endif
private:
/// @cond DETAIL
col_type value[3];

View File

@ -49,6 +49,18 @@ namespace glm
typedef tmat3x3<T, P> transpose_type;
typedef T value_type;
# if GLM_HAS_CONSTEXPR
static GLM_CONSTEXPR length_t components = 3;
static GLM_CONSTEXPR length_t cols = 3;
static GLM_CONSTEXPR length_t rows = 3;
static GLM_CONSTEXPR precision prec = P;
# else
static const length_t components = 3;
static const length_t cols = 3;
static const length_t rows = 3;
static const precision prec = P;
# endif
template <typename U, precision Q>
friend tvec3<U, Q> operator/(tmat3x3<U, Q> const & m, tvec3<U, Q> const & v);
template <typename U, precision Q>

View File

@ -50,6 +50,18 @@ namespace glm
typedef tmat4x3<T, P> transpose_type;
typedef T value_type;
# if GLM_HAS_CONSTEXPR
static GLM_CONSTEXPR length_t components = 3;
static GLM_CONSTEXPR length_t cols = 4;
static GLM_CONSTEXPR length_t rows = 3;
static GLM_CONSTEXPR precision prec = P;
# else
static const length_t components = 3;
static const length_t cols = 4;
static const length_t rows = 3;
static const precision prec = P;
# endif
private:
/// @cond DETAIL
col_type value[3];

View File

@ -50,6 +50,18 @@ namespace glm
typedef tmat2x4<T, P> transpose_type;
typedef T value_type;
# if GLM_HAS_CONSTEXPR
static GLM_CONSTEXPR length_t components = 4;
static GLM_CONSTEXPR length_t cols = 2;
static GLM_CONSTEXPR length_t rows = 4;
static GLM_CONSTEXPR precision prec = P;
# else
static const length_t components = 4;
static const length_t cols = 2;
static const length_t rows = 4;
static const precision prec = P;
# endif
private:
/// @cond DETAIL
col_type value[4];

View File

@ -50,6 +50,18 @@ namespace glm
typedef tmat3x4<T, P> transpose_type;
typedef T value_type;
# if GLM_HAS_CONSTEXPR
static GLM_CONSTEXPR length_t components = 4;
static GLM_CONSTEXPR length_t cols = 3;
static GLM_CONSTEXPR length_t rows = 4;
static GLM_CONSTEXPR precision prec = P;
# else
static const length_t components = 4;
static const length_t cols = 3;
static const length_t rows = 4;
static const precision prec = P;
# endif
private:
// Data
col_type value[4];

View File

@ -49,6 +49,18 @@ namespace glm
typedef tmat4x4<T, P> transpose_type;
typedef T value_type;
# if GLM_HAS_CONSTEXPR
static GLM_CONSTEXPR length_t components = 4;
static GLM_CONSTEXPR length_t cols = 4;
static GLM_CONSTEXPR length_t rows = 4;
static GLM_CONSTEXPR precision prec = P;
# else
static const length_t components = 4;
static const length_t cols = 4;
static const length_t rows = 4;
static const precision prec = P;
# endif
template <typename U, precision Q>
friend tvec4<U, Q> operator/(tmat4x4<U, Q> const & m, tvec4<U, Q> const & v);
template <typename U, precision Q>

View File

@ -54,7 +54,13 @@ namespace glm
typedef tvec1<T, P> type;
typedef tvec1<bool, P> bool_type;
typedef T value_type;
# if GLM_HAS_CONSTEXPR
static GLM_CONSTEXPR length_t components = 1;
static GLM_CONSTEXPR precision prec = P;
# else
static const length_t components = 1;
static const precision prec = P;
# endif
//////////////////////////////////////
// Data

View File

@ -54,6 +54,13 @@ namespace glm
typedef tvec2<T, P> type;
typedef tvec2<bool, P> bool_type;
typedef T value_type;
# if GLM_HAS_CONSTEXPR
static GLM_CONSTEXPR length_t components = 2;
static GLM_CONSTEXPR precision prec = P;
# else
static const length_t components = 2;
static const precision prec = P;
# endif
//////////////////////////////////////
// Data

View File

@ -54,6 +54,13 @@ namespace glm
typedef tvec3<T, P> type;
typedef tvec3<bool, P> bool_type;
typedef T value_type;
# if GLM_HAS_CONSTEXPR
static GLM_CONSTEXPR length_t components = 3;
static GLM_CONSTEXPR precision prec = P;
# else
static const length_t components = 3;
static const precision prec = P;
# endif
//////////////////////////////////////
// Data

View File

@ -108,6 +108,13 @@ namespace detail
typedef tvec4<T, P> type;
typedef tvec4<bool, P> bool_type;
typedef T value_type;
# if GLM_HAS_CONSTEXPR
static GLM_CONSTEXPR length_t components = 4;
static GLM_CONSTEXPR precision prec = P;
# else
static const length_t components = 4;
static const precision prec = P;
# endif
//////////////////////////////////////
// Data

View File

@ -64,6 +64,13 @@ namespace glm
{
typedef tquat<T, P> type;
typedef T value_type;
# if GLM_HAS_CONSTEXPR
static GLM_CONSTEXPR length_t components = 4;
static GLM_CONSTEXPR precision prec = P;
# else
static const length_t components = 4;
static const precision prec = P;
# endif
public:
T x, y, z, w;

View File

@ -63,6 +63,13 @@ namespace glm
{
typedef T value_type;
typedef glm::tquat<T, P> part_type;
# if GLM_HAS_CONSTEXPR
static GLM_CONSTEXPR length_t components = 8;
static GLM_CONSTEXPR precision prec = P;
# else
static const length_t components = 8;
static const precision prec = P;
# endif
public:
glm::tquat<T, P> real, dual;

View File

@ -71,6 +71,18 @@ namespace detail
typedef fmat4x4SIMD type;
typedef fmat4x4SIMD transpose_type;
# if GLM_HAS_CONSTEXPR
static GLM_CONSTEXPR length_t components = 4;
static GLM_CONSTEXPR length_t cols = 4;
static GLM_CONSTEXPR length_t rows = 4;
static GLM_CONSTEXPR precision prec = defaultp;
# else
static const length_t components = 4;
static const length_t cols = 4;
static const length_t rows = 4;
static const precision prec = defaultp;
# endif
GLM_FUNC_DECL length_t length() const;
fvec4SIMD Data[4];

View File

@ -75,6 +75,13 @@ namespace detail
typedef fquatSIMD type;
typedef tquat<bool, defaultp> bool_type;
# if GLM_HAS_CONSTEXPR
static GLM_CONSTEXPR length_t components = 4;
static GLM_CONSTEXPR precision prec = defaultp;
# else
static const length_t components = 4;
static const precision prec = defaultp;
# endif
#ifdef GLM_SIMD_ENABLE_XYZW_UNION
union

View File

@ -98,6 +98,13 @@ namespace detail
typedef fvec4SIMD type;
typedef tvec4<bool, highp> bool_type;
# if GLM_HAS_CONSTEXPR
static GLM_CONSTEXPR length_t components = 4;
static GLM_CONSTEXPR precision prec = defaultp;
# else
static const length_t components = 4;
static const precision prec = defaultp;
# endif
#ifdef GLM_SIMD_ENABLE_XYZW_UNION
union

View File

@ -131,6 +131,7 @@ int test_vec1_size()
Error += 8 == sizeof(glm::highp_dvec1) ? 0 : 1;
Error += glm::vec1().length() == 1 ? 0 : 1;
Error += glm::dvec1().length() == 1 ? 0 : 1;
Error += glm::vec1::components == 1 ? 0 : 1;
return Error;
}
@ -168,6 +169,7 @@ int main()
glm::vec1 v;
assert(v.length() == 1);
assert(glm::vec1::components == 1);
Error += test_vec1_size();
Error += test_vec1_ctor();

View File

@ -290,6 +290,7 @@ int test_vec2_size()
Error += 16 == sizeof(glm::highp_dvec2) ? 0 : 1;
Error += glm::vec2().length() == 2 ? 0 : 1;
Error += glm::dvec2().length() == 2 ? 0 : 1;
Error += glm::vec2::components == 2 ? 0 : 1;
return Error;
}
@ -327,6 +328,7 @@ int main()
glm::vec2 v;
assert(v.length() == 2);
assert(glm::vec2::components == 2);
Error += test_vec2_size();
Error += test_vec2_ctor();

View File

@ -263,7 +263,7 @@ int test_vec3_size()
Error += 24 == sizeof(glm::highp_dvec3) ? 0 : 1;
Error += glm::vec3().length() == 3 ? 0 : 1;
Error += glm::dvec3().length() == 3 ? 0 : 1;
Error += glm::vec3::components == 3 ? 0 : 1;
return Error;
}
@ -494,6 +494,10 @@ int main()
{
int Error = 0;
glm::vec3 v;
assert(v.length() == 3);
assert(glm::vec3::components == 3);
Error += test_vec3_ctor();
Error += test_vec3_operators();
Error += test_vec3_size();

View File

@ -446,9 +446,12 @@ int main()
{
int Error(0);
std::size_t const Size(1000000);
glm::vec4 v;
assert(v.length() == 4);
assert(glm::vec4::components == 4);
# ifdef NDEBUG
std::size_t const Size(1000000);
Error += test_vec4_perf_AoS(Size);
Error += test_vec4_perf_SoA(Size);
# endif//NDEBUG

View File

@ -324,6 +324,8 @@ int main()
{
int Error(0);
assert(glm::quat::components == 4);
Error += test_quat_ctr();
Error += test_quat_mul_vec();
Error += test_quat_two_axis_ctr();