lroundf -> lrintf.

This commit is contained in:
Steve Checkoway
2007-01-03 05:05:28 +00:00
parent 92e5ea3a9f
commit 4517499f0f
18 changed files with 33 additions and 38 deletions
+2 -2
View File
@@ -104,8 +104,8 @@ void BPMDisplay::SetBPMRange( const DisplayBpms &bpms )
long int MaxBPM = INT_MIN; long int MaxBPM = INT_MIN;
for( unsigned i = 0; i < BPMS.size(); ++i ) for( unsigned i = 0; i < BPMS.size(); ++i )
{ {
MinBPM = min( MinBPM, lroundf(BPMS[i]) ); MinBPM = min( MinBPM, lrintf(BPMS[i]) );
MaxBPM = max( MaxBPM, lroundf(BPMS[i]) ); MaxBPM = max( MaxBPM, lrintf(BPMS[i]) );
} }
if( MinBPM == MaxBPM ) if( MinBPM == MaxBPM )
{ {
+5 -5
View File
@@ -191,7 +191,7 @@ void BitmapText::BuildChars()
switch( m_VertAlign ) switch( m_VertAlign )
{ {
case VertAlign_Top: iY = 0; break; case VertAlign_Top: iY = 0; break;
case VertAlign_Middle: iY = -lroundf(m_size.y/2.0f); break; case VertAlign_Middle: iY = -lrintf(m_size.y/2.0f); break;
case VertAlign_Bottom: iY = -(int)m_size.y; break; case VertAlign_Bottom: iY = -(int)m_size.y; break;
default: ASSERT( false ); default: ASSERT( false );
} }
@@ -209,7 +209,7 @@ void BitmapText::BuildChars()
switch( m_HorizAlign ) switch( m_HorizAlign )
{ {
case HorizAlign_Left: iX = 0; break; case HorizAlign_Left: iX = 0; break;
case HorizAlign_Center: iX = -lroundf(iLineWidth/2.0f); break; case HorizAlign_Center: iX = -lrintf(iLineWidth/2.0f); break;
case HorizAlign_Right: iX = -iLineWidth; break; case HorizAlign_Right: iX = -iLineWidth; break;
default: ASSERT( false ); default: ASSERT( false );
} }
@@ -254,8 +254,8 @@ void BitmapText::DrawChars()
return; return;
const int iNumGlyphs = m_pTextures.size(); const int iNumGlyphs = m_pTextures.size();
int iStartGlyph = lroundf( SCALE( m_pTempState->crop.left, 0.f, 1.f, 0, (float) iNumGlyphs ) ); int iStartGlyph = lrintf( SCALE( m_pTempState->crop.left, 0.f, 1.f, 0, (float) iNumGlyphs ) );
int iEndGlyph = lroundf( SCALE( m_pTempState->crop.right, 0.f, 1.f, (float) iNumGlyphs, 0 ) ); int iEndGlyph = lrintf( 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 );
@@ -565,7 +565,7 @@ void BitmapText::DrawPrimitives()
vector<RageVector3> vGlyphJitter; vector<RageVector3> vGlyphJitter;
if( m_bJitter ) if( m_bJitter )
{ {
int iSeed = lroundf( RageTimer::GetTimeSinceStartFast()*8 ); int iSeed = lrintf( 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 )
+1 -1
View File
@@ -56,7 +56,7 @@ void FontPage::Load( const FontPageSettings &cfg )
if( cfg.m_fScaleAllWidthsBy != 1 ) if( cfg.m_fScaleAllWidthsBy != 1 )
{ {
for( int i=0; i<m_pTexture->GetNumFrames(); i++ ) for( int i=0; i<m_pTexture->GetNumFrames(); i++ )
aiFrameWidths[i] = lroundf( aiFrameWidths[i] * cfg.m_fScaleAllWidthsBy ); aiFrameWidths[i] = lrintf( aiFrameWidths[i] * cfg.m_fScaleAllWidthsBy );
} }
m_iCharToGlyphNo = cfg.CharToGlyphNo; m_iCharToGlyphNo = cfg.CharToGlyphNo;
+3 -3
View File
@@ -20,7 +20,7 @@ NoteType NoteDataUtil::GetSmallestNoteTypeForMeasure( const NoteData &n, int iMe
for( nt=(NoteType)0; nt<NUM_NoteType; nt=NoteType(nt+1) ) // for each NoteType, largest to largest for( nt=(NoteType)0; nt<NUM_NoteType; nt=NoteType(nt+1) ) // for each NoteType, largest to largest
{ {
float fBeatSpacing = NoteTypeToBeat( nt ); float fBeatSpacing = NoteTypeToBeat( nt );
int iRowSpacing = lroundf( fBeatSpacing * ROWS_PER_BEAT ); int iRowSpacing = lrintf( fBeatSpacing * ROWS_PER_BEAT );
bool bFoundSmallerNote = false; bool bFoundSmallerNote = false;
// for each index in this measure // for each index in this measure
@@ -340,7 +340,7 @@ void NoteDataUtil::GetSMNoteDataString( const NoteData &in, RString &sRet )
if( nt == NoteType_Invalid ) if( nt == NoteType_Invalid )
iRowSpacing = 1; iRowSpacing = 1;
else else
iRowSpacing = lroundf( NoteTypeToBeat(nt) * ROWS_PER_BEAT ); iRowSpacing = lrintf( NoteTypeToBeat(nt) * ROWS_PER_BEAT );
// (verify first) // (verify first)
// iRowSpacing = BeatToNoteRow( NoteTypeToBeat(nt) ); // iRowSpacing = BeatToNoteRow( NoteTypeToBeat(nt) );
@@ -1221,7 +1221,7 @@ void NoteDataUtil::Wide( NoteData &inout, int iStartIndex, int iEndIndex )
continue; // skip continue; // skip
// add a note determinitsitcally // add a note determinitsitcally
int iBeat = lroundf( NoteRowToBeat(i) ); int iBeat = lrintf( 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 );
+2 -2
View File
@@ -21,7 +21,7 @@ void KSFLoader::RemoveHoles( NoteData &out, const Song &song )
const int ToRow = (int) BeatToNoteRow(song.m_Timing.m_BPMSegments[seg].m_fStartBeat); const int ToRow = (int) BeatToNoteRow(song.m_Timing.m_BPMSegments[seg].m_fStartBeat);
LOG->Trace("from %f (%i) to (%i)", FromBeat, FromRow, ToRow); LOG->Trace("from %f (%i) to (%i)", FromBeat, FromRow, ToRow);
// const int ToRow = lroundf(FromRow * song.m_Timing.m_BPMSegments[0].m_fBPM / song.m_BPMSegments[seg].m_fBPM); // const int ToRow = lrintf(FromRow * song.m_Timing.m_BPMSegments[0].m_fBPM / song.m_BPMSegments[seg].m_fBPM);
// const int Rows = out.GetLastRow() - FromRow + 1; // const int Rows = out.GetLastRow() - FromRow + 1;
// int LastRow; // int LastRow;
// if(seg+1 < song.m_Timing.m_BPMSegments().size()) // if(seg+1 < song.m_Timing.m_BPMSegments().size())
@@ -46,7 +46,7 @@ void KSFLoader::RemoveHoles( NoteData &out, const Song &song )
if( tn == TAP_EMPTY ) if( tn == TAP_EMPTY )
continue; continue;
const int RealRow = lroundf(row * OrigBPM / CurBPM); const int RealRow = lrintf(row * OrigBPM / CurBPM);
if( RealRow == row ) if( RealRow == row )
continue; continue;
LOG->Trace("from %i to %i", row, RealRow); LOG->Trace("from %i to %i", row, RealRow);
+1 -1
View File
@@ -361,7 +361,7 @@ bool NotesWriterDWI::Write( RString sPath, const Song &out )
ASSERT( out.m_Timing.m_BPMSegments[0].m_iStartIndex == 0 ); ASSERT( out.m_Timing.m_BPMSegments[0].m_iStartIndex == 0 );
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;", out.m_Timing.m_BPMSegments[0].GetBPM()) ); f.PutLine( ssprintf("#BPM:%.3f;", out.m_Timing.m_BPMSegments[0].GetBPM()) );
f.PutLine( ssprintf("#GAP:%ld;", -lroundf( out.m_Timing.m_fBeat0OffsetInSeconds*1000 )) ); f.PutLine( ssprintf("#GAP:%ld;", -lrintf( out.m_Timing.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() )
+3 -3
View File
@@ -704,9 +704,9 @@ void OptionRow::GetWidthXY( PlayerNumber pn, int iChoiceOnRow, int &iWidthOut, i
{ {
const BitmapText &text = GetTextItemForRow( pn, iChoiceOnRow ); const BitmapText &text = GetTextItemForRow( pn, iChoiceOnRow );
iWidthOut = lroundf( text.GetZoomedWidth() ); iWidthOut = lrintf( text.GetZoomedWidth() );
iXOut = lroundf( text.GetDestX() ); iXOut = lrintf( text.GetDestX() );
iYOut = lroundf( m_Frame.GetDestY() ); iYOut = lrintf( m_Frame.GetDestY() );
} }
+1 -1
View File
@@ -71,7 +71,7 @@ static void AddPart( vector<RString> &AddTo, float level, RString name )
if( level == 0 ) if( level == 0 )
return; return;
const RString LevelStr = (level == 1)? RString(""): ssprintf( "%ld%% ", lroundf(level*100) ); const RString LevelStr = (level == 1)? RString(""): ssprintf( "%ld%% ", lrintf(level*100) );
AddTo.push_back( LevelStr + name ); AddTo.push_back( LevelStr + name );
} }
+2 -2
View File
@@ -528,10 +528,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 = lroundf( fGLVersion * 10 ); g_glVersion = lrintf( fGLVersion * 10 );
const float fGLUVersion = StringToFloat( (const char *) gluGetString(GLU_VERSION) ); const float fGLUVersion = StringToFloat( (const char *) gluGetString(GLU_VERSION) );
g_gluVersion = lroundf( fGLUVersion * 10 ); g_gluVersion = lrintf( fGLUVersion * 10 );
GLExt.Load( g_pWind ); GLExt.Load( g_pWind );
+1 -1
View File
@@ -208,7 +208,7 @@ void GLExt_t::Load( LowLevelWindow *pWind )
else else
{ {
const float fVersion = StringToFloat( pzVersion ); const float fVersion = StringToFloat( pzVersion );
m_iShadingLanguageVersion = lroundf( fVersion * 100 ); m_iShadingLanguageVersion = lrintf( fVersion * 100 );
/* The version string may contain extra information beyond the version number. */ /* The version string may contain extra information beyond the version number. */
LOG->Info( "OpenGL shading language: %s", pzVersion ); LOG->Info( "OpenGL shading language: %s", pzVersion );
} }
+2 -2
View File
@@ -876,13 +876,13 @@ RageSurface *RageSurfaceUtils::PalettizeToGrayscale( const RageSurface *src_surf
if( Ivalues == 1 ) if( Ivalues == 1 )
ScaledI = 255; // if only one intensity value, always fullbright ScaledI = 255; // if only one intensity value, always fullbright
else else
ScaledI = clamp( lroundf(I * (255.0f / (Ivalues-1))), 0L, 255L ); ScaledI = clamp( lrintf(I * (255.0f / (Ivalues-1))), 0L, 255L );
int ScaledA; int ScaledA;
if( Avalues == 1 ) if( Avalues == 1 )
ScaledA = 255; // if only one alpha value, always opaque ScaledA = 255; // if only one alpha value, always opaque
else else
ScaledA = clamp( lroundf(A * (255.0f / (Avalues-1))), 0L, 255L ); ScaledA = clamp( lrintf(A * (255.0f / (Avalues-1))), 0L, 255L );
RageSurfaceColor c; RageSurfaceColor c;
c.r = uint8_t(ScaledI); c.r = uint8_t(ScaledI);
+2 -2
View File
@@ -559,8 +559,8 @@ void ScreenEvaluation::Init()
RadarCategory_Jumps, RadarCategory_Holds, RadarCategory_Mines, RadarCategory_Hands, RadarCategory_Rolls RadarCategory_Jumps, RadarCategory_Holds, RadarCategory_Mines, RadarCategory_Hands, RadarCategory_Rolls
}; };
const int ind = indeces[l]; const int ind = indeces[l];
const int iActual = lroundf(STATSMAN->m_CurStageStats.m_player[p].m_radarActual[ind]); const int iActual = lrintf(STATSMAN->m_CurStageStats.m_player[p].m_radarActual[ind]);
const int iPossible = lroundf(STATSMAN->m_CurStageStats.m_player[p].m_radarPossible[ind]); const int iPossible = lrintf(STATSMAN->m_CurStageStats.m_player[p].m_radarPossible[ind]);
m_textStatsText[l][p].SetText( ssprintf("%3d/%3d",iActual,iPossible) ); m_textStatsText[l][p].SetText( ssprintf("%3d/%3d",iActual,iPossible) );
} }
+2 -2
View File
@@ -67,7 +67,7 @@ void ScreenNameEntry::ScrollingText::Init( const RString &sName, const vector<fl
void ScreenNameEntry::ScrollingText::DrawPrimitives() void ScreenNameEntry::ScrollingText::DrawPrimitives()
{ {
const float fFakeBeat = GAMESTATE->m_fSongBeat; const float fFakeBeat = GAMESTATE->m_fSongBeat;
const size_t iClosestIndex = lroundf( fFakeBeat ) % g_sNameChars.size(); const size_t iClosestIndex = lrintf( fFakeBeat ) % g_sNameChars.size();
const float fClosestYOffset = GetClosestCharYOffset( fFakeBeat ); const float fClosestYOffset = GetClosestCharYOffset( fFakeBeat );
size_t iCharIndex = ( iClosestIndex - NUM_CHARS_TO_DRAW_BEHIND + g_sNameChars.size() ) % g_sNameChars.size(); size_t iCharIndex = ( iClosestIndex - NUM_CHARS_TO_DRAW_BEHIND + g_sNameChars.size() ) % g_sNameChars.size();
@@ -103,7 +103,7 @@ 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 g_sNameChars[lroundf(fFakeBeat) % g_sNameChars.size()]; return g_sNameChars[lrintf(fFakeBeat) % g_sNameChars.size()];
} }
// return value is relative to gray arrows // return value is relative to gray arrows
+1 -1
View File
@@ -43,7 +43,7 @@ static void AddPart( vector<RString> &AddTo, float level, RString name )
if( level == 0 ) if( level == 0 )
return; return;
const RString LevelStr = (level == 1)? RString(""): ssprintf( "%ld%% ", lroundf(level*100) ); const RString LevelStr = (level == 1)? RString(""): ssprintf( "%ld%% ", lrintf(level*100) );
AddTo.push_back( LevelStr + name ); AddTo.push_back( LevelStr + name );
} }
+1 -1
View File
@@ -112,7 +112,7 @@ int Trail::GetMeter() const
float fMeter = GetTotalMeter() / (float)m_vEntries.size(); float fMeter = GetTotalMeter() / (float)m_vEntries.size();
return lroundf( fMeter ); return lrintf( fMeter );
} }
int Trail::GetTotalMeter() const int Trail::GetTotalMeter() const
+3 -3
View File
@@ -69,7 +69,7 @@ static int CalculateWorkoutProgramMeter( WorkoutProgram wp, int iAverageMeter, i
case WorkoutProgram_FatBurn: case WorkoutProgram_FatBurn:
{ {
float fMeter = SCALE( iSongInBodyIndex % 4, 0.0f, 3.0f, (float)iMinMeter, (float)iMaxMeter ); float fMeter = SCALE( iSongInBodyIndex % 4, 0.0f, 3.0f, (float)iMinMeter, (float)iMaxMeter );
iMeter = lroundf( fMeter ); iMeter = lrintf( fMeter );
} }
break; break;
case WorkoutProgram_FitnessTest: case WorkoutProgram_FitnessTest:
@@ -92,7 +92,7 @@ static int CalculateWorkoutProgramMeter( WorkoutProgram wp, int iAverageMeter, i
break; break;
case 4: case 4:
case 5: case 5:
iMeter = lroundf( SCALE( 0.5f, 0.0f, 1.0f, (float)iMinMeter, (float)iMaxMeter ) ); iMeter = lrintf( SCALE( 0.5f, 0.0f, 1.0f, (float)iMinMeter, (float)iMaxMeter ) );
break; break;
} }
} }
@@ -107,7 +107,7 @@ static int CalculateWorkoutProgramMeter( WorkoutProgram wp, int iAverageMeter, i
float fMeter = SCALE( iSongInBodyIndex % 4, 0.0f, 3.0f, (float)iMinMeter, (float)iMaxMeter ); float fMeter = SCALE( iSongInBodyIndex % 4, 0.0f, 3.0f, (float)iMinMeter, (float)iMaxMeter );
if( (iSongInBodyIndex % 8) >= 4 ) if( (iSongInBodyIndex % 8) >= 4 )
fMeter = SCALE( fMeter, (float)iMinMeter, (float)iMaxMeter, (float)iMaxMeter, (float)iMinMeter ); fMeter = SCALE( fMeter, (float)iMinMeter, (float)iMaxMeter, (float)iMaxMeter, (float)iMinMeter );
iMeter = lroundf( fMeter ); iMeter = lrintf( fMeter );
} }
break; break;
case WorkoutProgram_Flat: case WorkoutProgram_Flat:
@@ -58,7 +58,7 @@ void SetThreadPrecedence( float prec )
// Real values are between 0 and 63. // Real values are between 0 and 63.
if( CLAMP(prec, 0.0f, 1.0f) ) if( CLAMP(prec, 0.0f, 1.0f) )
LOG->Warn( "Thread precedence clamped to %f.", prec ); LOG->Warn( "Thread precedence clamped to %f.", prec );
thread_precedence_policy po = { integer_t( lroundf(prec * 63) ) }; thread_precedence_policy po = { integer_t( lrintf(prec * 63) ) };
kern_return_t ret = thread_policy_set( mach_thread_self(), THREAD_PRECEDENCE_POLICY, kern_return_t ret = thread_policy_set( mach_thread_self(), THREAD_PRECEDENCE_POLICY,
(thread_policy_t)&po, THREAD_PRECEDENCE_POLICY_COUNT ); (thread_policy_t)&po, THREAD_PRECEDENCE_POLICY_COUNT );
-5
View File
@@ -208,11 +208,6 @@ inline float roundf( float f ) CONST_FUNCTION;
float roundf( float f ) { if( f < 0.0f ) return truncf( f-0.5f ); return truncf( f+0.5f ); } float roundf( float f ) { if( f < 0.0f ) return truncf( f-0.5f ); return truncf( f+0.5f ); }
#endif #endif
#ifdef NEED_LROUNDF
inline long int lroundf( float f ) CONST_FUNCTION;
long int lroundf( float f ) { return (long int)roundf( f ); }
#endif
#ifdef NEED_STRTOF #ifdef NEED_STRTOF
inline float strtof( const char *s, char **se ) { return (float) strtod( s, se ); } inline float strtof( const char *s, char **se ) { return (float) strtod( s, se ); }
#endif #endif