]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_particles.c
converted vertex fogging to use a fogtable array which matches the fog texture
[xonotic/darkplaces.git] / cl_particles.c
index 235a5424f4f58418b8d99d90f7fc9a11e489eed4..d43ce7d8943fea2a93c883d714b28c7a4b9e62bf 100644 (file)
@@ -558,7 +558,7 @@ void CL_ReadPointFile_f (void)
 #if WORKINGLQUAKE
        pointfile = COM_LoadTempFile (name);
 #else
-       pointfile = FS_LoadFile(name, tempmempool, true);
+       pointfile = (char *)FS_LoadFile(name, tempmempool, true);
 #endif
        if (!pointfile)
        {
@@ -567,6 +567,7 @@ void CL_ReadPointFile_f (void)
        }
 
        Con_Printf("Reading %s...\n", name);
+       VectorClear(leakorg);
        c = 0;
        s = 0;
        pointfilepos = pointfile;
@@ -955,7 +956,7 @@ void CL_ParticleRain (vec3_t mins, vec3_t maxs, vec3_t dir, int count, int color
                }
                break;
        default:
-               Host_Error("CL_ParticleRain: unknown type %i (0 = rain, 1 = snow)\n", type);
+               Con_Printf ("CL_ParticleRain: unknown type %i (0 = rain, 1 = snow)\n", type);
        }
 }
 
@@ -1214,6 +1215,8 @@ void CL_RocketTrail (vec3_t start, vec3_t end, int type, int color, entity_t *en
                                        particle(particletype + pt_alphastatic, color, color, tex_particle, 5, qd*128, qd*320, 0, 0, pos[0], pos[1], pos[2], 0, 0, 0, 0);
                                break;
 #endif
+                       default:
+                               Sys_Error("CL_RocketTrail: unknown trail type %i\n", type);
                }
 
                // advance to next time and position
@@ -1519,7 +1522,7 @@ void CL_MoveParticles (void)
 
 #define MAX_PARTICLETEXTURES 64
 // particletexture_t is a rectangle in the particlefonttexture
-typedef struct
+typedef struct particletexture_s
 {
        rtexture_t *texture;
        float s1, t1, s2, t2;
@@ -1683,7 +1686,7 @@ static void R_InitParticleTexture (void)
        // and white on black background) so we can alpha fade it to black, then
        // we invert it again during the blendfunc to make it work...
 
-       particletexturedata = Mem_Alloc(tempmempool, PARTICLEFONTSIZE*PARTICLEFONTSIZE*4);
+       particletexturedata = (qbyte *)Mem_Alloc(tempmempool, PARTICLEFONTSIZE*PARTICLEFONTSIZE*4);
        memset(particletexturedata, 255, PARTICLEFONTSIZE*PARTICLEFONTSIZE*4);
 
        // smoke
@@ -1895,11 +1898,11 @@ void R_DrawParticle(particle_t *p)
 #else
 void R_DrawParticleCallback(const void *calldata1, int calldata2)
 {
-       const particle_t *p = calldata1;
+       const particle_t *p = (particle_t *)calldata1;
        rmeshstate_t m;
 #endif
        pblend_t blendmode;
-       float org[3], up2[3], v[3], right[3], up[3], fog, ifog, fogvec[3], cr, cg, cb, ca, size;
+       float org[3], up2[3], v[3], right[3], up[3], fog, ifog, cr, cg, cb, ca, size;
        particletexture_t *tex;
 
        VectorCopy(p->org, org);
@@ -1931,8 +1934,7 @@ void R_DrawParticleCallback(const void *calldata1, int calldata2)
        }
        if (fogenabled)
        {
-               VectorSubtract(org, r_vieworigin, fogvec);
-               fog = exp(fogdensity/DotProduct(fogvec,fogvec));
+               fog = VERTEXFOGTABLE(VectorDistance(org, r_vieworigin));
                ifog = 1 - fog;
                cr = cr * ifog;
                cg = cg * ifog;
@@ -2025,7 +2027,10 @@ void R_DrawParticleCallback(const void *calldata1, int calldata2)
                particle_texcoord2f[6] = 1;particle_texcoord2f[7] = v[1];
        }
        else
-               Host_Error("R_DrawParticles: unknown particle orientation %i\n", p->type->orientation);
+       {
+               Con_Printf("R_DrawParticles: unknown particle orientation %i\n", p->type->orientation);
+               return;
+       }
 
 #if WORKINGLQUAKE
        if (blendmode == PBLEND_ALPHA)
@@ -2080,7 +2085,7 @@ void R_DrawParticles (void)
        {
                if (p->type)
                {
-                       c_particles++;
+                       renderstats.particles++;
                        if (DotProduct(p->org, r_viewforward) >= minparticledist || p->type->orientation == PARTICLE_BEAM)
                        {
                                if (p->type == particletype + pt_decal)