From 75b700282c7aabe3ce0cdad6596df132453b1dc5 Mon Sep 17 00:00:00 2001 From: havoc Date: Mon, 22 Jan 2007 14:42:05 +0000 Subject: [PATCH] moved EF_MUZZLEFLASH checking to CL_MoveLerpEntityStates to make muzzleflashes reliably work when the client is running slower than the server made muzzleflash 1.5x as large and 4x as bright as before, and fade in 50ms instead of 100ms changed dlight decay to scale color instead of radius git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6725 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_main.c | 22 +++++++++++++--------- cl_parse.c | 3 +++ client.h | 9 ++++++++- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/cl_main.c b/cl_main.c index e41c9254..6cad103b 100644 --- a/cl_main.c +++ b/cl_main.c @@ -647,7 +647,12 @@ dlightsetup: dl->color[0] = red; dl->color[1] = green; dl->color[2] = blue; - dl->decay = decay; + dl->initialradius = radius; + dl->initialcolor[0] = red; + dl->initialcolor[1] = green; + dl->initialcolor[2] = blue; + dl->decay = decay / radius; // changed decay to be a percentage decrease + dl->intensity = 1; // this is what gets decayed if (lifetime) dl->die = cl.time + lifetime; else @@ -668,7 +673,7 @@ void CL_DecayLights(void) { int i, oldmax; dlight_t *dl; - float time, f; + float time; time = bound(0, cl.time - cl.oldtime, 0.1); oldmax = cl.num_dlights; @@ -677,10 +682,11 @@ void CL_DecayLights(void) { if (dl->radius) { - f = dl->radius - time * dl->decay; - if (cl.time < dl->die && f > 0) + dl->intensity -= time * dl->decay; + if (cl.time < dl->die && dl->intensity > 0) { - dl->radius = dl->radius - time * dl->decay; + //dl->radius = dl->initialradius * dl->intensity; + VectorScale(dl->initialcolor, dl->intensity, dl->color); cl.num_dlights = i + 1; } else @@ -1030,8 +1036,6 @@ void CL_UpdateNetworkEntity(entity_t *e) else CL_EntityParticles(e); } - if (e->render.effects & EF_MUZZLEFLASH) - e->persistent.muzzleflash = 1.0f; if (e->render.effects & EF_DIMLIGHT) { dlightradius = max(dlightradius, 200); @@ -1078,8 +1082,8 @@ void CL_UpdateNetworkEntity(entity_t *e) trace = CL_TraceBox(origin, vec3_origin, vec3_origin, v2, true, NULL, SUPERCONTENTS_SOLID | SUPERCONTENTS_SKY, false); tempmatrix = e->render.matrix; Matrix4x4_SetOrigin(&tempmatrix, trace.endpos[0], trace.endpos[1], trace.endpos[2]); - CL_AllocDlight(NULL, &tempmatrix, 100, e->persistent.muzzleflash, e->persistent.muzzleflash, e->persistent.muzzleflash, 0, 0, 0, -1, true, 0, 0.25, 0.25, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE); - e->persistent.muzzleflash -= bound(0, cl.time - cl.oldtime, 0.1) * 10; + CL_AllocDlight(NULL, &tempmatrix, 150, e->persistent.muzzleflash * 4.0f, e->persistent.muzzleflash * 4.0f, e->persistent.muzzleflash * 4.0f, 0, 0, 0, -1, true, 0, 0.25, 0, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE); + e->persistent.muzzleflash -= bound(0, cl.time - cl.oldtime, 0.1) * 20; } // LordHavoc: if the model has no flags, don't check each if (e->render.model && e->render.model->flags && (!e->state_current.tagentity && !(e->render.flags & RENDER_VIEWMODEL))) diff --git a/cl_parse.c b/cl_parse.c index 948a4b60..06595e9a 100644 --- a/cl_parse.c +++ b/cl_parse.c @@ -1545,6 +1545,9 @@ void CL_MoveLerpEntityStates(entity_t *ent) VectorCopy(ent->state_current.origin, ent->persistent.neworigin); VectorCopy(ent->state_current.angles, ent->persistent.newangles); } + // trigger muzzleflash effect if necessary + if (ent->state_current.effects & EF_MUZZLEFLASH) + ent->persistent.muzzleflash = 1; } /* diff --git a/client.h b/client.h index f6772bd2..1a6ac795 100644 --- a/client.h +++ b/client.h @@ -159,9 +159,16 @@ typedef struct dlight_s // brightness (not really radius anymore) // (worldlight: saved to .rtlights file) vec_t radius; - // drop radius this much each second + // drop intensity this much each second // (dlight only) vec_t decay; + // intensity value which is dropped over time + // (dlight only) + vec_t intensity; + // initial values for intensity to modify + // (dlight only) + vec_t initialradius; + vec3_t initialcolor; // light style which controls intensity of this light // (worldlight: saved to .rtlights file) int style; -- 2.39.2