try to improve performance with scroll segments:

- optimize GetDisplayedBeat (seems to be a bottleneck here).
- make sure that fFirstBeatToDraw <= fBeat <= fLastBeatToDraw in IS_ON_SCREEN.
This commit is contained in:
Thai Pangsakulyanont
2011-06-04 19:02:45 +07:00
parent a1681faa06
commit 49042c4878
2 changed files with 13 additions and 5 deletions
+12 -4
View File
@@ -1002,11 +1002,19 @@ float TimingData::GetElapsedTimeFromBeatNoOffset( float fBeat ) const
float TimingData::GetDisplayedBeat( float fBeat ) const
{
unsigned index = GetScrollSegmentIndexAtBeat(fBeat);
float fOutBeat = ( fBeat - NoteRowToBeat(m_ScrollSegments[index].m_iStartRow) ) * m_ScrollSegments[index].m_fPercent;
for( unsigned i = 0; i < index; i ++ )
vector<ScrollSegment>::const_iterator it = m_ScrollSegments.begin(), end = m_ScrollSegments.end();
float fOutBeat = 0.0;
for( ; it != end; it++ )
{
fOutBeat += ( NoteRowToBeat(m_ScrollSegments[i + 1].m_iStartRow) - NoteRowToBeat(m_ScrollSegments[i].m_iStartRow) ) * m_ScrollSegments[i].m_fPercent;
if( it+1 == end || BeatToNoteRow(fBeat) <= (it+1)->m_iStartRow )
{
fOutBeat += ( fBeat - NoteRowToBeat((it)->m_iStartRow) ) * (it)->m_fPercent;
break;
}
else
{
fOutBeat += ( NoteRowToBeat((it+1)->m_iStartRow) - NoteRowToBeat((it)->m_iStartRow) ) * (it)->m_fPercent;
}
}
return fOutBeat;
}