Browse Source

ref: make api thinner by removing IsNormalPass and moving CL_FxBlend to refdll

pull/2/head
Alibek Omarov 6 years ago
parent
commit
4d9563ea03
  1. 119
      engine/client/cl_tent.c
  2. 1
      engine/client/client.h
  3. 1
      engine/client/ref_common.c
  4. 4
      engine/ref_api.h
  5. 4
      ref_gl/gl_beams.c
  6. 7
      ref_gl/gl_context.c
  7. 1
      ref_gl/gl_local.h
  8. 124
      ref_gl/gl_rmain.c
  9. 4
      ref_gl/gl_studio.c

119
engine/client/cl_tent.c

@ -196,125 +196,6 @@ void CL_AddClientResources( void )
#endif #endif
} }
/*
===============
CL_FxBlend
===============
*/
int CL_FxBlend( cl_entity_t *e )
{
int blend = 0;
float offset, dist;
vec3_t tmp;
offset = ((int)e->index ) * 363.0f; // Use ent index to de-sync these fx
switch( e->curstate.renderfx )
{
case kRenderFxPulseSlowWide:
blend = e->curstate.renderamt + 0x40 * sin( cl.time * 2 + offset );
break;
case kRenderFxPulseFastWide:
blend = e->curstate.renderamt + 0x40 * sin( cl.time * 8 + offset );
break;
case kRenderFxPulseSlow:
blend = e->curstate.renderamt + 0x10 * sin( cl.time * 2 + offset );
break;
case kRenderFxPulseFast:
blend = e->curstate.renderamt + 0x10 * sin( cl.time * 8 + offset );
break;
case kRenderFxFadeSlow:
if( ref.dllFuncs.IsNormalPass( ))
{
if( e->curstate.renderamt > 0 )
e->curstate.renderamt -= 1;
else e->curstate.renderamt = 0;
}
blend = e->curstate.renderamt;
break;
case kRenderFxFadeFast:
if( ref.dllFuncs.IsNormalPass( ))
{
if( e->curstate.renderamt > 3 )
e->curstate.renderamt -= 4;
else e->curstate.renderamt = 0;
}
blend = e->curstate.renderamt;
break;
case kRenderFxSolidSlow:
if( ref.dllFuncs.IsNormalPass( ))
{
if( e->curstate.renderamt < 255 )
e->curstate.renderamt += 1;
else e->curstate.renderamt = 255;
}
blend = e->curstate.renderamt;
break;
case kRenderFxSolidFast:
if( ref.dllFuncs.IsNormalPass( ))
{
if( e->curstate.renderamt < 252 )
e->curstate.renderamt += 4;
else e->curstate.renderamt = 255;
}
blend = e->curstate.renderamt;
break;
case kRenderFxStrobeSlow:
blend = 20 * sin( cl.time * 4 + offset );
if( blend < 0 ) blend = 0;
else blend = e->curstate.renderamt;
break;
case kRenderFxStrobeFast:
blend = 20 * sin( cl.time * 16 + offset );
if( blend < 0 ) blend = 0;
else blend = e->curstate.renderamt;
break;
case kRenderFxStrobeFaster:
blend = 20 * sin( cl.time * 36 + offset );
if( blend < 0 ) blend = 0;
else blend = e->curstate.renderamt;
break;
case kRenderFxFlickerSlow:
blend = 20 * (sin( cl.time * 2 ) + sin( cl.time * 17 + offset ));
if( blend < 0 ) blend = 0;
else blend = e->curstate.renderamt;
break;
case kRenderFxFlickerFast:
blend = 20 * (sin( cl.time * 16 ) + sin( cl.time * 23 + offset ));
if( blend < 0 ) blend = 0;
else blend = e->curstate.renderamt;
break;
case kRenderFxHologram:
case kRenderFxDistort:
VectorCopy( e->origin, tmp );
VectorSubtract( tmp, refState.vieworg, tmp );
dist = DotProduct( tmp, refState.vforward );
// turn off distance fade
if( e->curstate.renderfx == kRenderFxDistort )
dist = 1;
if( dist <= 0 )
{
blend = 0;
}
else
{
e->curstate.renderamt = 180;
if( dist <= 100 ) blend = e->curstate.renderamt;
else blend = (int) ((1.0f - ( dist - 100 ) * ( 1.0f / 400.0f )) * e->curstate.renderamt );
blend += COM_RandomLong( -32, 31 );
}
break;
default:
blend = e->curstate.renderamt;
break;
}
blend = bound( 0, blend, 255 );
return blend;
}
/* /*
================ ================

1
engine/client/client.h

@ -974,7 +974,6 @@ void CL_PlayerDecal( int playerIndex, int textureIndex, int entityIndex, float *
void R_FreeDeadParticles( struct particle_s **ppparticles ); void R_FreeDeadParticles( struct particle_s **ppparticles );
void CL_AddClientResource( const char *filename, int type ); void CL_AddClientResource( const char *filename, int type );
void CL_AddClientResources( void ); void CL_AddClientResources( void );
int CL_FxBlend( cl_entity_t *e );
void CL_InitParticles( void ); void CL_InitParticles( void );
void CL_ClearParticles( void ); void CL_ClearParticles( void );
void CL_FreeParticles( void ); void CL_FreeParticles( void );

1
engine/client/ref_common.c

@ -271,7 +271,6 @@ static ref_api_t gEngfuncs =
CL_ExtraUpdate, CL_ExtraUpdate,
COM_HashKey, COM_HashKey,
Host_Error, Host_Error,
CL_FxBlend,
COM_SetRandomSeed, COM_SetRandomSeed,
COM_RandomFloat, COM_RandomFloat,
COM_RandomLong, COM_RandomLong,

4
engine/ref_api.h

@ -336,7 +336,6 @@ typedef struct ref_api_s
void (*CL_ExtraUpdate)( void ); void (*CL_ExtraUpdate)( void );
uint (*COM_HashKey)( const char *strings, uint hashSize ); uint (*COM_HashKey)( const char *strings, uint hashSize );
void (*Host_Error)( const char *fmt, ... ); void (*Host_Error)( const char *fmt, ... );
int (*CL_FxBlend)( cl_entity_t *e );
void (*COM_SetRandomSeed)( int lSeed ); void (*COM_SetRandomSeed)( int lSeed );
float (*COM_RandomFloat)( float rmin, float rmax ); float (*COM_RandomFloat)( float rmin, float rmax );
int (*COM_RandomLong)( int rmin, int rmax ); int (*COM_RandomLong)( int rmin, int rmax );
@ -465,9 +464,6 @@ typedef struct ref_interface_s
void (*CL_AddCustomBeam)( cl_entity_t *pEnvBeam ); void (*CL_AddCustomBeam)( cl_entity_t *pEnvBeam );
void (*R_ProcessEntData)( qboolean allocate ); void (*R_ProcessEntData)( qboolean allocate );
// view info
qboolean (*IsNormalPass)( void );
// debug // debug
void (*R_ShowTextures)( void ); void (*R_ShowTextures)( void );
void (*R_ShowTree)( void ); void (*R_ShowTree)( void );

4
ref_gl/gl_beams.c

@ -1070,7 +1070,7 @@ void R_BeamDraw( BEAM *pbeam, float frametime )
// XASH SPECIFIC: get brightness from head entity // XASH SPECIFIC: get brightness from head entity
pStart = gEngfuncs.R_BeamGetEntity( pbeam->startEntity ); pStart = gEngfuncs.R_BeamGetEntity( pbeam->startEntity );
if( pStart && pStart->curstate.rendermode != kRenderNormal ) if( pStart && pStart->curstate.rendermode != kRenderNormal )
pbeam->brightness = gEngfuncs.CL_FxBlend( pStart ) / 255.0f; pbeam->brightness = CL_FxBlend( pStart ) / 255.0f;
} }
if( FBitSet( pbeam->flags, FBEAM_FADEIN )) if( FBitSet( pbeam->flags, FBEAM_FADEIN ))
@ -1190,7 +1190,7 @@ void R_BeamDrawCustomEntity( cl_entity_t *ent )
{ {
BEAM beam; BEAM beam;
float amp = ent->curstate.body / 100.0f; float amp = ent->curstate.body / 100.0f;
float blend = gEngfuncs.CL_FxBlend( ent ) / 255.0f; float blend = CL_FxBlend( ent ) / 255.0f;
float r, g, b; float r, g, b;
int beamFlags; int beamFlags;

7
ref_gl/gl_context.c

@ -25,11 +25,6 @@ static void R_ClearScreen( void )
pglClear( GL_COLOR_BUFFER_BIT ); pglClear( GL_COLOR_BUFFER_BIT );
} }
static qboolean IsNormalPass( void )
{
return RP_NORMALPASS();
}
static void R_IncrementSpeedsCounter( int type ) static void R_IncrementSpeedsCounter( int type )
{ {
switch( type ) switch( type )
@ -412,8 +407,6 @@ ref_interface_t gReffuncs =
CL_AddCustomBeam, CL_AddCustomBeam,
R_ProcessEntData, R_ProcessEntData,
IsNormalPass,
R_ShowTextures, R_ShowTextures,
R_ShowTree, R_ShowTree,
R_IncrementSpeedsCounter, R_IncrementSpeedsCounter,

1
ref_gl/gl_local.h

@ -391,6 +391,7 @@ void R_FindViewLeaf( void );
void R_PushScene( void ); void R_PushScene( void );
void R_PopScene( void ); void R_PopScene( void );
void R_DrawFog( void ); void R_DrawFog( void );
int CL_FxBlend( cl_entity_t *e );
// //
// gl_rmath.c // gl_rmath.c

124
ref_gl/gl_rmain.c

@ -246,7 +246,7 @@ qboolean R_AddEntity( struct cl_entity_s *clent, int type )
if( FBitSet( clent->curstate.effects, EF_NODRAW )) if( FBitSet( clent->curstate.effects, EF_NODRAW ))
return false; // done return false; // done
if( !R_ModelOpaque( clent->curstate.rendermode ) && gEngfuncs.CL_FxBlend( clent ) <= 0 ) if( !R_ModelOpaque( clent->curstate.rendermode ) && CL_FxBlend( clent ) <= 0 )
return true; // invisible return true; // invisible
if( type == ET_FRAGMENTED ) if( type == ET_FRAGMENTED )
@ -875,7 +875,7 @@ void R_DrawEntitiesOnList( void )
// handle studiomodels with custom rendermodes on texture // handle studiomodels with custom rendermodes on texture
if( RI.currententity->curstate.rendermode != kRenderNormal ) if( RI.currententity->curstate.rendermode != kRenderNormal )
tr.blend = gEngfuncs.CL_FxBlend( RI.currententity ) / 255.0f; tr.blend = CL_FxBlend( RI.currententity ) / 255.0f;
else tr.blend = 1.0f; // draw as solid but sorted by distance else tr.blend = 1.0f; // draw as solid but sorted by distance
if( tr.blend <= 0.0f ) continue; if( tr.blend <= 0.0f ) continue;
@ -1173,3 +1173,123 @@ void R_DrawCubemapView( const vec3_t origin, const vec3_t angles, int size )
RI.viewleaf = NULL; // force markleafs next frame RI.viewleaf = NULL; // force markleafs next frame
} }
/*
===============
CL_FxBlend
===============
*/
int CL_FxBlend( cl_entity_t *e )
{
int blend = 0;
float offset, dist;
vec3_t tmp;
offset = ((int)e->index ) * 363.0f; // Use ent index to de-sync these fx
switch( e->curstate.renderfx )
{
case kRenderFxPulseSlowWide:
blend = e->curstate.renderamt + 0x40 * sin( gpGlobals->time * 2 + offset );
break;
case kRenderFxPulseFastWide:
blend = e->curstate.renderamt + 0x40 * sin( gpGlobals->time * 8 + offset );
break;
case kRenderFxPulseSlow:
blend = e->curstate.renderamt + 0x10 * sin( gpGlobals->time * 2 + offset );
break;
case kRenderFxPulseFast:
blend = e->curstate.renderamt + 0x10 * sin( gpGlobals->time * 8 + offset );
break;
case kRenderFxFadeSlow:
if( RP_NORMALPASS( ))
{
if( e->curstate.renderamt > 0 )
e->curstate.renderamt -= 1;
else e->curstate.renderamt = 0;
}
blend = e->curstate.renderamt;
break;
case kRenderFxFadeFast:
if( RP_NORMALPASS( ))
{
if( e->curstate.renderamt > 3 )
e->curstate.renderamt -= 4;
else e->curstate.renderamt = 0;
}
blend = e->curstate.renderamt;
break;
case kRenderFxSolidSlow:
if( RP_NORMALPASS( ))
{
if( e->curstate.renderamt < 255 )
e->curstate.renderamt += 1;
else e->curstate.renderamt = 255;
}
blend = e->curstate.renderamt;
break;
case kRenderFxSolidFast:
if( RP_NORMALPASS( ))
{
if( e->curstate.renderamt < 252 )
e->curstate.renderamt += 4;
else e->curstate.renderamt = 255;
}
blend = e->curstate.renderamt;
break;
case kRenderFxStrobeSlow:
blend = 20 * sin( gpGlobals->time * 4 + offset );
if( blend < 0 ) blend = 0;
else blend = e->curstate.renderamt;
break;
case kRenderFxStrobeFast:
blend = 20 * sin( gpGlobals->time * 16 + offset );
if( blend < 0 ) blend = 0;
else blend = e->curstate.renderamt;
break;
case kRenderFxStrobeFaster:
blend = 20 * sin( gpGlobals->time * 36 + offset );
if( blend < 0 ) blend = 0;
else blend = e->curstate.renderamt;
break;
case kRenderFxFlickerSlow:
blend = 20 * (sin( gpGlobals->time * 2 ) + sin( gpGlobals->time * 17 + offset ));
if( blend < 0 ) blend = 0;
else blend = e->curstate.renderamt;
break;
case kRenderFxFlickerFast:
blend = 20 * (sin( gpGlobals->time * 16 ) + sin( gpGlobals->time * 23 + offset ));
if( blend < 0 ) blend = 0;
else blend = e->curstate.renderamt;
break;
case kRenderFxHologram:
case kRenderFxDistort:
VectorCopy( e->origin, tmp );
VectorSubtract( tmp, RI.vieworg, tmp );
dist = DotProduct( tmp, RI.vforward );
// turn off distance fade
if( e->curstate.renderfx == kRenderFxDistort )
dist = 1;
if( dist <= 0 )
{
blend = 0;
}
else
{
e->curstate.renderamt = 180;
if( dist <= 100 ) blend = e->curstate.renderamt;
else blend = (int) ((1.0f - ( dist - 100 ) * ( 1.0f / 400.0f )) * e->curstate.renderamt );
blend += gEngfuncs.COM_RandomLong( -32, 31 );
}
break;
default:
blend = e->curstate.renderamt;
break;
}
blend = bound( 0, blend, 255 );
return blend;
}

4
ref_gl/gl_studio.c

@ -1885,7 +1885,7 @@ void R_StudioSetRenderamt( int iRenderamt )
if( !RI.currententity ) return; if( !RI.currententity ) return;
RI.currententity->curstate.renderamt = iRenderamt; RI.currententity->curstate.renderamt = iRenderamt;
tr.blend = gEngfuncs.CL_FxBlend( RI.currententity ) / 255.0f; tr.blend = CL_FxBlend( RI.currententity ) / 255.0f;
} }
/* /*
@ -3708,7 +3708,7 @@ void R_DrawViewModel( void )
if( !RP_NORMALPASS() || ENGINE_GET_PARM( PARM_LOCAL_HEALTH ) <= 0 || !CL_IsViewEntityLocalPlayer()) if( !RP_NORMALPASS() || ENGINE_GET_PARM( PARM_LOCAL_HEALTH ) <= 0 || !CL_IsViewEntityLocalPlayer())
return; return;
tr.blend = gEngfuncs.CL_FxBlend( view ) / 255.0f; tr.blend = CL_FxBlend( view ) / 255.0f;
if( !R_ModelOpaque( view->curstate.rendermode ) && tr.blend <= 0.0f ) if( !R_ModelOpaque( view->curstate.rendermode ) && tr.blend <= 0.0f )
return; // invisible ? return; // invisible ?

Loading…
Cancel
Save