Fixed bug #11, added missing quat based epsilonEqual and epsilonNotEqual definitions

This commit is contained in:
Christophe Riccio 2012-11-15 15:37:28 +01:00
parent 47b610c6d3
commit b8f30c5ad3
2 changed files with 57 additions and 0 deletions

View File

@ -254,6 +254,21 @@ namespace glm
abs(x.w - y.w) >= epsilon.w); abs(x.w - y.w) >= epsilon.w);
} }
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<bool> epsilonEqual
(
detail::tquat<valType> const & x,
detail::tquat<valType> const & y,
valType const & epsilon
)
{
return detail::tvec4<bool>(
abs(x.x - y.x) < epsilon,
abs(x.y - y.y) < epsilon,
abs(x.z - y.z) < epsilon,
abs(x.w - y.w) < epsilon);
}
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<bool> epsilonEqual GLM_FUNC_QUALIFIER detail::tvec4<bool> epsilonEqual
( (
@ -269,6 +284,21 @@ namespace glm
abs(x.w - y.w) < epsilon.w); abs(x.w - y.w) < epsilon.w);
} }
template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<bool> epsilonNotEqual
(
detail::tquat<valType> const & x,
detail::tquat<valType> const & y,
valType const & epsilon
)
{
return detail::tvec4<bool>(
abs(x.x - y.x) >= epsilon,
abs(x.y - y.y) >= epsilon,
abs(x.z - y.z) >= epsilon,
abs(x.w - y.w) >= epsilon);
}
template <typename valType> template <typename valType>
GLM_FUNC_QUALIFIER detail::tvec4<bool> epsilonNotEqual GLM_FUNC_QUALIFIER detail::tvec4<bool> epsilonNotEqual
( (

View File

@ -12,6 +12,32 @@
#include <glm/gtc/epsilon.hpp> #include <glm/gtc/epsilon.hpp>
#include <glm/gtc/constants.hpp> #include <glm/gtc/constants.hpp>
int test_defined()
{
glm::epsilonEqual(glm::vec2(), glm::vec2(), glm::vec2());
glm::epsilonEqual(glm::vec3(), glm::vec3(), glm::vec3());
glm::epsilonEqual(glm::vec4(), glm::vec4(), glm::vec4());
glm::epsilonEqual(glm::quat(), glm::quat(), glm::quat());
glm::epsilonNotEqual(glm::vec2(), glm::vec2(), glm::vec2());
glm::epsilonNotEqual(glm::vec3(), glm::vec3(), glm::vec3());
glm::epsilonNotEqual(glm::vec4(), glm::vec4(), glm::vec4());
glm::epsilonNotEqual(glm::quat(), glm::quat(), glm::quat());
glm::epsilonEqual(glm::vec2(), glm::vec2(), 0.0f);
glm::epsilonEqual(glm::vec3(), glm::vec3(), 0.0f);
glm::epsilonEqual(glm::vec4(), glm::vec4(), 0.0f);
glm::epsilonEqual(glm::quat(), glm::quat(), 0.0f);
glm::epsilonNotEqual(glm::vec2(), glm::vec2(), 0.0f);
glm::epsilonNotEqual(glm::vec3(), glm::vec3(), 0.0f);
glm::epsilonNotEqual(glm::vec4(), glm::vec4(), 0.0f);
glm::epsilonNotEqual(glm::quat(), glm::quat(), 0.0f);
return 0;
}
template <typename T> template <typename T>
int test_equal() int test_equal()
{ {
@ -54,6 +80,7 @@ int main()
{ {
int Error(0); int Error(0);
Error += test_defined();
Error += test_equal<glm::half>(); Error += test_equal<glm::half>();
Error += test_equal<float>(); Error += test_equal<float>();
Error += test_equal<double>(); Error += test_equal<double>();