make GetClosestNote and GetClosestNonEmptyRow seconds based, and not time-based.

This commit is contained in:
Thai Pangsakulyanont
2011-05-26 01:12:41 +07:00
parent 8f35c048b8
commit 8b159a9df7
+12 -2
View File
@@ -1563,8 +1563,13 @@ int Player::GetClosestNote( int col, int iNoteRow, int iMaxRowsAhead, int iMaxRo
if( iPrevIndex == -1 ) if( iPrevIndex == -1 )
return iNextIndex; return iNextIndex;
// Get the current time, previous time, and next time.
float fNoteTime = m_pPlayerState->m_Position.m_fMusicSeconds ;
float fNextTime = m_Timing->GetElapsedTimeFromBeat(NoteRowToBeat(iNextIndex));
float fPrevTime = m_Timing->GetElapsedTimeFromBeat(NoteRowToBeat(iPrevIndex));
/* Figure out which row is closer. */ /* Figure out which row is closer. */
if( abs(iNoteRow-iNextIndex) > abs(iNoteRow-iPrevIndex) ) if( fabsf(fNoteTime-fNextTime) > fabsf(fNoteTime-fPrevTime) )
return iPrevIndex; return iPrevIndex;
else else
return iNextIndex; return iNextIndex;
@@ -1623,8 +1628,13 @@ int Player::GetClosestNonEmptyRow( int iNoteRow, int iMaxRowsAhead, int iMaxRows
if( iPrevRow == -1 ) if( iPrevRow == -1 )
return iNextRow; return iNextRow;
// Get the current time, previous time, and next time.
float fNoteTime = m_pPlayerState->m_Position.m_fMusicSeconds;
float fNextTime = m_Timing->GetElapsedTimeFromBeat(NoteRowToBeat(iNextRow));
float fPrevTime = m_Timing->GetElapsedTimeFromBeat(NoteRowToBeat(iPrevRow));
/* Figure out which row is closer. */ /* Figure out which row is closer. */
if( abs(iNoteRow-iNextRow) > abs(iNoteRow-iPrevRow) ) if( fabsf(fNoteTime-fNextTime) > fabsf(fNoteTime-fPrevTime) )
return iPrevRow; return iPrevRow;
else else
return iNextRow; return iNextRow;