cache Trail RadarValues. There needs to be more coordination with Course's Trail cache though.

This commit is contained in:
Chris Danford
2004-07-23 05:28:41 +00:00
parent 27ece3ecbf
commit 6564a39a9e
2 changed files with 36 additions and 25 deletions
+33 -25
View File
@@ -51,34 +51,42 @@ bool TrailEntry::ContainsTransformOrTurn() const
RadarValues Trail::GetRadarValues() const
{
RadarValues rv;
FOREACH_CONST( TrailEntry, m_vEntries, e )
if( m_bRadarValuesCached )
{
const Steps *pSteps = e->pSteps;
ASSERT( pSteps );
if( e->ContainsTransformOrTurn() )
{
NoteData nd;
pSteps->GetNoteData( &nd );
RadarValues rv_orig;
NoteDataUtil::GetRadarValues( nd, e->pSong->m_fMusicLengthSeconds, rv_orig );
PlayerOptions po;
po.FromString( e->Modifiers );
if( po.ContainsTransformOrTurn() )
NoteDataUtil::TransformNoteData( nd, po, pSteps->m_StepsType );
NoteDataUtil::TransformNoteData( nd, e->Attacks, pSteps->m_StepsType, e->pSong );
RadarValues rv2;
NoteDataUtil::GetRadarValues( nd, e->pSong->m_fMusicLengthSeconds, rv2 );
rv += rv2;
}
else
{
rv += pSteps->GetRadarValues();
}
return m_CachedRadarValues;
}
else
{
m_bRadarValuesCached = true;
m_CachedRadarValues.Init();
return rv;
FOREACH_CONST( TrailEntry, m_vEntries, e )
{
const Steps *pSteps = e->pSteps;
ASSERT( pSteps );
if( e->ContainsTransformOrTurn() )
{
NoteData nd;
pSteps->GetNoteData( &nd );
RadarValues rv_orig;
NoteDataUtil::GetRadarValues( nd, e->pSong->m_fMusicLengthSeconds, rv_orig );
PlayerOptions po;
po.FromString( e->Modifiers );
if( po.ContainsTransformOrTurn() )
NoteDataUtil::TransformNoteData( nd, po, pSteps->m_StepsType );
NoteDataUtil::TransformNoteData( nd, e->Attacks, pSteps->m_StepsType, e->pSong );
RadarValues rv;
NoteDataUtil::GetRadarValues( nd, e->pSong->m_fMusicLengthSeconds, rv );
m_CachedRadarValues += rv;
}
else
{
m_CachedRadarValues += pSteps->GetRadarValues();
}
}
return m_CachedRadarValues;
}
}
int Trail::GetMeter() const
+3
View File
@@ -45,6 +45,8 @@ public:
CourseDifficulty m_CourseDifficulty;
vector<TrailEntry> m_vEntries;
int m_iSpecifiedMeter; // == -1 if no meter specified
mutable bool m_bRadarValuesCached;
mutable RadarValues m_CachedRadarValues;
Trail()
{
@@ -56,6 +58,7 @@ public:
m_CourseDifficulty = DIFFICULTY_INVALID;
m_iSpecifiedMeter = -1;
m_vEntries.clear();
m_bRadarValuesCached = false;
}
RadarValues GetRadarValues() const;