From 3bf13f95396f8758bebf62c30db727e35e7d2c5a Mon Sep 17 00:00:00 2001 From: Samuel Kim Date: Mon, 16 Oct 2017 03:13:06 -0400 Subject: [PATCH] use fabs where needed --- Main/Camera.cpp | 6 +++--- Main/Input.cpp | 4 ++-- Main/Scoring.cpp | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Main/Camera.cpp b/Main/Camera.cpp index b45ff145b..66fef1951 100644 --- a/Main/Camera.cpp +++ b/Main/Camera.cpp @@ -21,7 +21,7 @@ void Camera::Tick(float deltaTime, class BeatmapPlayback& playback) float rollDelta = m_targetRoll - m_laserRoll; rollSpeedLimit *= Math::Sign(rollDelta); - m_laserRoll += (abs(rollDelta) < abs(rollSpeedLimit)) ? rollDelta : rollSpeedLimit; + m_laserRoll += (fabs(rollDelta) < fabs(rollSpeedLimit)) ? rollDelta : rollSpeedLimit; // Calculate camera spin @@ -209,10 +209,10 @@ float Camera::GetRoll() const float Camera::m_ClampRoll(float in) const { - float ain = abs(in); + float ain = fabs(in); if(ain < 1.0f) return in; - bool odd = ((uint32)abs(in) % 2) == 1; + bool odd = ((uint32)fabs(in) % 2) == 1; float sign = Math::Sign(in); if(odd) { diff --git a/Main/Input.cpp b/Main/Input.cpp index 3fda5bb5e..b61d103db 100644 --- a/Main/Input.cpp +++ b/Main/Input.cpp @@ -119,9 +119,9 @@ void Input::Update(float deltaTime) { float axisState = m_gamepad->GetAxis(m_controllerAxisMapping[i]); float delta = axisState - m_prevLaserStates[i]; - if (abs(delta) > 1.5f) + if (fabs(delta) > 1.5f) delta += 2 * (Math::Sign(delta) * -1); - if (abs(delta) < m_controllerDeadzone) + if (fabs(delta) < m_controllerDeadzone) m_laserStates[i] = 0.0f; else m_laserStates[i] = delta * m_controllerSensitivity; diff --git a/Main/Scoring.cpp b/Main/Scoring.cpp index 6822c1d55..324170d4d 100644 --- a/Main/Scoring.cpp +++ b/Main/Scoring.cpp @@ -485,7 +485,7 @@ void Scoring::m_UpdateTicks() } // Check laser input - float laserDelta = abs(laserPositions[laserObject->index] - laserTargetPositions[laserObject->index]);\ + float laserDelta = fabs(laserPositions[laserObject->index] - laserTargetPositions[laserObject->index]);\ if(laserDelta < laserDistanceLeniency) { @@ -770,7 +770,7 @@ void Scoring::m_UpdateLasers(float deltaTime) if (laserDir == 0.0f && currentSegment->prev == nullptr) laserPositions[i] = laserTargetPositions[i]; // Lock lasers on straight parts - else if (laserDir == 0.0f && abs(positionDelta) < laserDistanceLeniency) + else if (laserDir == 0.0f && fabs(positionDelta) < laserDistanceLeniency) { laserPositions[i] = laserTargetPositions[i]; if (m_autoLaserTick[i] < m_assistLevel)