rendermode optimisations for all CBaseEntity classes.

This commit is contained in:
Marco Cawthorne 2019-01-10 11:15:10 +01:00
parent d244904f84
commit e4981f6d41
2 changed files with 36 additions and 13 deletions

View file

@ -37,7 +37,7 @@ class CBaseEntity
void CBaseEntity :: CBaseEntity ( void )
{
gflags |= GF_CANRESPAWN;
m_oldModel = model;
m_oldModel = Util_FixModel(model);
m_oldSolid = solid;
m_oldHealth = health;
m_oldOrigin = origin;
@ -65,18 +65,23 @@ void CBaseEntity :: CBaseEntity ( void )
void CBaseEntity::RendermodeUpdate(void)
{
if ( m_rendermode != RM_NORMAL ) {
alpha = ( m_renderamt / 255 );
colormod = m_rendercolor;
if( alpha == 0 ) {
alpha = 0.0001;
}
if ( m_rendermode == RM_ADDITIVE ) {
effects = EF_ADDITIVE; // QWSSQC: EF_FLAG2
} else if ( m_rendermode == RM_GLOW ) {
effects = EF_ADDITIVE | EF_FULLBRIGHT;
}
if (m_rendermode == RM_NORMAL) {
return;
}
if (m_rendermode == RM_SOLID && m_renderamt != 0) {
return;
}
colormod = m_rendercolor / 255;
alpha = bound(0.001, ( m_renderamt / 255 ), 1.0);
if ( m_rendermode == RM_ADDITIVE ) {
effects = EF_ADDITIVE; // QWSSQC: EF_FLAG2
} else if ( m_rendermode == RM_GLOW ) {
effects = EF_ADDITIVE | EF_FULLBRIGHT;
}
}
void CBaseEntity :: Respawn ( void )

View file

@ -6,7 +6,7 @@
*
****/
//#define GS_DEVELOPER
#define GS_DEVELOPER
.float gflags;
@ -21,3 +21,21 @@ enumflags
void Effect_CreateSpark(vector pos, vector ang);
void Effect_BreakModel(vector mins, vector maxs,vector vel, float mat);
string Util_FixModel(string mdl)
{
int c = tokenizebyseparator(mdl, "/", "\\ ");
string newpath = "";
for (int i = 0; i < c; i++) {
newpath = sprintf("%s/%s", newpath, argv(i));
}
// Kill the first /
newpath = substring(newpath, 1, strlen(newpath)-1);
#if 0
return newpath;
#else
return mdl;
#endif
}