Fixed equal operator on quat

This commit is contained in:
Christophe Riccio 2013-04-17 18:24:02 +02:00
parent 54e9d54579
commit 604405e941
3 changed files with 39 additions and 57 deletions

View file

@ -52,8 +52,8 @@ namespace glm
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/lessThan.xml">GLSL lessThan man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.7 Vector Relational Functions</a>
template <typename vecType>
typename vecType::bool_type lessThan(vecType const & x, vecType const & y);
template <typename T, precision P, template <typename, precision> class vecType>
typename vecType<T, P>::bool_type lessThan(vecType<T, P> const & x, vecType<T, P> const & y);
/// Returns the component-wise comparison of result x <= y.
///
@ -61,8 +61,8 @@ namespace glm
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/lessThanEqual.xml">GLSL lessThanEqual man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.7 Vector Relational Functions</a>
template <typename vecType>
typename vecType::bool_type lessThanEqual(vecType const & x, vecType const & y);
template <typename T, precision P, template <typename, precision> class vecType>
typename vecType<T, P>::bool_type lessThanEqual(vecType<T, P> const & x, vecType<T, P> const & y);
/// Returns the component-wise comparison of result x > y.
///
@ -70,8 +70,8 @@ namespace glm
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/greaterThan.xml">GLSL greaterThan man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.7 Vector Relational Functions</a>
template <typename vecType>
typename vecType::bool_type greaterThan(vecType const & x, vecType const & y);
template <typename T, precision P, template <typename, precision> class vecType>
typename vecType<T, P>::bool_type greaterThan(vecType<T, P> const & x, vecType<T, P> const & y);
/// Returns the component-wise comparison of result x >= y.
///
@ -79,8 +79,8 @@ namespace glm
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/greaterThanEqual.xml">GLSL greaterThanEqual man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.7 Vector Relational Functions</a>
template <typename vecType>
typename vecType::bool_type greaterThanEqual(vecType const & x, vecType const & y);
template <typename T, precision P, template <typename, precision> class vecType>
typename vecType<T, P>::bool_type greaterThanEqual(vecType<T, P> const & x, vecType<T, P> const & y);
/// Returns the component-wise comparison of result x == y.
///
@ -88,8 +88,8 @@ namespace glm
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/equal.xml">GLSL equal man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.7 Vector Relational Functions</a>
template <typename vecType>
typename vecType::bool_type equal(vecType const & x, vecType const & y);
template <typename T, precision P, template <typename, precision> class vecType>
typename vecType<T, P>::bool_type equal(vecType<T, P> const & x, vecType<T, P> const & y);
/// Returns the component-wise comparison of result x != y.
///
@ -97,8 +97,8 @@ namespace glm
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/notEqual.xml">GLSL notEqual man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.7 Vector Relational Functions</a>
template <typename vecType>
typename vecType::bool_type notEqual(vecType const & x, vecType const & y);
template <typename T, precision P, template <typename, precision> class vecType>
typename vecType<T, P>::bool_type notEqual(vecType<T, P> const & x, vecType<T, P> const & y);
/// Returns true if any component of x is true.
///
@ -106,7 +106,7 @@ namespace glm
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/any.xml">GLSL any man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.7 Vector Relational Functions</a>
template <template <typename> class vecType>
template <template <typename> class vecType>
bool any(vecType<bool> const & v);
/// Returns true if all components of x are true.
@ -115,7 +115,7 @@ namespace glm
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/all.xml">GLSL all man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.7 Vector Relational Functions</a>
template <template <typename> class vecType>
template <template <typename> class vecType>
bool all(vecType<bool> const & v);
/// Returns the component-wise logical complement of x.
@ -125,7 +125,7 @@ namespace glm
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/not.xml">GLSL not man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.7 Vector Relational Functions</a>
template <template <typename> class vecType>
template <template <typename> class vecType>
vecType<bool> not_(vecType<bool> const & v);
/// @}

View file

@ -796,12 +796,6 @@ namespace detail
detail::tquat<T, P> const & y
)
{
//GLM_STATIC_ASSERT(detail::is_vector<vecType<T, P> >::_YES,
// "Invalid template instantiation of 'lessThan', GLM vector types required");
GLM_STATIC_ASSERT(detail::is_bool<T>::_NO,
"Invalid template instantiation of 'lessThan', GLM vector types required floating-point or integer value types vectors");
assert(x.length() == y.length());
typename detail::tquat<T, P>::bool_type Result(detail::tquat<T, P>::null);
for(typename detail::tquat<T, P>::size_type i = 0; i < x.length(); ++i)
Result[i] = x[i] < y[i];
@ -816,12 +810,6 @@ namespace detail
detail::tquat<T, P> const & y
)
{
//GLM_STATIC_ASSERT(detail::is_vector<vecType<T, P> >::_YES,
// "Invalid template instantiation of 'lessThanEqual', GLM vector types required");
GLM_STATIC_ASSERT(detail::is_bool<T>::_NO,
"Invalid template instantiation of 'lessThanEqual', GLM vector types required floating-point or integer value types vectors");
assert(x.length() == y.length());
typename detail::tquat<T, P>::bool_type Result(detail::tquat<T, P>::null);
for(typename detail::tquat<T, P>::size_type i = 0; i < x.length(); ++i)
Result[i] = x[i] <= y[i];
@ -835,12 +823,6 @@ namespace detail
detail::tquat<T, P> const & y
)
{
//GLM_STATIC_ASSERT(detail::is_vector<vecType<T, P> >::_YES,
// "Invalid template instantiation of 'greaterThan', GLM vector types required");
GLM_STATIC_ASSERT(detail::is_bool<T>::_NO,
"Invalid template instantiation of 'greaterThan', GLM vector types required floating-point or integer value types vectors");
assert(x.length() == y.length());
typename detail::tquat<T, P>::bool_type Result(detail::tquat<T, P>::null);
for(typename detail::tquat<T, P>::size_type i = 0; i < x.length(); ++i)
Result[i] = x[i] > y[i];
@ -854,12 +836,6 @@ namespace detail
detail::tquat<T, P> const & y
)
{
//GLM_STATIC_ASSERT(detail::is_vector<vecType<T, P> >::_YES,
// "Invalid template instantiation of 'greaterThanEqual', GLM vector types required");
GLM_STATIC_ASSERT(detail::is_bool<T>::_NO,
"Invalid template instantiation of 'greaterThanEqual', GLM vector types required floating-point or integer value types vectors");
assert(x.length() == y.length());
typename detail::tquat<T, P>::bool_type Result(detail::tquat<T, P>::null);
for(typename detail::tquat<T, P>::size_type i = 0; i < x.length(); ++i)
Result[i] = x[i] >= y[i];
@ -867,16 +843,12 @@ namespace detail
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER typename detail::tquat<T, P>::bool_type equal
GLM_FUNC_QUALIFIER typename detail::tquat<T, P>::bool_type equal
(
detail::tquat<T, P> const & x,
detail::tquat<T, P> const & y
)
{
//GLM_STATIC_ASSERT(detail::is_vector<vecType<T, P> >::_YES,
// "Invalid template instantiation of 'equal', GLM vector types required");
assert(x.length() == y.length());
typename detail::tquat<T, P>::bool_type Result(detail::tquat<T, P>::null);
for(typename detail::tquat<T, P>::size_type i = 0; i < x.length(); ++i)
Result[i] = x[i] == y[i];
@ -884,16 +856,12 @@ namespace detail
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER typename detail::tquat<T, P>::bool_type notEqual
GLM_FUNC_QUALIFIER typename detail::tquat<T, P>::bool_type notEqual
(
detail::tquat<T, P> const & x,
detail::tquat<T, P> const & y
)
{
//GLM_STATIC_ASSERT(detail::is_vector<vecType<T, P> >::_YES,
// "Invalid template instantiation of 'notEqual', GLM vector types required");
assert(x.length() == y.length());
typename detail::tquat<T, P>::bool_type Result(detail::tquat<T, P>::null);
for(typename detail::tquat<T, P>::size_type i = 0; i < x.length(); ++i)
Result[i] = x[i] != y[i];

View file

@ -152,7 +152,18 @@ static int test_hvec_precision()
static int test_fvec_precision()
{
int Error(0);
/*
{
glm::f32vec2 v1;
glm::lowp_f32vec2 v2((glm::f32vec2(v1)));
glm::mediump_f32vec2 v3((glm::f32vec2(v1)));
glm::highp_f32vec2 v4((glm::f32vec2(v1)));
Error += glm::all(glm::equal(v1, v2)) ? 0 : 1;
Error += glm::all(glm::equal(v1, v3)) ? 0 : 1;
Error += glm::all(glm::equal(v1, v4)) ? 0 : 1;
}
*/
{
glm::f32vec2 v1;
glm::lowp_f32vec2 v2(v1);
@ -927,15 +938,18 @@ static int test_quat_precision()
{
glm::f32quat q1;
glm::f32quat q2(glm::lowp_f32quat(q1));
glm::f32quat q3(glm::mediump_f32quat(q1));
glm::f32quat q4(glm::highp_f32quat(q1));
glm::lowp_f32quat qA(q1);
glm::mediump_f32quat qB(q1);
glm::highp_f32quat qC(q1);
glm::f32quat q2(qA);
glm::f32quat q3(qB);
glm::f32quat q4(qC);
//Error += glm::all(glm::equal(q1, q2)) ? 0 : 1;
//Error += glm::all(glm::equal(q1, q3)) ? 0 : 1;
//Error += glm::all(glm::equal(q1, q4)) ? 0 : 1;
Error += glm::all(glm::equal(q1, q2)) ? 0 : 1;
Error += glm::all(glm::equal(q1, q3)) ? 0 : 1;
Error += glm::all(glm::equal(q1, q4)) ? 0 : 1;
}
return Error;
}