From fcbedf5058ef8613dd02aac62ef00d55dcfeadd7 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Sun, 22 Oct 2017 16:58:09 +0200 Subject: [PATCH] Fixed glm::step that didn't work with scalars #684 --- glm/detail/func_common.inl | 2 +- test/core/core_func_common.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/glm/detail/func_common.inl b/glm/detail/func_common.inl index 7bf0f737f..37d62125f 100644 --- a/glm/detail/func_common.inl +++ b/glm/detail/func_common.inl @@ -582,7 +582,7 @@ namespace detail template GLM_FUNC_QUALIFIER genType step(genType edge, genType x) { - return mix(static_cast(1), static_cast(0), glm::lessThan(x, edge)); + return mix(static_cast(1), static_cast(0), x < edge); } template diff --git a/test/core/core_func_common.cpp b/test/core/core_func_common.cpp index 7651bea9c..15493df9b 100644 --- a/test/core/core_func_common.cpp +++ b/test/core/core_func_common.cpp @@ -527,6 +527,20 @@ namespace step_ { int Error = 0; + // scalar + { + float const Edge = 2.0f; + + float const A = glm::step(Edge, 1.0f); + Error += glm::epsilonEqual(A, 0.0f, glm::epsilon()) ? 0 : 1; + + float const B = glm::step(Edge, 3.0f); + Error += glm::epsilonEqual(B, 1.0f, glm::epsilon()) ? 0 : 1; + + float const C = glm::step(Edge, 2.0f); + Error += glm::epsilonEqual(C, 1.0f, glm::epsilon()) ? 0 : 1; + } + // vec4 and float { for (std::size_t i = 0; i < sizeof(TestVec4Scalar) / sizeof(entry); ++i)