optimize updating of holds (10-13 fps => 15-18 in multiplayer)
This commit is contained in:
+42
-10
@@ -158,6 +158,7 @@ Player::Player( NoteData &nd, bool bVisible ) : m_NoteData(nd)
|
|||||||
m_pSecondaryScoreKeeper = NULL;
|
m_pSecondaryScoreKeeper = NULL;
|
||||||
m_pInventory = NULL;
|
m_pInventory = NULL;
|
||||||
m_pIterNotJudged = NULL;
|
m_pIterNotJudged = NULL;
|
||||||
|
m_pIterCurrentOrUpcoming = NULL;
|
||||||
m_pIterUncrossedRows = NULL;
|
m_pIterUncrossedRows = NULL;
|
||||||
|
|
||||||
m_bPaused = false;
|
m_bPaused = false;
|
||||||
@@ -190,6 +191,7 @@ Player::~Player()
|
|||||||
SAFE_DELETE( m_vpHoldJudgment[i] );
|
SAFE_DELETE( m_vpHoldJudgment[i] );
|
||||||
SAFE_DELETE( m_pJudgedRows );
|
SAFE_DELETE( m_pJudgedRows );
|
||||||
SAFE_DELETE( m_pIterNotJudged );
|
SAFE_DELETE( m_pIterNotJudged );
|
||||||
|
SAFE_DELETE( m_pIterCurrentOrUpcoming );
|
||||||
SAFE_DELETE( m_pIterUncrossedRows );
|
SAFE_DELETE( m_pIterUncrossedRows );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -518,6 +520,9 @@ void Player::Load()
|
|||||||
SAFE_DELETE( m_pIterNotJudged );
|
SAFE_DELETE( m_pIterNotJudged );
|
||||||
m_pIterNotJudged = new NoteData::all_tracks_iterator( m_NoteData.GetTapNoteRangeAllTracks(iNoteRow, MAX_NOTE_ROW, NotJudged) );
|
m_pIterNotJudged = new NoteData::all_tracks_iterator( m_NoteData.GetTapNoteRangeAllTracks(iNoteRow, MAX_NOTE_ROW, NotJudged) );
|
||||||
|
|
||||||
|
SAFE_DELETE( m_pIterCurrentOrUpcoming );
|
||||||
|
m_pIterCurrentOrUpcoming = new NoteData::all_tracks_iterator( m_NoteData.GetTapNoteRangeAllTracks(iNoteRow, MAX_NOTE_ROW, NotJudged) );
|
||||||
|
|
||||||
SAFE_DELETE( m_pIterUncrossedRows );
|
SAFE_DELETE( m_pIterUncrossedRows );
|
||||||
m_pIterUncrossedRows = new NoteData::all_tracks_iterator( m_NoteData.GetTapNoteRangeAllTracks(iNoteRow, MAX_NOTE_ROW, NotJudged) );
|
m_pIterUncrossedRows = new NoteData::all_tracks_iterator( m_NoteData.GetTapNoteRangeAllTracks(iNoteRow, MAX_NOTE_ROW, NotJudged) );
|
||||||
}
|
}
|
||||||
@@ -701,20 +706,45 @@ void Player::Update( float fDeltaTime )
|
|||||||
// update HoldNotes logic
|
// update HoldNotes logic
|
||||||
//
|
//
|
||||||
{
|
{
|
||||||
// Check only 1 beat back for holds. Even 1 beat is overkill.
|
// Update CurrentOrUpcomingNote pointers to point to the note
|
||||||
const int iStartCheckingAt = max( 0, iSongRow-BeatToNoteRow(1) );
|
// at or after iSongRow.
|
||||||
vector<TrackRowTapNote> vHoldNotesToGradeTogether;
|
NoteData::all_tracks_iterator &iter = *m_pIterCurrentOrUpcoming;
|
||||||
int iRowOfLastHoldNote = -1;
|
while( !iter.IsAtEnd() && iter.Row() < iSongRow )
|
||||||
NoteData::all_tracks_iterator iter = m_NoteData.GetTapNoteRangeAllTracks( iStartCheckingAt, iSongRow+1, NULL, true );
|
|
||||||
for( ; !iter.IsAtEnd(); ++iter )
|
|
||||||
{
|
{
|
||||||
TapNote &tn = *iter;
|
iter++;
|
||||||
|
}
|
||||||
|
|
||||||
|
map<int,TrackRowTapNote> mapRowToTap;
|
||||||
|
for( int t=0; t<m_NoteData.GetNumTracks(); t++ )
|
||||||
|
{
|
||||||
|
// If there is a hold on this track that overlaps the current row
|
||||||
|
// (overlaps because head has passed the current row),
|
||||||
|
// it will be the the TapNote one before the TapNote pointed to
|
||||||
|
// by CurrentOrUpcoming.
|
||||||
|
NoteData::iterator iter = m_pIterCurrentOrUpcoming->GetIter(t);
|
||||||
|
if( iter == m_NoteData.begin(t) )
|
||||||
|
continue; // no previous note available
|
||||||
|
iter--;
|
||||||
|
TapNote &tn = iter->second;
|
||||||
|
int iRow = iter->first;
|
||||||
|
ASSERT( iRow < iSongRow );
|
||||||
if( tn.type != TapNote::hold_head )
|
if( tn.type != TapNote::hold_head )
|
||||||
continue;
|
continue;
|
||||||
|
bool bInRange = iSongRow < iRow + tn.iDuration;
|
||||||
|
if( !bInRange )
|
||||||
|
continue;
|
||||||
|
TrackRowTapNote trtn = { t, iRow, &tn };
|
||||||
|
mapRowToTap[iRow] = trtn;
|
||||||
|
}
|
||||||
|
|
||||||
int iTrack = iter.Track();
|
// mapRowToTap now contains all overlapping holds sored by row
|
||||||
int iRow = iter.Row();
|
int iRowOfLastHoldNote = -1;
|
||||||
TrackRowTapNote trtn = { iTrack, iRow, &tn };
|
vector<TrackRowTapNote> vHoldNotesToGradeTogether;
|
||||||
|
FOREACHM( int, TrackRowTapNote, mapRowToTap, iter )
|
||||||
|
{
|
||||||
|
TrackRowTapNote &trtn = iter->second;
|
||||||
|
TapNote &tn = *trtn.pTN;
|
||||||
|
int iRow = iter->first;
|
||||||
|
|
||||||
/* All holds must be of the same subType because fLife is handled
|
/* All holds must be of the same subType because fLife is handled
|
||||||
* in different ways depending on the SubType. Handle Rolls one at a time
|
* in different ways depending on the SubType. Handle Rolls one at a time
|
||||||
@@ -752,6 +782,7 @@ void Player::Update( float fDeltaTime )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
// Why was this originally "BeatToNoteRowNotRounded"? It should be rounded. -Chris
|
// Why was this originally "BeatToNoteRowNotRounded"? It should be rounded. -Chris
|
||||||
/* We want to send the crossed row message exactly when we cross the row--not
|
/* We want to send the crossed row message exactly when we cross the row--not
|
||||||
@@ -766,6 +797,7 @@ void Player::Update( float fDeltaTime )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
// TRICKY:
|
// TRICKY:
|
||||||
float fPositionSeconds = GAMESTATE->m_fMusicSeconds;
|
float fPositionSeconds = GAMESTATE->m_fMusicSeconds;
|
||||||
|
|||||||
@@ -170,6 +170,7 @@ protected:
|
|||||||
int m_iFirstUncrossedRow;
|
int m_iFirstUncrossedRow;
|
||||||
int m_iFirstUncrossedMineRow;
|
int m_iFirstUncrossedMineRow;
|
||||||
NoteData::all_tracks_iterator *m_pIterNotJudged;
|
NoteData::all_tracks_iterator *m_pIterNotJudged;
|
||||||
|
NoteData::all_tracks_iterator *m_pIterCurrentOrUpcoming;
|
||||||
NoteData::all_tracks_iterator *m_pIterUncrossedRows;
|
NoteData::all_tracks_iterator *m_pIterUncrossedRows;
|
||||||
int m_iRowLastJudged; // Everything up to and including this row has been judged.
|
int m_iRowLastJudged; // Everything up to and including this row has been judged.
|
||||||
int m_iMineRowLastJudged;
|
int m_iMineRowLastJudged;
|
||||||
|
|||||||
Reference in New Issue
Block a user