Clean up math functions
- Remove checking for standard functions from the build system - Prefix all invocations with std:: - Replace suffixed functions with unprefixed versions - Include <cmath> in all files that use it and remove the global include e.g. floorf(x) -> std::floor(x)
This commit is contained in:
+16
-14
@@ -15,6 +15,8 @@
|
||||
#include "ThemeMetric.h"
|
||||
#include "ScreenDimensions.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
const int MAX_WHEEL_SOUND_SPEED = 15;
|
||||
AutoScreenMessage( SM_SongChanged ); // TODO: Replace this with a Message and MESSAGEMAN
|
||||
|
||||
@@ -41,7 +43,7 @@ WheelBase::~WheelBase()
|
||||
m_LastSelection = nullptr;
|
||||
}
|
||||
|
||||
void WheelBase::Load( RString sType )
|
||||
void WheelBase::Load( RString sType )
|
||||
{
|
||||
LOG->Trace( "WheelBase::Load('%s')", sType.c_str() );
|
||||
ASSERT( this->GetNumChildren() == 0 ); // only load once
|
||||
@@ -87,7 +89,7 @@ void WheelBase::Load( RString sType )
|
||||
ActorUtil::LoadAllCommands( *m_sprHighlight, m_sName );
|
||||
|
||||
m_ScrollBar.SetName( "ScrollBar" );
|
||||
m_ScrollBar.SetBarHeight( SCROLL_BAR_HEIGHT );
|
||||
m_ScrollBar.SetBarHeight( SCROLL_BAR_HEIGHT );
|
||||
this->AddChild( &m_ScrollBar );
|
||||
ActorUtil::LoadAllCommands( m_ScrollBar, m_sName );
|
||||
|
||||
@@ -137,7 +139,7 @@ void WheelBase::SetPositions()
|
||||
{
|
||||
WheelItemBase *pDisplay = m_WheelBaseItems[i];
|
||||
const float fOffsetFromSelection = i - NUM_WHEEL_ITEMS/2 + m_fPositionOffsetFromSelection;
|
||||
if( fabsf(fOffsetFromSelection) > NUM_WHEEL_ITEMS_TO_DRAW/2 )
|
||||
if( std::abs(fOffsetFromSelection) > NUM_WHEEL_ITEMS_TO_DRAW/2 )
|
||||
pDisplay->SetVisible( false );
|
||||
else
|
||||
pDisplay->SetVisible( true );
|
||||
@@ -198,7 +200,7 @@ void WheelBase::Update( float fDeltaTime )
|
||||
|
||||
m_fPositionOffsetFromSelection += m_fLockedWheelVelocity*t;
|
||||
|
||||
if( fabsf(m_fPositionOffsetFromSelection) < 0.01f && fabsf(m_fLockedWheelVelocity) < 0.01f )
|
||||
if( std::abs(m_fPositionOffsetFromSelection) < 0.01f && std::abs(m_fLockedWheelVelocity) < 0.01f )
|
||||
{
|
||||
m_fPositionOffsetFromSelection = 0;
|
||||
m_fLockedWheelVelocity = 0;
|
||||
@@ -236,7 +238,7 @@ void WheelBase::Update( float fDeltaTime )
|
||||
else
|
||||
{
|
||||
// "rotate" wheel toward selected song
|
||||
float fSpinSpeed = 0.2f + fabsf( m_fPositionOffsetFromSelection ) / SWITCH_SECONDS;
|
||||
float fSpinSpeed = 0.2f + std::abs( m_fPositionOffsetFromSelection ) / SWITCH_SECONDS;
|
||||
|
||||
if( m_fPositionOffsetFromSelection > 0 )
|
||||
{
|
||||
@@ -345,7 +347,7 @@ void WheelBase::ChangeMusicUnlessLocked( int n )
|
||||
{
|
||||
if(n)
|
||||
{
|
||||
int iSign = n/abs(n);
|
||||
int iSign = n / std::abs(n);
|
||||
m_fLockedWheelVelocity = iSign*LOCKED_INITIAL_VELOCITY;
|
||||
m_soundLocked.Play(true);
|
||||
}
|
||||
@@ -364,7 +366,7 @@ void WheelBase::Move(int n)
|
||||
{
|
||||
if(n)
|
||||
{
|
||||
int iSign = n/abs(n);
|
||||
int iSign = n / std::abs(n);
|
||||
m_fLockedWheelVelocity = iSign*LOCKED_INITIAL_VELOCITY;
|
||||
m_soundLocked.Play(true);
|
||||
}
|
||||
@@ -386,8 +388,8 @@ bool WheelBase::MoveSpecific( int n )
|
||||
{
|
||||
/* If we're not selecting, discard this. We won't ignore it; we'll
|
||||
* get called again every time the key is repeated. */
|
||||
/* Still process Move(0) so we sometimes continue moving immediate
|
||||
* after the sort change finished and before the repeat event causes a
|
||||
/* Still process Move(0) so we sometimes continue moving immediate
|
||||
* after the sort change finished and before the repeat event causes a
|
||||
* Move(0). -Chris */
|
||||
switch( m_WheelState )
|
||||
{
|
||||
@@ -407,7 +409,7 @@ bool WheelBase::MoveSpecific( int n )
|
||||
/* We were moving, and now we're stopping. If we're really close to
|
||||
* the selection, move to the next one, so we have a chance to spin down
|
||||
* smoothly. */
|
||||
if(fabsf(m_fPositionOffsetFromSelection) < 0.25f )
|
||||
if(std::abs(m_fPositionOffsetFromSelection) < 0.25f )
|
||||
ChangeMusic(m_Moving);
|
||||
|
||||
/* Make sure the user always gets an SM_SongChanged when
|
||||
@@ -500,7 +502,7 @@ int WheelBase::FirstVisibleIndex()
|
||||
int iFirstVisibleIndex = m_iSelection;
|
||||
if( m_iSelection >= int(m_CurWheelItemData.size()) )
|
||||
m_iSelection = 0;
|
||||
|
||||
|
||||
// find the first wheel item shown
|
||||
iFirstVisibleIndex -= NUM_WHEEL_ITEMS/2;
|
||||
|
||||
@@ -511,7 +513,7 @@ int WheelBase::FirstVisibleIndex()
|
||||
// lua start
|
||||
#include "LuaBinding.h"
|
||||
|
||||
/** @brief Allow Lua to have access to the WheelBase. */
|
||||
/** @brief Allow Lua to have access to the WheelBase. */
|
||||
class LunaWheelBase: public Luna<WheelBase>
|
||||
{
|
||||
public:
|
||||
@@ -562,7 +564,7 @@ LUA_REGISTER_DERIVED_CLASS( WheelBase, ActorFrame )
|
||||
/*
|
||||
* (c) 2001-2004 Chris Danford, Chris Gomez, Glenn Maynard, Josh Allen
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -572,7 +574,7 @@ LUA_REGISTER_DERIVED_CLASS( WheelBase, ActorFrame )
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
Reference in New Issue
Block a user