From fb3bb1003adc1a1b54ccb97dc86f68db0398d0fe Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 9 Feb 2003 03:32:04 +0000 Subject: [PATCH] track to the beginning of freeze seconds higher precision --- stepmania/src/Song.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/stepmania/src/Song.cpp b/stepmania/src/Song.cpp index f3ca13f11e..d8f1cfb1c6 100644 --- a/stepmania/src/Song.cpp +++ b/stepmania/src/Song.cpp @@ -207,10 +207,20 @@ float Song::GetElapsedTimeFromBeat( float fBeat ) const float fBeatOut, fBPSOut; bool bFreezeOut; - while( fSecondsToMove > 0.1f ) + /* 0.001 gives higher precision and *takes about 7 more iterations than + * 0.100. A 90-second song took about 9 iterations; now it takes about + * 16. -glenn */ + while( fSecondsToMove > 0.001f ) { GetBeatAndBPSFromElapsedTime( fElapsedTimeBestGuess, fBeatOut, fBPSOut, bFreezeOut ); - if( fBeatOut > fBeat ) + /* If this is an exact match, we're done. However, if we're on a + * freeze segment, keep moving backwards until we're off it, so we + * return the time associated with the beginning of the freeze segment + * and not some random place in its middle. */ + if( fBeatOut == fBeat && !bFreezeOut) + break; + + if( fBeatOut >= fBeat ) fElapsedTimeBestGuess -= fSecondsToMove; else fElapsedTimeBestGuess += fSecondsToMove;