Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix laser lag on Linux by using fabs where needed #14

Merged
merged 1 commit into from
Oct 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Main/Camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
{
Expand Down
4 changes: 2 additions & 2 deletions Main/Input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions Main/Scoring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
Expand Down