summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cgame/cg_ents.c49
-rw-r--r--src/game/bg_public.h1
-rw-r--r--src/game/g_misc.c10
-rw-r--r--src/game/g_spawn.c2
4 files changed, 62 insertions, 0 deletions
diff --git a/src/cgame/cg_ents.c b/src/cgame/cg_ents.c
index dc65015b..0c0d6e9e 100644
--- a/src/cgame/cg_ents.c
+++ b/src/cgame/cg_ents.c
@@ -777,6 +777,52 @@ static void CG_TorchLight( centity_t *cent )
/*
=========================
+CG_LensFlare
+=========================
+*/
+static void CG_LensFlare( centity_t *cent )
+{
+ refEntity_t flare;
+ entityState_t *es;
+ vec3_t forward, delta;
+ float len;
+ trace_t tr;
+
+ es = &cent->currentState;
+
+ memset( &flare, 0, sizeof( flare ) );
+
+ //bunch of geometry
+ AngleVectors( cent->lerpAngles, forward, NULL, NULL );
+ VectorCopy( cent->lerpOrigin, flare.origin );
+ VectorSubtract( flare.origin, cg.refdef.vieworg, delta );
+ len = VectorLength( delta );
+ VectorNormalize( delta );
+
+ flare.reType = RT_SPRITE;
+ flare.customShader = cgs.gameShaders[ es->modelindex ];
+ flare.shaderRGBA[ 0 ] = 0xFF;
+ flare.shaderRGBA[ 1 ] = 0xFF;
+ flare.shaderRGBA[ 2 ] = 0xFF;
+ flare.shaderRGBA[ 3 ] = 0xFF;
+
+ //can only see the flare when in front of it
+ flare.radius = len / es->origin2[ 0 ];
+ flare.radius *= DotProduct( delta, forward );
+
+ //if can't see the centre do not draw
+ CG_Trace( &tr, flare.origin, NULL, NULL, cg.refdef.vieworg, 0, MASK_SHOT );
+ if( tr.fraction < 1.0f )
+ return;
+
+ if( flare.radius < 0 )
+ flare.radius = 0;
+
+ trap_R_AddRefEntityToScene( &flare );
+}
+
+/*
+=========================
CG_AdjustPositionForMover
Also called by client movement prediction code
@@ -959,6 +1005,9 @@ static void CG_AddCEntity( centity_t *cent ) {
case ET_ANIMMAPOBJ:
CG_animMapObj( cent );
break;
+ case ET_LENSFLARE:
+ CG_LensFlare( cent );
+ break;
}
}
diff --git a/src/game/bg_public.h b/src/game/bg_public.h
index f5e5cef1..e4fd3704 100644
--- a/src/game/bg_public.h
+++ b/src/game/bg_public.h
@@ -1011,6 +1011,7 @@ typedef enum {
ET_CORPSE,
ET_SPRITER,
ET_ANIMMAPOBJ,
+ ET_LENSFLARE,
ET_EVENTS // any of the EV_* events can be added freestanding
// by setting eType to ET_EVENTS + eventNum
diff --git a/src/game/g_misc.c b/src/game/g_misc.c
index 03530500..b6711afd 100644
--- a/src/game/g_misc.c
+++ b/src/game/g_misc.c
@@ -459,3 +459,13 @@ void SP_misc_anim_model( gentity_t *self )
trap_LinkEntity( self );
}
+
+//TA: spawn function for lens flares
+void SP_misc_lens_flare( gentity_t *self )
+{
+ self->s.eType = ET_LENSFLARE;
+ self->s.modelindex = G_ShaderIndex( self->targetShaderName );
+ VectorCopy( self->pos2, self->s.origin2 );
+
+ trap_LinkEntity( self );
+}
diff --git a/src/game/g_spawn.c b/src/game/g_spawn.c
index 101a1acb..f3afeb12 100644
--- a/src/game/g_spawn.c
+++ b/src/game/g_spawn.c
@@ -215,6 +215,7 @@ void SP_team_CTF_bluespawn( gentity_t *ent );
//TA:
void SP_misc_spriter( gentity_t *ent );
void SP_misc_anim_model( gentity_t *ent );
+void SP_misc_lens_flare( gentity_t *ent );
spawn_t spawns[] = {
// info entities don't do anything at all, but provide positional
@@ -289,6 +290,7 @@ spawn_t spawns[] = {
{"misc_spriter", SP_misc_spriter},
{"misc_anim_model", SP_misc_anim_model},
+ {"misc_lens_flare", SP_misc_lens_flare},
{0, 0}
};