]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - r_explosion.c
more size_t
[xonotic/darkplaces.git] / r_explosion.c
index 800c9106bcfb29a35a57a335cc1e00482a786c92..af83b7e26574b42431a391f7351aa15dc815c97b 100644 (file)
@@ -145,13 +145,13 @@ void R_NewExplosion(vec3_t org)
 {
        int i, j;
        float dist, n;
-       vec3_t impact;
        explosion_t *e;
+       trace_t trace;
        qbyte noise[EXPLOSIONGRID*EXPLOSIONGRID];
        fractalnoisequick(noise, EXPLOSIONGRID, 4); // adjust noise grid size according to explosion
        for (i = 0, e = explosion;i < MAX_EXPLOSIONS;i++, e++)
        {
-               if (e->alpha <= cl_explosions_alpha_end.value)
+               if (cl.time >= e->endtime)
                {
                        e->starttime = cl.time;
                        e->endtime = cl.time + cl_explosions_lifetime.value;
@@ -171,8 +171,8 @@ void R_NewExplosion(vec3_t org)
                                // clip start origin
                                if (e->clipping)
                                {
-                                       CL_TraceLine(e->origin, e->vert[j], impact, NULL, true, NULL, SUPERCONTENTS_SOLID);
-                                       VectorCopy(impact, e->vert[i]);
+                                       trace = CL_TraceBox(e->origin, vec3_origin, vec3_origin, e->vert[j], true, NULL, SUPERCONTENTS_SOLID, false);
+                                       VectorCopy(trace.endpos, e->vert[i]);
                                }
                        }
                        break;
@@ -213,7 +213,8 @@ void R_DrawExplosionCallback(const void *calldata1, int calldata2)
 void R_MoveExplosion(explosion_t *e)
 {
        int i;
-       float dot, end[3], impact[3], normal[3], frametime;
+       float dot, end[3], frametime;
+       trace_t trace;
 
        frametime = cl.time - e->time;
        e->time = cl.time;
@@ -225,13 +226,14 @@ void R_MoveExplosion(explosion_t *e)
                        VectorMA(e->vert[i], frametime, e->vertvel[i], end);
                        if (e->clipping)
                        {
-                               if (CL_TraceLine(e->vert[i], end, impact, normal, true, NULL, SUPERCONTENTS_SOLID) < 1)
+                               trace = CL_TraceBox(e->vert[i], vec3_origin, vec3_origin, end, true, NULL, SUPERCONTENTS_SOLID, false);
+                               if (trace.fraction < 1)
                                {
                                        // clip velocity against the wall
-                                       dot = -DotProduct(e->vertvel[i], normal);
-                                       VectorMA(e->vertvel[i], dot, normal, e->vertvel[i]);
+                                       dot = -DotProduct(e->vertvel[i], trace.plane.normal);
+                                       VectorMA(e->vertvel[i], dot, trace.plane.normal, e->vertvel[i]);
                                }
-                               VectorCopy(impact, e->vert[i]);
+                               VectorCopy(trace.endpos, e->vert[i]);
                        }
                        else
                                VectorCopy(end, e->vert[i]);
@@ -243,10 +245,6 @@ void R_MoveExplosion(explosion_t *e)
 void R_MoveExplosions(void)
 {
        int i;
-       float frametime;
-
-       frametime = cl.time - cl.oldtime;
-
        for (i = 0;i < MAX_EXPLOSIONS;i++)
                if (cl.time < explosion[i].endtime)
                        R_MoveExplosion(&explosion[i]);