Added lookup table system to TimingData so that GetBeatAndBPS and GetElapsedTime don't have to walk through the entire list of timing segments several times every frame during gameplay.

This commit is contained in:
Kyzentun
2015-03-14 23:17:35 -06:00
parent 0d309e633d
commit 2b7ebb3729
7 changed files with 410 additions and 237 deletions
+4 -5
View File
@@ -712,16 +712,15 @@ void BackgroundImpl::Layer::UpdateCurBGChange( const Song *pSong, float fLastMus
if( m_aBGChanges.size() == 0 )
return;
float fBeat, fBPS, fThrowAway;
bool bFreeze;
int iThrowAway;
pSong->m_SongTiming.GetBeatAndBPSFromElapsedTime( fCurrentTime, fBeat, fBPS, bFreeze, bFreeze, iThrowAway, fThrowAway );
TimingData::GetBeatArgs beat_info;
beat_info.elapsed_time= fCurrentTime;
pSong->m_SongTiming.GetBeatAndBPSFromElapsedTime(beat_info);
// Calls to Update() should *not* be scaled by music rate; fCurrentTime is. Undo it.
const float fRate = GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate;
// Find the BGSegment we're in
const int i = FindBGSegmentForBeat( fBeat );
const int i = FindBGSegmentForBeat(beat_info.beat);
float fDeltaTime = fCurrentTime - fLastMusicSeconds;
if( i != -1 && i != m_iCurBGChangeIndex ) // we're changing backgrounds