Skip to content

Commit

Permalink
fix(input): do not use std::clamp
Browse files Browse the repository at this point in the history
  • Loading branch information
RiscadoA committed Sep 30, 2023
1 parent 4345076 commit a943450
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions engine/src/cubos/engine/input/axis.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <cmath>

#include <cubos/core/io/keyboard.hpp>
#include <cubos/core/log.hpp>

Expand Down Expand Up @@ -45,9 +47,11 @@ float InputAxis::value() const

void InputAxis::value(float value)
{
if (std::abs(value) > 1.0F)
mValue = value;

if (std::abs(mValue) > 1.0F)
{
CUBOS_WARN("Axis value out of range: {}", value);
CUBOS_WARN("Axis value out of range: {}", mValue);
mValue = mValue > 1.0F ? 1.0F : -1.0F;
}
mValue = std::clamp(value, -1.0F, 1.0F);
}

0 comments on commit a943450

Please sign in to comment.