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
+21 -19
View File
@@ -7,6 +7,8 @@
#include "PlayerNumber.h"
#include "RageLog.h"
#include <cmath>
class XNode;
/** @brief The result of hitting (or missing) a tap note. */
@@ -20,7 +22,7 @@ struct TapNoteResult
/**
* @brief Offset, in seconds, for a tap grade.
*
* Negative numbers mean the note was hit early; positive numbers mean
* Negative numbers mean the note was hit early; positive numbers mean
* it was hit late. These values are only meaningful for graded taps
* (tns >= TNS_W5). */
float fTapNoteOffset;
@@ -48,11 +50,11 @@ struct HoldNoteResult
/**
* @brief the current life of the hold.
*
*
* 1.0 means this HoldNote has full life.
*
*
* 0.0 means this HoldNote is dead.
*
*
* When this value hits 0.0 for the first time, m_HoldScore becomes HNS_LetGo.
* If the life is > 0.0 when the HoldNote ends, then m_HoldScore becomes HNS_Held. */
float fLife;
@@ -152,7 +154,7 @@ struct TapNote
// also used for hold_head only:
int iDuration;
HoldNoteResult HoldResult;
// XML
XNode* CreateNode() const;
void LoadFromNode( const XNode* pNode );
@@ -161,22 +163,22 @@ struct TapNote
void PushSelf( lua_State *L );
TapNote(): type(TapNoteType_Empty), subType(TapNoteSubType_Invalid),
source(TapNoteSource_Original), result(), pn(PLAYER_INVALID), sAttackModifiers(""),
source(TapNoteSource_Original), result(), pn(PLAYER_INVALID), sAttackModifiers(""),
fAttackDurationSeconds(0), iKeysoundIndex(-1), iDuration(0), HoldResult() {}
void Init()
{
type = TapNoteType_Empty;
subType = TapNoteSubType_Invalid;
source = TapNoteSource_Original;
pn = PLAYER_INVALID,
fAttackDurationSeconds = 0.f;
subType = TapNoteSubType_Invalid;
source = TapNoteSource_Original;
pn = PLAYER_INVALID,
fAttackDurationSeconds = 0.f;
iKeysoundIndex = -1;
iDuration = 0;
}
TapNote(
TapNote(
TapNoteType type_,
TapNoteSubType subType_,
TapNoteSource source_,
TapNoteSource source_,
RString sAttackModifiers_,
float fAttackDurationSeconds_,
int iKeysoundIndex_ ):
@@ -251,8 +253,8 @@ const int ROWS_PER_BEAT = 48;
const int MAX_NOTE_ROW = (1<<30);
/** @brief The list of quantized note types allowed at present. */
enum NoteType
{
enum NoteType
{
NOTE_TYPE_4TH, /**< quarter note */
NOTE_TYPE_8TH, /**< eighth note */
NOTE_TYPE_12TH, /**< quarter note triplet */
@@ -280,16 +282,16 @@ bool IsNoteOfType( int row, NoteType t );
/*
inline int BeatToNoteRow( float fBeatNum )
{
float fraction = fBeatNum - truncf(fBeatNum);
float fraction = fBeatNum - std::trunc(fBeatNum);
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.
* @param fBeatNum the beat to convert.
* @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.
* @param fBeatNum the beat to convert.
@@ -353,7 +355,7 @@ inline T ScalePosition( T start, T length, T newLength, T position )
* @author Chris Danford, Glenn Maynard (c) 2001-2004
* @section LICENSE
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -363,7 +365,7 @@ inline T ScalePosition( T start, T length, T newLength, T position )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF