[timing] More conversion.

This commit is contained in:
Jason Felds
2011-07-14 13:00:03 -04:00
parent da291c2097
commit 26e311a49e
3 changed files with 48 additions and 38 deletions
+20 -14
View File
@@ -421,35 +421,41 @@ void BackgroundImpl::LoadFromRandom( float fFirstBeat, float fEndBeat, const Bac
const TimingData &timing = m_pSong->m_SongTiming;
// change BG every time signature change or 4 measures
FOREACH_CONST( TimeSignatureSegment, timing.m_vTimeSignatureSegments, iter )
const vector<TimingSegment *> &tSigs = timing.allTimingSegments[SEGMENT_TIME_SIG];
for (unsigned i = 0; i < tSigs.size(); i++)
{
vector<TimeSignatureSegment>::const_iterator next = iter;
next++;
int iSegmentEndRow = (next == timing.m_vTimeSignatureSegments.end()) ? iEndRow : next->GetRow();
TimeSignatureSegment *ts = static_cast<TimeSignatureSegment *>(tSigs[i]);
int iSegmentEndRow = (i + 1 == tSigs.size()) ? iEndRow : tSigs[i+1]->GetRow();
for( int i=max(iter->GetRow(),iStartRow); i<min(iEndRow,iSegmentEndRow); i+=4*iter->GetNoteRowsPerMeasure() )
for(int j=max(ts->GetRow(),iStartRow);
j<min(iEndRow,iSegmentEndRow);
j+=4*ts->GetNoteRowsPerMeasure())
{
// Don't fade. It causes frame rate dip, especially on slower machines.
BackgroundDef bd = m_Layer[0].CreateRandomBGA( m_pSong, change.m_def.m_sEffect, m_RandomBGAnimations, this );
BackgroundDef bd = m_Layer[0].CreateRandomBGA(m_pSong,
change.m_def.m_sEffect,
m_RandomBGAnimations, this);
if( !bd.IsEmpty() )
{
BackgroundChange c = change;
c.m_def = bd;
c.m_fStartBeat = NoteRowToBeat(i);
c.m_fStartBeat = NoteRowToBeat(j);
m_Layer[0].m_aBGChanges.push_back( c );
}
}
}
// change BG every BPM change that is at the beginning of a measure
for( unsigned i=0; i<timing.m_BPMSegments.size(); i++ )
const vector<TimingSegment *> &bpms = timing.allTimingSegments[SEGMENT_BPM];
for( unsigned i=0; i<bpms.size(); i++ )
{
const BPMSegment& bpmseg = timing.m_BPMSegments[i];
bool bAtBeginningOfMeasure = false;
FOREACH_CONST( TimeSignatureSegment, timing.m_vTimeSignatureSegments, iter )
for (unsigned j=0; j<tSigs.size(); j++)
{
if( (bpmseg.GetRow() - iter->GetRow()) % iter->GetNoteRowsPerMeasure() == 0 )
TimeSignatureSegment *ts = static_cast<TimeSignatureSegment *>(tSigs[j]);
if ((bpms[i]->GetRow() - ts->GetRow()) % ts->GetNoteRowsPerMeasure() == 0)
{
bAtBeginningOfMeasure = true;
break;
@@ -460,7 +466,7 @@ void BackgroundImpl::LoadFromRandom( float fFirstBeat, float fEndBeat, const Bac
continue; // skip
// start so that we don't create a BGChange right on top of fEndBeat
bool bInRange = bpmseg.GetRow() >= iStartRow && bpmseg.GetRow() < iEndRow;
bool bInRange = bpms[i]->GetRow() >= iStartRow && bpms[i]->GetRow() < iEndRow;
if( !bInRange )
continue; // skip
@@ -470,7 +476,7 @@ void BackgroundImpl::LoadFromRandom( float fFirstBeat, float fEndBeat, const Bac
BackgroundChange c = change;
c.m_def.m_sFile1 = bd.m_sFile1;
c.m_def.m_sFile2 = bd.m_sFile2;
c.m_fStartBeat = bpmseg.GetBeat();
c.m_fStartBeat = bpms[i]->GetBeat();
m_Layer[0].m_aBGChanges.push_back( c );
}
}