mirror of
https://github.com/g-truc/glm.git
synced 2024-11-22 17:04:35 +00:00
Improved vertor type check and fixed vertor relational tests
This commit is contained in:
parent
ba0d3bbaff
commit
ac7e851692
@ -250,16 +250,16 @@ namespace detail{
|
||||
};
|
||||
};
|
||||
|
||||
#define GLM_DETAIL_IS_VECTOR(T) \
|
||||
template <> \
|
||||
struct is_vector \
|
||||
{ \
|
||||
enum is_vector_enum \
|
||||
{ \
|
||||
_YES = 1, \
|
||||
_NO = 0 \
|
||||
}; \
|
||||
}
|
||||
# define GLM_DETAIL_IS_VECTOR(TYPE) \
|
||||
template <typename T> \
|
||||
struct is_vector<TYPE<T> > \
|
||||
{ \
|
||||
enum is_vector_enum \
|
||||
{ \
|
||||
_YES = 1, \
|
||||
_NO = 0 \
|
||||
}; \
|
||||
};
|
||||
|
||||
//////////////////
|
||||
// matrix
|
||||
|
@ -10,6 +10,8 @@
|
||||
#ifndef glm_core_func_vector_relational
|
||||
#define glm_core_func_vector_relational
|
||||
|
||||
#include "_detail.hpp"
|
||||
|
||||
namespace glm
|
||||
{
|
||||
namespace test{
|
||||
@ -31,10 +33,11 @@ namespace glm
|
||||
vecType<T> const & y
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(
|
||||
GLM_STATIC_ASSERT((
|
||||
detail::type<T>::is_float ||
|
||||
detail::type<T>::is_int ||
|
||||
detail::type<T>::is_uint, "'lessThan' only accept numbers");
|
||||
detail::type<T>::is_uint) && detail::is_vector<vecType<T> >::_YES,
|
||||
"'lessThan' only accept numbers");
|
||||
|
||||
typename vecType<bool>::bool_type Result(vecType<bool>::null);
|
||||
for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
|
||||
@ -51,10 +54,11 @@ namespace glm
|
||||
vecType<T> const & y
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(
|
||||
GLM_STATIC_ASSERT((
|
||||
detail::type<T>::is_float ||
|
||||
detail::type<T>::is_int ||
|
||||
detail::type<T>::is_uint, "'lessThanEqual' only accept numbers");
|
||||
detail::type<T>::is_uint) && detail::is_vector<vecType<T> >::_YES,
|
||||
"'lessThanEqual' only accept numbers");
|
||||
|
||||
typename vecType<bool>::bool_type Result(vecType<bool>::null);
|
||||
for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
|
||||
@ -71,10 +75,11 @@ namespace glm
|
||||
vecType<T> const & y
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(
|
||||
GLM_STATIC_ASSERT((
|
||||
detail::type<T>::is_float ||
|
||||
detail::type<T>::is_int ||
|
||||
detail::type<T>::is_uint, "'greaterThan' only accept numbers");
|
||||
detail::type<T>::is_uint) && detail::is_vector<vecType<T> >::_YES,
|
||||
"'greaterThan' only accept numbers");
|
||||
|
||||
typename vecType<bool>::bool_type Result(vecType<bool>::null);
|
||||
for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
|
||||
@ -91,10 +96,11 @@ namespace glm
|
||||
vecType<T> const & y
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(
|
||||
GLM_STATIC_ASSERT((
|
||||
detail::type<T>::is_float ||
|
||||
detail::type<T>::is_int ||
|
||||
detail::type<T>::is_uint, "'greaterThanEqual' only accept numbers");
|
||||
detail::type<T>::is_uint) && detail::is_vector<vecType<T> >::_YES,
|
||||
"'greaterThanEqual' only accept numbers");
|
||||
|
||||
typename vecType<bool>::bool_type Result(vecType<bool>::null);
|
||||
for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
|
||||
@ -111,11 +117,7 @@ namespace glm
|
||||
vecType<T> const & y
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(
|
||||
detail::type<T>::is_float ||
|
||||
detail::type<T>::is_int ||
|
||||
detail::type<T>::is_uint ||
|
||||
detail::type<T>::is_bool, "'equal' only accept GLM vectors");
|
||||
GLM_STATIC_ASSERT(detail::is_vector<vecType<T> >::_YES, "'equal' only accept GLM vectors");
|
||||
|
||||
typename vecType<bool>::bool_type Result(vecType<bool>::null);
|
||||
for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
|
||||
@ -132,11 +134,7 @@ namespace glm
|
||||
vecType<T> const & y
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(
|
||||
detail::type<T>::is_float ||
|
||||
detail::type<T>::is_int ||
|
||||
detail::type<T>::is_uint ||
|
||||
detail::type<T>::is_bool, "'notEqual' only accept GLM vectors");
|
||||
GLM_STATIC_ASSERT(detail::is_vector<vecType<T> >::_YES, "'notEqual' only accept GLM vectors");
|
||||
|
||||
typename vecType<bool>::bool_type Result(vecType<bool>::null);
|
||||
for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
|
||||
@ -149,8 +147,7 @@ namespace glm
|
||||
template <template <typename> class vecType>
|
||||
inline bool any(vecType<bool> const & v)
|
||||
{
|
||||
GLM_STATIC_ASSERT(
|
||||
vecType<bool>::is_bool, "'any' only accept GLM boolean vectors");
|
||||
GLM_STATIC_ASSERT(detail::is_vector<vecType<bool> >::_YES, "'any' only accept GLM boolean vectors");
|
||||
|
||||
bool Result = false;
|
||||
for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
|
||||
@ -163,8 +160,7 @@ namespace glm
|
||||
template <template <typename> class vecType>
|
||||
inline bool all(vecType<bool> const & v)
|
||||
{
|
||||
GLM_STATIC_ASSERT(
|
||||
vecType<bool>::is_bool, "'all' only accept GLM boolean vectors");
|
||||
GLM_STATIC_ASSERT(detail::is_vector<vecType<bool> >::_YES, "'all' only accept GLM boolean vectors");
|
||||
|
||||
bool Result = true;
|
||||
for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
|
||||
@ -177,8 +173,7 @@ namespace glm
|
||||
template <template <typename> class vecType>
|
||||
inline vecType<bool> not_(vecType<bool> const & v)
|
||||
{
|
||||
GLM_STATIC_ASSERT(
|
||||
vecType<bool>::is_bool, "'not_' only accept GLM boolean vectors");
|
||||
GLM_STATIC_ASSERT(detail::is_vector<vecType<bool> >::_YES, "'not_' only accept GLM boolean vectors");
|
||||
|
||||
typename vecType<bool>::bool_type Result(vecType<bool>::null);
|
||||
for(typename vecType<bool>::size_type i = 0; i < vecType<bool>::value_size(); ++i)
|
||||
|
@ -38,6 +38,8 @@ namespace glm
|
||||
struct tvec1
|
||||
{
|
||||
enum ctor{null};
|
||||
enum {_size = 1};
|
||||
|
||||
typedef T value_type;
|
||||
typedef std::size_t size_type;
|
||||
static size_type value_size();
|
||||
@ -154,6 +156,8 @@ namespace glm
|
||||
T& x;
|
||||
};
|
||||
|
||||
GLM_DETAIL_IS_VECTOR(tvec1);
|
||||
|
||||
typedef detail::tvec1<core::type::precision::highp_float> highp_vec1_t;
|
||||
typedef detail::tvec1<core::type::precision::mediump_float> mediump_vec1_t;
|
||||
typedef detail::tvec1<core::type::precision::lowp_float> lowp_vec1_t;
|
||||
|
@ -36,6 +36,8 @@ namespace glm
|
||||
struct tvec2
|
||||
{
|
||||
enum ctor{null};
|
||||
enum {_size = 2};
|
||||
|
||||
typedef T value_type;
|
||||
typedef std::size_t size_type;
|
||||
static size_type value_size();
|
||||
@ -193,6 +195,9 @@ namespace glm
|
||||
T& x;
|
||||
T& y;
|
||||
};
|
||||
|
||||
GLM_DETAIL_IS_VECTOR(tvec2);
|
||||
|
||||
} //namespace detail
|
||||
|
||||
namespace core{
|
||||
|
@ -35,6 +35,8 @@ namespace glm
|
||||
struct tvec3
|
||||
{
|
||||
enum ctor{null};
|
||||
enum {_size = 3};
|
||||
|
||||
typedef T value_type;
|
||||
typedef std::size_t size_type;
|
||||
static size_type value_size();
|
||||
@ -199,6 +201,8 @@ namespace glm
|
||||
T & y;
|
||||
T & z;
|
||||
};
|
||||
|
||||
GLM_DETAIL_IS_VECTOR(tvec3);
|
||||
} //namespace detail
|
||||
|
||||
namespace core{
|
||||
|
@ -37,6 +37,7 @@ namespace glm
|
||||
{
|
||||
enum ctor{null};
|
||||
enum {_size = 4};
|
||||
|
||||
typedef T value_type;
|
||||
typedef std::size_t size_type;
|
||||
static size_type value_size();
|
||||
@ -214,6 +215,8 @@ namespace glm
|
||||
T & z;
|
||||
T & w;
|
||||
};
|
||||
|
||||
GLM_DETAIL_IS_VECTOR(tvec4);
|
||||
} //namespace detail
|
||||
|
||||
namespace core{
|
||||
|
@ -8,6 +8,7 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/half_float.hpp>
|
||||
#include <xmmintrin.h>
|
||||
#include <emmintrin.h>
|
||||
|
||||
@ -32,8 +33,18 @@ __m128 swizzle(glm::vec4 const & v)
|
||||
return _mm_shuffle_ps(Src, Src, mask<(int(W) << 6) | (int(Z) << 4) | (int(Y) << 2) | (int(X) << 0)>::value);
|
||||
}
|
||||
|
||||
void test_hvec4()
|
||||
{
|
||||
glm::hvec4 const A = glm::hvec4(0, 1, 2, 3);
|
||||
//glm::hvec4 B = glm::swizzle<glm::X, glm::Y, glm::Z, glm::W>(A);
|
||||
|
||||
//glm::vec4 B = glm::detail::tvec##(glm::vec4::_size)<float>();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_hvec4();
|
||||
|
||||
__m128 DataA = swizzle<X, Y, Z, W>(glm::vec4(1.0f, 2.0f, 3.0f, 4.0f));
|
||||
__m128 DataB = swizzle<W, Z, Y, X>(glm::vec4(1.0f, 2.0f, 3.0f, 4.0f));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user