froundf -> Quantize

This commit is contained in:
Chris Danford
2004-10-24 17:44:51 +00:00
parent bb0da6a289
commit ce4780559f
8 changed files with 16 additions and 16 deletions
+1 -1
View File
@@ -350,7 +350,7 @@ static float ArrowGetPercentVisible( PlayerNumber pn, int iCol, float fYOffset,
if( fAppearances[PlayerOptions::APPEARANCE_BLINK] > 0 )
{
float f = sinf(RageTimer::GetTimeSinceStart()*10);
f = froundf( f, 0.3333f );
f = Quantize( f, 0.3333f );
fVisibleAdjust += SCALE( f, 0, 1, -1, 0 );
}
if( fAppearances[PlayerOptions::APPEARANCE_RANDOMVANISH] > 0)
+1 -1
View File
@@ -112,7 +112,7 @@ public:
float fPercentBetweenStrips = 1.0f/NUM_STRIPS;
// round this so that the chamber overflows align
if( NUM_CHAMBERS > 10 )
fPercentBetweenStrips = froundf( fPercentBetweenStrips, fChamberWidthInPercent );
fPercentBetweenStrips = Quantize( fPercentBetweenStrips, fChamberWidthInPercent );
float fPercentOffset = fmodf( GAMESTATE->m_fSongBeat/4+1000, fPercentBetweenStrips );
ASSERT( fPercentOffset >= 0 && fPercentOffset <= fPercentBetweenStrips );
+5 -5
View File
@@ -863,7 +863,7 @@ void NoteDataUtil::Wide( NoteData &inout, float fStartBeat, float fEndBeat )
inout.ConvertHoldNotesTo4s();
/* Start on an even beat. */
fStartBeat = froundf( fStartBeat, 2 );
fStartBeat = Quantize( fStartBeat, 2 );
const int first_row = BeatToNoteRow( fStartBeat );
const int last_row = min( BeatToNoteRow(fEndBeat), inout.GetLastRow() );
@@ -949,7 +949,7 @@ void NoteDataUtil::InsertIntelligentTaps(
bool bRequireNoteAtEndOfWindow = true;
/* Start on a multiple of fBeatInterval. */
fStartBeat = froundf( fStartBeat, fWindowStrideBeats );
fStartBeat = Quantize( fStartBeat, fWindowStrideBeats );
// Insert a beat in the middle of every fBeatInterval.
const int first_row = BeatToNoteRow( fStartBeat );
@@ -1098,7 +1098,7 @@ void NoteDataUtil::Echo( NoteData &inout, float fStartBeat, float fEndBeat )
// add 8th note tap "echos" after all taps
int iEchoTrack = -1;
fStartBeat = froundf( fStartBeat, 0.5 );
fStartBeat = Quantize( fStartBeat, 0.5 );
const int first_row = BeatToNoteRow( fStartBeat );
const int last_row = min( BeatToNoteRow(fEndBeat), inout.GetLastRow() );
@@ -1304,8 +1304,8 @@ void NoteDataUtil::SnapToNearestNoteType( NoteData &inout, NoteType nt1, NoteTyp
{
int iOldIndex = i;
float fOldBeat = NoteRowToBeat( iOldIndex );
float fNewBeat1 = froundf( fOldBeat, fSnapInterval1 );
float fNewBeat2 = froundf( fOldBeat, fSnapInterval2 );
float fNewBeat1 = Quantize( fOldBeat, fSnapInterval1 );
float fNewBeat2 = Quantize( fOldBeat, fSnapInterval2 );
bool bNewBeat1IsCloser = fabsf(fNewBeat1-fOldBeat) < fabsf(fNewBeat2-fOldBeat);
float fNewBeat = bNewBeat1IsCloser ? fNewBeat1 : fNewBeat2;
+1 -1
View File
@@ -369,7 +369,7 @@ void NoteDisplay::SetActiveFrame( float fNoteBeat, Actor &actorToSet, float fAni
// one tick off in general
const float fFraction = fNoteBeatFraction - 0.25f/fAnimationLengthInBeats;
const float fInterval = 1.f / fAnimationLengthInBeats;
fPercentIntoAnimation += froundf(fFraction,fInterval);
fPercentIntoAnimation += Quantize(fFraction,fInterval);
}
// just in case somehow we're majorly negative with the subtraction
+1 -1
View File
@@ -447,7 +447,7 @@ void NoteField::DrawPrimitives()
// Draw beat bars
//
{
float fStartDrawingMeasureBars = max( 0, froundf(fFirstBeatToDraw-0.25f,0.25f) );
float fStartDrawingMeasureBars = max( 0, Quantize(fFirstBeatToDraw-0.25f,0.25f) );
for( float f=fStartDrawingMeasureBars; f<fLastBeatToDraw; f+=0.25f )
DrawBeatBar( f );
}
+1 -1
View File
@@ -315,7 +315,7 @@ bool BMSLoader::LoadFromBMSFile( const CString &sPath, Steps &out, const map<CSt
// some BMS files seem to have funky alignment, causing us to write gigantic cache files.
// Try to correct for this by quantizing.
row = froundf( row, ROWS_PER_MEASURE/64 );
row = Quantize( row, ROWS_PER_MEASURE/64 );
BmsTrack bmsTrack;
bool bIsHold;
+1 -1
View File
@@ -151,7 +151,7 @@ inline float randomf( const float low=-1.0f, const float high=1.0f )
}
/* return f rounded to the nearest multiple of fRoundInterval */
inline float froundf( const float f, const float fRoundInterval )
inline float Quantize( const float f, const float fRoundInterval )
{
return int( (f + fRoundInterval/2)/fRoundInterval ) * fRoundInterval;
}
+5 -5
View File
@@ -453,8 +453,8 @@ void ScreenEdit::Update( float fDeltaTime )
float fEndBeat = max( fStartBeat, GAMESTATE->m_fSongBeat );
// Round hold start and end to the nearest snap interval
fStartBeat = froundf( fStartBeat, NoteTypeToBeat(m_SnapDisplay.GetNoteType()) );
fEndBeat = froundf( fEndBeat, NoteTypeToBeat(m_SnapDisplay.GetNoteType()) );
fStartBeat = Quantize( fStartBeat, NoteTypeToBeat(m_SnapDisplay.GetNoteType()) );
fEndBeat = Quantize( fEndBeat, NoteTypeToBeat(m_SnapDisplay.GetNoteType()) );
// create a new hold note
HoldNote newHN( t, BeatToNoteRow(fStartBeat), BeatToNoteRow(fEndBeat) );
@@ -856,7 +856,7 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ
GAMESTATE->m_fSongBeat += fBeatsToMove;
GAMESTATE->m_fSongBeat = max( GAMESTATE->m_fSongBeat, 0 );
GAMESTATE->m_fSongBeat = froundf( GAMESTATE->m_fSongBeat, NoteTypeToBeat(m_SnapDisplay.GetNoteType()) );
GAMESTATE->m_fSongBeat = Quantize( GAMESTATE->m_fSongBeat, NoteTypeToBeat(m_SnapDisplay.GetNoteType()) );
m_soundChangeLine.Play();
}
break;
@@ -1207,7 +1207,7 @@ void ScreenEdit::InputRecord( const DeviceInput& DeviceI, const InputEventType t
// Add a tap
float fBeat = GAMESTATE->m_fSongBeat;
fBeat = froundf( fBeat, NoteTypeToBeat(m_SnapDisplay.GetNoteType()) );
fBeat = Quantize( fBeat, NoteTypeToBeat(m_SnapDisplay.GetNoteType()) );
const int iRow = BeatToNoteRow( fBeat );
if( iRow < 0 )
@@ -1301,7 +1301,7 @@ void ScreenEdit::TransitionToEdit()
m_rectRecordBack.SetDiffuse( RageColor(0,0,0,0) );
/* Make sure we're snapped. */
GAMESTATE->m_fSongBeat = froundf( GAMESTATE->m_fSongBeat, NoteTypeToBeat(m_SnapDisplay.GetNoteType()) );
GAMESTATE->m_fSongBeat = Quantize( GAMESTATE->m_fSongBeat, NoteTypeToBeat(m_SnapDisplay.GetNoteType()) );
/* Playing and recording have lead-ins, which may start before beat 0;
* make sure we don't stay there if we escaped out early. */