prepwork: also generate a data structure for note statistics that can
determine the number of notes to display from any beat to any beat in O(log n) [n = number of non-empty rows]. it might be used to determine the first displayed beat or last displayed beat based on number of notes on screen (instead of fixed beats), if this can be implemented properly, then notes will no longer disappear or appear during a long slow scrolls/speeds [as long as the number of notes to display is in our limit].
This commit is contained in:
+39
-23
@@ -583,6 +583,42 @@ static bool NeedsHoldJudging( const TapNote &tn )
|
||||
}
|
||||
}
|
||||
|
||||
static void GenerateCacheDataStructure(PlayerState *pPlayerState, const NoteData ¬es) {
|
||||
|
||||
pPlayerState->m_CacheDisplayedBeat.clear();
|
||||
|
||||
const vector<TimingSegment*> vScrolls = pPlayerState->GetDisplayedTiming().GetTimingSegments( SEGMENT_SCROLL );
|
||||
|
||||
float displayedBeat = 0.0f;
|
||||
float lastRealBeat = 0.0f;
|
||||
float lastRatio = 1.0f;
|
||||
for ( unsigned i = 0; i < vScrolls.size(); i++ )
|
||||
{
|
||||
ScrollSegment *seg = ToScroll( vScrolls[i] );
|
||||
displayedBeat += ( seg->GetBeat() - lastRealBeat ) * lastRatio;
|
||||
lastRealBeat = seg->GetBeat();
|
||||
lastRatio = seg->GetRatio();
|
||||
CacheDisplayedBeat c = { seg->GetBeat(), displayedBeat, seg->GetRatio() };
|
||||
pPlayerState->m_CacheDisplayedBeat.push_back( c );
|
||||
}
|
||||
|
||||
pPlayerState->m_CacheNoteStat.clear();
|
||||
|
||||
NoteData::all_tracks_const_iterator it = notes.GetTapNoteRangeAllTracks( 0, MAX_NOTE_ROW, true );
|
||||
int count = 0, lastCount = 0;
|
||||
for( ; !it.IsAtEnd(); ++it )
|
||||
{
|
||||
for( int t = 0; t < notes.GetNumTracks(); t++ )
|
||||
{
|
||||
if( notes.GetTapNote( t, it.Row() ) != TAP_EMPTY ) count ++;
|
||||
}
|
||||
CacheNoteStat c = { NoteRowToBeat(it.Row()), lastCount, count };
|
||||
lastCount = count;
|
||||
pPlayerState->m_CacheNoteStat.push_back(c);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Player::Load()
|
||||
{
|
||||
m_bLoaded = true;
|
||||
@@ -624,6 +660,9 @@ void Player::Load()
|
||||
|
||||
m_Timing = &GAMESTATE->m_pCurSteps[pn]->m_Timing;
|
||||
|
||||
// Generate some cache data structure.
|
||||
GenerateCacheDataStructure(m_pPlayerState, m_NoteData);
|
||||
|
||||
switch( GAMESTATE->m_PlayMode )
|
||||
{
|
||||
case PLAY_MODE_RAVE:
|
||||
@@ -751,26 +790,6 @@ void Player::SendComboMessages( int iOldCombo, int iOldMissCombo )
|
||||
}
|
||||
}
|
||||
|
||||
static void GenerateCacheDataStructure(PlayerState *pPlayerState, NoteData ¬es) {
|
||||
|
||||
pPlayerState->m_CacheDisplayedBeat.clear();
|
||||
|
||||
const vector<TimingSegment*> vScrolls = pPlayerState->GetDisplayedTiming().GetTimingSegments( SEGMENT_SCROLL );
|
||||
|
||||
float displayedBeat = 0.0f;
|
||||
float lastRealBeat = 0.0f;
|
||||
float lastRatio = 1.0f;
|
||||
for ( unsigned i = 0; i < vScrolls.size(); i++ )
|
||||
{
|
||||
ScrollSegment *seg = ToScroll( vScrolls[i] );
|
||||
displayedBeat += ( seg->GetBeat() - lastRealBeat ) * lastRatio;
|
||||
lastRealBeat = seg->GetBeat();
|
||||
lastRatio = seg->GetRatio();
|
||||
CacheDisplayedBeat c = { seg->GetBeat(), displayedBeat, seg->GetRatio() };
|
||||
pPlayerState->m_CacheDisplayedBeat.push_back( c );
|
||||
}
|
||||
}
|
||||
|
||||
void Player::Update( float fDeltaTime )
|
||||
{
|
||||
const RageTimer now;
|
||||
@@ -900,9 +919,6 @@ void Player::Update( float fDeltaTime )
|
||||
if( m_bPaused )
|
||||
return;
|
||||
|
||||
// Generate some cache data structure.
|
||||
GenerateCacheDataStructure(m_pPlayerState, m_NoteData);
|
||||
|
||||
// Check for a strum miss
|
||||
if( m_pPlayerState->m_fLastStrumMusicSeconds != -1 &&
|
||||
m_pPlayerState->m_fLastStrumMusicSeconds + g_fTimingWindowStrum < m_pPlayerState->m_Position.m_fMusicSeconds )
|
||||
|
||||
Reference in New Issue
Block a user