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:
Martin Natano
2023-04-19 19:31:40 +02:00
parent f39ed52dbf
commit b68ca517e6
111 changed files with 1831 additions and 1785 deletions
-9
View File
@@ -106,15 +106,6 @@ check_cxx_symbol_exists(strcasecmp cstring HAVE_STRCASECMP)
check_function_exists(waitpid HAVE_WAITPID) check_function_exists(waitpid HAVE_WAITPID)
# Mostly universal symbols. # Mostly universal symbols.
check_cxx_symbol_exists(powf cmath HAVE_POWF)
check_cxx_symbol_exists(sqrtf cmath HAVE_SQRTF)
check_cxx_symbol_exists(sinf cmath HAVE_SINF)
check_cxx_symbol_exists(tanf cmath HAVE_TANF)
check_cxx_symbol_exists(cosf cmath HAVE_COSF)
check_cxx_symbol_exists(acosf cmath HAVE_ACOSF)
check_cxx_symbol_exists(truncf cmath HAVE_TRUNCF)
check_cxx_symbol_exists(roundf cmath HAVE_ROUNDF)
check_cxx_symbol_exists(lrintf cmath HAVE_LRINTF)
check_cxx_symbol_exists(strtof cstdlib HAVE_STRTOF) check_cxx_symbol_exists(strtof cstdlib HAVE_STRTOF)
check_symbol_exists(M_PI math.h HAVE_M_PI) check_symbol_exists(M_PI math.h HAVE_M_PI)
check_symbol_exists(size_t stddef.h HAVE_SIZE_T_STDDEF) check_symbol_exists(size_t stddef.h HAVE_SIZE_T_STDDEF)
+4 -2
View File
@@ -13,6 +13,8 @@
#include "LightsManager.h" // for NUM_CabinetLight #include "LightsManager.h" // for NUM_CabinetLight
#include "ActorUtil.h" #include "ActorUtil.h"
#include "Preference.h" #include "Preference.h"
#include <cmath>
#include <typeinfo> #include <typeinfo>
static Preference<bool> g_bShowMasks("ShowMasks", false); static Preference<bool> g_bShowMasks("ShowMasks", false);
@@ -1080,8 +1082,8 @@ void Actor::ScaleTo( const RectF &rect, StretchType st )
if( rect_height < 0 ) SetRotationX( 180 ); if( rect_height < 0 ) SetRotationX( 180 );
// zoom fActor needed to scale the Actor to fill the rectangle // zoom fActor needed to scale the Actor to fill the rectangle
float fNewZoomX = fabsf(rect_width / m_size.x); float fNewZoomX = std::abs(rect_width / m_size.x);
float fNewZoomY = fabsf(rect_height / m_size.y); float fNewZoomY = std::abs(rect_height / m_size.y);
float fNewZoom = 0.f; float fNewZoom = 0.f;
switch( st ) switch( st )
+8 -6
View File
@@ -8,6 +8,8 @@
#include "ActorUtil.h" #include "ActorUtil.h"
#include "LuaBinding.h" #include "LuaBinding.h"
#include <cmath>
/* Tricky: We need ActorFrames created in Lua to auto delete their children. /* Tricky: We need ActorFrames created in Lua to auto delete their children.
* We don't want classes that derive from ActorFrame to auto delete their * We don't want classes that derive from ActorFrame to auto delete their
* children. The name "ActorFrame" is widely used in Lua, so we'll have * children. The name "ActorFrame" is widely used in Lua, so we'll have
@@ -116,7 +118,7 @@ float ActorScroller::GetSecondsForCompleteScrollThrough() const
float ActorScroller::GetSecondsToDestination() const float ActorScroller::GetSecondsToDestination() const
{ {
float fTotalItemsToMove = fabsf(m_fCurrentItem - m_fDestinationItem); float fTotalItemsToMove = std::abs(m_fCurrentItem - m_fDestinationItem);
return fTotalItemsToMove * m_fSecondsPerItem; return fTotalItemsToMove * m_fSecondsPerItem;
} }
@@ -195,7 +197,7 @@ void ActorScroller::UpdateInternal( float fDeltaTime )
float fApproachSpeed = fDeltaTime/m_fSecondsPerItem; float fApproachSpeed = fDeltaTime/m_fSecondsPerItem;
if( m_bFastCatchup ) if( m_bFastCatchup )
{ {
float fDistanceToMove = fabsf(m_fCurrentItem - m_fDestinationItem); float fDistanceToMove = std::abs(m_fCurrentItem - m_fDestinationItem);
if( fDistanceToMove > 1 ) if( fDistanceToMove > 1 )
fApproachSpeed *= fDistanceToMove*fDistanceToMove; fApproachSpeed *= fDistanceToMove*fDistanceToMove;
} }
@@ -210,13 +212,13 @@ void ActorScroller::UpdateInternal( float fDeltaTime )
if( m_bWrap ) if( m_bWrap )
{ {
float Delta = m_fDestinationItem - m_fCurrentItem; float Delta = m_fDestinationItem - m_fCurrentItem;
m_fCurrentItem = fmodf( m_fCurrentItem, (float) m_iNumItems ); m_fCurrentItem = std::fmod( m_fCurrentItem, (float) m_iNumItems );
m_fDestinationItem = m_fCurrentItem + Delta; m_fDestinationItem = m_fCurrentItem + Delta;
} }
if( m_bLoop ) if( m_bLoop )
{ {
m_fCurrentItem = fmodf( m_fCurrentItem, (float) m_iNumItems ); m_fCurrentItem = std::fmod( m_fCurrentItem, (float) m_iNumItems );
} }
} }
@@ -261,8 +263,8 @@ void ActorScroller::PositionItemsAndDrawPrimitives( bool bDrawPrimitives )
float fFirstItemToDraw = m_fCurrentItem - fNumItemsToDraw/2.f; float fFirstItemToDraw = m_fCurrentItem - fNumItemsToDraw/2.f;
float fLastItemToDraw = m_fCurrentItem + fNumItemsToDraw/2.f; float fLastItemToDraw = m_fCurrentItem + fNumItemsToDraw/2.f;
int iFirstItemToDraw = (int) ceilf( fFirstItemToDraw ); int iFirstItemToDraw = std::ceil( fFirstItemToDraw );
int iLastItemToDraw = (int) ceilf( fLastItemToDraw ); int iLastItemToDraw = std::ceil( fLastItemToDraw );
if( !m_bLoop && !m_bWrap ) if( !m_bLoop && !m_bWrap )
{ {
iFirstItemToDraw = clamp( iFirstItemToDraw, 0, m_iNumItems ); iFirstItemToDraw = clamp( iFirstItemToDraw, 0, m_iNumItems );
+7 -5
View File
@@ -42,6 +42,8 @@
#include "PrefsManager.h" #include "PrefsManager.h"
#include "ScreenManager.h" #include "ScreenManager.h"
#include <cmath>
std::vector<TimingData> AdjustSync::s_vpTimingDataOriginal; std::vector<TimingData> AdjustSync::s_vpTimingDataOriginal;
float AdjustSync::s_fGlobalOffsetSecondsOriginal = 0.0f; float AdjustSync::s_fGlobalOffsetSecondsOriginal = 0.0f;
@@ -314,7 +316,7 @@ void AdjustSync::GetSyncChangeTextGlobal( std::vector<RString> &vsAddTo )
float fNew = Quantize( PREFSMAN->m_fGlobalOffsetSeconds, 0.001f ) ; float fNew = Quantize( PREFSMAN->m_fGlobalOffsetSeconds, 0.001f ) ;
float fDelta = fNew - fOld; float fDelta = fNew - fOld;
if( fabsf(fDelta) > 0.0001f ) if( std::abs(fDelta) > 0.0001f )
{ {
vsAddTo.push_back( ssprintf( vsAddTo.push_back( ssprintf(
GLOBAL_OFFSET_FROM.GetValue(), GLOBAL_OFFSET_FROM.GetValue(),
@@ -344,7 +346,7 @@ void AdjustSync::GetSyncChangeTextSong( std::vector<RString> &vsAddTo )
float fNew = Quantize( testing.m_fBeat0OffsetInSeconds, 0.001f ); float fNew = Quantize( testing.m_fBeat0OffsetInSeconds, 0.001f );
float fDelta = fNew - fOld; float fDelta = fNew - fOld;
if( fabsf(fDelta) > 0.0001f ) if( std::abs(fDelta) > 0.0001f )
{ {
vsAddTo.push_back( ssprintf( vsAddTo.push_back( ssprintf(
SONG_OFFSET_FROM.GetValue(), SONG_OFFSET_FROM.GetValue(),
@@ -362,7 +364,7 @@ void AdjustSync::GetSyncChangeTextSong( std::vector<RString> &vsAddTo )
float fNew = Quantize( ToBPM(bpmTest[i])->GetBPM(), 0.001f ); float fNew = Quantize( ToBPM(bpmTest[i])->GetBPM(), 0.001f );
float fOld = Quantize( ToBPM(bpmOrig[i])->GetBPM(), 0.001f ); float fOld = Quantize( ToBPM(bpmOrig[i])->GetBPM(), 0.001f );
if( fabsf(fNew - fOld) < 1e-4 ) if( std::abs(fNew - fOld) < 1e-4 )
continue; continue;
if ( i >= 4 ) if ( i >= 4 )
@@ -387,7 +389,7 @@ void AdjustSync::GetSyncChangeTextSong( std::vector<RString> &vsAddTo )
float fNew = Quantize( ToStop(stopTest[i])->GetPause(), 0.001f ); float fNew = Quantize( ToStop(stopTest[i])->GetPause(), 0.001f );
float fDelta = fNew - fOld; float fDelta = fNew - fOld;
if( fabsf(fDelta) < 1e-4 ) if( std::abs(fDelta) < 1e-4 )
continue; continue;
if ( i >= 4 ) if ( i >= 4 )
@@ -413,7 +415,7 @@ void AdjustSync::GetSyncChangeTextSong( std::vector<RString> &vsAddTo )
float fNew = Quantize( ToDelay(delyTest[i])->GetPause(), 0.001f ); float fNew = Quantize( ToDelay(delyTest[i])->GetPause(), 0.001f );
float fDelta = fNew - fOld; float fDelta = fNew - fOld;
if( fabsf(fDelta) < 1e-4 ) if( std::abs(fDelta) < 1e-4 )
continue; continue;
if ( i >= 4 ) if ( i >= 4 )
+29 -27
View File
@@ -12,7 +12,9 @@
#include "GameState.h" #include "GameState.h"
#include "Style.h" #include "Style.h"
#include "ThemeMetric.h" #include "ThemeMetric.h"
#include <float.h>
#include <cfloat>
#include <cmath>
static char const dimension_names[4]= "XYZ"; static char const dimension_names[4]= "XYZ";
@@ -84,7 +86,7 @@ float ArrowGetPercentVisible(float fYPosWithoutReverse, int iCol, float fYOffset
static float GetNoteFieldHeight() static float GetNoteFieldHeight()
{ {
return SCREEN_HEIGHT + fabsf(curr_options->m_fPerspectiveTilt)*200; return SCREEN_HEIGHT + std::abs(curr_options->m_fPerspectiveTilt)*200;
} }
float ArrowEffects::GetTime() float ArrowEffects::GetTime()
@@ -158,7 +160,7 @@ static float CalculateTornadoOffsetFromMagnitude(int dimension, int col_id,
data.m_MaxTornado[dimension][col_id] * field_zoom, data.m_MaxTornado[dimension][col_id] * field_zoom,
tornado_position_scale_to_low[dimension], tornado_position_scale_to_low[dimension],
tornado_position_scale_to_high[dimension]); tornado_position_scale_to_high[dimension]);
float rads= acosf(position_between); float rads= std::acos(position_between);
float frequency= tornado_offset_frequency[dimension]; float frequency= tornado_offset_frequency[dimension];
rads+= (y_offset + effect_offset) * ((period * frequency) + frequency) / SCREEN_HEIGHT; rads+= (y_offset + effect_offset) * ((period * frequency) + frequency) / SCREEN_HEIGHT;
float processed_rads = is_tan ? SelectTanType(rads, curr_options->m_bCosecant) : RageFastCos(rads); float processed_rads = is_tan ? SelectTanType(rads, curr_options->m_bCosecant) : RageFastCos(rads);
@@ -201,9 +203,9 @@ static void UpdateBeat(int dimension, PerPlayerData &data, const SongPosition &p
return; return;
// -100.2 -> -0.2 -> 0.2 // -100.2 -> -0.2 -> 0.2
fBeat -= truncf( fBeat ); fBeat -= std::trunc( fBeat );
fBeat += 1; fBeat += 1;
fBeat -= truncf( fBeat ); fBeat -= std::trunc( fBeat );
if( fBeat >= fTotalTime ) if( fBeat >= fTotalTime )
return; return;
@@ -333,9 +335,9 @@ void ArrowEffects::Update()
if( !position.m_bFreeze || !position.m_bDelay ) if( !position.m_bFreeze || !position.m_bDelay )
{ {
data.m_fExpandSeconds += fTime - fLastTime; data.m_fExpandSeconds += fTime - fLastTime;
data.m_fExpandSeconds = fmodf( data.m_fExpandSeconds, (PI*2)/(accels[PlayerOptions::ACCEL_EXPAND_PERIOD]+1) ); data.m_fExpandSeconds = std::fmod( data.m_fExpandSeconds, (PI*2)/(accels[PlayerOptions::ACCEL_EXPAND_PERIOD]+1) );
data.m_fTanExpandSeconds += fTime - fLastTime; data.m_fTanExpandSeconds += fTime - fLastTime;
data.m_fTanExpandSeconds = fmodf( data.m_fTanExpandSeconds, (PI*2)/(accels[PlayerOptions::ACCEL_TAN_EXPAND_PERIOD]+1) ); data.m_fTanExpandSeconds = std::fmod( data.m_fTanExpandSeconds, (PI*2)/(accels[PlayerOptions::ACCEL_TAN_EXPAND_PERIOD]+1) );
} }
// Update Invert // Update Invert
@@ -609,7 +611,7 @@ static void ArrowGetReverseShiftAndScale(int iCol, float fYReverseOffsetPixels,
float fZoom = 1 - fMiniPercent*0.5f; float fZoom = 1 - fMiniPercent*0.5f;
// don't divide by 0 // don't divide by 0
if( fabsf(fZoom) < 0.01 ) if( std::abs(fZoom) < 0.01 )
fZoom = 0.01f; fZoom = 0.01f;
float fPercentReverse = curr_options->GetReversePercentForColumn(iCol); float fPercentReverse = curr_options->GetReversePercentForColumn(iCol);
@@ -662,7 +664,7 @@ float ArrowEffects::GetYPos( const PlayerState* pPlayerState, int iCol, float fY
// floored, making arrows show on integer Y coordinates. Supposedly it makes // floored, making arrows show on integer Y coordinates. Supposedly it makes
// the arrows look better, but testing needs to be done. // the arrows look better, but testing needs to be done.
// todo: make this a noteskin metric instead of a theme metric? -aj // todo: make this a noteskin metric instead of a theme metric? -aj
return QUANTIZE_ARROW_Y ? floor(f) : f; return QUANTIZE_ARROW_Y ? std::floor(f) : f;
} }
float ArrowEffects::GetYOffsetFromYPos(int iCol, float YPos, float fYReverseOffsetPixels) float ArrowEffects::GetYOffsetFromYPos(int iCol, float YPos, float fYReverseOffsetPixels)
@@ -775,7 +777,7 @@ float ArrowEffects::GetXPos( const PlayerState* pPlayerState, int iColNum, float
if( fEffects[PlayerOptions::EFFECT_SAWTOOTH] != 0 ) if( fEffects[PlayerOptions::EFFECT_SAWTOOTH] != 0 )
fPixelOffsetFromCenter += (fEffects[PlayerOptions::EFFECT_SAWTOOTH]*ARROW_SIZE) * fPixelOffsetFromCenter += (fEffects[PlayerOptions::EFFECT_SAWTOOTH]*ARROW_SIZE) *
((0.5f / (fEffects[PlayerOptions::EFFECT_SAWTOOTH_PERIOD]+1) * fYOffset) / ARROW_SIZE - ((0.5f / (fEffects[PlayerOptions::EFFECT_SAWTOOTH_PERIOD]+1) * fYOffset) / ARROW_SIZE -
floor((0.5f / (fEffects[PlayerOptions::EFFECT_SAWTOOTH_PERIOD]+1) * fYOffset) / ARROW_SIZE) ); std::floor((0.5f / (fEffects[PlayerOptions::EFFECT_SAWTOOTH_PERIOD]+1) * fYOffset) / ARROW_SIZE) );
if( fEffects[PlayerOptions::EFFECT_PARABOLA_X] != 0 ) if( fEffects[PlayerOptions::EFFECT_PARABOLA_X] != 0 )
fPixelOffsetFromCenter += fEffects[PlayerOptions::EFFECT_PARABOLA_X] * (fYOffset/ARROW_SIZE) * (fYOffset/ARROW_SIZE); fPixelOffsetFromCenter += fEffects[PlayerOptions::EFFECT_PARABOLA_X] * (fYOffset/ARROW_SIZE) * (fYOffset/ARROW_SIZE);
@@ -788,14 +790,14 @@ float ArrowEffects::GetXPos( const PlayerState* pPlayerState, int iColNum, float
if( fEffects[PlayerOptions::EFFECT_DIGITAL] != 0 ) if( fEffects[PlayerOptions::EFFECT_DIGITAL] != 0 )
fPixelOffsetFromCenter += (fEffects[PlayerOptions::EFFECT_DIGITAL] * ARROW_SIZE * 0.5f) * fPixelOffsetFromCenter += (fEffects[PlayerOptions::EFFECT_DIGITAL] * ARROW_SIZE * 0.5f) *
round((fEffects[PlayerOptions::EFFECT_DIGITAL_STEPS]+1) * RageFastSin( std::round((fEffects[PlayerOptions::EFFECT_DIGITAL_STEPS]+1) * RageFastSin(
CalculateDigitalAngle(fYOffset, CalculateDigitalAngle(fYOffset,
fEffects[PlayerOptions::EFFECT_DIGITAL_OFFSET], fEffects[PlayerOptions::EFFECT_DIGITAL_OFFSET],
fEffects[PlayerOptions::EFFECT_DIGITAL_PERIOD]) ) )/(fEffects[PlayerOptions::EFFECT_DIGITAL_STEPS]+1); fEffects[PlayerOptions::EFFECT_DIGITAL_PERIOD]) ) )/(fEffects[PlayerOptions::EFFECT_DIGITAL_STEPS]+1);
if( fEffects[PlayerOptions::EFFECT_TAN_DIGITAL] != 0 ) if( fEffects[PlayerOptions::EFFECT_TAN_DIGITAL] != 0 )
fPixelOffsetFromCenter += (fEffects[PlayerOptions::EFFECT_TAN_DIGITAL] * ARROW_SIZE * 0.5f) * fPixelOffsetFromCenter += (fEffects[PlayerOptions::EFFECT_TAN_DIGITAL] * ARROW_SIZE * 0.5f) *
round((fEffects[PlayerOptions::EFFECT_TAN_DIGITAL_STEPS]+1) * SelectTanType( std::round((fEffects[PlayerOptions::EFFECT_TAN_DIGITAL_STEPS]+1) * SelectTanType(
CalculateDigitalAngle(fYOffset, CalculateDigitalAngle(fYOffset,
fEffects[PlayerOptions::EFFECT_TAN_DIGITAL_OFFSET], fEffects[PlayerOptions::EFFECT_TAN_DIGITAL_OFFSET],
fEffects[PlayerOptions::EFFECT_TAN_DIGITAL_PERIOD]), curr_options->m_bCosecant ) )/(fEffects[PlayerOptions::EFFECT_TAN_DIGITAL_STEPS]+1); fEffects[PlayerOptions::EFFECT_TAN_DIGITAL_PERIOD]), curr_options->m_bCosecant ) )/(fEffects[PlayerOptions::EFFECT_TAN_DIGITAL_STEPS]+1);
@@ -811,7 +813,7 @@ float ArrowEffects::GetXPos( const PlayerState* pPlayerState, int iColNum, float
if( fEffects[PlayerOptions::EFFECT_BOUNCE] != 0 ) if( fEffects[PlayerOptions::EFFECT_BOUNCE] != 0 )
{ {
float fBounceAmt = fabsf( RageFastSin( ( (fYOffset + (1.0f * (fEffects[PlayerOptions::EFFECT_BOUNCE_OFFSET]) ) ) / float fBounceAmt = std::abs( RageFastSin( ( (fYOffset + (1.0f * (fEffects[PlayerOptions::EFFECT_BOUNCE_OFFSET]) ) ) /
( 60 + (fEffects[PlayerOptions::EFFECT_BOUNCE_PERIOD]*60) ) ) ) ); ( 60 + (fEffects[PlayerOptions::EFFECT_BOUNCE_PERIOD]*60) ) ) ) );
fPixelOffsetFromCenter += fEffects[PlayerOptions::EFFECT_BOUNCE] * ARROW_SIZE * 0.5f * fBounceAmt; fPixelOffsetFromCenter += fEffects[PlayerOptions::EFFECT_BOUNCE] * ARROW_SIZE * 0.5f * fBounceAmt;
@@ -828,7 +830,7 @@ float ArrowEffects::GetXPos( const PlayerState* pPlayerState, int iColNum, float
{ {
// find the middle, and split based on iColNum // find the middle, and split based on iColNum
// it's unknown if this will work for routine. // it's unknown if this will work for routine.
const int iMiddleColumn = static_cast<int>(floor(pStyle->m_iColsPerPlayer/2.0f)); const int iMiddleColumn = std::floor(pStyle->m_iColsPerPlayer/2.0f);
if( iColNum > iMiddleColumn-1 ) if( iColNum > iMiddleColumn-1 )
fPixelOffsetFromCenter += fEffects[PlayerOptions::EFFECT_XMODE]*-(fYOffset); fPixelOffsetFromCenter += fEffects[PlayerOptions::EFFECT_XMODE]*-(fYOffset);
else else
@@ -855,7 +857,7 @@ float ArrowEffects::GetXPos( const PlayerState* pPlayerState, int iColNum, float
{ {
// Allow Tiny to pull tracks together, but not to push them apart. // Allow Tiny to pull tracks together, but not to push them apart.
float fTinyPercent = fEffects[PlayerOptions::EFFECT_TINY]; float fTinyPercent = fEffects[PlayerOptions::EFFECT_TINY];
fTinyPercent = std::min( powf(TINY_PERCENT_BASE, fTinyPercent), (float)TINY_PERCENT_GATE ); fTinyPercent = std::min( std::pow(TINY_PERCENT_BASE, fTinyPercent), (float)TINY_PERCENT_GATE );
fPixelOffsetFromCenter *= fTinyPercent; fPixelOffsetFromCenter *= fTinyPercent;
} }
@@ -907,7 +909,7 @@ float ArrowEffects::GetRotationZ( const PlayerState* pPlayerState, float fNoteBe
const float fSongBeat = pPlayerState->m_Position.m_fSongBeatVisible; const float fSongBeat = pPlayerState->m_Position.m_fSongBeatVisible;
float fDizzyRotation = fNoteBeat - fSongBeat; float fDizzyRotation = fNoteBeat - fSongBeat;
fDizzyRotation *= fEffects[PlayerOptions::EFFECT_DIZZY]; fDizzyRotation *= fEffects[PlayerOptions::EFFECT_DIZZY];
fDizzyRotation = fmodf( fDizzyRotation, 2*PI ); fDizzyRotation = std::fmod( fDizzyRotation, 2*PI );
fDizzyRotation *= 180/PI; fDizzyRotation *= 180/PI;
fRotation += fDizzyRotation; fRotation += fDizzyRotation;
} }
@@ -929,7 +931,7 @@ float ArrowEffects::ReceptorGetRotationZ( const PlayerState* pPlayerState, int i
{ {
float fConfRotation = pPlayerState->m_Position.m_fSongBeatVisible; float fConfRotation = pPlayerState->m_Position.m_fSongBeatVisible;
fConfRotation *= fEffects[PlayerOptions::EFFECT_CONFUSION]; fConfRotation *= fEffects[PlayerOptions::EFFECT_CONFUSION];
fConfRotation = fmodf( fConfRotation, 2*PI ); fConfRotation = std::fmod( fConfRotation, 2*PI );
fConfRotation *= -180/PI; fConfRotation *= -180/PI;
fRotation += fConfRotation; fRotation += fConfRotation;
} }
@@ -952,7 +954,7 @@ float ArrowEffects::ReceptorGetRotationX( const PlayerState* pPlayerState, int i
{ {
float fConfRotation = pPlayerState->m_Position.m_fSongBeatVisible; float fConfRotation = pPlayerState->m_Position.m_fSongBeatVisible;
fConfRotation *= fEffects[PlayerOptions::EFFECT_CONFUSION_X]; fConfRotation *= fEffects[PlayerOptions::EFFECT_CONFUSION_X];
fConfRotation = fmodf( fConfRotation, 2*PI ); fConfRotation = std::fmod( fConfRotation, 2*PI );
fConfRotation *= -180/PI; fConfRotation *= -180/PI;
fRotation += fConfRotation; fRotation += fConfRotation;
} }
@@ -975,7 +977,7 @@ float ArrowEffects::ReceptorGetRotationY( const PlayerState* pPlayerState, int i
{ {
float fConfRotation = pPlayerState->m_Position.m_fSongBeatVisible; float fConfRotation = pPlayerState->m_Position.m_fSongBeatVisible;
fConfRotation *= fEffects[PlayerOptions::EFFECT_CONFUSION_Y]; fConfRotation *= fEffects[PlayerOptions::EFFECT_CONFUSION_Y];
fConfRotation = fmodf( fConfRotation, 2*PI ); fConfRotation = std::fmod( fConfRotation, 2*PI );
fConfRotation *= -180/PI; fConfRotation *= -180/PI;
fRotation += fConfRotation; fRotation += fConfRotation;
} }
@@ -1115,7 +1117,7 @@ float ArrowGetPercentVisible(float fYPosWithoutReverse, int iCol, float fYOffset
if( fAppearances[PlayerOptions::APPEARANCE_RANDOMVANISH] != 0 ) if( fAppearances[PlayerOptions::APPEARANCE_RANDOMVANISH] != 0 )
{ {
const float fRealFadeDist = 80; const float fRealFadeDist = 80;
fVisibleAdjust += SCALE( fabsf(fDistFromCenterLine), fRealFadeDist, 2*fRealFadeDist, -1, 0 ) fVisibleAdjust += SCALE( std::abs(fDistFromCenterLine), fRealFadeDist, 2*fRealFadeDist, -1, 0 )
* fAppearances[PlayerOptions::APPEARANCE_RANDOMVANISH]; * fAppearances[PlayerOptions::APPEARANCE_RANDOMVANISH];
} }
@@ -1152,7 +1154,7 @@ float ArrowEffects::GetGlow( const PlayerState* pPlayerState, int iCol, float fY
if( fPercentFadeToFail != -1 ) if( fPercentFadeToFail != -1 )
fPercentVisible = 1 - fPercentFadeToFail; fPercentVisible = 1 - fPercentFadeToFail;
const float fDistFromHalf = fabsf( fPercentVisible - 0.5f ); const float fDistFromHalf = std::abs( fPercentVisible - 0.5f );
return SCALE( fDistFromHalf, 0, 0.5f, 1.3f, 0 ); return SCALE( fDistFromHalf, 0, 0.5f, 1.3f, 0 );
} }
@@ -1227,7 +1229,7 @@ float ArrowEffects::GetZPos( const PlayerState* pPlayerState, int iCol, float fY
if( fEffects[PlayerOptions::EFFECT_SAWTOOTH_Z] != 0 ) if( fEffects[PlayerOptions::EFFECT_SAWTOOTH_Z] != 0 )
fZPos += (fEffects[PlayerOptions::EFFECT_SAWTOOTH_Z]*ARROW_SIZE) * fZPos += (fEffects[PlayerOptions::EFFECT_SAWTOOTH_Z]*ARROW_SIZE) *
((0.5f/(fEffects[PlayerOptions::EFFECT_SAWTOOTH_Z_PERIOD]+1)*fYOffset)/ARROW_SIZE - ((0.5f/(fEffects[PlayerOptions::EFFECT_SAWTOOTH_Z_PERIOD]+1)*fYOffset)/ARROW_SIZE -
floor((0.5f/(fEffects[PlayerOptions::EFFECT_SAWTOOTH_Z_PERIOD]+1)*fYOffset)/ARROW_SIZE)); std::floor((0.5f/(fEffects[PlayerOptions::EFFECT_SAWTOOTH_Z_PERIOD]+1)*fYOffset)/ARROW_SIZE));
if( fEffects[PlayerOptions::EFFECT_PARABOLA_Z] != 0 ) if( fEffects[PlayerOptions::EFFECT_PARABOLA_Z] != 0 )
fZPos += fEffects[PlayerOptions::EFFECT_PARABOLA_Z] * (fYOffset/ARROW_SIZE) * (fYOffset/ARROW_SIZE); fZPos += fEffects[PlayerOptions::EFFECT_PARABOLA_Z] * (fYOffset/ARROW_SIZE) * (fYOffset/ARROW_SIZE);
@@ -1262,14 +1264,14 @@ float ArrowEffects::GetZPos( const PlayerState* pPlayerState, int iCol, float fY
if( fEffects[PlayerOptions::EFFECT_DIGITAL_Z] != 0 ) if( fEffects[PlayerOptions::EFFECT_DIGITAL_Z] != 0 )
fZPos += (fEffects[PlayerOptions::EFFECT_DIGITAL_Z] * ARROW_SIZE * 0.5f) * fZPos += (fEffects[PlayerOptions::EFFECT_DIGITAL_Z] * ARROW_SIZE * 0.5f) *
round((fEffects[PlayerOptions::EFFECT_DIGITAL_Z_STEPS]+1) * RageFastSin( std::round((fEffects[PlayerOptions::EFFECT_DIGITAL_Z_STEPS]+1) * RageFastSin(
CalculateDigitalAngle(fYOffset, CalculateDigitalAngle(fYOffset,
fEffects[PlayerOptions::EFFECT_DIGITAL_Z_OFFSET], fEffects[PlayerOptions::EFFECT_DIGITAL_Z_OFFSET],
fEffects[PlayerOptions::EFFECT_DIGITAL_Z_PERIOD]) ) ) /(fEffects[PlayerOptions::EFFECT_DIGITAL_Z_STEPS]+1); fEffects[PlayerOptions::EFFECT_DIGITAL_Z_PERIOD]) ) ) /(fEffects[PlayerOptions::EFFECT_DIGITAL_Z_STEPS]+1);
if( fEffects[PlayerOptions::EFFECT_TAN_DIGITAL_Z] != 0 ) if( fEffects[PlayerOptions::EFFECT_TAN_DIGITAL_Z] != 0 )
fZPos += (fEffects[PlayerOptions::EFFECT_TAN_DIGITAL_Z] * ARROW_SIZE * 0.5f) * fZPos += (fEffects[PlayerOptions::EFFECT_TAN_DIGITAL_Z] * ARROW_SIZE * 0.5f) *
round((fEffects[PlayerOptions::EFFECT_TAN_DIGITAL_Z_STEPS]+1) * SelectTanType( std::round((fEffects[PlayerOptions::EFFECT_TAN_DIGITAL_Z_STEPS]+1) * SelectTanType(
CalculateDigitalAngle(fYOffset, CalculateDigitalAngle(fYOffset,
fEffects[PlayerOptions::EFFECT_TAN_DIGITAL_Z_OFFSET], fEffects[PlayerOptions::EFFECT_TAN_DIGITAL_Z_OFFSET],
fEffects[PlayerOptions::EFFECT_TAN_DIGITAL_Z_PERIOD]), curr_options->m_bCosecant ) ) /(fEffects[PlayerOptions::EFFECT_TAN_DIGITAL_Z_STEPS]+1); fEffects[PlayerOptions::EFFECT_TAN_DIGITAL_Z_PERIOD]), curr_options->m_bCosecant ) ) /(fEffects[PlayerOptions::EFFECT_TAN_DIGITAL_Z_STEPS]+1);
@@ -1284,7 +1286,7 @@ float ArrowEffects::GetZPos( const PlayerState* pPlayerState, int iCol, float fY
if( fEffects[PlayerOptions::EFFECT_BOUNCE_Z] != 0 ) if( fEffects[PlayerOptions::EFFECT_BOUNCE_Z] != 0 )
{ {
float fBounceAmt = fabsf( RageFastSin( ( (fYOffset + (1.0f * (fEffects[PlayerOptions::EFFECT_BOUNCE_Z_OFFSET]) ) ) / float fBounceAmt = std::abs( RageFastSin( ( (fYOffset + (1.0f * (fEffects[PlayerOptions::EFFECT_BOUNCE_Z_OFFSET]) ) ) /
( 60 + (fEffects[PlayerOptions::EFFECT_BOUNCE_Z_PERIOD]*60) ) ) ) ); ( 60 + (fEffects[PlayerOptions::EFFECT_BOUNCE_Z_PERIOD]*60) ) ) ) );
fZPos += fEffects[PlayerOptions::EFFECT_BOUNCE_Z] * ARROW_SIZE * 0.5f * fBounceAmt; fZPos += fEffects[PlayerOptions::EFFECT_BOUNCE_Z] * ARROW_SIZE * 0.5f * fBounceAmt;
@@ -1344,12 +1346,12 @@ float ArrowEffects::GetZoom( const PlayerState* pPlayerState, float fYOffset, in
float fTinyPercent = curr_options->m_fEffects[PlayerOptions::EFFECT_TINY]; float fTinyPercent = curr_options->m_fEffects[PlayerOptions::EFFECT_TINY];
if( fTinyPercent != 0 ) if( fTinyPercent != 0 )
{ {
fTinyPercent = powf( 0.5f, fTinyPercent ); fTinyPercent = std::pow( 0.5f, fTinyPercent );
fZoom *= fTinyPercent; fZoom *= fTinyPercent;
} }
if( curr_options->m_fTiny[iCol] != 0 ) if( curr_options->m_fTiny[iCol] != 0 )
{ {
fTinyPercent = powf( 0.5f, curr_options->m_fTiny[iCol] ); fTinyPercent = std::pow( 0.5f, curr_options->m_fTiny[iCol] );
fZoom *= fTinyPercent; fZoom *= fTinyPercent;
} }
return fZoom; return fZoom;
+4 -3
View File
@@ -3,10 +3,11 @@
#include "GameState.h" #include "GameState.h"
#include "RageUtil.h" #include "RageUtil.h"
#include "Song.h" #include "Song.h"
#include "PlayerOptions.h" #include "PlayerOptions.h"
#include "PlayerState.h" #include "PlayerState.h"
#include <cmath>
void Attack::GetAttackBeats( const Song *pSong, float &fStartBeat, float &fEndBeat ) const void Attack::GetAttackBeats( const Song *pSong, float &fStartBeat, float &fEndBeat ) const
{ {
ASSERT( pSong != nullptr ); ASSERT( pSong != nullptr );
@@ -34,13 +35,13 @@ void Attack::GetRealtimeAttackBeats( const Song *pSong, const PlayerState* pPlay
/* If reasonable, push the attack forward 8 beats so that notes on screen don't change suddenly. */ /* If reasonable, push the attack forward 8 beats so that notes on screen don't change suddenly. */
fStartBeat = std::min( GAMESTATE->m_Position.m_fSongBeat+8, pPlayerState->m_fLastDrawnBeat ); fStartBeat = std::min( GAMESTATE->m_Position.m_fSongBeat+8, pPlayerState->m_fLastDrawnBeat );
fStartBeat = truncf(fStartBeat)+1; fStartBeat = std::trunc(fStartBeat) + 1;
const TimingData &timing = pSong->m_SongTiming; const TimingData &timing = pSong->m_SongTiming;
const float lStartSecond = timing.GetElapsedTimeFromBeat( fStartBeat ); const float lStartSecond = timing.GetElapsedTimeFromBeat( fStartBeat );
const float fEndSecond = lStartSecond + fSecsRemaining; const float fEndSecond = lStartSecond + fSecsRemaining;
fEndBeat = timing.GetBeatFromElapsedTime( fEndSecond ); fEndBeat = timing.GetBeatFromElapsedTime( fEndSecond );
fEndBeat = truncf(fEndBeat)+1; fEndBeat = std::trunc(fEndBeat) + 1;
// loading the course should have caught this. // loading the course should have caught this.
ASSERT_M( fEndBeat >= fStartBeat, ssprintf("EndBeat %f >= StartBeat %f", fEndBeat, fStartBeat) ); ASSERT_M( fEndBeat >= fStartBeat, ssprintf("EndBeat %f >= StartBeat %f", fEndBeat, fStartBeat) );
+2 -2
View File
@@ -322,8 +322,8 @@ void AutoKeysounds::Update( float fDelta )
iRowNow = std::max( 0, iRowNow ); iRowNow = std::max( 0, iRowNow );
static int iRowLastCrossed = 0; static int iRowLastCrossed = 0;
float fBeatLast = roundf(NoteRowToBeat(iRowLastCrossed)); float fBeatLast = std::round(NoteRowToBeat(iRowLastCrossed));
float fBeatNow = roundf(NoteRowToBeat(iRowNow)); float fBeatNow = std::round(NoteRowToBeat(iRowNow));
bCrossedABeat = fBeatLast != fBeatNow; bCrossedABeat = fBeatLast != fBeatNow;
+4 -2
View File
@@ -14,6 +14,8 @@
#include "AutoActor.h" #include "AutoActor.h"
#include "ThemeManager.h" #include "ThemeManager.h"
#include <cmath>
const float PARTICLE_SPEED = 300; const float PARTICLE_SPEED = 300;
@@ -627,8 +629,8 @@ void BGAnimationLayer::UpdateInternal( float fDeltaTime )
fX += m_fTilesSpacingX/2; fX += m_fTilesSpacingX/2;
fY += m_fTilesSpacingY/2; fY += m_fTilesSpacingY/2;
fX = fmodf( fX, fTotalWidth ); fX = std::fmod( fX, fTotalWidth );
fY = fmodf( fY, fTotalHeight ); fY = std::fmod( fY, fTotalHeight );
if( fX < 0 ) fX += fTotalWidth; if( fX < 0 ) fX += fTotalWidth;
if( fY < 0 ) fY += fTotalHeight; if( fY < 0 ) fY += fTotalHeight;
+3 -2
View File
@@ -11,6 +11,7 @@
#include "Song.h" #include "Song.h"
#include "Steps.h" #include "Steps.h"
#include <cmath>
#include <limits.h> #include <limits.h>
REGISTER_ACTOR_CLASS( BPMDisplay ); REGISTER_ACTOR_CLASS( BPMDisplay );
@@ -117,8 +118,8 @@ void BPMDisplay::SetBPMRange( const DisplayBpms &bpms )
int MaxBPM = INT_MIN; int MaxBPM = INT_MIN;
for( unsigned i = 0; i < BPMS.size(); ++i ) for( unsigned i = 0; i < BPMS.size(); ++i )
{ {
MinBPM = std::min( MinBPM, (int) lrintf(BPMS[i]) ); MinBPM = std::min( MinBPM, static_cast<int>(std::lrint(BPMS[i])) );
MaxBPM = std::max( MaxBPM, (int) lrintf(BPMS[i]) ); MaxBPM = std::max( MaxBPM, static_cast<int>(std::lrint(BPMS[i])) );
} }
if( MinBPM == MaxBPM ) if( MinBPM == MaxBPM )
{ {
+2 -1
View File
@@ -17,13 +17,14 @@
#include "ThemeMetric.h" #include "ThemeMetric.h"
#include "PlayerState.h" #include "PlayerState.h"
#include "ActorUtil.h" #include "ActorUtil.h"
#include <float.h>
#include "XmlFile.h" #include "XmlFile.h"
#include "XmlFileUtil.h" #include "XmlFileUtil.h"
#include "BackgroundUtil.h" #include "BackgroundUtil.h"
#include "Song.h" #include "Song.h"
#include "AutoActor.h" #include "AutoActor.h"
#include <cfloat>
static ThemeMetric<float> LEFT_EDGE ("Background","LeftEdge"); static ThemeMetric<float> LEFT_EDGE ("Background","LeftEdge");
static ThemeMetric<float> TOP_EDGE ("Background","TopEdge"); static ThemeMetric<float> TOP_EDGE ("Background","TopEdge");
static ThemeMetric<float> RIGHT_EDGE ("Background","RightEdge"); static ThemeMetric<float> RIGHT_EDGE ("Background","RightEdge");
+9 -7
View File
@@ -10,6 +10,8 @@
#include "ActorUtil.h" #include "ActorUtil.h"
#include "LuaBinding.h" #include "LuaBinding.h"
#include <cmath>
REGISTER_ACTOR_CLASS( BitmapText ); REGISTER_ACTOR_CLASS( BitmapText );
@@ -277,7 +279,7 @@ void BitmapText::BuildChars()
m_size.y += iPadding * int(m_wTextLines.size()-1); m_size.y += iPadding * int(m_wTextLines.size()-1);
// the top position of the first row of characters // the top position of the first row of characters
int iY = lrintf(-m_size.y/2.0f); int iY = std::lrint(-m_size.y/2.0f);
for( unsigned i=0; i<m_wTextLines.size(); i++ ) // foreach line for( unsigned i=0; i<m_wTextLines.size(); i++ ) // foreach line
{ {
@@ -289,7 +291,7 @@ void BitmapText::BuildChars()
const int iLineWidth = m_iLineWidths[i]; const int iLineWidth = m_iLineWidths[i];
float fX = SCALE( m_fHorizAlign, 0.0f, 1.0f, -m_size.x/2.0f, +m_size.x/2.0f - iLineWidth ); float fX = SCALE( m_fHorizAlign, 0.0f, 1.0f, -m_size.x/2.0f, +m_size.x/2.0f - iLineWidth );
int iX = lrintf( fX ); int iX = std::lrint( fX );
for( unsigned j = 0; j < sLine.size(); ++j ) for( unsigned j = 0; j < sLine.size(); ++j )
{ {
@@ -326,7 +328,7 @@ void BitmapText::BuildChars()
if( m_bUsingDistortion ) if( m_bUsingDistortion )
{ {
int iSeed = lrintf( RageTimer::GetTimeSinceStartFast()*500000.0f ); int iSeed = std::lrint( RageTimer::GetTimeSinceStartFast()*500000.0f );
RandomGen rnd( iSeed ); RandomGen rnd( iSeed );
for(unsigned int i= 0; i < m_aVertices.size(); i+=4) for(unsigned int i= 0; i < m_aVertices.size(); i+=4)
{ {
@@ -349,8 +351,8 @@ void BitmapText::DrawChars( bool bUseStrokeTexture )
return; return;
const int iNumGlyphs = m_vpFontPageTextures.size(); const int iNumGlyphs = m_vpFontPageTextures.size();
int iStartGlyph = lrintf( SCALE( m_pTempState->crop.left, 0.f, 1.f, 0, (float) iNumGlyphs ) ); int iStartGlyph = std::lrint( SCALE( m_pTempState->crop.left, 0.f, 1.f, 0, (float) iNumGlyphs ) );
int iEndGlyph = lrintf( SCALE( m_pTempState->crop.right, 0.f, 1.f, (float) iNumGlyphs, 0 ) ); int iEndGlyph = std::lrint( SCALE( m_pTempState->crop.right, 0.f, 1.f, (float) iNumGlyphs, 0 ) );
iStartGlyph = clamp( iStartGlyph, 0, iNumGlyphs ); iStartGlyph = clamp( iStartGlyph, 0, iNumGlyphs );
iEndGlyph = clamp( iEndGlyph, 0, iNumGlyphs ); iEndGlyph = clamp( iEndGlyph, 0, iNumGlyphs );
@@ -612,7 +614,7 @@ void BitmapText::UpdateBaseZoom()
} \ } \
if(dimension != 0) \ if(dimension != 0) \
{ \ { \
const float zoom= fmin(1, dimension_max / dimension); \ const float zoom= std::fmin(1, dimension_max / dimension); \
base_zoom_set(zoom); \ base_zoom_set(zoom); \
} \ } \
} }
@@ -766,7 +768,7 @@ void BitmapText::DrawPrimitives()
std::vector<RageVector3> vGlyphJitter; std::vector<RageVector3> vGlyphJitter;
if( m_bJitter ) if( m_bJitter )
{ {
int iSeed = lrintf( RageTimer::GetTimeSinceStartFast()*8 ); int iSeed = std::lrint( RageTimer::GetTimeSinceStartFast()*8 );
RandomGen rnd( iSeed ); RandomGen rnd( iSeed );
for( unsigned i=0; i<m_aVertices.size(); i+=4 ) for( unsigned i=0; i<m_aVertices.size(); i+=4 )
+2 -1
View File
@@ -14,7 +14,8 @@
#include "CourseWriterCRS.h" #include "CourseWriterCRS.h"
#include "RageUtil.h" #include "RageUtil.h"
#include "CourseUtil.h" #include "CourseUtil.h"
#include <float.h>
#include <cfloat>
/** @brief Edit courses can only be so big before they are rejected. */ /** @brief Edit courses can only be so big before they are rejected. */
const int MAX_EDIT_COURSE_SIZE_BYTES = 32*1024; // 32KB const int MAX_EDIT_COURSE_SIZE_BYTES = 32*1024; // 32KB
+3 -1
View File
@@ -7,6 +7,8 @@
#include "RageUtil.h" #include "RageUtil.h"
#include "LuaBinding.h" #include "LuaBinding.h"
#include <cmath>
DynamicActorScroller *DynamicActorScroller::Copy() const { return new DynamicActorScroller(*this); } DynamicActorScroller *DynamicActorScroller::Copy() const { return new DynamicActorScroller(*this); }
void DynamicActorScroller::LoadFromNode( const XNode *pNode ) void DynamicActorScroller::LoadFromNode( const XNode *pNode )
@@ -84,7 +86,7 @@ void DynamicActorScroller::ShiftSubActors( int iDist )
* reconfigures much fewer actors. */ * reconfigures much fewer actors. */
int iWrapped = iDist; int iWrapped = iDist;
wrap( iWrapped, m_iNumItems ); wrap( iWrapped, m_iNumItems );
if( abs(iWrapped) < abs(iDist) ) if( std::abs(iWrapped) < std::abs(iDist) )
iDist = iWrapped; iDist = iWrapped;
} }
+3 -1
View File
@@ -11,6 +11,8 @@
#include "FontCharAliases.h" #include "FontCharAliases.h"
#include "arch/Dialog/Dialog.h" #include "arch/Dialog/Dialog.h"
#include <cmath>
FontPage::FontPage(): m_iHeight(0), m_iLineSpacing(0), m_fVshift(0), FontPage::FontPage(): m_iHeight(0), m_iLineSpacing(0), m_fVshift(0),
m_iDrawExtraPixelsLeft(0), m_iDrawExtraPixelsRight(0), m_iDrawExtraPixelsLeft(0), m_iDrawExtraPixelsRight(0),
m_FontPageTextures(), m_sTexturePath(""), m_aGlyphs(), m_FontPageTextures(), m_sTexturePath(""), m_aGlyphs(),
@@ -101,7 +103,7 @@ void FontPage::Load( const FontPageSettings &cfg )
if( cfg.m_fScaleAllWidthsBy != 1 ) if( cfg.m_fScaleAllWidthsBy != 1 )
{ {
for( int i=0; i<m_FontPageTextures.m_pTextureMain->GetNumFrames(); i++ ) for( int i=0; i<m_FontPageTextures.m_pTextureMain->GetNumFrames(); i++ )
aiFrameWidths[i] = lrintf( aiFrameWidths[i] * cfg.m_fScaleAllWidthsBy ); aiFrameWidths[i] = std::lrint( aiFrameWidths[i] * cfg.m_fScaleAllWidthsBy );
} }
m_iCharToGlyphNo = cfg.CharToGlyphNo; m_iCharToGlyphNo = cfg.CharToGlyphNo;
+4 -2
View File
@@ -9,7 +9,9 @@
#include "GameManager.h" #include "GameManager.h"
#include "LocalizedString.h" #include "LocalizedString.h"
#include "PlayerNumber.h" #include "PlayerNumber.h"
#include <float.h>
#include <cfloat>
#include <cmath>
RString StepsTypeToString( StepsType st ); RString StepsTypeToString( StepsType st );
@@ -406,7 +408,7 @@ float DisplayBpms::GetMaxWithin(float highest) const
bool DisplayBpms::BpmIsConstant() const bool DisplayBpms::BpmIsConstant() const
{ {
return fabsf( GetMin() - GetMax() ) < 0.001f; return std::abs( GetMin() - GetMax() ) < 0.001f;
} }
bool DisplayBpms::IsSecret() const bool DisplayBpms::IsSecret() const
+2 -1
View File
@@ -4,7 +4,8 @@
#define GAME_CONSTANTS_AND_TYPES_H #define GAME_CONSTANTS_AND_TYPES_H
#include "EnumHelper.h" #include "EnumHelper.h"
#include <float.h> // need the max for default.
#include <cfloat>
// Note definitions // Note definitions
/** @brief Define the mininum difficulty value allowed. */ /** @brief Define the mininum difficulty value allowed. */
+3 -1
View File
@@ -21,6 +21,8 @@
#include "RageTimer.h" #include "RageTimer.h"
#include "RageInput.h" #include "RageInput.h"
#include <cmath>
static RageTimer g_GameplayTimer; static RageTimer g_GameplayTimer;
static Preference<bool> g_bNeverBoostAppPriority( "NeverBoostAppPriority", false ); static Preference<bool> g_bNeverBoostAppPriority( "NeverBoostAppPriority", false );
@@ -56,7 +58,7 @@ static void CheckGameLoopTimerSkips( float fDeltaTime )
const float fExpectedTime = 1.0f / iThisFPS; const float fExpectedTime = 1.0f / iThisFPS;
const float fDifference = fDeltaTime - fExpectedTime; const float fDifference = fDeltaTime - fExpectedTime;
if( fabsf(fDifference) > 0.002f && fabsf(fDifference) < 0.100f ) if( std::abs(fDifference) > 0.002f && std::abs(fDifference) < 0.100f )
LOG->Trace( "GameLoop timer skip: %i FPS, expected %.3f, got %.3f (%.3f difference)", LOG->Trace( "GameLoop timer skip: %i FPS, expected %.3f, got %.3f (%.3f difference)",
iThisFPS, fExpectedTime, fDeltaTime, fDifference ); iThisFPS, fExpectedTime, fDeltaTime, fDifference );
} }
+8 -6
View File
@@ -20,13 +20,15 @@
#include "arch/Sound/RageSoundDriver.h" #include "arch/Sound/RageSoundDriver.h"
#include <cmath>
GameSoundManager *SOUND = nullptr; GameSoundManager *SOUND = nullptr;
/* /*
* When playing music, automatically search for an SM file for timing data. If one is * When playing music, automatically search for an SM file for timing data. If one is
* found, automatically handle GAMESTATE->m_fSongBeat, etc. * found, automatically handle GAMESTATE->m_fSongBeat, etc.
* *
* modf(GAMESTATE->m_fSongBeat) should always be continuously moving from 0 to 1. To do * std::modf(GAMESTATE->m_fSongBeat) should always be continuously moving from 0 to 1. To do
* this, wait before starting a sound until the fractional portion of the beat will be * this, wait before starting a sound until the fractional portion of the beat will be
* the same. * the same.
* *
@@ -236,7 +238,7 @@ static void StartMusic( MusicToPlay &ToPlay )
const float fStartBeat = NewMusic->m_NewTiming.GetBeatFromElapsedTimeNoOffset( ToPlay.fStartSecond ); const float fStartBeat = NewMusic->m_NewTiming.GetBeatFromElapsedTimeNoOffset( ToPlay.fStartSecond );
const float fStartBeatFraction = fmodfp( fStartBeat, 1 ); const float fStartBeatFraction = fmodfp( fStartBeat, 1 );
float fCurBeatToStartOn = truncf(fCurBeat) + fStartBeatFraction; float fCurBeatToStartOn = std::trunc(fCurBeat) + fStartBeatFraction;
if( fCurBeatToStartOn < fCurBeat ) if( fCurBeatToStartOn < fCurBeat )
fCurBeatToStartOn += 1.0f; fCurBeatToStartOn += 1.0f;
@@ -503,7 +505,7 @@ float GameSoundManager::GetFrameTimingAdjustment( float fDeltaTime )
const float fExpectedDelay = 1.0f / iThisFPS; const float fExpectedDelay = 1.0f / iThisFPS;
const float fExtraDelay = fDeltaTime - fExpectedDelay; const float fExtraDelay = fDeltaTime - fExpectedDelay;
if( fabsf(fExtraDelay) >= fExpectedDelay/2 ) if( std::abs(fExtraDelay) >= fExpectedDelay/2 )
return 0; return 0;
/* Subtract the extra delay. */ /* Subtract the extra delay. */
@@ -550,7 +552,7 @@ void GameSoundManager::Update( float fDeltaTime )
case FADE_NONE: break; case FADE_NONE: break;
case FADE_OUT: case FADE_OUT:
fapproach( fVolume, g_fDimVolume, fDeltaTime/fFadeOutSpeed ); fapproach( fVolume, g_fDimVolume, fDeltaTime/fFadeOutSpeed );
if( fabsf(fVolume-g_fDimVolume) < 0.001f ) if( std::abs(fVolume-g_fDimVolume) < 0.001f )
g_FadeState = FADE_WAIT; g_FadeState = FADE_WAIT;
break; break;
case FADE_WAIT: case FADE_WAIT:
@@ -560,7 +562,7 @@ void GameSoundManager::Update( float fDeltaTime )
break; break;
case FADE_IN: case FADE_IN:
fapproach( fVolume, g_fOriginalVolume, fDeltaTime/fFadeInSpeed ); fapproach( fVolume, g_fOriginalVolume, fDeltaTime/fFadeInSpeed );
if( fabsf(fVolume-g_fOriginalVolume) < 0.001f ) if( std::abs(fVolume-g_fOriginalVolume) < 0.001f )
g_FadeState = FADE_NONE; g_FadeState = FADE_NONE;
break; break;
} }
@@ -604,7 +606,7 @@ void GameSoundManager::Update( float fDeltaTime )
const RString ThisFile = g_Playing->m_Music->GetLoadedFilePath(); const RString ThisFile = g_Playing->m_Music->GetLoadedFilePath();
/* If fSoundTimePassed < 0, the sound has probably looped. */ /* If fSoundTimePassed < 0, the sound has probably looped. */
if( sLastFile == ThisFile && fSoundTimePassed >= 0 && fabsf(fDiff) > 0.003f ) if( sLastFile == ThisFile && fSoundTimePassed >= 0 && std::abs(fDiff) > 0.003f )
LOG->Trace("Song position skip in %s: expected %.3f, got %.3f (cur %f, prev %f) (%.3f difference)", LOG->Trace("Song position skip in %s: expected %.3f, got %.3f (cur %f, prev %f) (%.3f difference)",
Basename(ThisFile).c_str(), fExpectedTimePassed, fSoundTimePassed, fSeconds, GAMESTATE->m_Position.m_fMusicSeconds, fDiff ); Basename(ThisFile).c_str(), fExpectedTimePassed, fSoundTimePassed, fSeconds, GAMESTATE->m_Position.m_fMusicSeconds, fDiff );
sLastFile = ThisFile; sLastFile = ThisFile;
+2 -1
View File
@@ -42,6 +42,7 @@
#include "ScreenManager.h" #include "ScreenManager.h"
#include "Screen.h" #include "Screen.h"
#include <cmath>
#include <ctime> #include <ctime>
#include <set> #include <set>
@@ -1853,7 +1854,7 @@ StageResult GameState::GetStageResult( PlayerNumber pn ) const
{ {
case PLAY_MODE_BATTLE: case PLAY_MODE_BATTLE:
case PLAY_MODE_RAVE: case PLAY_MODE_RAVE:
if( fabsf(m_fTugLifePercentP1 - 0.5f) < 0.0001f ) if( std::abs(m_fTugLifePercentP1 - 0.5f) < 0.0001f )
return RESULT_DRAW; return RESULT_DRAW;
switch( pn ) switch( pn )
{ {
+3 -1
View File
@@ -11,6 +11,8 @@
#include "Song.h" #include "Song.h"
#include "XmlFile.h" #include "XmlFile.h"
#include <cmath>
//#define DIVIDE_LINE_WIDTH THEME->GetMetricI(m_sName,"TexturedBottomHalf") //#define DIVIDE_LINE_WIDTH THEME->GetMetricI(m_sName,"TexturedBottomHalf")
REGISTER_ACTOR_CLASS( GraphDisplay ); REGISTER_ACTOR_CLASS( GraphDisplay );
@@ -76,7 +78,7 @@ public:
float opp = p2.p.x - p1.p.x; float opp = p2.p.x - p1.p.x;
float adj = p2.p.y - p1.p.y; float adj = p2.p.y - p1.p.y;
float hyp = powf(opp*opp + adj*adj, 0.5f); float hyp = std::pow(opp*opp + adj*adj, 0.5f);
float lsin = opp/hyp; float lsin = opp/hyp;
float lcos = adj/hyp; float lcos = adj/hyp;
+3 -2
View File
@@ -17,9 +17,10 @@
#include "RageSurfaceUtils_Dither.h" #include "RageSurfaceUtils_Dither.h"
#include "RageSurfaceUtils_Zoom.h" #include "RageSurfaceUtils_Zoom.h"
#include "SpecialFiles.h" #include "SpecialFiles.h"
#include "Banner.h" #include "Banner.h"
#include <cmath>
static Preference<bool> g_bPalettedImageCache( "PalettedImageCache", false ); static Preference<bool> g_bPalettedImageCache( "PalettedImageCache", false );
/* Neither a global or a file scope static can be used for this because /* Neither a global or a file scope static can be used for this because
@@ -325,7 +326,7 @@ RageTextureID ImageCache::LoadCachedImage( RString sImageDir, RString sImagePath
static inline int closest( int num, int n1, int n2 ) static inline int closest( int num, int n1, int n2 )
{ {
if( abs(num - n1) > abs(num - n2) ) if( std::abs(num - n1) > std::abs(num - n2) )
return n2; return n2;
return n1; return n1;
} }
+3 -1
View File
@@ -7,6 +7,8 @@
#include "Course.h" #include "Course.h"
#include "ActorUtil.h" #include "ActorUtil.h"
#include <cmath>
LifeMeterBattery::LifeMeterBattery() LifeMeterBattery::LifeMeterBattery()
{ {
m_iLivesLeft= 4; m_iLivesLeft= 4;
@@ -144,7 +146,7 @@ void LifeMeterBattery::AddLives( int iLives )
void LifeMeterBattery::ChangeLives(int iLifeDiff) void LifeMeterBattery::ChangeLives(int iLifeDiff)
{ {
if( iLifeDiff < 0 ) if( iLifeDiff < 0 )
SubtractLives( abs(iLifeDiff) ); SubtractLives( std::abs(iLifeDiff) );
else if( iLifeDiff > 0 ) else if( iLifeDiff > 0 )
AddLives(iLifeDiff); AddLives(iLifeDiff);
} }
+3 -1
View File
@@ -14,6 +14,8 @@
#include "CommonMetrics.h" #include "CommonMetrics.h"
#include "Style.h" #include "Style.h"
#include <cmath>
const RString DEFAULT_LIGHTS_DRIVER = "SystemMessage,Export"; const RString DEFAULT_LIGHTS_DRIVER = "SystemMessage,Export";
static Preference<RString> g_sLightsDriver( "LightsDriver", "" ); // "" == DEFAULT_LIGHTS_DRIVER static Preference<RString> g_sLightsDriver( "LightsDriver", "" ); // "" == DEFAULT_LIGHTS_DRIVER
Preference<float> g_fLightsFalloffSeconds( "LightsFalloffSeconds", 0.1f ); Preference<float> g_fLightsFalloffSeconds( "LightsFalloffSeconds", 0.1f );
@@ -203,7 +205,7 @@ void LightsManager::Update( float fDeltaTime )
if( m_LightsMode == LIGHTSMODE_TEST_AUTO_CYCLE ) if( m_LightsMode == LIGHTSMODE_TEST_AUTO_CYCLE )
{ {
m_fTestAutoCycleCurrentIndex += fDeltaTime; m_fTestAutoCycleCurrentIndex += fDeltaTime;
m_fTestAutoCycleCurrentIndex = fmodf( m_fTestAutoCycleCurrentIndex, NUM_CabinetLight*100 ); m_fTestAutoCycleCurrentIndex = std::fmod( m_fTestAutoCycleCurrentIndex, NUM_CabinetLight*100 );
} }
switch( m_LightsMode ) switch( m_LightsMode )
+2 -1
View File
@@ -16,6 +16,7 @@
#include <sstream> // conversion for lua functions. #include <sstream> // conversion for lua functions.
#include <csetjmp> #include <csetjmp>
#include <cassert> #include <cassert>
#include <cmath>
#include <map> #include <map>
LuaManager *LUA = nullptr; LuaManager *LUA = nullptr;
@@ -740,7 +741,7 @@ XNode *LuaHelpers::GetLuaInformation()
XNode *pConstantNode = pConstantsNode->AppendChild( "Constant" ); XNode *pConstantNode = pConstantsNode->AppendChild( "Constant" );
pConstantNode->AppendAttr( "name", c.first ); pConstantNode->AppendAttr( "name", c.first );
if( c.second == truncf(c.second) ) if( c.second == std::trunc(c.second) )
pConstantNode->AppendAttr( "value", static_cast<int>(c.second) ); pConstantNode->AppendAttr( "value", static_cast<int>(c.second) );
else else
pConstantNode->AppendAttr( "value", c.second ); pConstantNode->AppendAttr( "value", c.second );
+3 -1
View File
@@ -9,6 +9,8 @@
#include "ThemeMetric.h" #include "ThemeMetric.h"
#include "ActorUtil.h" #include "ActorUtil.h"
#include <cmath>
RString WARNING_COMMAND_NAME( size_t i ) { return ssprintf("Warning%dCommand",int(i)); } RString WARNING_COMMAND_NAME( size_t i ) { return ssprintf("Warning%dCommand",int(i)); }
static const float TIMER_PAUSE_SECONDS = 99.99f; static const float TIMER_PAUSE_SECONDS = 99.99f;
@@ -100,7 +102,7 @@ void MenuTimer::Update( float fDeltaTime )
SOUND->PlayOnceFromAnnouncer( "hurry up" ); SOUND->PlayOnceFromAnnouncer( "hurry up" );
int iCrossed = (int)floorf(fOldSecondsLeft); int iCrossed = std::floor(fOldSecondsLeft);
if( fOldSecondsLeft > iCrossed && fNewSecondsLeft < iCrossed ) // crossed if( fOldSecondsLeft > iCrossed && fNewSecondsLeft < iCrossed ) // crossed
{ {
if( iCrossed <= WARNING_START ) if( iCrossed <= WARNING_START )
+2 -1
View File
@@ -9,6 +9,7 @@
#include "RageLog.h" #include "RageLog.h"
#include "RageDisplay.h" #include "RageDisplay.h"
#include <cmath>
#include <numeric> #include <numeric>
#define MS_MAX_NAME 32 #define MS_MAX_NAME 32
@@ -155,7 +156,7 @@ float AnimatedTexture::GetAnimationLengthSeconds() const
void AnimatedTexture::SetSecondsIntoAnimation( float fSeconds ) void AnimatedTexture::SetSecondsIntoAnimation( float fSeconds )
{ {
fSeconds = fmodf( fSeconds, GetAnimationLengthSeconds() ); fSeconds = std::fmod( fSeconds, GetAnimationLengthSeconds() );
m_iCurState = 0; m_iCurState = 0;
for( unsigned i=0; i<vFrames.size(); i++ ) for( unsigned i=0; i<vFrames.size(); i++ )
+3 -1
View File
@@ -23,10 +23,12 @@
#include "MessageManager.h" #include "MessageManager.h"
#include "LocalizedString.h" #include "LocalizedString.h"
#include <cmath>
static Preference<bool> g_bMoveRandomToEnd( "MoveRandomToEnd", false ); static Preference<bool> g_bMoveRandomToEnd( "MoveRandomToEnd", false );
static Preference<bool> g_bPrecacheAllSorts( "PreCacheAllWheelSorts", false); static Preference<bool> g_bPrecacheAllSorts( "PreCacheAllWheelSorts", false);
#define NUM_WHEEL_ITEMS ((int)ceil(NUM_WHEEL_ITEMS_TO_DRAW+2)) #define NUM_WHEEL_ITEMS ((int)std::ceil(NUM_WHEEL_ITEMS_TO_DRAW+2))
#define WHEEL_TEXT(s) THEME->GetString( "MusicWheel", ssprintf("%sText",s.c_str()) ); #define WHEEL_TEXT(s) THEME->GetString( "MusicWheel", ssprintf("%sText",s.c_str()) );
#define CUSTOM_ITEM_WHEEL_TEXT(s) THEME->GetString( "MusicWheel", ssprintf("CustomItem%sText",s.c_str()) ); #define CUSTOM_ITEM_WHEEL_TEXT(s) THEME->GetString( "MusicWheel", ssprintf("CustomItem%sText",s.c_str()) );
+12 -10
View File
@@ -9,6 +9,8 @@
#include "GameState.h" #include "GameState.h"
#include "RadarValues.h" #include "RadarValues.h"
#include "TimingData.h" #include "TimingData.h"
#include <cmath>
#include <utility> #include <utility>
// TODO: Remove these constants that aren't time signature-aware // TODO: Remove these constants that aren't time signature-aware
@@ -29,7 +31,7 @@ NoteType NoteDataUtil::GetSmallestNoteTypeInRange( const NoteData &n, int iStart
FOREACH_ENUM(NoteType, nt) FOREACH_ENUM(NoteType, nt)
{ {
float fBeatSpacing = NoteTypeToBeat( nt ); float fBeatSpacing = NoteTypeToBeat( nt );
int iRowSpacing = lrintf( fBeatSpacing * ROWS_PER_BEAT ); int iRowSpacing = std::lrint( fBeatSpacing * ROWS_PER_BEAT );
bool bFoundSmallerNote = false; bool bFoundSmallerNote = false;
// for each index in this measure // for each index in this measure
@@ -375,7 +377,7 @@ void NoteDataUtil::GetSMNoteDataString( const NoteData &in, RString &sRet )
if( nt == NoteType_Invalid ) if( nt == NoteType_Invalid )
iRowSpacing = 1; iRowSpacing = 1;
else else
iRowSpacing = lrintf( NoteTypeToBeat(nt) * ROWS_PER_BEAT ); iRowSpacing = std::lrint( NoteTypeToBeat(nt) * ROWS_PER_BEAT );
// (verify first) // (verify first)
// iRowSpacing = BeatToNoteRow( NoteTypeToBeat(nt) ); // iRowSpacing = BeatToNoteRow( NoteTypeToBeat(nt) );
@@ -515,7 +517,7 @@ void NoteDataUtil::LoadTransformedSlidingWindow( const NoteData &in, NoteData &o
int iCurTrackOffset = 0; int iCurTrackOffset = 0;
int iTrackOffsetMin = 0; int iTrackOffsetMin = 0;
int iTrackOffsetMax = abs( iNewNumTracks - in.GetNumTracks() ); int iTrackOffsetMax = std::abs( iNewNumTracks - in.GetNumTracks() );
int bOffsetIncreasing = true; int bOffsetIncreasing = true;
int iLastMeasure = 0; int iLastMeasure = 0;
@@ -2188,7 +2190,7 @@ void NoteDataUtil::Wide( NoteData &inout, int iStartIndex, int iEndIndex )
continue; // skip continue; // skip
// add a note determinitsitcally // add a note determinitsitcally
int iBeat = lrintf( NoteRowToBeat(i) ); int iBeat = std::lrint( NoteRowToBeat(i) );
int iTrackOfNote = inout.GetFirstTrackWithTap(i); int iTrackOfNote = inout.GetFirstTrackWithTap(i);
int iTrackToAdd = iTrackOfNote + (iBeat%5)-2; // won't be more than 2 tracks away from the existing note int iTrackToAdd = iTrackOfNote + (iBeat%5)-2; // won't be more than 2 tracks away from the existing note
CLAMP( iTrackToAdd, 0, inout.GetNumTracks()-1 ); CLAMP( iTrackToAdd, 0, inout.GetNumTracks()-1 );
@@ -2294,7 +2296,7 @@ void NoteDataUtil::InsertIntelligentTaps(
{ {
iTrackOfNoteToAdd = iTrackOfNoteEarlier; iTrackOfNoteToAdd = iTrackOfNoteEarlier;
} }
else if( abs(iTrackOfNoteEarlier-iTrackOfNoteLater) >= 2 ) else if( std::abs(iTrackOfNoteEarlier-iTrackOfNoteLater) >= 2 )
{ {
// try to choose a track between the earlier and later notes // try to choose a track between the earlier and later notes
iTrackOfNoteToAdd = std::min(iTrackOfNoteEarlier,iTrackOfNoteLater)+1; iTrackOfNoteToAdd = std::min(iTrackOfNoteEarlier,iTrackOfNoteLater)+1;
@@ -2628,7 +2630,7 @@ void NoteDataUtil::SnapToNearestNoteType( NoteData &inout, NoteType nt1, NoteTyp
int iNewIndex1 = Quantize( iOldIndex, BeatToNoteRow(fSnapInterval1) ); int iNewIndex1 = Quantize( iOldIndex, BeatToNoteRow(fSnapInterval1) );
int iNewIndex2 = Quantize( iOldIndex, BeatToNoteRow(fSnapInterval2) ); int iNewIndex2 = Quantize( iOldIndex, BeatToNoteRow(fSnapInterval2) );
bool bNewBeat1IsCloser = abs(iNewIndex1-iOldIndex) < abs(iNewIndex2-iOldIndex); bool bNewBeat1IsCloser = std::abs(iNewIndex1-iOldIndex) < std::abs(iNewIndex2-iOldIndex);
int iNewIndex = bNewBeat1IsCloser? iNewIndex1 : iNewIndex2; int iNewIndex = bNewBeat1IsCloser? iNewIndex1 : iNewIndex2;
for( int c=0; c<inout.GetNumTracks(); c++ ) for( int c=0; c<inout.GetNumTracks(); c++ )
@@ -2981,8 +2983,8 @@ void NoteDataUtil::Scale( NoteData &nd, float fScale )
for( NoteData::const_iterator iter = nd.begin(t); iter != nd.end(t); ++iter ) for( NoteData::const_iterator iter = nd.begin(t); iter != nd.end(t); ++iter )
{ {
TapNote tn = iter->second; TapNote tn = iter->second;
int iNewRow = lrintf( fScale * iter->first ); int iNewRow = std::lrint( fScale * iter->first );
int iNewDuration = lrintf( fScale * (iter->first + tn.iDuration) ); int iNewDuration = std::lrint( fScale * (iter->first + tn.iDuration) );
tn.iDuration = iNewDuration; tn.iDuration = iNewDuration;
ndOut.SetTapNote( t, iNewRow, tn ); ndOut.SetTapNote( t, iNewRow, tn );
} }
@@ -2998,9 +3000,9 @@ static inline int GetScaledRow( float fScale, int iStartIndex, int iEndIndex, in
if( iRow < iStartIndex ) if( iRow < iStartIndex )
return iRow; return iRow;
else if( iRow > iEndIndex ) else if( iRow > iEndIndex )
return iRow + lrintf( (iEndIndex - iStartIndex) * (fScale - 1) ); return iRow + std::lrint( (iEndIndex - iStartIndex) * (fScale - 1) );
else else
return lrintf( (iRow - iStartIndex) * fScale ) + iStartIndex; return std::lrint( (iRow - iStartIndex) * fScale ) + iStartIndex;
} }
void NoteDataUtil::ScaleRegion( NoteData &nd, float fScale, int iStartIndex, int iEndIndex ) void NoteDataUtil::ScaleRegion( NoteData &nd, float fScale, int iStartIndex, int iEndIndex )
+11 -9
View File
@@ -19,6 +19,8 @@
#include "Sprite.h" #include "Sprite.h"
#include "Style.h" #include "Style.h"
#include <cmath>
static Preference<bool> g_bRenderEarlierNotesOnTop( "RenderEarlierNotesOnTop", false ); static Preference<bool> g_bRenderEarlierNotesOnTop( "RenderEarlierNotesOnTop", false );
static const double PI_180= PI / 180.0; static const double PI_180= PI / 180.0;
@@ -664,13 +666,13 @@ void NoteDisplay::SetActiveFrame( float fNoteBeat, Actor &actorToSet, float fAni
/* -inf ... inf */ /* -inf ... inf */
float fBeatOrSecond = cache->m_bAnimationBasedOnBeats ? m_pPlayerState->m_Position.m_fSongBeat : m_pPlayerState->m_Position.m_fMusicSeconds; float fBeatOrSecond = cache->m_bAnimationBasedOnBeats ? m_pPlayerState->m_Position.m_fSongBeat : m_pPlayerState->m_Position.m_fMusicSeconds;
/* -len ... +len */ /* -len ... +len */
float fPercentIntoAnimation = fmodf( fBeatOrSecond, fAnimationLength ); float fPercentIntoAnimation = std::fmod( fBeatOrSecond, fAnimationLength );
/* -1 ... 1 */ /* -1 ... 1 */
fPercentIntoAnimation /= fAnimationLength; fPercentIntoAnimation /= fAnimationLength;
if( bVivid ) if( bVivid )
{ {
float fNoteBeatFraction = fmodf( fNoteBeat, 1.0f ); float fNoteBeatFraction = std::fmod( fNoteBeat, 1.0f );
const float fInterval = 1.f / fAnimationLength; const float fInterval = 1.f / fAnimationLength;
fPercentIntoAnimation += QuantizeDown( fNoteBeatFraction, fInterval ); fPercentIntoAnimation += QuantizeDown( fNoteBeatFraction, fInterval );
@@ -776,7 +778,7 @@ void NoteDisplay::DrawHoldPart(std::vector<Sprite*> &vpSpr,
float y_start_pos = (part_type == hpt_body) ? part_args.y_top : std::max(part_args.y_top, part_args.y_start_pos); float y_start_pos = (part_type == hpt_body) ? part_args.y_top : std::max(part_args.y_top, part_args.y_start_pos);
if (part_args.y_top < part_args.y_start_pos - unzoomed_frame_height) if (part_args.y_top < part_args.y_start_pos - unzoomed_frame_height)
{ {
y_start_pos = fmod((y_start_pos - part_args.y_start_pos), unzoomed_frame_height) + part_args.y_start_pos; y_start_pos = std::fmod((y_start_pos - part_args.y_start_pos), unzoomed_frame_height) + part_args.y_start_pos;
} }
float y_end_pos = std::min(part_args.y_bottom, part_args.y_end_pos); float y_end_pos = std::min(part_args.y_bottom, part_args.y_end_pos);
const float color_scale= glow ? 1 : part_args.color_scale; const float color_scale= glow ? 1 : part_args.color_scale;
@@ -800,7 +802,7 @@ void NoteDisplay::DrawHoldPart(std::vector<Sprite*> &vpSpr,
{ {
float tex_coord_bottom= SCALE(part_args.y_bottom - part_args.y_top, float tex_coord_bottom= SCALE(part_args.y_bottom - part_args.y_top,
0, unzoomed_frame_height, rect.top, rect.bottom); 0, unzoomed_frame_height, rect.top, rect.bottom);
float want_tex_coord_bottom = ceilf(tex_coord_bottom - 0.0001f); float want_tex_coord_bottom = std::ceil(tex_coord_bottom - 0.0001f);
add_to_tex_coord = want_tex_coord_bottom - tex_coord_bottom; add_to_tex_coord = want_tex_coord_bottom - tex_coord_bottom;
} }
@@ -811,7 +813,7 @@ void NoteDisplay::DrawHoldPart(std::vector<Sprite*> &vpSpr,
const float fDistFromTop = y_start_pos - part_args.y_top; const float fDistFromTop = y_start_pos - part_args.y_top;
float fTexCoordTop = SCALE(fDistFromTop, 0, unzoomed_frame_height, rect.top, rect.bottom); float fTexCoordTop = SCALE(fDistFromTop, 0, unzoomed_frame_height, rect.top, rect.bottom);
fTexCoordTop += add_to_tex_coord; fTexCoordTop += add_to_tex_coord;
add_to_tex_coord -= floorf(fTexCoordTop); add_to_tex_coord -= std::floor(fTexCoordTop);
} }
} }
// The bottom caps mysteriously hate me and their texture coords need to be // The bottom caps mysteriously hate me and their texture coords need to be
@@ -1078,7 +1080,7 @@ void NoteDisplay::DrawHoldBodyInternal(std::vector<Sprite*>& sprite_top,
part_args.y_top = y_tail + overlap_hack; part_args.y_top = y_tail + overlap_hack;
part_args.y_bottom = tail_plus_bottom + overlap_hack; part_args.y_bottom = tail_plus_bottom + overlap_hack;
part_args.top_beat = bottom_beat; part_args.top_beat = bottom_beat;
part_args.y_start_pos = fmaxf(part_args.y_start_pos, y_head); part_args.y_start_pos = std::fmax(part_args.y_start_pos, y_head);
part_args.wrapping = false; part_args.wrapping = false;
DrawHoldPart(sprite_bottom, field_args, column_args, part_args, glow, hpt_bottom); DrawHoldPart(sprite_bottom, field_args, column_args, part_args, glow, hpt_bottom);
} }
@@ -1352,15 +1354,15 @@ void NoteDisplay::DrawActor(const TapNote& tn, Actor* pActor, NotePart part,
color = clamp( color, 0.0f, (float) (cache->m_iNoteColorCount[part]-1) ); color = clamp( color, 0.0f, (float) (cache->m_iNoteColorCount[part]-1) );
break; break;
case NoteColorType_Progress: case NoteColorType_Progress:
color = fmodf( ceilf( fBeat * cache->m_iNoteColorCount[part] ), (float)cache->m_iNoteColorCount[part] ); color = std::fmod( std::ceil( fBeat * cache->m_iNoteColorCount[part] ), (float)cache->m_iNoteColorCount[part] );
break; break;
case NoteColorType_ProgressAlternate: case NoteColorType_ProgressAlternate:
fScaledBeat = fBeat * cache->m_iNoteColorCount[part]; fScaledBeat = fBeat * cache->m_iNoteColorCount[part];
if( fScaledBeat - int64_t(fScaledBeat) == 0.0f ) if( fScaledBeat - int64_t(fScaledBeat) == 0.0f )
//we're on a boundary, so move to the previous frame. //we're on a boundary, so move to the previous frame.
//doing it this way ensures that fScaledBeat is never negative so fmodf works. //doing it this way ensures that fScaledBeat is never negative so std::fmod works.
fScaledBeat += cache->m_iNoteColorCount[part] - 1; fScaledBeat += cache->m_iNoteColorCount[part] - 1;
color = fmodf( ceilf( fScaledBeat ), (float)cache->m_iNoteColorCount[part] ); color = std::fmod( std::ceil( fScaledBeat ), (float)cache->m_iNoteColorCount[part] );
break; break;
default: default:
FAIL_M(ssprintf("Invalid NoteColorType: %i", cache->m_NoteColorType[part])); FAIL_M(ssprintf("Invalid NoteColorType: %i", cache->m_NoteColorType[part]));
+5 -3
View File
@@ -15,12 +15,14 @@
#include "PlayerState.h" #include "PlayerState.h"
#include "Style.h" #include "Style.h"
#include "CommonMetrics.h" #include "CommonMetrics.h"
#include <float.h>
#include "BackgroundUtil.h" #include "BackgroundUtil.h"
#include "Course.h" #include "Course.h"
#include "NoteData.h" #include "NoteData.h"
#include "RageDisplay.h" #include "RageDisplay.h"
#include <cfloat>
#include <cmath>
float FindFirstDisplayedBeat( const PlayerState* pPlayerState, int iDrawDistanceAfterTargetsPixels ); float FindFirstDisplayedBeat( const PlayerState* pPlayerState, int iDrawDistanceAfterTargetsPixels );
float FindLastDisplayedBeat( const PlayerState* pPlayerState, int iDrawDistanceBeforeTargetsPixels ); float FindLastDisplayedBeat( const PlayerState* pPlayerState, int iDrawDistanceBeforeTargetsPixels );
@@ -735,8 +737,8 @@ void NoteField::CalcPixelsBeforeAndAfterTargets()
m_iDrawDistanceBeforeTargetsPixels * (1.f + curr_options.m_fDrawSize); m_iDrawDistanceBeforeTargetsPixels * (1.f + curr_options.m_fDrawSize);
float draw_scale= 1; float draw_scale= 1;
draw_scale*= 1 + 0.5f * fabsf(curr_options.m_fPerspectiveTilt); draw_scale*= 1 + 0.5f * std::abs(curr_options.m_fPerspectiveTilt);
draw_scale*= 1 + fabsf(curr_options.m_fEffects[PlayerOptions::EFFECT_MINI]); draw_scale*= 1 + std::abs(curr_options.m_fEffects[PlayerOptions::EFFECT_MINI]);
m_FieldRenderArgs.draw_pixels_after_targets= m_FieldRenderArgs.draw_pixels_after_targets=
(int)(m_FieldRenderArgs.draw_pixels_after_targets * draw_scale); (int)(m_FieldRenderArgs.draw_pixels_after_targets * draw_scale);
+5 -3
View File
@@ -7,6 +7,8 @@
#include "PlayerNumber.h" #include "PlayerNumber.h"
#include "RageLog.h" #include "RageLog.h"
#include <cmath>
class XNode; class XNode;
/** @brief The result of hitting (or missing) a tap note. */ /** @brief The result of hitting (or missing) a tap note. */
@@ -280,16 +282,16 @@ bool IsNoteOfType( int row, NoteType t );
/* /*
inline int BeatToNoteRow( float fBeatNum ) inline int BeatToNoteRow( float fBeatNum )
{ {
float fraction = fBeatNum - truncf(fBeatNum); float fraction = fBeatNum - std::trunc(fBeatNum);
int integer = int(fBeatNum) * ROWS_PER_BEAT; int integer = int(fBeatNum) * ROWS_PER_BEAT;
return integer + lrintf(fraction * ROWS_PER_BEAT); return integer + std::lrint(fraction * ROWS_PER_BEAT);
} }
*/ */
/** /**
* @brief Convert the beat into a note row. * @brief Convert the beat into a note row.
* @param fBeatNum the beat to convert. * @param fBeatNum the beat to convert.
* @return the note row. */ * @return the note row. */
inline int BeatToNoteRow( float fBeatNum ) { return lrintf( fBeatNum * ROWS_PER_BEAT ); } // round inline int BeatToNoteRow( float fBeatNum ) { return std::lrint( fBeatNum * ROWS_PER_BEAT ); } // round
/** /**
* @brief Convert the beat into a note row without rounding. * @brief Convert the beat into a note row without rounding.
* @param fBeatNum the beat to convert. * @param fBeatNum the beat to convert.
+4 -2
View File
@@ -11,6 +11,8 @@
#include "Song.h" #include "Song.h"
#include "Steps.h" #include "Steps.h"
#include <cmath>
RString OptimizeDWIString( RString holds, RString taps ); RString OptimizeDWIString( RString holds, RString taps );
/** /**
@@ -360,7 +362,7 @@ bool NotesWriterDWI::Write( RString sPath, const Song &out )
ssprintf("The first BPM Segment must be defined at row 0, not %d!", bpms[0]->GetRow()) ); ssprintf("The first BPM Segment must be defined at row 0, not %d!", bpms[0]->GetRow()) );
f.PutLine( ssprintf("#FILE:%s;", DwiEscape(out.m_sMusicFile).c_str()) ); f.PutLine( ssprintf("#FILE:%s;", DwiEscape(out.m_sMusicFile).c_str()) );
f.PutLine( ssprintf("#BPM:%.3f;", static_cast<BPMSegment *>(bpms[0])->GetBPM()) ); f.PutLine( ssprintf("#BPM:%.3f;", static_cast<BPMSegment *>(bpms[0])->GetBPM()) );
f.PutLine( ssprintf("#GAP:%ld;", -lrintf( out.m_SongTiming.m_fBeat0OffsetInSeconds*1000 )) ); f.PutLine( ssprintf("#GAP:%ld;", -std::lrint( out.m_SongTiming.m_fBeat0OffsetInSeconds*1000 )) );
f.PutLine( ssprintf("#SAMPLESTART:%.3f;", out.m_fMusicSampleStartSeconds) ); f.PutLine( ssprintf("#SAMPLESTART:%.3f;", out.m_fMusicSampleStartSeconds) );
f.PutLine( ssprintf("#SAMPLELENGTH:%.3f;", out.m_fMusicSampleLengthSeconds) ); f.PutLine( ssprintf("#SAMPLELENGTH:%.3f;", out.m_fMusicSampleLengthSeconds) );
if( out.m_sCDTitleFile.size() ) if( out.m_sCDTitleFile.size() )
@@ -393,7 +395,7 @@ bool NotesWriterDWI::Write( RString sPath, const Song &out )
{ {
const StopSegment *fs = static_cast<StopSegment *>(stops[i]); const StopSegment *fs = static_cast<StopSegment *>(stops[i]);
f.Write( ssprintf("%.3f=%.3f", fs->GetRow() * 4.0f / ROWS_PER_BEAT, f.Write( ssprintf("%.3f=%.3f", fs->GetRow() * 4.0f / ROWS_PER_BEAT,
roundf(fs->GetPause()*1000)) ); std::round(fs->GetPause()*1000)) );
if( i != stops.size()-1 ) if( i != stops.size()-1 )
f.Write( "," ); f.Write( "," );
} }
+5 -3
View File
@@ -11,6 +11,8 @@
#include "Style.h" #include "Style.h"
#include "ActorUtil.h" #include "ActorUtil.h"
#include <cmath>
const RString NEXT_ROW_NAME = "NextRow"; const RString NEXT_ROW_NAME = "NextRow";
const RString EXIT_NAME = "Exit"; const RString EXIT_NAME = "Exit";
@@ -681,9 +683,9 @@ void OptionRow::GetWidthXY( PlayerNumber pn, int iChoiceOnRow, int &iWidthOut, i
{ {
const BitmapText &text = GetTextItemForRow( pn, iChoiceOnRow ); const BitmapText &text = GetTextItemForRow( pn, iChoiceOnRow );
iWidthOut = lrintf( text.GetZoomedWidth() ); iWidthOut = std::lrint( text.GetZoomedWidth() );
iXOut = lrintf( text.GetDestX() ); iXOut = std::lrint( text.GetDestX() );
iYOut = lrintf( m_Frame.GetDestY() ); iYOut = std::lrint( m_Frame.GetDestY() );
} }
int OptionRow::GetOneSelection( PlayerNumber pn, bool bAllowFail ) const int OptionRow::GetOneSelection( PlayerNumber pn, bool bAllowFail ) const
+3 -1
View File
@@ -4,6 +4,8 @@
#include "ThemeManager.h" #include "ThemeManager.h"
#include "ActorUtil.h" #include "ActorUtil.h"
#include <cmath>
OptionsCursor::OptionsCursor() OptionsCursor::OptionsCursor()
{ {
m_iOriginalLeftX = 0; m_iOriginalLeftX = 0;
@@ -108,7 +110,7 @@ void OptionsCursor::BeginTweening( float fSecs, TweenType tt )
void OptionsCursor::SetBarWidth( int iWidth ) void OptionsCursor::SetBarWidth( int iWidth )
{ {
float fWidth = ceilf(iWidth/2.0f)*2.0f; // round up to nearest even number float fWidth = std::ceil(iWidth/2.0f)*2.0f; // round up to nearest even number
m_sprMiddle->ZoomToWidth( fWidth ); m_sprMiddle->ZoomToWidth( fWidth );
+8 -6
View File
@@ -41,6 +41,8 @@
#include "LocalizedString.h" #include "LocalizedString.h"
#include "AdjustSync.h" #include "AdjustSync.h"
#include <cmath>
RString ATTACK_DISPLAY_X_NAME( size_t p, size_t both_sides ); RString ATTACK_DISPLAY_X_NAME( size_t p, size_t both_sides );
void TimingWindowSecondsInit( size_t /*TimingWindow*/ i, RString &sNameOut, float &defaultValueOut ); void TimingWindowSecondsInit( size_t /*TimingWindow*/ i, RString &sNameOut, float &defaultValueOut );
@@ -879,7 +881,7 @@ void Player::Update( float fDeltaTime )
float fMiniPercent = m_pPlayerState->m_PlayerOptions.GetCurrent().m_fEffects[PlayerOptions::EFFECT_MINI]; float fMiniPercent = m_pPlayerState->m_PlayerOptions.GetCurrent().m_fEffects[PlayerOptions::EFFECT_MINI];
float fTinyPercent = m_pPlayerState->m_PlayerOptions.GetCurrent().m_fEffects[PlayerOptions::EFFECT_TINY]; float fTinyPercent = m_pPlayerState->m_PlayerOptions.GetCurrent().m_fEffects[PlayerOptions::EFFECT_TINY];
float fJudgmentZoom = std::min( powf(0.5f, fMiniPercent+fTinyPercent), 1.0f ); float fJudgmentZoom = std::min( std::pow(0.5f, fMiniPercent+fTinyPercent), 1.0f );
// Update Y positions // Update Y positions
{ {
@@ -1042,7 +1044,7 @@ void Player::Update( float fDeltaTime )
continue; continue;
const float notePosition = m_Timing->GetElapsedTimeFromBeat(NoteRowToBeat(row)); const float notePosition = m_Timing->GetElapsedTimeFromBeat(NoteRowToBeat(row));
const float offset = fabsf((notePosition - musicPosition) / rate); const float offset = std::abs((notePosition - musicPosition) / rate);
// Skip if we are outside of the largest timing window // Skip if we are outside of the largest timing window
if (offset > largestWindow) if (offset > largestWindow)
@@ -1883,7 +1885,7 @@ int Player::GetClosestNote( int col, int iNoteRow, int iMaxRowsAhead, int iMaxRo
return iNextIndex; return iNextIndex;
/* Figure out which row is closer. */ /* Figure out which row is closer. */
if( abs(iNoteRow-iNextIndex) > abs(iNoteRow-iPrevIndex) ) if( std::abs(iNoteRow-iNextIndex) > std::abs(iNoteRow-iPrevIndex) )
return iPrevIndex; return iPrevIndex;
else else
return iNextIndex; return iNextIndex;
@@ -1948,7 +1950,7 @@ int Player::GetClosestNonEmptyRow( int iNoteRow, int iMaxRowsAhead, int iMaxRows
float fPrevTime = m_Timing->GetElapsedTimeFromBeat(NoteRowToBeat(iPrevRow)); float fPrevTime = m_Timing->GetElapsedTimeFromBeat(NoteRowToBeat(iPrevRow));
/* Figure out which row is closer. */ /* Figure out which row is closer. */
if( fabsf(fNoteTime-fNextTime) > fabsf(fNoteTime-fPrevTime) ) if( std::abs(fNoteTime-fNextTime) > std::abs(fNoteTime-fPrevTime) )
return iPrevRow; return iPrevRow;
else else
return iNextRow; return iNextRow;
@@ -2240,7 +2242,7 @@ void Player::Step( int col, int row, const RageTimer &tm, bool bHeld, bool bRele
*/ */
} }
const float fSecondsFromExact = fabsf( fNoteOffset ); const float fSecondsFromExact = std::abs( fNoteOffset );
TapNote tnDummy = TAP_ORIGINAL_TAP; TapNote tnDummy = TAP_ORIGINAL_TAP;
TapNote *pTN = nullptr; TapNote *pTN = nullptr;
@@ -3325,7 +3327,7 @@ void Player::SetCombo( unsigned int iCombo, unsigned int iMisses )
{ {
int iSongIndexStartColoring = GAMESTATE->m_pCurCourse->GetEstimatedNumStages(); int iSongIndexStartColoring = GAMESTATE->m_pCurCourse->GetEstimatedNumStages();
iSongIndexStartColoring = iSongIndexStartColoring =
static_cast<int>(floor(iSongIndexStartColoring*PERCENT_UNTIL_COLOR_COMBO)); static_cast<int>(std::floor(iSongIndexStartColoring*PERCENT_UNTIL_COLOR_COMBO));
bPastBeginning = GAMESTATE->GetCourseSongIndex() >= iSongIndexStartColoring; bPastBeginning = GAMESTATE->GetCourseSongIndex() >= iSongIndexStartColoring;
} }
else else
+8 -6
View File
@@ -9,7 +9,9 @@
#include "ThemeManager.h" #include "ThemeManager.h"
#include "Style.h" #include "Style.h"
#include "CommonMetrics.h" #include "CommonMetrics.h"
#include <float.h>
#include <cfloat>
#include <cmath>
#include <sstream> #include <sstream>
static const char *LifeTypeNames[] = { static const char *LifeTypeNames[] = {
@@ -199,7 +201,7 @@ static void AddPart( std::vector<RString> &AddTo, float level, RString name )
if( level == 0 ) if( level == 0 )
return; return;
const RString LevelStr = (level == 1)? RString(""): ssprintf( "%ld%% ", lrintf(level*100) ); const RString LevelStr = (level == 1)? RString(""): ssprintf( "%ld%% ", std::lrint(level*100) );
AddTo.push_back( LevelStr + name ); AddTo.push_back( LevelStr + name );
} }
@@ -540,11 +542,11 @@ void PlayerOptions::GetMods( std::vector<RString> &AddTo, bool bForceNoteSkin )
else else
AddPart( AddTo, -m_fPerspectiveTilt, "Hallway" ); AddPart( AddTo, -m_fPerspectiveTilt, "Hallway" );
} }
else if( fabsf(m_fSkew-m_fPerspectiveTilt) < 0.0001f ) else if( std::abs(m_fSkew-m_fPerspectiveTilt) < 0.0001f )
{ {
AddPart( AddTo, m_fSkew, "Space" ); AddPart( AddTo, m_fSkew, "Space" );
} }
else if( fabsf(m_fSkew+m_fPerspectiveTilt) < 0.0001f ) else if( std::abs(m_fSkew+m_fPerspectiveTilt) < 0.0001f )
{ {
AddPart( AddTo, m_fSkew, "Incoming" ); AddPart( AddTo, m_fSkew, "Incoming" );
} }
@@ -562,7 +564,7 @@ void PlayerOptions::GetMods( std::vector<RString> &AddTo, bool bForceNoteSkin )
AddTo.push_back( s ); AddTo.push_back( s );
} }
if ( fabsf(m_fVisualDelay) > 0.0001f ) if ( std::abs(m_fVisualDelay) > 0.0001f )
{ {
// Format the string to be something like "10ms VisualDelay". // Format the string to be something like "10ms VisualDelay".
// Note that we don't process sub-millisecond visual delay. // Note that we don't process sub-millisecond visual delay.
@@ -1393,7 +1395,7 @@ float PlayerOptions::GetReversePercentForColumn( int iCol ) const
f += m_fScrolls[SCROLL_CROSS]; f += m_fScrolls[SCROLL_CROSS];
if( f > 2 ) if( f > 2 )
f = fmodf( f, 2 ); f = std::fmod( f, 2 );
if( f > 1 ) if( f > 1 )
f = SCALE( f, 1.f, 2.f, 1.f, 0.f ); f = SCALE( f, 1.f, 2.f, 1.f, 0.f );
return f; return f;
+5 -4
View File
@@ -3,7 +3,6 @@
#include "RageLog.h" #include "RageLog.h"
#include "ThemeManager.h" #include "ThemeManager.h"
#include "LuaManager.h" #include "LuaManager.h"
#include <float.h>
#include "GameState.h" #include "GameState.h"
#include "Course.h" #include "Course.h"
#include "Steps.h" #include "Steps.h"
@@ -11,6 +10,8 @@
#include "PrefsManager.h" #include "PrefsManager.h"
#include "CommonMetrics.h" #include "CommonMetrics.h"
#include <cfloat>
#include <cmath>
#include <numeric> #include <numeric>
#define GRADE_PERCENT_TIER(i) THEME->GetMetricF("PlayerStageStats",ssprintf("GradePercent%s",GradeToString((Grade)i).c_str())) #define GRADE_PERCENT_TIER(i) THEME->GetMetricF("PlayerStageStats",ssprintf("GradePercent%s",GradeToString((Grade)i).c_str()))
@@ -151,7 +152,7 @@ void PlayerStageStats::AddStats( const PlayerStageStats& other )
Combo_t &combo = m_ComboList[i]; Combo_t &combo = m_ComboList[i];
const float PrevComboEnd = prevcombo.m_fStartSecond + prevcombo.m_fSizeSeconds; const float PrevComboEnd = prevcombo.m_fStartSecond + prevcombo.m_fSizeSeconds;
const float ThisComboStart = combo.m_fStartSecond; const float ThisComboStart = combo.m_fStartSecond;
if( fabsf(PrevComboEnd - ThisComboStart) > 0.001 ) if( std::abs(PrevComboEnd - ThisComboStart) > 0.001 )
continue; continue;
// These are really the same combo. // These are really the same combo.
@@ -261,7 +262,7 @@ float PlayerStageStats::MakePercentScore( int iActual, int iPossible )
// TRICKY: printf will round, but we want to truncate. Otherwise, we may display // TRICKY: printf will round, but we want to truncate. Otherwise, we may display
// a percent score that's too high and doesn't match up with the calculated grade. // a percent score that's too high and doesn't match up with the calculated grade.
float fTruncInterval = powf( 0.1f, (float)iPercentTotalDigits-1 ); float fTruncInterval = std::pow( 0.1f, (float)iPercentTotalDigits-1 );
// TRICKY: ftruncf is rounding 1.0000000 to 0.99990004. Give a little boost // TRICKY: ftruncf is rounding 1.0000000 to 0.99990004. Give a little boost
// to fPercentDancePoints to correct for this. // to fPercentDancePoints to correct for this.
@@ -338,7 +339,7 @@ int PlayerStageStats::GetLessonScoreNeeded() const
{ {
float fScore = std::accumulate(m_vpPossibleSteps.begin(), m_vpPossibleSteps.end(), 0.f, float fScore = std::accumulate(m_vpPossibleSteps.begin(), m_vpPossibleSteps.end(), 0.f,
[](float total, Steps const *steps) { return total + steps->GetRadarValues(PLAYER_1)[RadarCategory_TapsAndHolds]; }); [](float total, Steps const *steps) { return total + steps->GetRadarValues(PLAYER_1)[RadarCategory_TapsAndHolds]; });
return lrintf( fScore * LESSON_PASS_THRESHOLD ); return std::lrint( fScore * LESSON_PASS_THRESHOLD );
} }
void PlayerStageStats::ResetScoreForLesson() void PlayerStageStats::ResetScoreForLesson()
+4 -2
View File
@@ -13,6 +13,8 @@
#include "arch/Dialog/Dialog.h" #include "arch/Dialog/Dialog.h"
#include "StepMania.h" #include "StepMania.h"
#include <cmath>
static void GetResolutionFromFileName( RString sPath, int &iWidth, int &iHeight ) static void GetResolutionFromFileName( RString sPath, int &iWidth, int &iHeight )
{ {
/* Match: /* Match:
@@ -302,8 +304,8 @@ void RageBitmapTexture::Create()
{ {
float fFrameWidth = this->GetSourceWidth() / (float)this->GetFramesWide(); float fFrameWidth = this->GetSourceWidth() / (float)this->GetFramesWide();
float fFrameHeight = this->GetSourceHeight() / (float)this->GetFramesHigh(); float fFrameHeight = this->GetSourceHeight() / (float)this->GetFramesHigh();
float fBetterFrameWidth = ceilf(fFrameWidth/iDimensionMultiple) * iDimensionMultiple; float fBetterFrameWidth = std::ceil(fFrameWidth/iDimensionMultiple) * iDimensionMultiple;
float fBetterFrameHeight = ceilf(fFrameHeight/iDimensionMultiple) * iDimensionMultiple; float fBetterFrameHeight = std::ceil(fFrameHeight/iDimensionMultiple) * iDimensionMultiple;
float fBetterSourceWidth = this->GetFramesWide() * fBetterFrameWidth; float fBetterSourceWidth = this->GetFramesWide() * fBetterFrameWidth;
float fBetterSourceHeight = this->GetFramesHigh() * fBetterFrameHeight; float fBetterSourceHeight = this->GetFramesHigh() * fBetterFrameHeight;
if( fFrameWidth!=fBetterFrameWidth || fFrameHeight!=fBetterFrameHeight ) if( fFrameWidth!=fBetterFrameWidth || fFrameHeight!=fBetterFrameHeight )
+11 -9
View File
@@ -15,6 +15,8 @@
#include "DisplaySpec.h" #include "DisplaySpec.h"
#include "arch/ArchHooks/ArchHooks.h" #include "arch/ArchHooks/ArchHooks.h"
#include <cmath>
// Statistics stuff // Statistics stuff
RageTimer g_LastCheckTimer; RageTimer g_LastCheckTimer;
int g_iNumVerts; int g_iNumVerts;
@@ -116,7 +118,7 @@ RString RageDisplay::SetVideoMode( VideoModeParams p, bool &bNeedReloadTextures
const DisplayMode supported = d.currentMode() != nullptr ? *d.currentMode() : *d.supportedModes().begin(); const DisplayMode supported = d.currentMode() != nullptr ? *d.currentMode() : *d.supportedModes().begin();
p.width = supported.width; p.width = supported.width;
p.height = supported.height; p.height = supported.height;
p.rate = static_cast<int> (round(supported.refreshRate)); p.rate = std::round(supported.refreshRate);
if( (err = this->TryVideoMode(p,bNeedReloadTextures)) == "" ) if( (err = this->TryVideoMode(p,bNeedReloadTextures)) == "" )
return RString(); return RString();
vs.push_back( err ); vs.push_back( err );
@@ -133,9 +135,9 @@ void RageDisplay::ProcessStatsOnFlip()
{ {
float fActualTime = g_LastCheckTimer.GetDeltaTime(); float fActualTime = g_LastCheckTimer.GetDeltaTime();
g_iNumChecksSinceLastReset++; g_iNumChecksSinceLastReset++;
g_iFPS = lrintf( g_iFramesRenderedSinceLastCheck / fActualTime ); g_iFPS = std::lrint( g_iFramesRenderedSinceLastCheck / fActualTime );
g_iCFPS = g_iFramesRenderedSinceLastReset / g_iNumChecksSinceLastReset; g_iCFPS = g_iFramesRenderedSinceLastReset / g_iNumChecksSinceLastReset;
g_iCFPS = lrintf( g_iCFPS / fActualTime ); g_iCFPS = std::lrint( g_iCFPS / fActualTime );
g_iVPF = g_iVertsRenderedSinceLastCheck / g_iFramesRenderedSinceLastCheck; g_iVPF = g_iVertsRenderedSinceLastCheck / g_iFramesRenderedSinceLastCheck;
g_iFramesRenderedSinceLastCheck = g_iVertsRenderedSinceLastCheck = 0; g_iFramesRenderedSinceLastCheck = g_iVertsRenderedSinceLastCheck = 0;
if( LOG_FPS ) if( LOG_FPS )
@@ -199,7 +201,7 @@ void RageDisplay::DrawPolyLine(const RageSpriteVertex &p1, const RageSpriteVerte
// soh cah toa strikes strikes again! // soh cah toa strikes strikes again!
float opp = p2.p.x - p1.p.x; float opp = p2.p.x - p1.p.x;
float adj = p2.p.y - p1.p.y; float adj = p2.p.y - p1.p.y;
float hyp = powf(opp*opp + adj*adj, 0.5f); float hyp = std::pow(opp*opp + adj*adj, 0.5f);
float lsin = opp/hyp; float lsin = opp/hyp;
float lcos = adj/hyp; float lcos = adj/hyp;
@@ -578,7 +580,7 @@ void RageDisplay::LoadMenuPerspective( float fovDegrees, float fWidth, float fHe
CLAMP( fovDegrees, 0.1f, 179.9f ); CLAMP( fovDegrees, 0.1f, 179.9f );
float fovRadians = fovDegrees / 180.f * PI; float fovRadians = fovDegrees / 180.f * PI;
float theta = fovRadians/2; float theta = fovRadians/2;
float fDistCameraFromImage = fWidth/2 / tanf( theta ); float fDistCameraFromImage = fWidth/2 / std::tan( theta );
fVanishPointX = SCALE( fVanishPointX, 0, fWidth, fWidth, 0 ); fVanishPointX = SCALE( fVanishPointX, 0, fWidth, fWidth, 0 );
fVanishPointY = SCALE( fVanishPointY, 0, fHeight, fHeight, 0 ); fVanishPointY = SCALE( fVanishPointY, 0, fHeight, fHeight, 0 );
@@ -634,7 +636,7 @@ void RageDisplay::LoadLookAt( float fFOV, const RageVector3 &Eye, const RageVect
RageMatrix RageDisplay::GetPerspectiveMatrix(float fovy, float aspect, float zNear, float zFar) RageMatrix RageDisplay::GetPerspectiveMatrix(float fovy, float aspect, float zNear, float zFar)
{ {
float ymax = zNear * tanf(fovy * PI / 360.0f); float ymax = zNear * std::tan(fovy * PI / 360.0f);
float ymin = -ymax; float ymin = -ymax;
float xmin = ymin * aspect; float xmin = ymin * aspect;
float xmax = ymax * aspect; float xmax = ymax * aspect;
@@ -781,9 +783,9 @@ bool RageDisplay::SaveScreenshot( RString sPath, GraphicsFileFormat format )
// Maintain the DAR. // Maintain the DAR.
ASSERT( GetActualVideoModeParams().fDisplayAspectRatio > 0 ); ASSERT( GetActualVideoModeParams().fDisplayAspectRatio > 0 );
int iHeight = 480; int iHeight = 480;
// This used to be lrintf. However, lrintf causes odd resolutions like // This used to be lrint. However, lrint causes odd resolutions like
// 639x480 (4:3) and 853x480 (16:9). ceilf gives correct values. -aj // 639x480 (4:3) and 853x480 (16:9). ceil gives correct values. -aj
int iWidth = static_cast<int>(ceilf( iHeight * GetActualVideoModeParams().fDisplayAspectRatio )); int iWidth = std::ceil( iHeight * GetActualVideoModeParams().fDisplayAspectRatio );
timer.Touch(); timer.Touch();
RageSurfaceUtils::Zoom( surface, iWidth, iHeight ); RageSurfaceUtils::Zoom( surface, iWidth, iHeight );
// LOG->Trace( "%ix%i -> %ix%i (%.3f) in %f seconds", surface->w, surface->h, iWidth, iHeight, GetActualVideoModeParams().fDisplayAspectRatio, timer.GetDeltaTime() ); // LOG->Trace( "%ix%i -> %ix%i (%.3f) in %f seconds", surface->w, surface->h, iWidth, iHeight, GetActualVideoModeParams().fDisplayAspectRatio, timer.GetDeltaTime() );
+1 -1
View File
@@ -24,7 +24,7 @@
#pragma comment(lib, "d3d9.lib") #pragma comment(lib, "d3d9.lib")
#endif #endif
#include <math.h> #include <cmath>
#include <list> #include <list>
// Globals // Globals
+3 -2
View File
@@ -19,6 +19,7 @@ using namespace RageDisplay_Legacy_Helpers;
#include "arch/LowLevelWindow/LowLevelWindow.h" #include "arch/LowLevelWindow/LowLevelWindow.h"
#include <cmath>
#include <set> #include <set>
#if defined(WINDOWS) #if defined(WINDOWS)
@@ -686,10 +687,10 @@ static void CheckReversePackedPixels()
void SetupExtensions() void SetupExtensions()
{ {
const float fGLVersion = StringToFloat( (const char *) glGetString(GL_VERSION) ); const float fGLVersion = StringToFloat( (const char *) glGetString(GL_VERSION) );
g_glVersion = lrintf( fGLVersion * 10 ); g_glVersion = std::lrint( fGLVersion * 10 );
const float fGLUVersion = StringToFloat( (const char *) gluGetString(GLU_VERSION) ); const float fGLUVersion = StringToFloat( (const char *) gluGetString(GLU_VERSION) );
g_gluVersion = lrintf( fGLUVersion * 10 ); g_gluVersion = std::lrint( fGLUVersion * 10 );
#ifndef HAVE_X11 // LLW_X11 needs to init GLEW early for GLX exts #ifndef HAVE_X11 // LLW_X11 needs to init GLEW early for GLX exts
glewInit(); glewInit();
+13 -10
View File
@@ -8,7 +8,10 @@
#include "RageLog.h" #include "RageLog.h"
#include "RageMath.h" #include "RageMath.h"
#include "RageTypes.h" #include "RageTypes.h"
#include <float.h>
#include <cfloat>
#include <cmath>
void RageVec3ClearBounds( RageVector3 &mins, RageVector3 &maxs ) void RageVec3ClearBounds( RageVector3 &mins, RageVector3 &maxs )
{ {
@@ -28,14 +31,14 @@ void RageVec3AddToBounds( const RageVector3 &p, RageVector3 &mins, RageVector3 &
void RageVec2Normalize( RageVector2* pOut, const RageVector2* pV ) void RageVec2Normalize( RageVector2* pOut, const RageVector2* pV )
{ {
float scale = 1.0f / sqrtf( pV->x*pV->x + pV->y*pV->y ); float scale = 1.0f / std::sqrt( pV->x*pV->x + pV->y*pV->y );
pOut->x = pV->x * scale; pOut->x = pV->x * scale;
pOut->y = pV->y * scale; pOut->y = pV->y * scale;
} }
void RageVec3Normalize( RageVector3* pOut, const RageVector3* pV ) void RageVec3Normalize( RageVector3* pOut, const RageVector3* pV )
{ {
float scale = 1.0f / sqrtf( pV->x*pV->x + pV->y*pV->y + pV->z*pV->z ); float scale = 1.0f / std::sqrt( pV->x*pV->x + pV->y*pV->y + pV->z*pV->z );
pOut->x = pV->x * scale; pOut->x = pV->x * scale;
pOut->y = pV->y * scale; pOut->y = pV->y * scale;
pOut->z = pV->z * scale; pOut->z = pV->z * scale;
@@ -44,7 +47,7 @@ void RageVec3Normalize( RageVector3* pOut, const RageVector3* pV )
void VectorFloatNormalize(std::vector<float>& v) void VectorFloatNormalize(std::vector<float>& v)
{ {
ASSERT_M(v.size() == 3, "Can't normalize a non-3D vector."); ASSERT_M(v.size() == 3, "Can't normalize a non-3D vector.");
float scale = 1.0f / sqrtf(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); float scale = 1.0f / std::sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
v[0]*= scale; v[0]*= scale;
v[1]*= scale; v[1]*= scale;
v[2]*= scale; v[2]*= scale;
@@ -358,7 +361,7 @@ void RageQuatMultiply( RageVector4* pOut, const RageVector4 &pA, const RageVecto
square = out.x * out.x + out.y * out.y + out.z * out.z + out.w * out.w; square = out.x * out.x + out.y * out.y + out.z * out.z + out.w * out.w;
if (square > 0.0) if (square > 0.0)
dist = 1.0f / sqrtf(square); dist = 1.0f / std::sqrt(square);
else dist = 1; else dist = 1;
out.x *= dist; out.x *= dist;
@@ -505,7 +508,7 @@ void RageQuatSlerp(RageVector4 *pOut, const RageVector4 &from, const RageVector4
if ( cosom < 0.9999f ) if ( cosom < 0.9999f )
{ {
// standard case (slerp) // standard case (slerp)
float omega = acosf(cosom); float omega = std::acos(cosom);
float sinom = RageFastSin(omega); float sinom = RageFastSin(omega);
scale0 = RageFastSin((1.0f - t) * omega) / sinom; scale0 = RageFastSin((1.0f - t) * omega) / sinom;
scale1 = RageFastSin(t * omega) / sinom; scale1 = RageFastSin(t * omega) / sinom;
@@ -606,7 +609,7 @@ struct sine_initter
for(unsigned int i= 0; i < sine_table_size; ++i) for(unsigned int i= 0; i < sine_table_size; ++i)
{ {
float angle= SCALE(i, 0, sine_table_size, 0.0f, PI); float angle= SCALE(i, 0, sine_table_size, 0.0f, PI);
sine_table[i]= sinf(angle); sine_table[i]= std::sin(angle);
} }
} }
}; };
@@ -654,7 +657,7 @@ float RageFastCsc( float x )
float RageSquare( float angle ) float RageSquare( float angle )
{ {
float fAngle = fmod( angle , (PI * 2) ); float fAngle = std::fmod( angle , (PI * 2) );
//Hack: This ensures the hold notes don't flicker right before they're hit. //Hack: This ensures the hold notes don't flicker right before they're hit.
if(fAngle < 0.01f) if(fAngle < 0.01f)
{ {
@@ -665,7 +668,7 @@ float RageSquare( float angle )
float RageTriangle( float angle ) float RageTriangle( float angle )
{ {
float fAngle= fmod(angle, PI * 2.0f); float fAngle= std::fmod(angle, PI * 2.0f);
if(fAngle < 0.0) if(fAngle < 0.0)
{ {
fAngle+= PI * 2.0; fAngle+= PI * 2.0;
@@ -742,7 +745,7 @@ float RageBezier2D::EvaluateYFromX( float fX ) const
float fError = fX-fGuessedX; float fError = fX-fGuessedX;
/* If our guess is good enough, evaluate the result Y and return. */ /* If our guess is good enough, evaluate the result Y and return. */
if( unlikely(fabsf(fError) < 0.0001f) ) if( unlikely(std::abs(fError) < 0.0001f) )
return m_Y.Evaluate( fT ); return m_Y.Evaluate( fT );
float fSlope = m_X.GetSlope( fT ); float fSlope = m_X.GetSlope( fT );
+3 -1
View File
@@ -36,6 +36,8 @@
#include "RageSoundReader_FileReader.h" #include "RageSoundReader_FileReader.h"
#include "RageSoundReader_ThreadedBuffer.h" #include "RageSoundReader_ThreadedBuffer.h"
#include <cmath>
#define samplerate() m_pSource->GetSampleRate() #define samplerate() m_pSource->GetSampleRate()
RageSoundParams::RageSoundParams(): RageSoundParams::RageSoundParams():
@@ -328,7 +330,7 @@ void RageSound::StartPlaying()
ASSERT( !m_bPlaying ); ASSERT( !m_bPlaying );
// Move to the start position. // Move to the start position.
SetPositionFrames( lrintf(m_Param.m_StartSecond * samplerate()) ); SetPositionFrames( std::lrint(m_Param.m_StartSecond * samplerate()) );
/* If m_StartTime is in the past, then we probably set a start time but took too /* If m_StartTime is in the past, then we probably set a start time but took too
* long loading. We don't want that; log it, since it can be unobvious. */ * long loading. We don't want that; log it, since it can be unobvious. */
+3 -1
View File
@@ -2,6 +2,8 @@
#include "RageSoundMixBuffer.h" #include "RageSoundMixBuffer.h"
#include "RageUtil.h" #include "RageUtil.h"
#include <cmath>
#if defined(MACOSX) #if defined(MACOSX)
#include "archutils/Darwin/VectorHelper.h" #include "archutils/Darwin/VectorHelper.h"
#ifdef USE_VEC #ifdef USE_VEC
@@ -79,7 +81,7 @@ void RageSoundMixBuffer::read( int16_t *pBuf )
{ {
float iOut = m_pMixbuf[iPos]; float iOut = m_pMixbuf[iPos];
iOut = clamp( iOut, -1.0f, +1.0f ); iOut = clamp( iOut, -1.0f, +1.0f );
pBuf[iPos] = lrintf(iOut * 32767); pBuf[iPos] = std::lrint(iOut * 32767);
} }
m_iBufUsed = 0; m_iBufUsed = 0;
} }
+6 -5
View File
@@ -4,7 +4,8 @@
#include "RageUtil.h" #include "RageUtil.h"
#include "RageTimer.h" #include "RageTimer.h"
#include <limits.h> #include <climits>
#include <cmath>
#include <list> #include <list>
/* The number of frames we should keep pos_map data for. This being too high /* The number of frames we should keep pos_map data for. This being too high
@@ -60,7 +61,7 @@ void pos_map_queue::Insert( int64_t iSourceFrame, int iFrames, int64_t iDestFram
pos_map_t &last = m_pImpl->m_Queue.back(); pos_map_t &last = m_pImpl->m_Queue.back();
if( last.m_iSourceFrame + last.m_iFrames == iSourceFrame && if( last.m_iSourceFrame + last.m_iFrames == iSourceFrame &&
last.m_fSourceToDestRatio == fSourceToDestRatio && last.m_fSourceToDestRatio == fSourceToDestRatio &&
llabs(last.m_iDestFrame + lrintf(last.m_iFrames * last.m_fSourceToDestRatio) - iDestFrame) <= 1 ) llabs(last.m_iDestFrame + std::lrint(last.m_iFrames * last.m_fSourceToDestRatio) - iDestFrame) <= 1 )
{ {
last.m_iFrames += iFrames; last.m_iFrames += iFrames;
@@ -82,7 +83,7 @@ void pos_map_queue::Insert( int64_t iSourceFrame, int iFrames, int64_t iDestFram
next.m_iSourceFrame += iDeleteFrames; next.m_iSourceFrame += iDeleteFrames;
next.m_iFrames -= iDeleteFrames; next.m_iFrames -= iDeleteFrames;
next.m_iDestFrame += lrintf( iDeleteFrames * next.m_fSourceToDestRatio ); next.m_iDestFrame += std::lrint( iDeleteFrames * next.m_fSourceToDestRatio );
m_pImpl->m_Queue.push_back( next ); m_pImpl->m_Queue.push_back( next );
} }
@@ -143,7 +144,7 @@ int64_t pos_map_queue::Search( int64_t iSourceFrame, bool *bApproximate ) const
/* iSourceFrame lies in this block; it's an exact match. Figure /* iSourceFrame lies in this block; it's an exact match. Figure
* out the exact position. */ * out the exact position. */
int iDiff = int(iSourceFrame - pm.m_iSourceFrame); int iDiff = int(iSourceFrame - pm.m_iSourceFrame);
iDiff = lrintf( iDiff * pm.m_fSourceToDestRatio ); iDiff = std::lrint( iDiff * pm.m_fSourceToDestRatio );
return pm.m_iDestFrame + iDiff; return pm.m_iDestFrame + iDiff;
} }
@@ -162,7 +163,7 @@ int64_t pos_map_queue::Search( int64_t iSourceFrame, bool *bApproximate ) const
{ {
iClosestPositionDist = dist; iClosestPositionDist = dist;
pClosestBlock = &pm; pClosestBlock = &pm;
iClosestPosition = pm.m_iDestFrame + lrintf( pm.m_iFrames * pm.m_fSourceToDestRatio ); iClosestPosition = pm.m_iDestFrame + std::lrint( pm.m_iFrames * pm.m_fSourceToDestRatio );
} }
} }
+3 -1
View File
@@ -9,6 +9,8 @@
#include "RageSoundMixBuffer.h" #include "RageSoundMixBuffer.h"
#include "RageSoundUtil.h" #include "RageSoundUtil.h"
#include <cmath>
/* /*
* Keyed sounds should pass this object to SoundReader_Preload, to preprocess it. * Keyed sounds should pass this object to SoundReader_Preload, to preprocess it.
@@ -53,7 +55,7 @@ void RageSoundReader_Chain::AddSound( int iIndex, float fOffsetSecs, float fPan
Sound s; Sound s;
s.iIndex = iIndex; s.iIndex = iIndex;
s.iOffsetMS = lrintf( fOffsetSecs * 1000 ); s.iOffsetMS = std::lrint( fOffsetSecs * 1000 );
s.fPan = fPan; s.fPan = fPan;
s.pSound = nullptr; s.pSound = nullptr;
m_aSounds.push_back( s ); m_aSounds.push_back( s );
+6 -4
View File
@@ -4,6 +4,8 @@
#include "RageSoundUtil.h" #include "RageSoundUtil.h"
#include "RageUtil.h" #include "RageUtil.h"
#include <cmath>
/* /*
* Add support for negative seeks (adding a delay), extending a sound * Add support for negative seeks (adding a delay), extending a sound
* beyond its end (m_LengthSeconds and M_CONTINUE), looping and fading. * beyond its end (m_LengthSeconds and M_CONTINUE), looping and fading.
@@ -153,7 +155,7 @@ bool RageSoundReader_Extend::SetProperty( const RString &sProperty, float fValue
{ {
if( sProperty == "StartSecond" ) if( sProperty == "StartSecond" )
{ {
m_iStartFrames = lrintf( fValue * this->GetSampleRate() ); m_iStartFrames = std::lrint( fValue * this->GetSampleRate() );
return true; return true;
} }
@@ -162,7 +164,7 @@ bool RageSoundReader_Extend::SetProperty( const RString &sProperty, float fValue
if( fValue == -1 ) if( fValue == -1 )
m_iLengthFrames = -1; m_iLengthFrames = -1;
else else
m_iLengthFrames = lrintf( fValue * this->GetSampleRate() ); m_iLengthFrames = std::lrint( fValue * this->GetSampleRate() );
return true; return true;
} }
@@ -186,13 +188,13 @@ bool RageSoundReader_Extend::SetProperty( const RString &sProperty, float fValue
if( sProperty == "FadeInSeconds" ) if( sProperty == "FadeInSeconds" )
{ {
m_iFadeInFrames = lrintf( fValue * this->GetSampleRate() ); m_iFadeInFrames = std::lrint( fValue * this->GetSampleRate() );
return true; return true;
} }
if( sProperty == "FadeSeconds" || sProperty == "FadeOutSeconds" ) if( sProperty == "FadeSeconds" || sProperty == "FadeOutSeconds" )
{ {
m_iFadeOutFrames = lrintf( fValue * this->GetSampleRate() ); m_iFadeOutFrames = std::lrint( fValue * this->GetSampleRate() );
return true; return true;
} }
+10 -8
View File
@@ -7,6 +7,8 @@
#include "RageSoundMixBuffer.h" #include "RageSoundMixBuffer.h"
#include "RageSoundUtil.h" #include "RageSoundUtil.h"
#include <cmath>
RageSoundReader_Merge::RageSoundReader_Merge() RageSoundReader_Merge::RageSoundReader_Merge()
{ {
@@ -140,8 +142,8 @@ bool RageSoundReader_Merge::SetProperty( const RString &sProperty, float fValue
return bRet; return bRet;
} }
static float Difference( float a, float b ) { return fabsf( a - b ); } static float Difference( float a, float b ) { return std::abs( a - b ); }
static int Difference( int a, int b ) { return abs( a - b ); } static int Difference( int a, int b ) { return std::abs( a - b ); }
/* /*
* If the audio position drifts apart further than ERROR_CORRECTION_THRESHOLD frames, * If the audio position drifts apart further than ERROR_CORRECTION_THRESHOLD frames,
@@ -212,7 +214,7 @@ int RageSoundReader_Merge::Read( float *pBuffer, int iFrames )
/* A sound is being delayed to resync it; clamp the number of frames we /* A sound is being delayed to resync it; clamp the number of frames we
* read now, so we don't advance past it. */ * read now, so we don't advance past it. */
int iMaxSourceFramesToRead = aNextSourceFrames[i] - iMinPosition; int iMaxSourceFramesToRead = aNextSourceFrames[i] - iMinPosition;
int iMaxStreamFramesToRead = lrintf( iMaxSourceFramesToRead / m_fCurrentStreamToSourceRatio ); int iMaxStreamFramesToRead = std::lrint( iMaxSourceFramesToRead / m_fCurrentStreamToSourceRatio );
iFrames = std::min( iFrames, iMaxStreamFramesToRead ); iFrames = std::min( iFrames, iMaxStreamFramesToRead );
// LOG->Warn( "RageSoundReader_Merge: sound positions moving at different rates" ); // LOG->Warn( "RageSoundReader_Merge: sound positions moving at different rates" );
} }
@@ -224,7 +226,7 @@ int RageSoundReader_Merge::Read( float *pBuffer, int iFrames )
RageSoundReader *pSound = m_aSounds.front(); RageSoundReader *pSound = m_aSounds.front();
iFrames = pSound->Read( pBuffer, iFrames ); iFrames = pSound->Read( pBuffer, iFrames );
if( iFrames > 0 ) if( iFrames > 0 )
m_iNextSourceFrame += lrintf( iFrames * m_fCurrentStreamToSourceRatio ); m_iNextSourceFrame += std::lrint( iFrames * m_fCurrentStreamToSourceRatio );
aNextSourceFrames.front() = pSound->GetNextSourceFrame(); aNextSourceFrames.front() = pSound->GetNextSourceFrame();
aRatios.front() = pSound->GetStreamToSourceRatio(); aRatios.front() = pSound->GetStreamToSourceRatio();
return iFrames; return iFrames;
@@ -244,11 +246,11 @@ int RageSoundReader_Merge::Read( float *pBuffer, int iFrames )
while( iFramesRead < iFrames ) while( iFramesRead < iFrames )
{ {
// if( i == 0 ) // if( i == 0 )
//LOG->Trace( "*** %i", Difference(aNextSourceFrames[i], m_iNextSourceFrame + lrintf(iFramesRead * aRatios[i])) ); //LOG->Trace( "*** %i", Difference(aNextSourceFrames[i], m_iNextSourceFrame + std::lrint(iFramesRead * aRatios[i])) );
if( Difference(aNextSourceFrames[i], m_iNextSourceFrame + lrintf(iFramesRead * aRatios[i])) > ERROR_CORRECTION_THRESHOLD ) if( Difference(aNextSourceFrames[i], m_iNextSourceFrame + std::lrint(iFramesRead * aRatios[i])) > ERROR_CORRECTION_THRESHOLD )
{ {
LOG->Trace( "*** hurk %i", Difference(aNextSourceFrames[i], m_iNextSourceFrame + lrintf(iFramesRead * aRatios[i])) ); LOG->Trace( "*** hurk %i", Difference(aNextSourceFrames[i], m_iNextSourceFrame + std::lrint(iFramesRead * aRatios[i])) );
break; break;
} }
@@ -276,7 +278,7 @@ int RageSoundReader_Merge::Read( float *pBuffer, int iFrames )
int iMaxFramesRead = mix.size() / m_iChannels; int iMaxFramesRead = mix.size() / m_iChannels;
mix.read( pBuffer ); mix.read( pBuffer );
m_iNextSourceFrame += lrintf( iMaxFramesRead * m_fCurrentStreamToSourceRatio ); m_iNextSourceFrame += std::lrint( iMaxFramesRead * m_fCurrentStreamToSourceRatio );
return iMaxFramesRead; return iMaxFramesRead;
} }
+5 -3
View File
@@ -7,6 +7,8 @@
#include "RageSoundUtil.h" #include "RageSoundUtil.h"
#include "Preference.h" #include "Preference.h"
#include <cmath>
/* If true, preloaded sounds are stored in 16-bit instead of floats. Most /* If true, preloaded sounds are stored in 16-bit instead of floats. Most
* processing happens after preloading, and it's usually a waste to store high- * processing happens after preloading, and it's usually a waste to store high-
* resolution data for sound effects. */ * resolution data for sound effects. */
@@ -60,7 +62,7 @@ bool RageSoundReader_Preload::Open( RageSoundReader *pSource )
{ {
float fSecs = iLen / 1000.f; float fSecs = iLen / 1000.f;
int iFrames = lrintf( fSecs * m_iSampleRate ); /* seconds -> frames */ int iFrames = std::lrint( fSecs * m_iSampleRate ); /* seconds -> frames */
int iSamples = unsigned( iFrames * m_iChannels ); /* frames -> samples */ int iSamples = unsigned( iFrames * m_iChannels ); /* frames -> samples */
if( iSamples > iMaxSamples ) if( iSamples > iMaxSamples )
return false; /* Don't bother trying to preload it. */ return false; /* Don't bother trying to preload it. */
@@ -123,7 +125,7 @@ int RageSoundReader_Preload::GetLength_Fast() const
int RageSoundReader_Preload::SetPosition( int iFrame ) int RageSoundReader_Preload::SetPosition( int iFrame )
{ {
m_iPosition = iFrame; m_iPosition = iFrame;
m_iPosition = lrintf(m_iPosition / m_fRate); m_iPosition = std::lrint(m_iPosition / m_fRate);
if( m_iPosition >= int(m_Buffer->size() / framesize) ) if( m_iPosition >= int(m_Buffer->size() / framesize) )
{ {
@@ -136,7 +138,7 @@ int RageSoundReader_Preload::SetPosition( int iFrame )
int RageSoundReader_Preload::GetNextSourceFrame() const int RageSoundReader_Preload::GetNextSourceFrame() const
{ {
return lrintf(m_iPosition * m_fRate); return std::lrint(m_iPosition * m_fRate);
} }
int RageSoundReader_Preload::Read( float *pBuffer, int iFrames ) int RageSoundReader_Preload::Read( float *pBuffer, int iFrames )
+8 -7
View File
@@ -12,6 +12,7 @@
#include "RageMath.h" #include "RageMath.h"
#include "RageThreads.h" #include "RageThreads.h"
#include <cmath>
#include <numeric> #include <numeric>
/* Filter length. This must be a power of 2. */ /* Filter length. This must be a power of 2. */
@@ -23,14 +24,14 @@ namespace
{ {
if( f == 0 ) if( f == 0 )
return 1; return 1;
return sinf(f)/f; return std::sin(f) / f;
} }
/* Modified Bessel function I0. From Abramowitz and Stegun "Handbook of Mathematical /* Modified Bessel function I0. From Abramowitz and Stegun "Handbook of Mathematical
* Functions", "Modified Bessel Functions I and K". */ * Functions", "Modified Bessel Functions I and K". */
float BesselI0( float fX ) float BesselI0( float fX )
{ {
float fAbsX = fabsf( fX ); float fAbsX = std::abs( fX );
if( fAbsX < 3.75f ) if( fAbsX < 3.75f )
{ {
float y = fX / 3.75f; float y = fX / 3.75f;
@@ -41,7 +42,7 @@ namespace
else else
{ {
float y = 3.75f/fAbsX; float y = 3.75f/fAbsX;
float fRet = (exp(fAbsX)/sqrt(fAbsX)) * float fRet = (std::exp(fAbsX)/std::sqrt(fAbsX)) *
(+0.39894228f+y*(+0.01328592f+y*(+0.00225319f+y*(-0.00157565f+y*(0.00916281f+ (+0.39894228f+y*(+0.01328592f+y*(+0.00225319f+y*(-0.00157565f+y*(0.00916281f+
y*(-0.02057706f+y*(+0.02635537f+y*(-0.01647633f+y*+0.00392377f)))))))); y*(-0.02057706f+y*(+0.02635537f+y*(-0.01647633f+y*+0.00392377f))))))));
return fRet; return fRet;
@@ -63,8 +64,8 @@ namespace
float p = (iLen-1)/2.0f; float p = (iLen-1)/2.0f;
for( int n = 0; n < iLen; ++n ) for( int n = 0; n < iLen; ++n )
{ {
float fN1 = fabsf((n-p)/p); float fN1 = std::abs((n-p)/p);
float fNum = fBeta * sqrtf( std::max(1-fN1*fN1, 0.0f) ); float fNum = fBeta * std::sqrt( std::max(1.0f - fN1*fN1, 0.0f) );
fNum = BesselI0( fNum ); fNum = BesselI0( fNum );
float fVal = fNum/fDenom; float fVal = fNum/fDenom;
pBuf[n] *= fVal; pBuf[n] *= fVal;
@@ -620,7 +621,7 @@ void RageSoundReader_Resample_Good::ReopenResampler()
} }
if( m_fRate != -1 ) if( m_fRate != -1 )
iDownFactor = lrintf( m_fRate * iDownFactor ); iDownFactor = std::lrint( m_fRate * iDownFactor );
for( size_t iChannel = 0; iChannel < m_apResamplers.size(); ++iChannel ) for( size_t iChannel = 0; iChannel < m_apResamplers.size(); ++iChannel )
m_apResamplers[iChannel]->SetDownFactor( iDownFactor ); m_apResamplers[iChannel]->SetDownFactor( iDownFactor );
@@ -696,7 +697,7 @@ void RageSoundReader_Resample_Good::SetRate( float fRatio )
int iDownFactor, iUpFactor; int iDownFactor, iUpFactor;
GetFactors( iDownFactor, iUpFactor ); GetFactors( iDownFactor, iUpFactor );
if( m_fRate != -1 ) if( m_fRate != -1 )
iDownFactor = lrintf( m_fRate * iDownFactor ); iDownFactor = std::lrint( m_fRate * iDownFactor );
/* Set m_fRate to the actual rate, after quantization by iUpFactor. */ /* Set m_fRate to the actual rate, after quantization by iUpFactor. */
m_fRate = float(iDownFactor) / iUpFactor; m_fRate = float(iDownFactor) / iUpFactor;
+5 -3
View File
@@ -3,6 +3,8 @@
#include "RageUtil.h" #include "RageUtil.h"
#include "RageLog.h" #include "RageLog.h"
#include <cmath>
static const int WINDOW_SIZE_MS = 30; static const int WINDOW_SIZE_MS = 30;
RageSoundReader_SpeedChange::RageSoundReader_SpeedChange( RageSoundReader *pSource ): RageSoundReader_SpeedChange::RageSoundReader_SpeedChange( RageSoundReader *pSource ):
@@ -63,7 +65,7 @@ static int FindClosestMatch( const float *pBuffer, int iBufferSize, const float
for( int j = 0; j < iCorrelateBufferSize; j += iStride ) for( int j = 0; j < iCorrelateBufferSize; j += iStride )
{ {
float fDiff = pFrames[j] - pCorrelateBuffer[j]; float fDiff = pFrames[j] - pCorrelateBuffer[j];
fScore += fabsf(fDiff); fScore += std::abs(fDiff);
} }
if( i == 0 || fScore < fBestScore ) if( i == 0 || fScore < fBestScore )
@@ -163,7 +165,7 @@ int RageSoundReader_SpeedChange::Step()
* by 2.0 frames, and advance by 0.3 more the next time around. */ * by 2.0 frames, and advance by 0.3 more the next time around. */
float fAdvanceFrames = GetWindowSizeFrames() * m_fTrailingSpeedRatio; float fAdvanceFrames = GetWindowSizeFrames() * m_fTrailingSpeedRatio;
fAdvanceFrames += m_fErrorFrames; fAdvanceFrames += m_fErrorFrames;
int iTrailingDeltaFrames = lrintf( fAdvanceFrames ); int iTrailingDeltaFrames = std::lrint( fAdvanceFrames );
m_fErrorFrames = fAdvanceFrames - iTrailingDeltaFrames; m_fErrorFrames = fAdvanceFrames - iTrailingDeltaFrames;
m_iUncorrelatedPos += iTrailingDeltaFrames; m_iUncorrelatedPos += iTrailingDeltaFrames;
@@ -312,7 +314,7 @@ int RageSoundReader_SpeedChange::GetNextSourceFrame() const
float fRatio = m_fTrailingSpeedRatio; float fRatio = m_fTrailingSpeedRatio;
int iSourceFrame = RageSoundReader_Filter::GetNextSourceFrame(); int iSourceFrame = RageSoundReader_Filter::GetNextSourceFrame();
int iPos = lrintf(m_iPos * fRatio); int iPos = std::lrint(m_iPos * fRatio);
iSourceFrame -= m_iDataBufferAvailFrames; iSourceFrame -= m_iDataBufferAvailFrames;
iSourceFrame += m_iUncorrelatedPos + iPos; iSourceFrame += m_iUncorrelatedPos + iPos;
+3 -1
View File
@@ -4,6 +4,8 @@
#include "RageTimer.h" #include "RageTimer.h"
#include "RageLog.h" #include "RageLog.h"
#include <cmath>
/* Implement threaded read-ahead buffering. /* Implement threaded read-ahead buffering.
* *
* If a buffer is low on data, keep filling until it has a g_iMinFillFrames. * If a buffer is low on data, keep filling until it has a g_iMinFillFrames.
@@ -235,7 +237,7 @@ void RageSoundReader_ThreadedBuffer::BufferingThread()
else else
{ {
m_Event.Unlock(); m_Event.Unlock();
usleep( lrintf(fTimeToSleep * 1000000) ); usleep( std::lrint(fTimeToSleep * 1000000) );
m_Event.Lock(); m_Event.Lock();
} }
} }
+3 -1
View File
@@ -2,6 +2,8 @@
#include "RageSoundUtil.h" #include "RageSoundUtil.h"
#include "RageUtil.h" #include "RageUtil.h"
#include <cmath>
void RageSoundUtil::Attenuate( float *pBuf, int iSamples, float fVolume ) void RageSoundUtil::Attenuate( float *pBuf, int iSamples, float fVolume )
{ {
while( iSamples-- ) while( iSamples-- )
@@ -91,7 +93,7 @@ void RageSoundUtil::ConvertFloatToNativeInt16( const float *pFrom, int16_t *pTo,
{ {
for( int i = 0; i < iSamples; ++i ) for( int i = 0; i < iSamples; ++i )
{ {
int iOut = lrintf( pFrom[i] * 32768.0f ); int iOut = std::lrint( pFrom[i] * 32768.0f );
pTo[i] = clamp( iOut, -32768, 32767 ); pTo[i] = clamp( iOut, -32768, 32767 );
} }
} }
+6 -5
View File
@@ -2,7 +2,8 @@
#include "RageSurface.h" #include "RageSurface.h"
#include "RageUtil.h" #include "RageUtil.h"
#include <limits.h> #include <climits>
#include <cmath>
int32_t RageSurfacePalette::FindColor( const RageSurfaceColor &color ) const int32_t RageSurfacePalette::FindColor( const RageSurfaceColor &color ) const
@@ -23,10 +24,10 @@ int32_t RageSurfacePalette::FindClosestColor( const RageSurfaceColor &color ) co
if( colors[i] == color ) if( colors[i] == color )
return i; return i;
int iDist = abs( colors[i].r - color.r ) + int iDist = std::abs( colors[i].r - color.r ) +
abs( colors[i].g - color.g ) + std::abs( colors[i].g - color.g ) +
abs( colors[i].b - color.b ) + std::abs( colors[i].b - color.b ) +
abs( colors[i].a - color.a ); std::abs( colors[i].a - color.a );
if( iDist < iBestDist ) if( iDist < iBestDist )
{ {
iBestDist = iDist ; iBestDist = iDist ;
+9 -7
View File
@@ -5,6 +5,8 @@
#include "RageLog.h" #include "RageLog.h"
#include "RageFile.h" #include "RageFile.h"
#include <cmath>
uint32_t RageSurfaceUtils::decodepixel( const uint8_t *p, int bpp ) uint32_t RageSurfaceUtils::decodepixel( const uint8_t *p, int bpp )
{ {
switch(bpp) switch(bpp)
@@ -420,10 +422,10 @@ void RageSurfaceUtils::BlitTransform( const RageSurface *src, RageSurface *dst,
* pixel[1]; 2 indicates 50% pixel[1], 50% pixel[2] (which is clamped * pixel[1]; 2 indicates 50% pixel[1], 50% pixel[2] (which is clamped
* to pixel[1]). */ * to pixel[1]). */
int src_x[2], src_y[2]; int src_x[2], src_y[2];
src_x[0] = (int) truncf(src_xp - 0.5f); src_x[0] = std::trunc(src_xp - 0.5f);
src_x[1] = src_x[0] + 1; src_x[1] = src_x[0] + 1;
src_y[0] = (int) truncf(src_yp - 0.5f); src_y[0] = std::trunc(src_yp - 0.5f);
src_y[1] = src_y[0] + 1; src_y[1] = src_y[0] + 1;
// Emulate GL_REPEAT. // Emulate GL_REPEAT.
@@ -452,7 +454,7 @@ void RageSurfaceUtils::BlitTransform( const RageSurface *src, RageSurface *dst,
sum += v[1][i] * (1-weight_x) * (weight_y); sum += v[1][i] * (1-weight_x) * (weight_y);
sum += v[2][i] * (weight_x) * (1-weight_y); sum += v[2][i] * (weight_x) * (1-weight_y);
sum += v[3][i] * (weight_x) * (weight_y); sum += v[3][i] * (weight_x) * (weight_y);
out[i] = (uint8_t) clamp( lrintf(sum), 0L, 255L ); out[i] = (uint8_t) clamp( std::lrint(sum), 0L, 255L );
} }
// If the source has no alpha, set the destination to opaque. // If the source has no alpha, set the destination to opaque.
@@ -547,7 +549,7 @@ static bool blit_rgba_to_rgba( const RageSurface *src_surf, const RageSurface *d
* { 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3 } * { 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3 }
* SCALE( i, 0, max_src_val, 0, max_dst_val ); * SCALE( i, 0, max_src_val, 0, max_dst_val );
* { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3 } * { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3 }
* lrintf( ((float) i / max_src_val) * max_dst_val ) * std::lrint( ((float) i / max_src_val) * max_dst_val )
* { 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3 } * { 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3 }
* *
* We use the first for increasing resolution, since it gives the most even * We use the first for increasing resolution, since it gives the most even
@@ -558,7 +560,7 @@ static bool blit_rgba_to_rgba( const RageSurface *src_surf, const RageSurface *d
* { 0, 4, 8, 12 } * { 0, 4, 8, 12 }
* SCALE( i, 0, max_src_val, 0, max_dst_val ); * SCALE( i, 0, max_src_val, 0, max_dst_val );
* { 0, 5, 10, 15 } * { 0, 5, 10, 15 }
* lrintf( ((float) i / max_src_val) * max_dst_val ) * std::lrint( ((float) i / max_src_val) * max_dst_val )
* { 0, 5, 10, 15 } * { 0, 5, 10, 15 }
* *
* The latter two are equivalent and give an even distribution; we use the * The latter two are equivalent and give an even distribution; we use the
@@ -861,10 +863,10 @@ RageSurface *RageSurfaceUtils::PalettizeToGrayscale( const RageSurface *src_surf
const unsigned int A = (index & Amask) >> Ashift; const unsigned int A = (index & Amask) >> Ashift;
// if only one intensity value, always fullbright // if only one intensity value, always fullbright
const uint8_t ScaledI = Ivalues == 1 ? 255 : clamp( lrintf(I * (255.0f / (Ivalues-1))), 0L, 255L ); const uint8_t ScaledI = Ivalues == 1 ? 255 : clamp( std::lrint(I * (255.0f / (Ivalues-1))), 0L, 255L );
// if only one alpha value, always opaque // if only one alpha value, always opaque
const uint8_t ScaledA = Avalues == 1 ? 255 : clamp( lrintf(A * (255.0f / (Avalues-1))), 0L, 255L ); const uint8_t ScaledA = Avalues == 1 ? 255 : clamp( std::lrint(A * (255.0f / (Avalues-1))), 0L, 255L );
RageSurfaceColor c; RageSurfaceColor c;
c.r = ScaledI; c.r = ScaledI;
+4 -3
View File
@@ -4,6 +4,7 @@
#include "RageSurfaceUtils.h" #include "RageSurfaceUtils.h"
#include "RageUtil.h" #include "RageUtil.h"
#include <cmath>
#include <vector> #include <vector>
/* Coordinate 0x0 represents the exact top-left corner of a bitmap. .5x.5 /* Coordinate 0x0 represents the exact top-left corner of a bitmap. .5x.5
@@ -72,7 +73,7 @@ static void InitVectors( std::vector<int> &s0, std::vector<int> &s1, std::vector
s0.push_back( clamp(int(sax), 0, src-1)); s0.push_back( clamp(int(sax), 0, src-1));
s1.push_back( clamp(int(sax+1), 0, src-1) ); s1.push_back( clamp(int(sax+1), 0, src-1) );
const float p = (1.0f - (sax - floorf(sax))) * 16777216.0f; const float p = (1.0f - (sax - std::floor(sax))) * 16777216.0f;
percent.push_back( uint32_t(p) ); percent.push_back( uint32_t(p) );
} }
} }
@@ -156,8 +157,8 @@ void RageSurfaceUtils::Zoom( RageSurface *&src, int dstwidth, int dstheight )
xscale = clamp( xscale, .5f, 2.0f ); xscale = clamp( xscale, .5f, 2.0f );
yscale = clamp( yscale, .5f, 2.0f ); yscale = clamp( yscale, .5f, 2.0f );
int target_width = lrintf( src->w*xscale ); int target_width = std::lrint( src->w*xscale );
int target_height = lrintf( src->h*yscale ); int target_height = std::lrint( src->h*yscale );
RageSurface *dst = RageSurface *dst =
CreateSurface(target_width, target_height, 32, CreateSurface(target_width, target_height, 32,
+3 -1
View File
@@ -27,6 +27,8 @@
#include "arch/ArchHooks/ArchHooks.h" #include "arch/ArchHooks/ArchHooks.h"
#include <cmath>
#define TIMESTAMP_RESOLUTION 1000000 #define TIMESTAMP_RESOLUTION 1000000
const RageTimer RageZeroTimer(0,0); const RageTimer RageZeroTimer(0,0);
@@ -122,7 +124,7 @@ RageTimer RageTimer::Sum(const RageTimer &lhs, float tm)
{ {
/* tm == 5.25 -> secs = 5, us = 5.25 - ( 5) = .25 /* tm == 5.25 -> secs = 5, us = 5.25 - ( 5) = .25
* tm == -1.25 -> secs = -2, us = -1.25 - (-2) = .75 */ * tm == -1.25 -> secs = -2, us = -1.25 - (-2) = .75 */
int seconds = (int) floorf(tm); int seconds = std::floor(tm);
int us = int( (tm - seconds) * TIMESTAMP_RESOLUTION ); int us = int( (tm - seconds) * TIMESTAMP_RESOLUTION );
RageTimer ret(0,0); // Prevent unnecessarily checking the time RageTimer ret(0,0); // Prevent unnecessarily checking the time
+6 -4
View File
@@ -2,6 +2,8 @@
#include "RageTypes.h" #include "RageTypes.h"
#include "LuaManager.h" #include "LuaManager.h"
#include <cmath>
void RageColor::PushTable( lua_State *L ) const void RageColor::PushTable( lua_State *L ) const
{ {
lua_newtable( L ); lua_newtable( L );
@@ -53,10 +55,10 @@ void RageColor::FromStackCompat( lua_State *L, int iPos )
RString RageColor::ToString() const RString RageColor::ToString() const
{ {
int iR = clamp( (int) lrintf(r * 255), 0, 255 ); int iR = clamp( static_cast<int>(std::lrint(r * 255)), 0, 255 );
int iG = clamp( (int) lrintf(g * 255), 0, 255 ); int iG = clamp( static_cast<int>(std::lrint(g * 255)), 0, 255 );
int iB = clamp( (int) lrintf(b * 255), 0, 255 ); int iB = clamp( static_cast<int>(std::lrint(b * 255)), 0, 255 );
int iA = clamp( (int) lrintf(a * 255), 0, 255 ); int iA = clamp( static_cast<int>(std::lrint(a * 255)), 0, 255 );
if( iA == 255 ) if( iA == 255 )
return ssprintf( "#%02X%02X%02X", iR, iG, iB ); return ssprintf( "#%02X%02X%02X", iR, iG, iB );
+14 -14
View File
@@ -8,19 +8,19 @@
#include "LocalizedString.h" #include "LocalizedString.h"
#include "LuaBinding.h" #include "LuaBinding.h"
#include "LuaManager.h" #include "LuaManager.h"
#include <float.h>
#include <json/json.h> #include <json/json.h>
#include <pcre.h> #include <pcre.h>
#include <numeric> #include <cfloat>
#include <cmath>
#include <ctime> #include <ctime>
#include <sstream>
#include <map>
#include <functional> #include <functional>
#include <map>
#include <numeric>
#include <sstream>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <math.h>
const RString CUSTOM_SONG_PATH= "/@mem/"; const RString CUSTOM_SONG_PATH= "/@mem/";
@@ -38,7 +38,7 @@ namespace
MersenneTwister g_LuaPRNG; MersenneTwister g_LuaPRNG;
/* To map from [0..2^31-1] to [0..1), we divide by 2^31. */ /* To map from [0..2^31-1] to [0..1), we divide by 2^31. */
const double DIVISOR = pow( double(2), double(31) ); const double DIVISOR = std::pow( double(2), double(31) );
static int Seed( lua_State *L ) static int Seed( lua_State *L )
{ {
@@ -103,9 +103,9 @@ void fapproach( float& val, float other_val, float to_move )
if( val == other_val ) if( val == other_val )
return; return;
float fDelta = other_val - val; float fDelta = other_val - val;
float fSign = fDelta / fabsf( fDelta ); float fSign = fDelta / std::abs( fDelta );
float fToMove = fSign*to_move; float fToMove = fSign*to_move;
if( fabsf(fToMove) > fabsf(fDelta) ) if( std::abs(fToMove) > std::abs(fDelta) )
fToMove = fDelta; // snap fToMove = fDelta; // snap
val += fToMove; val += fToMove;
} }
@@ -113,9 +113,9 @@ void fapproach( float& val, float other_val, float to_move )
/* Return a positive x mod y. */ /* Return a positive x mod y. */
float fmodfp(float x, float y) float fmodfp(float x, float y)
{ {
x = fmodf(x, y); /* x is [-y,y] */ x = std::fmod(x, y); /* x is [-y,y] */
x += y; /* x is [0,y*2] */ x += y; /* x is [0,y*2] */
x = fmodf(x, y); /* x is [0,y] */ x = std::fmod(x, y); /* x is [0,y] */
return x; return x;
} }
@@ -1180,7 +1180,7 @@ float calc_stddev( const float *pStart, const float *pEnd, bool bSample )
for( const float *i=pStart; i != pEnd; ++i ) for( const float *i=pStart; i != pEnd; ++i )
fDev += (*i - fMean) * (*i - fMean); fDev += (*i - fMean) * (*i - fMean);
fDev /= std::distance( pStart, pEnd ) - (bSample ? 1 : 0); fDev /= std::distance( pStart, pEnd ) - (bSample ? 1 : 0);
fDev = sqrtf( fDev ); fDev = std::sqrt( fDev );
return fDev; return fDev;
} }
@@ -1209,7 +1209,7 @@ bool CalcLeastSquares( const std::vector<std::pair<float, float>> &vCoordinates,
fError += fOneError * fOneError; fError += fOneError * fOneError;
} }
fError /= vCoordinates.size(); fError /= vCoordinates.size();
fError = sqrtf( fError ); fError = std::sqrt( fError );
return true; return true;
} }
@@ -1220,7 +1220,7 @@ void FilterHighErrorPoints( std::vector<std::pair<float, float>> &vCoordinates,
for( unsigned int iIn = 0; iIn < vCoordinates.size(); ++iIn ) for( unsigned int iIn = 0; iIn < vCoordinates.size(); ++iIn )
{ {
const float fError = fIntercept + fSlope * vCoordinates[iIn].first - vCoordinates[iIn].second; const float fError = fIntercept + fSlope * vCoordinates[iIn].first - vCoordinates[iIn].second;
if( fabsf(fError) < fCutoff ) if( std::abs(fError) < fCutoff )
{ {
vCoordinates[iOut] = vCoordinates[iIn]; vCoordinates[iOut] = vCoordinates[iIn];
++iOut; ++iOut;
+7 -6
View File
@@ -4,6 +4,7 @@
#define RAGE_UTIL_H #define RAGE_UTIL_H
#include <algorithm> #include <algorithm>
#include <cmath>
#include <map> #include <map>
#include <random> #include <random>
#include <vector> #include <vector>
@@ -73,16 +74,16 @@ inline void wrap( unsigned &x, unsigned n )
inline void wrap( float &x, float n ) inline void wrap( float &x, float n )
{ {
if (x<0) if (x<0)
x += truncf(((-x/n)+1))*n; x += std::trunc(((-x/n)+1))*n;
x = fmodf(x,n); x = std::fmod(x,n);
} }
inline float fracf( float f ) { return f - truncf(f); } inline float fracf( float f ) { return f - std::trunc(f); }
template<class T> template<class T>
void CircularShift( std::vector<T> &v, int dist ) void CircularShift( std::vector<T> &v, int dist )
{ {
for( int i = abs(dist); i>0; i-- ) for( int i = std::abs(dist); i>0; i-- )
{ {
if( dist > 0 ) if( dist > 0 )
{ {
@@ -313,7 +314,7 @@ inline int QuantizeUp( int i, int iInterval )
inline float QuantizeUp( float i, float iInterval ) inline float QuantizeUp( float i, float iInterval )
{ {
return ceilf( i/iInterval ) * iInterval; return std::ceil( i/iInterval ) * iInterval;
} }
/* Return i rounded down to the nearest multiple of iInterval. */ /* Return i rounded down to the nearest multiple of iInterval. */
@@ -324,7 +325,7 @@ inline int QuantizeDown( int i, int iInterval )
inline float QuantizeDown( float i, float iInterval ) inline float QuantizeDown( float i, float iInterval )
{ {
return floorf( i/iInterval ) * iInterval; return std::floor( i/iInterval ) * iInterval;
} }
// Move val toward other_val by to_move. // Move val toward other_val by to_move.
+4 -1
View File
@@ -6,6 +6,9 @@
#include "ActorUtil.h" #include "ActorUtil.h"
#include "LuaManager.h" #include "LuaManager.h"
#include "ThemeManager.h" #include "ThemeManager.h"
#include <cmath>
REGISTER_ACTOR_CLASS( RollingNumbers ); REGISTER_ACTOR_CLASS( RollingNumbers );
RollingNumbers::RollingNumbers() RollingNumbers::RollingNumbers()
@@ -90,7 +93,7 @@ void RollingNumbers::Update( float fDeltaTime )
{ {
if(m_fCurrentNumber != m_fTargetNumber) if(m_fCurrentNumber != m_fTargetNumber)
{ {
fapproach( m_fCurrentNumber, m_fTargetNumber, fabsf(m_fScoreVelocity) * fDeltaTime ); fapproach( m_fCurrentNumber, m_fTargetNumber, std::abs(m_fScoreVelocity) * fDeltaTime );
UpdateText(); UpdateText();
} }
+5 -3
View File
@@ -3,6 +3,8 @@
#include "RageLog.h" #include "RageLog.h"
#include "RageUtil.h" #include "RageUtil.h"
#include <cmath>
inline float sample_step_size(int samples_per_second) inline float sample_step_size(int samples_per_second)
{ {
@@ -16,7 +18,7 @@ SampleHistory::SampleHistory()
m_fHistorySeconds = 0.0f; m_fHistorySeconds = 0.0f;
m_fToSample = sample_step_size(m_iHistorySamplesPerSecond); m_fToSample = sample_step_size(m_iHistorySamplesPerSecond);
m_fHistorySeconds = 10.0f; m_fHistorySeconds = 10.0f;
int iSamples = lrintf( m_iHistorySamplesPerSecond * m_fHistorySeconds ); int iSamples = std::lrint( m_iHistorySamplesPerSecond * m_fHistorySeconds );
m_afHistory.resize( iSamples ); m_afHistory.resize( iSamples );
} }
@@ -30,8 +32,8 @@ float SampleHistory::GetSampleNum( float fSamplesAgo ) const
float fSample = m_iLastHistory - fSamplesAgo - 1; float fSample = m_iLastHistory - fSamplesAgo - 1;
float f = floorf( fSample ); float f = std::floor( fSample );
int iSample = lrintf(f); int iSample = std::lrint(f);
int iNextSample = iSample + 1; int iNextSample = iSample + 1;
wrap( iSample, m_afHistory.size() ); wrap( iSample, m_afHistory.size() );
wrap( iNextSample, m_afHistory.size() ); wrap( iNextSample, m_afHistory.size() );
+3 -1
View File
@@ -8,6 +8,8 @@
#include "MenuTimer.h" #include "MenuTimer.h"
#include "MemoryCardManager.h" #include "MemoryCardManager.h"
#include <cmath>
REGISTER_SCREEN_CLASS( ScreenContinue ); REGISTER_SCREEN_CLASS( ScreenContinue );
@@ -69,7 +71,7 @@ bool ScreenContinue::Input( const InputEventPlus &input )
case GAME_BUTTON_LEFT: case GAME_BUTTON_LEFT:
case GAME_BUTTON_RIGHT: case GAME_BUTTON_RIGHT:
{ {
float fSeconds = floorf(m_MenuTimer->GetSeconds()) - 0.0001f; float fSeconds = std::floor(m_MenuTimer->GetSeconds()) - 0.0001f;
fSeconds = std::max( fSeconds, 0.0001f ); // don't set to 0 fSeconds = std::max( fSeconds, 0.0001f ); // don't set to 0
m_MenuTimer->SetSeconds( fSeconds ); m_MenuTimer->SetSeconds( fSeconds );
Message msg("HurryTimer"); Message msg("HurryTimer");
+7 -5
View File
@@ -5,6 +5,8 @@
#include "LuaManager.h" #include "LuaManager.h"
#include "ThemeMetric.h" #include "ThemeMetric.h"
#include <cmath>
static ThemeMetric<float> THEME_SCREEN_WIDTH("Common","ScreenWidth"); static ThemeMetric<float> THEME_SCREEN_WIDTH("Common","ScreenWidth");
static ThemeMetric<float> THEME_SCREEN_HEIGHT("Common","ScreenHeight"); static ThemeMetric<float> THEME_SCREEN_HEIGHT("Common","ScreenHeight");
@@ -24,8 +26,8 @@ float ScreenDimensions::GetThemeAspectRatio()
return THEME_NATIVE_ASPECT; return THEME_NATIVE_ASPECT;
} }
/* ceilf was originally lrintf. However, lrintf causes odd resolutions like /* ceil was originally lrint. However, lrint causes odd resolutions like
* 639x480 (4:3) and 853x480 (16:9). ceilf gives the correct values of 640x480 * 639x480 (4:3) and 853x480 (16:9). ceil gives the correct values of 640x480
* and 854x480 (should really be 852 so that SCREEN_CENTER_X == 426 and not 427) * and 854x480 (should really be 852 so that SCREEN_CENTER_X == 426 and not 427)
* respectively. -aj */ * respectively. -aj */
float ScreenDimensions::GetScreenWidth() float ScreenDimensions::GetScreenWidth()
@@ -35,9 +37,9 @@ float ScreenDimensions::GetScreenWidth()
if( fAspect > THEME_NATIVE_ASPECT ) if( fAspect > THEME_NATIVE_ASPECT )
fScale = fAspect / THEME_NATIVE_ASPECT; fScale = fAspect / THEME_NATIVE_ASPECT;
ASSERT( fScale >= 1 ); ASSERT( fScale >= 1 );
// ceilf causes the width to come out odd when it shouldn't. // ceil causes the width to come out odd when it shouldn't.
// 576 * 1.7778 = 1024.0128, which is rounded to 1025. -Kyz // 576 * 1.7778 = 1024.0128, which is rounded to 1025. -Kyz
int width= (int)ceilf(THEME_SCREEN_WIDTH * fScale); int width= std::ceil(THEME_SCREEN_WIDTH * fScale);
width-= width % 2; width-= width % 2;
return (float)width; return (float)width;
} }
@@ -49,7 +51,7 @@ float ScreenDimensions::GetScreenHeight()
if( fAspect < THEME_NATIVE_ASPECT ) if( fAspect < THEME_NATIVE_ASPECT )
fScale = THEME_NATIVE_ASPECT / fAspect; fScale = THEME_NATIVE_ASPECT / fAspect;
ASSERT( fScale >= 1 ); ASSERT( fScale >= 1 );
return (float) ceilf(THEME_SCREEN_HEIGHT * fScale); return std::ceil(THEME_SCREEN_HEIGHT * fScale);
} }
void ScreenDimensions::ReloadScreenDimensions() void ScreenDimensions::ReloadScreenDimensions()
+9 -7
View File
@@ -1,6 +1,4 @@
#include "global.h" #include "global.h"
#include <utility>
#include <float.h>
#include "ScreenEdit.h" #include "ScreenEdit.h"
#include "ActorUtil.h" #include "ActorUtil.h"
#include "AdjustSync.h" #include "AdjustSync.h"
@@ -40,6 +38,10 @@
#include "Game.h" #include "Game.h"
#include "RageSoundReader.h" #include "RageSoundReader.h"
#include <cfloat>
#include <cmath>
#include <utility>
static Preference<float> g_iDefaultRecordLength( "DefaultRecordLength", 4 ); static Preference<float> g_iDefaultRecordLength( "DefaultRecordLength", 4 );
static Preference<bool> g_bEditorShowBGChangesPlay( "EditorShowBGChangesPlay", true ); static Preference<bool> g_bEditorShowBGChangesPlay( "EditorShowBGChangesPlay", true );
@@ -1769,12 +1771,12 @@ void ScreenEdit::Update( float fDeltaTime )
// Update trailing beat // Update trailing beat
float fDelta = GetBeat() - m_fTrailingBeat; float fDelta = GetBeat() - m_fTrailingBeat;
if( fabsf(fDelta) < 10 ) if( std::abs(fDelta) < 10 )
fapproach( m_fTrailingBeat, GetBeat(), fapproach( m_fTrailingBeat, GetBeat(),
fDeltaTime*40 / m_NoteFieldEdit.GetPlayerState()->m_PlayerOptions.GetCurrent().m_fScrollSpeed ); fDeltaTime*40 / m_NoteFieldEdit.GetPlayerState()->m_PlayerOptions.GetCurrent().m_fScrollSpeed );
else else
fapproach( m_fTrailingBeat, GetBeat(), fapproach( m_fTrailingBeat, GetBeat(),
fabsf(fDelta) * fDeltaTime*5 ); std::abs(fDelta) * fDeltaTime*5 );
PlayTicks(); PlayTicks();
} }
@@ -1784,7 +1786,7 @@ static std::vector<int> FindAllAttacksAtTime(const AttackArray& attacks, float f
std::vector<int> ret; std::vector<int> ret;
for (unsigned i = 0; i < attacks.size(); ++i) for (unsigned i = 0; i < attacks.size(); ++i)
{ {
if (fabs(attacks[i].fStartSecond - fStartTime) < 0.001f) if (std::abs(attacks[i].fStartSecond - fStartTime) < 0.001f)
{ {
ret.push_back(i); ret.push_back(i);
} }
@@ -1796,7 +1798,7 @@ static int FindAttackAtTime( const AttackArray& attacks, float fStartTime )
{ {
for( unsigned i = 0; i < attacks.size(); ++i ) for( unsigned i = 0; i < attacks.size(); ++i )
{ {
if( fabs(attacks[i].fStartSecond - fStartTime) < 0.001f ) if( std::abs(attacks[i].fStartSecond - fStartTime) < 0.001f )
return i; return i;
} }
return -1; return -1;
@@ -5272,7 +5274,7 @@ void ScreenEdit::HandleAlterMenuChoice(AlterMenuChoice c, const std::vector<int>
int iStartIndex = m_NoteFieldEdit.m_iBeginMarker; int iStartIndex = m_NoteFieldEdit.m_iBeginMarker;
int iEndIndex = m_NoteFieldEdit.m_iEndMarker; int iEndIndex = m_NoteFieldEdit.m_iEndMarker;
int iNewEndIndex = iEndIndex + lrintf( (iEndIndex - iStartIndex) * (fScale - 1) ); int iNewEndIndex = iEndIndex + std::lrint( (iEndIndex - iStartIndex) * (fScale - 1) );
// scale currently editing notes // scale currently editing notes
NoteDataUtil::ScaleRegion( m_NoteDataEdit, fScale, iStartIndex, iEndIndex ); NoteDataUtil::ScaleRegion( m_NoteDataEdit, fScale, iStartIndex, iEndIndex );
+3 -1
View File
@@ -20,6 +20,8 @@
#include "CommonMetrics.h" #include "CommonMetrics.h"
#include "InputEventPlus.h" #include "InputEventPlus.h"
#include <cmath>
REGISTER_SCREEN_CLASS( ScreenEnding ); REGISTER_SCREEN_CLASS( ScreenEnding );
ScreenEnding::ScreenEnding() ScreenEnding::ScreenEnding()
@@ -51,7 +53,7 @@ ScreenEnding::ScreenEnding()
for( float f = 0; f < 100.0f; f += 1.0f ) for( float f = 0; f < 100.0f; f += 1.0f )
{ {
float fP1 = fmodf(f/100*4+.3f,1); float fP1 = std::fmod(f/100*4+.3f,1);
STATSMAN->m_CurStageStats.m_player[PLAYER_1].SetLifeRecordAt( fP1, f ); STATSMAN->m_CurStageStats.m_player[PLAYER_1].SetLifeRecordAt( fP1, f );
STATSMAN->m_CurStageStats.m_player[PLAYER_2].SetLifeRecordAt( 1-fP1, f ); STATSMAN->m_CurStageStats.m_player[PLAYER_2].SetLifeRecordAt( 1-fP1, f );
} }
+5 -3
View File
@@ -30,6 +30,8 @@
#include "ScoreKeeperNormal.h" #include "ScoreKeeperNormal.h"
#include "InputEventPlus.h" #include "InputEventPlus.h"
#include <cmath>
// metrics that are common to all ScreenEvaluation classes // metrics that are common to all ScreenEvaluation classes
#define BANNER_WIDTH THEME->GetMetricF(m_sName,"BannerWidth") #define BANNER_WIDTH THEME->GetMetricF(m_sName,"BannerWidth")
#define BANNER_HEIGHT THEME->GetMetricF(m_sName,"BannerHeight") #define BANNER_HEIGHT THEME->GetMetricF(m_sName,"BannerHeight")
@@ -143,7 +145,7 @@ void ScreenEvaluation::Init()
for( float f = 0; f < 100.0f; f += 1.0f ) for( float f = 0; f < 100.0f; f += 1.0f )
{ {
float fP1 = fmodf(f/100*4+.3f,1); float fP1 = std::fmod(f/100*4+.3f,1);
ss.m_player[PLAYER_1].SetLifeRecordAt( fP1, f ); ss.m_player[PLAYER_1].SetLifeRecordAt( fP1, f );
ss.m_player[PLAYER_2].SetLifeRecordAt( 1-fP1, f ); ss.m_player[PLAYER_2].SetLifeRecordAt( 1-fP1, f );
} }
@@ -581,8 +583,8 @@ void ScreenEvaluation::Init()
RadarCategory_Hands, RadarCategory_Rolls, RadarCategory_Lifts, RadarCategory_Fakes RadarCategory_Hands, RadarCategory_Rolls, RadarCategory_Lifts, RadarCategory_Fakes
}; };
const int ind = indices[l]; const int ind = indices[l];
const int iActual = lrintf(m_pStageStats->m_player[p].m_radarActual[ind]); const int iActual = std::lrint(m_pStageStats->m_player[p].m_radarActual[ind]);
const int iPossible = lrintf(m_pStageStats->m_player[p].m_radarPossible[ind]); const int iPossible = std::lrint(m_pStageStats->m_player[p].m_radarPossible[ind]);
// todo: check if format string is valid // todo: check if format string is valid
// (two integer values in DETAILLINE_FORMAT) -aj // (two integer values in DETAILLINE_FORMAT) -aj
+3 -1
View File
@@ -61,6 +61,8 @@
#include "Profile.h" // for replay data stuff #include "Profile.h" // for replay data stuff
#include "RageDisplay.h" #include "RageDisplay.h"
#include <cmath>
// Defines // Defines
#define SHOW_LIFE_METER_FOR_DISABLED_PLAYERS THEME->GetMetricB(m_sName,"ShowLifeMeterForDisabledPlayers") #define SHOW_LIFE_METER_FOR_DISABLED_PLAYERS THEME->GetMetricB(m_sName,"ShowLifeMeterForDisabledPlayers")
#define SHOW_SCORE_IN_RAVE THEME->GetMetricB(m_sName,"ShowScoreInRave") #define SHOW_SCORE_IN_RAVE THEME->GetMetricB(m_sName,"ShowScoreInRave")
@@ -1701,7 +1703,7 @@ void ScreenGameplay::Update( float fDeltaTime )
fSpeed *= GetHasteRate(); fSpeed *= GetHasteRate();
RageSoundParams p = m_pSoundMusic->GetParams(); RageSoundParams p = m_pSoundMusic->GetParams();
if( fabsf(p.m_fSpeed - fSpeed) > 0.01f && fSpeed >= 0.0f) if( std::abs(p.m_fSpeed - fSpeed) > 0.01f && fSpeed >= 0.0f)
{ {
p.m_fSpeed = fSpeed; p.m_fSpeed = fSpeed;
m_pSoundMusic->SetParams( p ); m_pSoundMusic->SetParams( p );
+6 -4
View File
@@ -25,6 +25,8 @@
#include "Song.h" #include "Song.h"
#include "StatsManager.h" #include "StatsManager.h"
#include <cmath>
// Defines specific to ScreenNameEntry // Defines specific to ScreenNameEntry
#define CATEGORY_Y THEME->GetMetricF(m_sName,"CategoryY") #define CATEGORY_Y THEME->GetMetricF(m_sName,"CategoryY")
#define CATEGORY_ZOOM THEME->GetMetricF(m_sName,"CategoryZoom") #define CATEGORY_ZOOM THEME->GetMetricF(m_sName,"CategoryZoom")
@@ -62,7 +64,7 @@ void ScreenNameEntry::ScrollingText::Init( const RString &sName, const std::vect
void ScreenNameEntry::ScrollingText::DrawPrimitives() void ScreenNameEntry::ScrollingText::DrawPrimitives()
{ {
const float fFakeBeat = GAMESTATE->m_Position.m_fSongBeat; const float fFakeBeat = GAMESTATE->m_Position.m_fSongBeat;
const size_t iClosestIndex = lrintf( fFakeBeat ) % CHARS_CHOICES.size(); const size_t iClosestIndex = std::lrint( fFakeBeat ) % CHARS_CHOICES.size();
const float fClosestYOffset = GetClosestCharYOffset( fFakeBeat ); const float fClosestYOffset = GetClosestCharYOffset( fFakeBeat );
size_t iCharIndex = ( iClosestIndex - NUM_CHARS_TO_DRAW_BEHIND + CHARS_CHOICES.size() ) % CHARS_CHOICES.size(); size_t iCharIndex = ( iClosestIndex - NUM_CHARS_TO_DRAW_BEHIND + CHARS_CHOICES.size() ) % CHARS_CHOICES.size();
@@ -75,7 +77,7 @@ void ScreenNameEntry::ScrollingText::DrawPrimitives()
float fAlpha = 1.f; float fAlpha = 1.f;
if( iCharIndex == iClosestIndex ) if( iCharIndex == iClosestIndex )
fZoom = SCALE( fabs(fClosestYOffset), 0, 0.5f, g_fCharsZoomLarge, g_fCharsZoomSmall ); fZoom = SCALE( std::abs(fClosestYOffset), 0, 0.5f, g_fCharsZoomLarge, g_fCharsZoomSmall );
if( i == 0 ) if( i == 0 )
fAlpha *= SCALE( fClosestYOffset, -0.5f, 0.f, 0.f, 1.f ); fAlpha *= SCALE( fClosestYOffset, -0.5f, 0.f, 0.f, 1.f );
if( i == g_iNumCharsToDrawTotal-1 ) if( i == g_iNumCharsToDrawTotal-1 )
@@ -98,13 +100,13 @@ void ScreenNameEntry::ScrollingText::DrawPrimitives()
char ScreenNameEntry::ScrollingText::GetClosestChar( float fFakeBeat ) const char ScreenNameEntry::ScrollingText::GetClosestChar( float fFakeBeat ) const
{ {
ASSERT( fFakeBeat >= 0.f ); ASSERT( fFakeBeat >= 0.f );
return CHARS_CHOICES[lrintf(fFakeBeat) % CHARS_CHOICES.size()]; return CHARS_CHOICES[std::lrint(fFakeBeat) % CHARS_CHOICES.size()];
} }
// return value is relative to gray arrows // return value is relative to gray arrows
float ScreenNameEntry::ScrollingText::GetClosestCharYOffset( float fFakeBeat ) const float ScreenNameEntry::ScrollingText::GetClosestCharYOffset( float fFakeBeat ) const
{ {
float f = fmodf(fFakeBeat, 1.0f); float f = std::fmod(fFakeBeat, 1.0f);
if( f > 0.5f ) if( f > 0.5f )
f -= 1; f -= 1;
ASSERT( f>-0.5f && f<=0.5f ); ASSERT( f>-0.5f && f<=0.5f );
+3 -1
View File
@@ -15,6 +15,8 @@
#include "LuaBinding.h" #include "LuaBinding.h"
#include "InputEventPlus.h" #include "InputEventPlus.h"
#include <cmath>
/* /*
* These navigation types are provided: * These navigation types are provided:
@@ -1210,7 +1212,7 @@ void ScreenOptions::AfterChangeRow( PlayerNumber pn )
{ {
int iWidth, iX, iY; int iWidth, iX, iY;
GetWidthXY( pn, m_iCurrentRow[pn], i, iWidth, iX, iY ); GetWidthXY( pn, m_iCurrentRow[pn], i, iWidth, iX, iY );
const int iDist = abs( iX-m_iFocusX[pn] ); const int iDist = std::abs( iX-m_iFocusX[pn] );
if( iSelectionDist == -1 || iDist < iSelectionDist ) if( iSelectionDist == -1 || iDist < iSelectionDist )
{ {
iSelectionDist = iDist; iSelectionDist = iDist;
+6 -4
View File
@@ -32,6 +32,8 @@
#include "OptionsList.h" #include "OptionsList.h"
#include "RageFileManager.h" #include "RageFileManager.h"
#include <cmath>
static const char *SelectionStateNames[] = { static const char *SelectionStateNames[] = {
"SelectingSong", "SelectingSong",
"SelectingSteps", "SelectingSteps",
@@ -1644,10 +1646,10 @@ void ScreenSelectMusic::SwitchToPreferredDifficulty()
if( GAMESTATE->m_PreferredDifficulty[pn] != Difficulty_Invalid ) if( GAMESTATE->m_PreferredDifficulty[pn] != Difficulty_Invalid )
{ {
int iDifficultyDifference = abs( s->GetDifficulty() - GAMESTATE->m_PreferredDifficulty[pn] ); int iDifficultyDifference = std::abs( s->GetDifficulty() - GAMESTATE->m_PreferredDifficulty[pn] );
int iStepsTypeDifference = 0; int iStepsTypeDifference = 0;
if( GAMESTATE->m_PreferredStepsType != StepsType_Invalid ) if( GAMESTATE->m_PreferredStepsType != StepsType_Invalid )
iStepsTypeDifference = abs( s->m_StepsType - GAMESTATE->m_PreferredStepsType ); iStepsTypeDifference = std::abs( s->m_StepsType - GAMESTATE->m_PreferredStepsType );
int iTotalDifference = iStepsTypeDifference * NUM_Difficulty + iDifficultyDifference; int iTotalDifference = iStepsTypeDifference * NUM_Difficulty + iDifficultyDifference;
if( iCurDifference == -1 || iTotalDifference < iCurDifference ) if( iCurDifference == -1 || iTotalDifference < iCurDifference )
@@ -1681,8 +1683,8 @@ void ScreenSelectMusic::SwitchToPreferredDifficulty()
if( GAMESTATE->m_PreferredCourseDifficulty[pn] != Difficulty_Invalid && GAMESTATE->m_PreferredStepsType != StepsType_Invalid ) if( GAMESTATE->m_PreferredCourseDifficulty[pn] != Difficulty_Invalid && GAMESTATE->m_PreferredStepsType != StepsType_Invalid )
{ {
int iDifficultyDifference = abs( t->m_CourseDifficulty - GAMESTATE->m_PreferredCourseDifficulty[pn] ); int iDifficultyDifference = std::abs( t->m_CourseDifficulty - GAMESTATE->m_PreferredCourseDifficulty[pn] );
int iStepsTypeDifference = abs( t->m_StepsType - GAMESTATE->m_PreferredStepsType ); int iStepsTypeDifference = std::abs( t->m_StepsType - GAMESTATE->m_PreferredStepsType );
int iTotalDifference = iStepsTypeDifference * NUM_CourseDifficulty + iDifficultyDifference; int iTotalDifference = iStepsTypeDifference * NUM_CourseDifficulty + iDifficultyDifference;
if( iCurDifference == -1 || iTotalDifference < iCurDifference ) if( iCurDifference == -1 || iTotalDifference < iCurDifference )
+4 -2
View File
@@ -15,6 +15,8 @@
#include "LuaBinding.h" #include "LuaBinding.h"
#include "arch/ArchHooks/ArchHooks.h" // HOOKS->GetClipboard() #include "arch/ArchHooks/ArchHooks.h" // HOOKS->GetClipboard()
#include <cmath>
static const char* g_szKeys[NUM_KeyboardRow][KEYS_PER_ROW] = static const char* g_szKeys[NUM_KeyboardRow][KEYS_PER_ROW] =
{ {
{"A","B","C","D","E","F","G","H","I","J","K","L","M"}, {"A","B","C","D","E","F","G","H","I","J","K","L","M"},
@@ -684,8 +686,8 @@ void ScreenTextEntryVisual::BeginScreen()
for( int x=0; x<KEYS_PER_ROW; ++x ) for( int x=0; x<KEYS_PER_ROW; ++x )
{ {
BitmapText &bt = *m_ptextKeys[r][x]; BitmapText &bt = *m_ptextKeys[r][x];
float fX = roundf( SCALE( x, 0, KEYS_PER_ROW-1, ROW_START_X, ROW_END_X ) ); float fX = std::round( SCALE( x, 0, KEYS_PER_ROW-1, ROW_START_X, ROW_END_X ) );
float fY = roundf( SCALE( r, 0, NUM_KeyboardRow-1, ROW_START_Y, ROW_END_Y ) ); float fY = std::round( SCALE( r, 0, NUM_KeyboardRow-1, ROW_START_Y, ROW_END_Y ) );
bt.SetXY( fX, fY ); bt.SetXY( fX, fY );
} }
} }
+5 -3
View File
@@ -3,6 +3,8 @@
#include "ThemeManager.h" #include "ThemeManager.h"
#include "RageUtil.h" #include "RageUtil.h"
#include <cmath>
ScrollBar::ScrollBar() ScrollBar::ScrollBar()
{ {
@@ -52,7 +54,7 @@ void ScrollBar::SetPercentage( float fCenterPercent, float fSizePercent )
/* Set tick thumb */ /* Set tick thumb */
{ {
float fY = SCALE( fCenterPercent, 0.0f, 1.0f, -iBarContentHeight/2.0f, iBarContentHeight/2.0f ); float fY = SCALE( fCenterPercent, 0.0f, 1.0f, -iBarContentHeight/2.0f, iBarContentHeight/2.0f );
fY = roundf( fY ); fY = std::round( fY );
m_sprScrollTickThumb->SetY( fY ); m_sprScrollTickThumb->SetY( fY );
} }
@@ -61,8 +63,8 @@ void ScrollBar::SetPercentage( float fCenterPercent, float fSizePercent )
float fEndPercent = fCenterPercent + fSizePercent; float fEndPercent = fCenterPercent + fSizePercent;
// make sure the percent numbers are between 0 and 1 // make sure the percent numbers are between 0 and 1
fStartPercent = fmodf( fStartPercent+1, 1 ); fStartPercent = std::fmod( fStartPercent+1, 1 );
fEndPercent = fmodf( fEndPercent+1, 1 ); fEndPercent = std::fmod( fEndPercent+1, 1 );
CHECKPOINT_M("Percentages set."); CHECKPOINT_M("Percentages set.");
float fPartTopY[2], fPartBottomY[2]; float fPartTopY[2], fPartBottomY[2];
+4 -3
View File
@@ -37,9 +37,10 @@
#include "ActorUtil.h" #include "ActorUtil.h"
#include "CommonMetrics.h" #include "CommonMetrics.h"
#include <cfloat>
#include <cmath>
#include <time.h> #include <time.h>
#include <set> #include <set>
#include <float.h>
//-Nick12 Used for song file hashing //-Nick12 Used for song file hashing
#include <CryptManager.h> #include <CryptManager.h>
@@ -847,7 +848,7 @@ void Song::TidyUpData( bool from_cache, bool /* duringCache */ )
if(m_fMusicSampleStartSeconds+m_fMusicSampleLengthSeconds > this->m_fMusicLengthSeconds) if(m_fMusicSampleStartSeconds+m_fMusicSampleLengthSeconds > this->m_fMusicLengthSeconds)
{ {
// Attempt to get a reasonable default. // Attempt to get a reasonable default.
int iBeat = lrintf(this->m_SongTiming.GetBeatFromElapsedTime(this->GetLastSecond())/2); int iBeat = std::lrint(this->m_SongTiming.GetBeatFromElapsedTime(this->GetLastSecond())/2);
iBeat -= iBeat%4; iBeat -= iBeat%4;
m_fMusicSampleStartSeconds = timing.GetElapsedTimeFromBeat((float)iBeat); m_fMusicSampleStartSeconds = timing.GetElapsedTimeFromBeat((float)iBeat);
} }
@@ -1443,7 +1444,7 @@ void Song::AddAutoGenNotes()
// has (non-autogen) Steps of this type // has (non-autogen) Steps of this type
const int iNumTracks = GAMEMAN->GetStepsTypeInfo(st).iNumTracks; const int iNumTracks = GAMEMAN->GetStepsTypeInfo(st).iNumTracks;
const int iTrackDifference = abs(iNumTracks-iNumTracksOfMissing); const int iTrackDifference = std::abs(iNumTracks-iNumTracksOfMissing);
if( iTrackDifference < iBestTrackDifference ) if( iTrackDifference < iBestTrackDifference )
{ {
stBestMatch = st; stBestMatch = st;
+3 -1
View File
@@ -4,6 +4,8 @@
#include "GameState.h" #include "GameState.h"
#include "CommonMetrics.h" #include "CommonMetrics.h"
#include <cmath>
static const char *AutosyncTypeNames[] = { static const char *AutosyncTypeNames[] = {
"Off", "Off",
"Song", "Song",
@@ -49,7 +51,7 @@ static void AddPart( std::vector<RString> &AddTo, float level, RString name )
if( level == 0 ) if( level == 0 )
return; return;
const RString LevelStr = (level == 1)? RString(""): ssprintf( "%ld%% ", lrintf(level*100) ); const RString LevelStr = (level == 1)? RString(""): ssprintf( "%ld%% ", std::lrint(level*100) );
AddTo.push_back( LevelStr + name ); AddTo.push_back( LevelStr + name );
} }
+3 -1
View File
@@ -18,6 +18,8 @@
#include "LuaBinding.h" #include "LuaBinding.h"
#include "EnumHelper.h" #include "EnumHelper.h"
#include <cmath>
ThemeMetric<int> SORT_BPM_DIVISION ( "MusicWheel", "SortBPMDivision" ); ThemeMetric<int> SORT_BPM_DIVISION ( "MusicWheel", "SortBPMDivision" );
ThemeMetric<int> SORT_LENGTH_DIVISION ( "MusicWheel", "SortLengthDivision" ); ThemeMetric<int> SORT_LENGTH_DIVISION ( "MusicWheel", "SortLengthDivision" );
ThemeMetric<bool> SHOW_SECTIONS_IN_BPM_SORT ( "MusicWheel", "ShowSectionsInBPMSort" ); ThemeMetric<bool> SHOW_SECTIONS_IN_BPM_SORT ( "MusicWheel", "ShowSectionsInBPMSort" );
@@ -235,7 +237,7 @@ Steps* SongUtil::GetClosestNotes( const Song *pSong, StepsType st, Difficulty dc
if( bIgnoreLocked && UNLOCKMAN->StepsIsLocked(pSong,pSteps) ) if( bIgnoreLocked && UNLOCKMAN->StepsIsLocked(pSong,pSteps) )
continue; continue;
int iDistance = abs(dc - pSteps->GetDifficulty()); int iDistance = std::abs(dc - pSteps->GetDifficulty());
if( iDistance < iClosestDistance ) if( iDistance < iClosestDistance )
{ {
pClosest = pSteps; pClosest = pSteps;
+6 -5
View File
@@ -1,7 +1,4 @@
#include "global.h" #include "global.h"
#include <cassert>
#include <float.h>
#include "Sprite.h" #include "Sprite.h"
#include "RageTextureManager.h" #include "RageTextureManager.h"
#include "XmlFile.h" #include "XmlFile.h"
@@ -17,6 +14,10 @@
#include "ThemeMetric.h" #include "ThemeMetric.h"
#include <numeric> #include <numeric>
#include <cassert>
#include <cfloat>
#include <cmath>
REGISTER_ACTOR_CLASS( Sprite ); REGISTER_ACTOR_CLASS( Sprite );
const float min_state_delay= 0.0001f; const float min_state_delay= 0.0001f;
@@ -500,8 +501,8 @@ void Sprite::Update( float fDelta )
* coordinates by the same amount, this won't be visible. */ * coordinates by the same amount, this won't be visible. */
if( m_bTextureWrapping ) if( m_bTextureWrapping )
{ {
const float fXAdjust = floorf( fTexCoords[0] ); const float fXAdjust = std::floor( fTexCoords[0] );
const float fYAdjust = floorf( fTexCoords[1] ); const float fYAdjust = std::floor( fTexCoords[1] );
fTexCoords[0] -= fXAdjust; fTexCoords[0] -= fXAdjust;
fTexCoords[2] -= fXAdjust; fTexCoords[2] -= fXAdjust;
fTexCoords[4] -= fXAdjust; fTexCoords[4] -= fXAdjust;
+4 -2
View File
@@ -1,4 +1,4 @@
#include "global.h" #include "global.h"
#include "StatsManager.h" #include "StatsManager.h"
#include "RageFileManager.h" #include "RageFileManager.h"
#include "GameState.h" #include "GameState.h"
@@ -19,6 +19,8 @@
#include "PlayerState.h" #include "PlayerState.h"
#include "Player.h" #include "Player.h"
#include <cmath>
StatsManager* STATSMAN = nullptr; // global object accessible from anywhere in the program StatsManager* STATSMAN = nullptr; // global object accessible from anywhere in the program
void AddPlayerStatsToProfile( Profile *pProfile, const StageStats &ss, PlayerNumber pn ); void AddPlayerStatsToProfile( Profile *pProfile, const StageStats &ss, PlayerNumber pn );
@@ -209,7 +211,7 @@ void StatsManager::CommitStatsToProfiles( const StageStats *pSS )
// Update profile stats // Update profile stats
Profile* pMachineProfile = PROFILEMAN->GetMachineProfile(); Profile* pMachineProfile = PROFILEMAN->GetMachineProfile();
int iGameplaySeconds = (int)truncf(pSS->m_fGameplaySeconds); int iGameplaySeconds = std::trunc(pSS->m_fGameplaySeconds);
pMachineProfile->m_iTotalGameplaySeconds += iGameplaySeconds; pMachineProfile->m_iTotalGameplaySeconds += iGameplaySeconds;
pMachineProfile->m_iNumTotalSongsPlayed += pSS->m_vpPlayedSongs.size(); pMachineProfile->m_iNumTotalSongsPlayed += pSS->m_vpPlayedSongs.size();
+4 -2
View File
@@ -70,6 +70,8 @@
#include "ActorUtil.h" #include "ActorUtil.h"
#include "ver.h" #include "ver.h"
#include <cmath>
#if defined(WIN32) #if defined(WIN32)
#include <windows.h> #include <windows.h>
#endif #endif
@@ -88,8 +90,8 @@ void StepMania::GetPreferredVideoModeParams( VideoModeParams &paramsOut )
{ {
//float fRatio = PREFSMAN->m_iDisplayHeight; //float fRatio = PREFSMAN->m_iDisplayHeight;
//iWidth = PREFSMAN->m_iDisplayHeight * fRatio; //iWidth = PREFSMAN->m_iDisplayHeight * fRatio;
iWidth = static_cast<int>(ceilf(PREFSMAN->m_iDisplayHeight * PREFSMAN->m_fDisplayAspectRatio)); iWidth = std::ceil(PREFSMAN->m_iDisplayHeight * PREFSMAN->m_fDisplayAspectRatio);
// ceilf causes the width to come out odd when it shouldn't. // ceil causes the width to come out odd when it shouldn't.
// 576 * 1.7778 = 1024.0128, which is rounded to 1025. -Kyz // 576 * 1.7778 = 1024.0128, which is rounded to 1025. -Kyz
iWidth-= iWidth % 2; iWidth-= iWidth % 2;
} }
+5 -3
View File
@@ -1,11 +1,13 @@
#include "global.h" #include "global.h"
#include "StreamDisplay.h" #include "StreamDisplay.h"
#include "GameState.h" #include "GameState.h"
#include <float.h>
#include "RageDisplay.h" #include "RageDisplay.h"
#include "ThemeManager.h" #include "ThemeManager.h"
#include "EnumHelper.h" #include "EnumHelper.h"
#include <cfloat>
#include <cmath>
static const char *StreamTypeNames[] = { static const char *StreamTypeNames[] = {
"Normal", "Normal",
"Passing", "Passing",
@@ -75,10 +77,10 @@ void StreamDisplay::Update( float fDeltaSecs )
// Just move straight to either full or empty. // Just move straight to either full or empty.
if( m_fPercent <= 0 || m_fPercent >= 1 ) if( m_fPercent <= 0 || m_fPercent >= 1 )
{ {
if( fabsf(fDelta) < 0.00001f ) if( std::abs(fDelta) < 0.00001f )
m_fVelocity = 0; // prevent div/0 m_fVelocity = 0; // prevent div/0
else else
m_fVelocity = (fDelta / fabsf(fDelta)) * VELOCITY_MULTIPLIER; m_fVelocity = (fDelta / std::abs(fDelta)) * VELOCITY_MULTIPLIER;
} }
else else
{ {
+2 -1
View File
@@ -19,7 +19,8 @@
#include "RageUtil.h" #include "RageUtil.h"
#include "InputMapper.h" #include "InputMapper.h"
#include "NoteData.h" #include "NoteData.h"
#include <float.h>
#include <cfloat>
bool Style::GetUsesCenteredArrows() const bool Style::GetUsesCenteredArrows() const
{ {
@@ -4,10 +4,10 @@
#include "TextureFont.h" #include "TextureFont.h"
#include "Utils.h" #include "Utils.h"
#include <vector> #include <cmath>
#include <fstream> #include <fstream>
#include <set> #include <set>
#include <math.h> #include <vector>
static TextureFont *g_pTextureFont = NULL; static TextureFont *g_pTextureFont = NULL;
+9 -9
View File
@@ -2,9 +2,9 @@
#include "TextureFont.h" #include "TextureFont.h"
#include "Utils.h" #include "Utils.h"
#include <fstream>
#include <math.h>
#include <cassert> #include <cassert>
#include <cmath>
#include <fstream>
TextureFont::TextureFont() TextureFont::TextureFont()
{ {
@@ -151,9 +151,9 @@ void TextureFont::FormatCharacter( wchar_t c, HDC hDC )
ABCFLOAT abcf; ABCFLOAT abcf;
GetCharABCWidthsFloatW( hDC, c, c, &abcf ); GetCharABCWidthsFloatW( hDC, c, c, &abcf );
abc.abcA = lrintf( abcf.abcfA ); abc.abcA = std::lrint( abcf.abcfA );
abc.abcB = lrintf( abcf.abcfB ); abc.abcB = std::lrint( abcf.abcfB );
abc.abcC = lrintf( abcf.abcfC ); abc.abcC = std::lrint( abcf.abcfC );
} }
/* /*
@@ -289,11 +289,11 @@ void TextureFont::FormatFontPage( int iPage, HDC hDC )
pPage->m_iFrameWidth = (m_BoundingRect.right - m_BoundingRect.left) + m_iPadding; pPage->m_iFrameWidth = (m_BoundingRect.right - m_BoundingRect.left) + m_iPadding;
pPage->m_iFrameHeight = (m_BoundingRect.bottom - m_BoundingRect.top) + m_iPadding; pPage->m_iFrameHeight = (m_BoundingRect.bottom - m_BoundingRect.top) + m_iPadding;
int iDimensionMultiple = 4; // TODO: This only needs to be 4 for doubleres textures. It could be 2 otherwise and use less space int iDimensionMultiple = 4; // TODO: This only needs to be 4 for doubleres textures. It could be 2 otherwise and use less space
pPage->m_iFrameWidth = (int)ceil( pPage->m_iFrameWidth /(double)iDimensionMultiple ) * iDimensionMultiple; pPage->m_iFrameWidth = std::ceil( pPage->m_iFrameWidth /(double)iDimensionMultiple ) * iDimensionMultiple;
pPage->m_iFrameHeight = (int)ceil( pPage->m_iFrameHeight /(double)iDimensionMultiple ) * iDimensionMultiple; pPage->m_iFrameHeight = std::ceil( pPage->m_iFrameHeight /(double)iDimensionMultiple ) * iDimensionMultiple;
pPage->m_iNumFramesX = (int) ceil( powf( (float) Desc.chars.size(), 0.5f ) ); pPage->m_iNumFramesX = std::ceil( std::pow( (float) Desc.chars.size(), 0.5f ) );
pPage->m_iNumFramesY = (int) ceil( (float) Desc.chars.size() / pPage->m_iNumFramesX ); pPage->m_iNumFramesY = std::ceil( (float) Desc.chars.size() / pPage->m_iNumFramesX );
pPage->Create( pPage->m_iNumFramesX*pPage->m_iFrameWidth, pPage->m_iNumFramesY*pPage->m_iFrameHeight ); pPage->Create( pPage->m_iNumFramesX*pPage->m_iFrameWidth, pPage->m_iNumFramesY*pPage->m_iFrameHeight );
-24
View File
@@ -3,30 +3,6 @@
#include "config.hpp" #include "config.hpp"
#if !defined(HAVE_TRUNCF)
inline float truncf( float f ) { return float(int(f)); };
#endif
#if !defined(HAVE_ROUNDF)
inline float roundf( float f ) { if(f < 0) return truncf(f-0.5f); return truncf(f+0.5f); };
#endif
#if !defined(HAVE_LRINTF)
#if defined(_MSC_VER) && defined(_X86_)
inline long int lrintf( float f )
{
int retval;
_asm fld f;
_asm fistp retval;
return retval;
}
#else
#define lrintf(x) ((int)rint(x))
#endif
#endif
struct Surface struct Surface
{ {
Surface() { pRGBA = NULL; } Surface() { pRGBA = NULL; }
+4 -2
View File
@@ -6,7 +6,9 @@
#include "RageLog.h" #include "RageLog.h"
#include "ThemeManager.h" #include "ThemeManager.h"
#include "NoteTypes.h" #include "NoteTypes.h"
#include <float.h>
#include <cfloat>
#include <cmath>
static void EraseSegment(std::vector<TimingSegment*> &vSegs, int index, TimingSegment *cur); static void EraseSegment(std::vector<TimingSegment*> &vSegs, int index, TimingSegment *cur);
static const int INVALID_INDEX = -1; static const int INVALID_INDEX = -1;
@@ -1030,7 +1032,7 @@ void TimingData::ScaleRegion( float fScale, int iStartIndex, int iEndIndex, bool
ASSERT( iStartIndex < iEndIndex ); ASSERT( iStartIndex < iEndIndex );
int length = iEndIndex - iStartIndex; int length = iEndIndex - iStartIndex;
int newLength = lrintf( fScale * length ); int newLength = std::lrint( fScale * length );
FOREACH_TimingSegmentType( tst ) FOREACH_TimingSegmentType( tst )
for (unsigned j = 0; j < m_avpTimingSegments[tst].size(); j++) for (unsigned j = 0; j < m_avpTimingSegments[tst].size(); j++)
+3 -1
View File
@@ -4,8 +4,10 @@
#include "NoteTypes.h" #include "NoteTypes.h"
#include "TimingSegments.h" #include "TimingSegments.h"
#include "PrefsManager.h" #include "PrefsManager.h"
#include <float.h> // max float
#include <cfloat>
#include <array> #include <array>
struct lua_State; struct lua_State;
/** @brief Compare a TimingData segment's properties with one another. */ /** @brief Compare a TimingData segment's properties with one another. */
+3 -1
View File
@@ -3,6 +3,8 @@
#include "NoteTypes.h" // Converting rows to beats and vice~versa. #include "NoteTypes.h" // Converting rows to beats and vice~versa.
#include <cmath>
enum TimingSegmentType enum TimingSegmentType
{ {
SEGMENT_BPM, SEGMENT_BPM,
@@ -37,7 +39,7 @@ const RString& TimingSegmentTypeToString( TimingSegmentType tst );
const int ROW_INVALID = -1; const int ROW_INVALID = -1;
#define COMPARE(x) if( this->x!=other.x ) return false #define COMPARE(x) if( this->x!=other.x ) return false
#define COMPARE_FLOAT(x) if( fabsf(this->x - other.x) > EPSILON ) return false #define COMPARE_FLOAT(x) if( std::abs(this->x - other.x) > EPSILON ) return false
/** /**
* @brief The base timing segment for make glorious benefit wolfman * @brief The base timing segment for make glorious benefit wolfman
+3 -1
View File
@@ -7,6 +7,8 @@
#include "NoteData.h" #include "NoteData.h"
#include "NoteDataUtil.h" #include "NoteDataUtil.h"
#include "CommonMetrics.h" #include "CommonMetrics.h"
#include <cmath>
#include <numeric> #include <numeric>
void TrailEntry::GetAttackArray( AttackArray &out ) const void TrailEntry::GetAttackArray( AttackArray &out ) const
@@ -154,7 +156,7 @@ int Trail::GetMeter() const
float fMeter = GetTotalMeter() / (float)m_vEntries.size(); float fMeter = GetTotalMeter() / (float)m_vEntries.size();
return lrintf( fMeter ); return std::lrint( fMeter );
} }
int Trail::GetTotalMeter() const int Trail::GetTotalMeter() const
+2 -1
View File
@@ -12,12 +12,13 @@
#include "Profile.h" #include "Profile.h"
#include "ThemeManager.h" #include "ThemeManager.h"
#include "Steps.h" #include "Steps.h"
#include <float.h>
#include "CommonMetrics.h" #include "CommonMetrics.h"
#include "LuaManager.h" #include "LuaManager.h"
#include "GameManager.h" #include "GameManager.h"
#include "Style.h" #include "Style.h"
#include <cfloat>
UnlockManager* UNLOCKMAN = nullptr; // global and accessible from anywhere in our program UnlockManager* UNLOCKMAN = nullptr; // global and accessible from anywhere in our program
#define UNLOCK_NAMES THEME->GetMetric ("UnlockManager","UnlockNames") #define UNLOCK_NAMES THEME->GetMetric ("UnlockManager","UnlockNames")
+8 -6
View File
@@ -15,6 +15,8 @@
#include "ThemeMetric.h" #include "ThemeMetric.h"
#include "ScreenDimensions.h" #include "ScreenDimensions.h"
#include <cmath>
const int MAX_WHEEL_SOUND_SPEED = 15; const int MAX_WHEEL_SOUND_SPEED = 15;
AutoScreenMessage( SM_SongChanged ); // TODO: Replace this with a Message and MESSAGEMAN AutoScreenMessage( SM_SongChanged ); // TODO: Replace this with a Message and MESSAGEMAN
@@ -137,7 +139,7 @@ void WheelBase::SetPositions()
{ {
WheelItemBase *pDisplay = m_WheelBaseItems[i]; WheelItemBase *pDisplay = m_WheelBaseItems[i];
const float fOffsetFromSelection = i - NUM_WHEEL_ITEMS/2 + m_fPositionOffsetFromSelection; 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 ); pDisplay->SetVisible( false );
else else
pDisplay->SetVisible( true ); pDisplay->SetVisible( true );
@@ -198,7 +200,7 @@ void WheelBase::Update( float fDeltaTime )
m_fPositionOffsetFromSelection += m_fLockedWheelVelocity*t; 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_fPositionOffsetFromSelection = 0;
m_fLockedWheelVelocity = 0; m_fLockedWheelVelocity = 0;
@@ -236,7 +238,7 @@ void WheelBase::Update( float fDeltaTime )
else else
{ {
// "rotate" wheel toward selected song // "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 ) if( m_fPositionOffsetFromSelection > 0 )
{ {
@@ -345,7 +347,7 @@ void WheelBase::ChangeMusicUnlessLocked( int n )
{ {
if(n) if(n)
{ {
int iSign = n/abs(n); int iSign = n / std::abs(n);
m_fLockedWheelVelocity = iSign*LOCKED_INITIAL_VELOCITY; m_fLockedWheelVelocity = iSign*LOCKED_INITIAL_VELOCITY;
m_soundLocked.Play(true); m_soundLocked.Play(true);
} }
@@ -364,7 +366,7 @@ void WheelBase::Move(int n)
{ {
if(n) if(n)
{ {
int iSign = n/abs(n); int iSign = n / std::abs(n);
m_fLockedWheelVelocity = iSign*LOCKED_INITIAL_VELOCITY; m_fLockedWheelVelocity = iSign*LOCKED_INITIAL_VELOCITY;
m_soundLocked.Play(true); m_soundLocked.Play(true);
} }
@@ -407,7 +409,7 @@ bool WheelBase::MoveSpecific( int n )
/* We were moving, and now we're stopping. If we're really close to /* 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 * the selection, move to the next one, so we have a chance to spin down
* smoothly. */ * smoothly. */
if(fabsf(m_fPositionOffsetFromSelection) < 0.25f ) if(std::abs(m_fPositionOffsetFromSelection) < 0.25f )
ChangeMusic(m_Moving); ChangeMusic(m_Moving);
/* Make sure the user always gets an SM_SongChanged when /* Make sure the user always gets an SM_SongChanged when
+3 -1
View File
@@ -12,7 +12,9 @@
#include "ThemeMetric.h" #include "ThemeMetric.h"
#include "LuaExpressionTransform.h" #include "LuaExpressionTransform.h"
#define NUM_WHEEL_ITEMS ((int)ceil(NUM_WHEEL_ITEMS_TO_DRAW+2)) #include <cmath>
#define NUM_WHEEL_ITEMS ((int)std::ceil(NUM_WHEEL_ITEMS_TO_DRAW+2))
enum WheelState { enum WheelState {
STATE_SELECTING, STATE_SELECTING,
+3 -1
View File
@@ -7,6 +7,8 @@
#include "RageTimer.h" #include "RageTimer.h"
#include "ThemeManager.h" #include "ThemeManager.h"
#include <cmath>
/* todo: replace this entire thing with a set of AutoActors and a Scroller. /* todo: replace this entire thing with a set of AutoActors and a Scroller.
* In reality, everything except the Beginner/Training icon can be replicated * In reality, everything except the Beginner/Training icon can be replicated
* in Lua (in stock StepMania 4), so I'm not sure if we even need this... -aj * in Lua (in stock StepMania 4), so I'm not sure if we even need this... -aj
@@ -84,7 +86,7 @@ void WheelNotifyIcon::Update( float fDeltaTime )
/* We should probably end up parsing the vector and then dynamically /* We should probably end up parsing the vector and then dynamically
* insert flag icons based on "priority". Easy to do, hopefully * insert flag icons based on "priority". Easy to do, hopefully
- Midiman */ - Midiman */
const float fSecondFraction = fmodf( RageTimer::GetTimeSinceStartFast(), 1 ); const float fSecondFraction = std::fmod( RageTimer::GetTimeSinceStartFast(), 1 );
const int index = (int)(fSecondFraction*m_vIconsToShow.size()); const int index = (int)(fSecondFraction*m_vIconsToShow.size());
Sprite::SetState( m_vIconsToShow[index] ); Sprite::SetState( m_vIconsToShow[index] );
} }
@@ -20,6 +20,7 @@
#pragma comment(lib, "xinput.lib") #pragma comment(lib, "xinput.lib")
#endif #endif
#include <cmath>
#include <XInput.h> #include <XInput.h>
#include <WbemIdl.h> #include <WbemIdl.h>
#include <OleAuto.h> #include <OleAuto.h>
@@ -783,7 +784,7 @@ void InputHandler_DInput::UpdateXInput( XIDevice &device, const RageTimer &tm )
// map joysticks // map joysticks
float lx = 0.f; float lx = 0.f;
float ly = 0.f; float ly = 0.f;
if (sqrt(pow(state.Gamepad.sThumbLX, 2) + pow(state.Gamepad.sThumbLY, 2)) > XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE) if (std::sqrt(std::pow(state.Gamepad.sThumbLX, 2) + std::pow(state.Gamepad.sThumbLY, 2)) > XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE)
{ {
lx = SCALE(state.Gamepad.sThumbLX + 0.f, XINPUT_GAMEPAD_THUMB_MIN + 0.f, XINPUT_GAMEPAD_THUMB_MAX + 0.f, -1.0f, 1.0f); lx = SCALE(state.Gamepad.sThumbLX + 0.f, XINPUT_GAMEPAD_THUMB_MIN + 0.f, XINPUT_GAMEPAD_THUMB_MAX + 0.f, -1.0f, 1.0f);
ly = SCALE(state.Gamepad.sThumbLY + 0.f, XINPUT_GAMEPAD_THUMB_MIN + 0.f, XINPUT_GAMEPAD_THUMB_MAX + 0.f, -1.0f, 1.0f); ly = SCALE(state.Gamepad.sThumbLY + 0.f, XINPUT_GAMEPAD_THUMB_MIN + 0.f, XINPUT_GAMEPAD_THUMB_MAX + 0.f, -1.0f, 1.0f);
@@ -795,7 +796,7 @@ void InputHandler_DInput::UpdateXInput( XIDevice &device, const RageTimer &tm )
float rx = 0.f; float rx = 0.f;
float ry = 0.f; float ry = 0.f;
if (sqrt(pow(state.Gamepad.sThumbRX, 2) + pow(state.Gamepad.sThumbRY, 2)) > XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE) if (std::sqrt(std::pow(state.Gamepad.sThumbRX, 2) + std::pow(state.Gamepad.sThumbRY, 2)) > XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE)
{ {
rx = SCALE(state.Gamepad.sThumbRX + 0.f, XINPUT_GAMEPAD_THUMB_MIN + 0.f, XINPUT_GAMEPAD_THUMB_MAX + 0.f, -1.0f, 1.0f); rx = SCALE(state.Gamepad.sThumbRX + 0.f, XINPUT_GAMEPAD_THUMB_MIN + 0.f, XINPUT_GAMEPAD_THUMB_MAX + 0.f, -1.0f, 1.0f);
ry = SCALE(state.Gamepad.sThumbRY + 0.f, XINPUT_GAMEPAD_THUMB_MIN + 0.f, XINPUT_GAMEPAD_THUMB_MAX + 0.f, -1.0f, 1.0f); ry = SCALE(state.Gamepad.sThumbRY + 0.f, XINPUT_GAMEPAD_THUMB_MIN + 0.f, XINPUT_GAMEPAD_THUMB_MAX + 0.f, -1.0f, 1.0f);
@@ -9,6 +9,8 @@
#include "InputMapper.h" #include "InputMapper.h"
#include "Game.h" #include "Game.h"
#include <cmath>
// xxx: don't hardcode the port address. -aj // xxx: don't hardcode the port address. -aj
static const int PORT_ADDRESS = 0x378; static const int PORT_ADDRESS = 0x378;
static const bool SCREEN_DEBUG = false; static const bool SCREEN_DEBUG = false;
@@ -46,7 +48,7 @@ void LightsDriver_LinuxParallel::Set( const LightsState *ls )
{ {
s += ls->m_bCabinetLights[cl] ? '1' : '0'; s += ls->m_bCabinetLights[cl] ? '1' : '0';
if ( ls->m_bCabinetLights[cl] ) if ( ls->m_bCabinetLights[cl] )
output += (unsigned char)pow((double)2,i); output += std::pow((double)2,i);
i++; i++;
} }
s += "\n"; s += "\n";
@@ -12,11 +12,13 @@
#include "RageSurface_Load.h" #include "RageSurface_Load.h"
#include "RageSurface.h" #include "RageSurface.h"
#include "RageSurfaceUtils.h" #include "RageSurfaceUtils.h"
#include "RageSurfaceUtils_Zoom.h"
#include "RageLog.h" #include "RageLog.h"
#include "ProductInfo.h" #include "ProductInfo.h"
#include "LocalizedString.h" #include "LocalizedString.h"
#include "RageSurfaceUtils_Zoom.h" #include <cmath>
static HBITMAP g_hBitmap = nullptr; static HBITMAP g_hBitmap = nullptr;
/* Load a RageSurface into a GDI surface. */ /* Load a RageSurface into a GDI surface. */
@@ -34,7 +36,7 @@ static HBITMAP LoadWin32Surface( const RageSurface *pSplash, HWND hWnd )
int iWidth = r.right; int iWidth = r.right;
float fRatio = (float) iWidth / s->w; float fRatio = (float) iWidth / s->w;
int iHeight = lrintf( s->h * fRatio ); int iHeight = std::lrint( s->h * fRatio );
RageSurfaceUtils::Zoom( s, iWidth, iHeight ); RageSurfaceUtils::Zoom( s, iWidth, iHeight );
} }
@@ -12,8 +12,8 @@
using namespace RageDisplay_Legacy_Helpers; using namespace RageDisplay_Legacy_Helpers;
using namespace X11Helper; using namespace X11Helper;
#include <cmath>
#include <set> #include <set>
#include <math.h> // ceil()
#include <GL/glxew.h> #include <GL/glxew.h>
#define GLX_GLXEXT_PROTOTYPES #define GLX_GLXEXT_PROTOTYPES
#include <GL/glx.h> // All sorts of stuff... #include <GL/glx.h> // All sorts of stuff...
@@ -410,7 +410,7 @@ RString LowLevelWindow_X11::TryVideoMode( const VideoModeParams &p, bool &bNewDe
} }
} }
} }
rate = roundf(fRefreshRate); rate = std::round(fRefreshRate);
g_usedCrtc = tgtOutCrtc; g_usedCrtc = tgtOutCrtc;
g_originalRandRMode = oldConf->mode; g_originalRandRMode = oldConf->mode;
@@ -559,7 +559,7 @@ RString LowLevelWindow_X11::TryVideoMode( const VideoModeParams &p, bool &bNewDe
CurrentParams.windowHeight = windowHeight; CurrentParams.windowHeight = windowHeight;
CurrentParams.renderOffscreen = renderOffscreen; CurrentParams.renderOffscreen = renderOffscreen;
ASSERT( rate > 0 ); ASSERT( rate > 0 );
CurrentParams.rate = static_cast<int> (roundf(rate)); CurrentParams.rate = std::round(rate);
if (!p.windowed) if (!p.windowed)
{ {
@@ -6,6 +6,8 @@
#include "PlayerNumber.h" #include "PlayerNumber.h"
#include "MemoryCardManager.h" #include "MemoryCardManager.h"
#include <cmath>
MemoryCardDriverThreaded_Windows::MemoryCardDriverThreaded_Windows() MemoryCardDriverThreaded_Windows::MemoryCardDriverThreaded_Windows()
{ {
m_dwLastLogicalDrives = 0; m_dwLastLogicalDrives = 0;
@@ -172,7 +174,7 @@ void MemoryCardDriverThreaded_Windows::GetUSBStorageDevices( std::vector<UsbStor
&dwNumberOfFreeClusters, &dwNumberOfFreeClusters,
&dwTotalNumberOfClusters ) ) &dwTotalNumberOfClusters ) )
{ {
usbd.iVolumeSizeMB = (int)roundf( dwTotalNumberOfClusters * (float)dwSectorsPerCluster * dwBytesPerSector / (1024*1024) ); usbd.iVolumeSizeMB = std::round( dwTotalNumberOfClusters * (float)dwSectorsPerCluster * dwBytesPerSector / (1024*1024) );
} }
} }
} }
@@ -4,6 +4,8 @@
#include "RageLog.h" #include "RageLog.h"
#include "archutils/Win32/DirectXHelpers.h" #include "archutils/Win32/DirectXHelpers.h"
#include <cmath>
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Define GUID for Texture Renderer // Define GUID for Texture Renderer
// {71771540-2017-11cf-AE26-0020AFD79767} // {71771540-2017-11cf-AE26-0020AFD79767}
@@ -54,7 +56,7 @@ HRESULT CTextureRenderer::SetMediaType(const CMediaType *pmt)
VIDEOINFO *pviBmp; // Bitmap info header VIDEOINFO *pviBmp; // Bitmap info header
pviBmp = (VIDEOINFO *)pmt->Format(); pviBmp = (VIDEOINFO *)pmt->Format();
m_lVidWidth = pviBmp->bmiHeader.biWidth; m_lVidWidth = pviBmp->bmiHeader.biWidth;
m_lVidHeight = abs(pviBmp->bmiHeader.biHeight); m_lVidHeight = std::abs(pviBmp->bmiHeader.biHeight);
m_lVidPitch = (m_lVidWidth * 3 + 3) + ~3; // We are forcing RGB24 m_lVidPitch = (m_lVidWidth * 3 + 3) + ~3; // We are forcing RGB24
return S_OK; return S_OK;
@@ -9,6 +9,8 @@
#include "RageUtil.h" #include "RageUtil.h"
#include "Sprite.h" #include "Sprite.h"
#include <cmath>
#if defined(WIN32) #if defined(WIN32)
#include "archutils/Win32/ErrorStrings.h" #include "archutils/Win32/ErrorStrings.h"
#include <windows.h> #include <windows.h>
@@ -193,9 +195,9 @@ void MovieTexture_Generic::CreateTexture()
/* Adjust m_iSourceWidth to support different source aspect ratios. */ /* Adjust m_iSourceWidth to support different source aspect ratios. */
float fSourceAspectRatio = m_pDecoder->GetSourceAspectRatio(); float fSourceAspectRatio = m_pDecoder->GetSourceAspectRatio();
if( fSourceAspectRatio < 1 ) if( fSourceAspectRatio < 1 )
m_iSourceHeight = lrintf( m_iSourceHeight / fSourceAspectRatio ); m_iSourceHeight = std::lrint( m_iSourceHeight / fSourceAspectRatio );
else if( fSourceAspectRatio > 1 ) else if( fSourceAspectRatio > 1 )
m_iSourceWidth = lrintf( m_iSourceWidth * fSourceAspectRatio ); m_iSourceWidth = std::lrint( m_iSourceWidth * fSourceAspectRatio );
/* HACK: Don't cap movie textures to the max texture size, since we /* HACK: Don't cap movie textures to the max texture size, since we
* render them onto the texture at the source dimensions. If we find a * render them onto the texture at the source dimensions. If we find a
+4 -2
View File
@@ -5,6 +5,8 @@
#include "archutils/Win32/DirectXHelpers.h" #include "archutils/Win32/DirectXHelpers.h"
#include "archutils/Win32/GetFileInformation.h" #include "archutils/Win32/GetFileInformation.h"
#include <cmath>
#if defined(_WINDOWS) #if defined(_WINDOWS)
#include <mmsystem.h> #include <mmsystem.h>
#endif #endif
@@ -282,8 +284,8 @@ void DSoundBuf::SetVolume( float fVolume )
ASSERT_M( fVolume >= 0 && fVolume <= 1, ssprintf("%f",fVolume) ); ASSERT_M( fVolume >= 0 && fVolume <= 1, ssprintf("%f",fVolume) );
if( fVolume == 0 ) if( fVolume == 0 )
fVolume = 0.001f; // fix log10f(0) == -INF fVolume = 0.001f; // fix log10(0) == -INF
float iVolumeLog2 = log10f(fVolume) / log10f(2); /* vol log 2 */ float iVolumeLog2 = std::log10(fVolume) / std::log10(2); /* vol log 2 */
/* Volume is a multiplier; SetVolume wants attenuation in hundredths of a decibel. */ /* Volume is a multiplier; SetVolume wants attenuation in hundredths of a decibel. */
const int iNewVolume = std::max( int(1000 * iVolumeLog2), DSBVOLUME_MIN ); const int iNewVolume = std::max( int(1000 * iVolumeLog2), DSBVOLUME_MIN );

Some files were not shown because too many files have changed in this diff Show More