diff --git a/engine/client/cl_tent.c b/engine/client/cl_tent.c index d86a9683..cd408128 100644 --- a/engine/client/cl_tent.c +++ b/engine/client/cl_tent.c @@ -196,125 +196,6 @@ void CL_AddClientResources( void ) #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; -} /* ================ diff --git a/engine/client/client.h b/engine/client/client.h index 8b3df9e3..fe5e7725 100644 --- a/engine/client/client.h +++ b/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 CL_AddClientResource( const char *filename, int type ); void CL_AddClientResources( void ); -int CL_FxBlend( cl_entity_t *e ); void CL_InitParticles( void ); void CL_ClearParticles( void ); void CL_FreeParticles( void ); diff --git a/engine/client/ref_common.c b/engine/client/ref_common.c index 8dab5d38..02dbb312 100644 --- a/engine/client/ref_common.c +++ b/engine/client/ref_common.c @@ -271,7 +271,6 @@ static ref_api_t gEngfuncs = CL_ExtraUpdate, COM_HashKey, Host_Error, - CL_FxBlend, COM_SetRandomSeed, COM_RandomFloat, COM_RandomLong, diff --git a/engine/ref_api.h b/engine/ref_api.h index 8bbf2b7f..1fc693a9 100644 --- a/engine/ref_api.h +++ b/engine/ref_api.h @@ -336,7 +336,6 @@ typedef struct ref_api_s void (*CL_ExtraUpdate)( void ); uint (*COM_HashKey)( const char *strings, uint hashSize ); void (*Host_Error)( const char *fmt, ... ); - int (*CL_FxBlend)( cl_entity_t *e ); void (*COM_SetRandomSeed)( int lSeed ); float (*COM_RandomFloat)( float rmin, float 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 (*R_ProcessEntData)( qboolean allocate ); - // view info - qboolean (*IsNormalPass)( void ); - // debug void (*R_ShowTextures)( void ); void (*R_ShowTree)( void ); diff --git a/ref_gl/gl_beams.c b/ref_gl/gl_beams.c index 9e65219d..a73f425f 100644 --- a/ref_gl/gl_beams.c +++ b/ref_gl/gl_beams.c @@ -1070,7 +1070,7 @@ void R_BeamDraw( BEAM *pbeam, float frametime ) // XASH SPECIFIC: get brightness from head entity pStart = gEngfuncs.R_BeamGetEntity( pbeam->startEntity ); 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 )) @@ -1190,7 +1190,7 @@ void R_BeamDrawCustomEntity( cl_entity_t *ent ) { BEAM beam; 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; int beamFlags; diff --git a/ref_gl/gl_context.c b/ref_gl/gl_context.c index bd68979e..992490d6 100644 --- a/ref_gl/gl_context.c +++ b/ref_gl/gl_context.c @@ -25,11 +25,6 @@ static void R_ClearScreen( void ) pglClear( GL_COLOR_BUFFER_BIT ); } -static qboolean IsNormalPass( void ) -{ - return RP_NORMALPASS(); -} - static void R_IncrementSpeedsCounter( int type ) { switch( type ) @@ -412,8 +407,6 @@ ref_interface_t gReffuncs = CL_AddCustomBeam, R_ProcessEntData, - IsNormalPass, - R_ShowTextures, R_ShowTree, R_IncrementSpeedsCounter, diff --git a/ref_gl/gl_local.h b/ref_gl/gl_local.h index ad398099..03c2bfb6 100644 --- a/ref_gl/gl_local.h +++ b/ref_gl/gl_local.h @@ -391,6 +391,7 @@ void R_FindViewLeaf( void ); void R_PushScene( void ); void R_PopScene( void ); void R_DrawFog( void ); +int CL_FxBlend( cl_entity_t *e ); // // gl_rmath.c diff --git a/ref_gl/gl_rmain.c b/ref_gl/gl_rmain.c index 97c257ba..fa220c16 100644 --- a/ref_gl/gl_rmain.c +++ b/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 )) 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 if( type == ET_FRAGMENTED ) @@ -875,7 +875,7 @@ void R_DrawEntitiesOnList( void ) // handle studiomodels with custom rendermodes on texture 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 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 } + +/* +=============== +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; +} diff --git a/ref_gl/gl_studio.c b/ref_gl/gl_studio.c index 16edad48..5260890b 100644 --- a/ref_gl/gl_studio.c +++ b/ref_gl/gl_studio.c @@ -1885,7 +1885,7 @@ void R_StudioSetRenderamt( int iRenderamt ) if( !RI.currententity ) return; 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()) 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 ) return; // invisible ?