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:
+12
-4
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user