mirror of
https://github.com/unknownworlds/NS.git
synced 2024-11-22 20:51:36 +00:00
Performance changes:
Added a dual cache for LookupSequence, to avoid the massive stricmp overhead associated with the fetching of animations. git-svn-id: https://unknownworlds.svn.cloudforge.com/ns1@221 67975925-1194-0748-b3d5-c16f83f1a3a1
This commit is contained in:
parent
dc79b89150
commit
f083c5eb31
5 changed files with 23 additions and 11 deletions
|
@ -128,7 +128,7 @@ void CBaseMonster :: MakeIdealYaw( Vector vecTarget ) { }
|
|||
float CBaseMonster::ChangeYaw ( int yawSpeed ) { return 0; }
|
||||
int CBaseAnimating :: LookupActivity ( int activity ) { return 0; }
|
||||
int CBaseAnimating :: LookupActivityHeaviest ( int activity ) { return 0; }
|
||||
int CBaseAnimating :: LookupSequence ( const char *label ) { return 0; }
|
||||
int CBaseAnimating :: LookupSequence ( const char *label, int queue ) { return 0; }
|
||||
void CBaseAnimating :: ResetSequenceInfo ( ) { }
|
||||
BOOL CBaseAnimating :: GetSequenceFlags( ) { return FALSE; }
|
||||
void CBaseAnimating :: DispatchAnimEvents ( float flInterval ) { }
|
||||
|
|
|
@ -97,11 +97,18 @@ int CBaseAnimating :: LookupActivityHeaviest ( int activity )
|
|||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
int CBaseAnimating :: LookupSequence ( const char *label )
|
||||
int CBaseAnimating :: LookupSequence ( const char *label, int queue )
|
||||
{
|
||||
void *pmodel = GET_MODEL_PTR( ENT(pev) );
|
||||
|
||||
return ::LookupSequence( pmodel, label );
|
||||
if (strcmp(label, this->mPreviousLookupString[queue]) == 0)
|
||||
{
|
||||
return this->mPreviousLookupSequence[queue];
|
||||
}
|
||||
|
||||
strcpy(this->mPreviousLookupString[queue], label);
|
||||
this->mPreviousLookupSequence[queue] = ::LookupSequence( pmodel, label );
|
||||
return this->mPreviousLookupSequence[queue];
|
||||
}
|
||||
|
||||
const char* CBaseAnimating::LookupSequence(int inSequence)
|
||||
|
|
|
@ -173,12 +173,12 @@ int LookupSequence( void *pmodel, const char *label )
|
|||
}
|
||||
|
||||
//if(GetGameRules()->GetIsTesting())
|
||||
if(CVAR_GET_FLOAT(kvTesting) > 0)
|
||||
{
|
||||
char theMessage[256];
|
||||
sprintf(theMessage, "%s%s\n", "Couldn't find animation: ", label);
|
||||
ALERT(at_console, theMessage);
|
||||
}
|
||||
//if(CVAR_GET_FLOAT(kvTesting) > 0)
|
||||
//{
|
||||
// char theMessage[256];
|
||||
// sprintf(theMessage, "%s%s\n", "Couldn't find animation: ", label);
|
||||
// ALERT(at_console, theMessage);
|
||||
//}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -482,7 +482,7 @@ public:
|
|||
int GetSequenceFlags( void );
|
||||
int LookupActivity ( int activity );
|
||||
int LookupActivityHeaviest ( int activity );
|
||||
int LookupSequence ( const char *label );
|
||||
int LookupSequence ( const char *label, int queue = 0);
|
||||
const char* LookupSequence(int inSequence);
|
||||
void ResetSequenceInfo ( );
|
||||
void DispatchAnimEvents ( float flFutureInterval = 0.1 ); // Handle events that have happend since last time called up until X seconds into the future
|
||||
|
@ -505,6 +505,11 @@ public:
|
|||
float m_flLastEventCheck; // last time the event list was checked
|
||||
BOOL m_fSequenceFinished;// flag set when StudioAdvanceFrame moves across a frame boundry
|
||||
BOOL m_fSequenceLoops; // true if the sequence loops
|
||||
|
||||
// For performance gain during LookupSequence:
|
||||
//void *mPreviousLookupModel[3];
|
||||
char mPreviousLookupString[3][64];
|
||||
int mPreviousLookupSequence[3];
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1404,7 +1404,7 @@ void CBasePlayer::SetAnimation( PLAYER_ANIM playerAnim )
|
|||
}
|
||||
|
||||
// Set the gaitsequence
|
||||
gaitDesired = LookupSequence(szAnim);
|
||||
gaitDesired = LookupSequence(szAnim, 1);
|
||||
if(gaitDesired == -1)
|
||||
{
|
||||
gaitDesired = 0;
|
||||
|
|
Loading…
Reference in a new issue