Replace MathUtil::Clamp with std::clamp

This commit is contained in:
Léo Lam
2017-12-26 00:38:44 +01:00
parent 6f84984b7b
commit ab9ece9bca
31 changed files with 101 additions and 109 deletions

View File

@ -109,7 +109,7 @@ Cursor::StateData Cursor::GetState(const bool adjusted)
// Smooth out z movement:
// FYI: Not using relative input for Z.
m_state.z += MathUtil::Clamp(z - m_state.z, -max_z_step, max_z_step);
m_state.z += std::clamp(z - m_state.z, -max_z_step, max_z_step);
// Relative input:
if (m_relative_setting.GetValue())
@ -122,8 +122,8 @@ Cursor::StateData Cursor::GetState(const bool adjusted)
}
else
{
m_state.x = MathUtil::Clamp(m_state.x + input.x * max_step, -1.0, 1.0);
m_state.y = MathUtil::Clamp(m_state.y + input.y * max_step, -1.0, 1.0);
m_state.x = std::clamp(m_state.x + input.x * max_step, -1.0, 1.0);
m_state.y = std::clamp(m_state.y + input.y * max_step, -1.0, 1.0);
}
}
// Absolute input:

View File

@ -4,6 +4,7 @@
#include "InputCommon/ControllerEmu/StickGate.h"
#include <algorithm>
#include <cmath>
#include "Common/Common.h"
@ -277,8 +278,8 @@ ReshapableInput::ReshapeData ReshapableInput::Reshape(ControlState x, ControlSta
// Scale to the gate shape/radius:
dist *= gate_max_dist;
return {MathUtil::Clamp(std::cos(angle) * dist, -1.0, 1.0),
MathUtil::Clamp(std::sin(angle) * dist, -1.0, 1.0)};
return {std::clamp(std::cos(angle) * dist, -1.0, 1.0),
std::clamp(std::sin(angle) * dist, -1.0, 1.0)};
}
} // namespace ControllerEmu