From dd02f1bc10b21f52bc8073ad16cd5878865e98cd Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 12 Mar 2005 06:09:43 +0000 Subject: [PATCH] eliminate extra fmodf for each rendered tap --- stepmania/src/NoteDisplay.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/stepmania/src/NoteDisplay.cpp b/stepmania/src/NoteDisplay.cpp index 3c1e68d77f..b9f4487def 100644 --- a/stepmania/src/NoteDisplay.cpp +++ b/stepmania/src/NoteDisplay.cpp @@ -362,9 +362,12 @@ void NoteDisplay::Update( float fDeltaTime ) void NoteDisplay::SetActiveFrame( float fNoteBeat, Actor &actorToSet, float fAnimationLengthInBeats, bool bVivid, bool bNoteColor ) { - + /* -inf ... inf */ float fSongBeat = GAMESTATE->m_fSongBeat; - float fPercentIntoAnimation = fmodf(fSongBeat,fAnimationLengthInBeats) / fAnimationLengthInBeats; + /* -len ... +len */ + float fPercentIntoAnimation = fmodf( fSongBeat, fAnimationLengthInBeats ); + /* -1 ... 1 */ + fPercentIntoAnimation /= fAnimationLengthInBeats; if( bVivid ) { @@ -374,10 +377,16 @@ void NoteDisplay::SetActiveFrame( float fNoteBeat, Actor &actorToSet, float fAni const float fFraction = fNoteBeatFraction - 0.25f/fAnimationLengthInBeats; const float fInterval = 1.f / fAnimationLengthInBeats; fPercentIntoAnimation += Quantize(fFraction,fInterval); - } - // just in case somehow we're majorly negative with the subtraction - wrap( fPercentIntoAnimation, 1.f ); + // just in case somehow we're majorly negative with the subtraction + wrap( fPercentIntoAnimation, 1.f ); + } + else + { + /* 0 ... 1, wrapped */ + if( fPercentIntoAnimation < 0 ) + fPercentIntoAnimation += 1.0f; + } float fLengthSeconds = actorToSet.GetAnimationLengthSeconds(); actorToSet.SetSecondsIntoAnimation( fPercentIntoAnimation*fLengthSeconds );