Fixed equal operator on quat

master
Christophe Riccio ago%!(EXTRA string=12 years)
parent 54e9d54579
commit 604405e941
  1. 24
      glm/core/func_vector_relational.hpp
  2. 32
      glm/gtc/quaternion.inl
  3. 28
      test/gtc/gtc_type_precision.cpp

@ -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/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> /// @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> template <typename T, precision P, template <typename, precision> class vecType>
typename vecType::bool_type lessThan(vecType const & x, vecType const & y); 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. /// 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/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> /// @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> template <typename T, precision P, template <typename, precision> class vecType>
typename vecType::bool_type lessThanEqual(vecType const & x, vecType const & y); 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. /// 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/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> /// @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> template <typename T, precision P, template <typename, precision> class vecType>
typename vecType::bool_type greaterThan(vecType const & x, vecType const & y); 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. /// 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/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> /// @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> template <typename T, precision P, template <typename, precision> class vecType>
typename vecType::bool_type greaterThanEqual(vecType const & x, vecType const & y); 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. /// 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/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> /// @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> template <typename T, precision P, template <typename, precision> class vecType>
typename vecType::bool_type equal(vecType const & x, vecType const & y); 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. /// 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/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> /// @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> template <typename T, precision P, template <typename, precision> class vecType>
typename vecType::bool_type notEqual(vecType const & x, vecType const & y); 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. /// Returns true if any component of x is true.
/// ///

@ -796,12 +796,6 @@ namespace detail
detail::tquat<T, P> const & y 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); 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) for(typename detail::tquat<T, P>::size_type i = 0; i < x.length(); ++i)
Result[i] = x[i] < y[i]; Result[i] = x[i] < y[i];
@ -816,12 +810,6 @@ namespace detail
detail::tquat<T, P> const & y 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); 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) for(typename detail::tquat<T, P>::size_type i = 0; i < x.length(); ++i)
Result[i] = x[i] <= y[i]; Result[i] = x[i] <= y[i];
@ -835,12 +823,6 @@ namespace detail
detail::tquat<T, P> const & y 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); 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) for(typename detail::tquat<T, P>::size_type i = 0; i < x.length(); ++i)
Result[i] = x[i] > y[i]; Result[i] = x[i] > y[i];
@ -854,12 +836,6 @@ namespace detail
detail::tquat<T, P> const & y 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); 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) for(typename detail::tquat<T, P>::size_type i = 0; i < x.length(); ++i)
Result[i] = x[i] >= y[i]; Result[i] = x[i] >= y[i];
@ -873,10 +849,6 @@ namespace detail
detail::tquat<T, P> const & y 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); 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) for(typename detail::tquat<T, P>::size_type i = 0; i < x.length(); ++i)
Result[i] = x[i] == y[i]; Result[i] = x[i] == y[i];
@ -890,10 +862,6 @@ namespace detail
detail::tquat<T, P> const & y 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); 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) for(typename detail::tquat<T, P>::size_type i = 0; i < x.length(); ++i)
Result[i] = x[i] != y[i]; Result[i] = x[i] != y[i];

@ -152,7 +152,18 @@ static int test_hvec_precision()
static int test_fvec_precision() static int test_fvec_precision()
{ {
int Error(0); 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::f32vec2 v1;
glm::lowp_f32vec2 v2(v1); glm::lowp_f32vec2 v2(v1);
@ -927,13 +938,16 @@ static int test_quat_precision()
{ {
glm::f32quat q1; glm::f32quat q1;
glm::f32quat q2(glm::lowp_f32quat(q1)); glm::lowp_f32quat qA(q1);
glm::f32quat q3(glm::mediump_f32quat(q1)); glm::mediump_f32quat qB(q1);
glm::f32quat q4(glm::highp_f32quat(q1)); glm::highp_f32quat qC(q1);
glm::f32quat q2(qA);
//Error += glm::all(glm::equal(q1, q2)) ? 0 : 1; glm::f32quat q3(qB);
//Error += glm::all(glm::equal(q1, q3)) ? 0 : 1; glm::f32quat q4(qC);
//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; return Error;

Loading…
Cancel
Save