]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
moved EF_MUZZLEFLASH checking to CL_MoveLerpEntityStates to make muzzleflashes reliab...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 22 Jan 2007 14:42:05 +0000 (14:42 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 22 Jan 2007 14:42:05 +0000 (14:42 +0000)
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
cl_parse.c
client.h

index e41c9254ad5dffe1bde99c883ff21adf93367b24..6cad103b8981b4b2f3effd3bd9fb5fa42c77fdf9 100644 (file)
--- 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)))
index 948a4b60409a886075242b5bb4a33650383563f8..06595e9a3a3d16edb322628579dfdfbade3297e9 100644 (file)
@@ -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;
 }
 
 /*
index f6772bd20f4b250e91d3b306950e340a574d09ea..1a6ac795a6668ca9818f33ce8f75ad338e45d1f9 100644 (file)
--- 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;