Skip to content

Commit

Permalink
Fixed glm::step that didn't work with scalars g-truc#684
Browse files Browse the repository at this point in the history
  • Loading branch information
Groovounet committed Oct 22, 2017
1 parent 5dbb447 commit fcbedf5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion glm/detail/func_common.inl
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ namespace detail
template<typename genType>
GLM_FUNC_QUALIFIER genType step(genType edge, genType x)
{
return mix(static_cast<genType>(1), static_cast<genType>(0), glm::lessThan(x, edge));
return mix(static_cast<genType>(1), static_cast<genType>(0), x < edge);
}

template<length_t L, typename T, qualifier Q>
Expand Down
14 changes: 14 additions & 0 deletions test/core/core_func_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<float>()) ? 0 : 1;

float const B = glm::step(Edge, 3.0f);
Error += glm::epsilonEqual(B, 1.0f, glm::epsilon<float>()) ? 0 : 1;

float const C = glm::step(Edge, 2.0f);
Error += glm::epsilonEqual(C, 1.0f, glm::epsilon<float>()) ? 0 : 1;
}

// vec4 and float
{
for (std::size_t i = 0; i < sizeof(TestVec4Scalar) / sizeof(entry<float, glm::vec4>); ++i)
Expand Down

0 comments on commit fcbedf5

Please sign in to comment.