]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_particles.c
rewrote r_speeds stats code, now uses renderstats global structure rather than indivi...
[xonotic/darkplaces.git] / cl_particles.c
index 90f6fda6fdc873c8557ad9840300bb20da33e3b6..b9d3efc957e88e5cf2f78abfd4c3d6be6d791e20 100644 (file)
@@ -25,7 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #define NUMVERTEXNORMALS       162
 siextern float r_avertexnormals[NUMVERTEXNORMALS][3];
 #define m_bytenormals r_avertexnormals
-#define VectorNormalizeFast VectorNormalize
 #define CL_PointQ1Contents(v) (Mod_PointInLeaf(v,cl.worldmodel)->contents)
 typedef unsigned char qbyte;
 #define cl_stainmaps.integer 0
@@ -46,16 +45,16 @@ void R_CalcBeam_Vertex3f (float *vert, vec3_t org1, vec3_t org2, float width)
        vec3_t right1, right2, diff, normal;
 
        VectorSubtract (org2, org1, normal);
-       VectorNormalizeFast (normal);
+       VectorNormalize (normal);
 
        // calculate 'right' vector for start
        VectorSubtract (r_vieworigin, org1, diff);
-       VectorNormalizeFast (diff);
+       VectorNormalize (diff);
        CrossProduct (normal, diff, right1);
 
        // calculate 'right' vector for end
        VectorSubtract (r_vieworigin, org2, diff);
-       VectorNormalizeFast (diff);
+       VectorNormalize (diff);
        CrossProduct (normal, diff, right2);
 
        vert[ 0] = org1[0] + width * right1[0];
@@ -79,11 +78,17 @@ void fractalnoise(qbyte *noise, int size, int startgrid)
 
        for (sizepower = 0;(1 << sizepower) < size;sizepower++);
        if (size != (1 << sizepower))
-               Sys_Error("fractalnoise: size must be power of 2\n");
+       {
+               Con_Printf("fractalnoise: size must be power of 2\n");
+               return;
+       }
 
        for (gridpower = 0;(1 << gridpower) < startgrid;gridpower++);
        if (startgrid != (1 << gridpower))
-               Sys_Error("fractalnoise: grid must be power of 2\n");
+       {
+               Con_Printf("fractalnoise: grid must be power of 2\n");
+               return;
+       }
 
        startgrid = bound(0, startgrid, size);
 
@@ -145,7 +150,7 @@ void VectorVectors(const vec3_t forward, vec3_t right, vec3_t up)
        right[0] -= d * forward[0];
        right[1] -= d * forward[1];
        right[2] -= d * forward[2];
-       VectorNormalizeFast(right);
+       VectorNormalize(right);
        CrossProduct(right, forward, up);
 }
 #if QW
@@ -553,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)
        {
@@ -562,6 +567,7 @@ void CL_ReadPointFile_f (void)
        }
 
        Con_Printf("Reading %s...\n", name);
+       VectorClear(leakorg);
        c = 0;
        s = 0;
        pointfilepos = pointfile;
@@ -950,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);
        }
 }
 
@@ -977,7 +983,7 @@ void CL_Stardust (vec3_t mins, vec3_t maxs, int count)
                o[1] = lhrandom(mins[1], maxs[1]);
                o[2] = lhrandom(mins[2], maxs[2]);
                VectorSubtract(o, center, v);
-               VectorNormalizeFast(v);
+               VectorNormalize(v);
                VectorScale(v, 100, v);
                v[2] += sv_gravity.value * 0.15f;
                particle(particletype + pt_static, 0x903010, 0xFFD030, tex_particle, 1.5, lhrandom(64, 128) / cl_particles_quality.value, 128 / cl_particles_quality.value, 1, 0, o[0], o[1], o[2], v[0], v[1], v[2], 0.2);
@@ -1209,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
@@ -1514,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;
@@ -1678,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
@@ -1890,7 +1898,7 @@ 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;
@@ -2011,7 +2019,7 @@ void R_DrawParticleCallback(const void *calldata1, int calldata2)
        {
                R_CalcBeam_Vertex3f(particle_vertex3f, p->org, p->vel, size);
                VectorSubtract(p->vel, p->org, up);
-               VectorNormalizeFast(up);
+               VectorNormalize(up);
                v[0] = DotProduct(p->org, up) * (1.0f / 64.0f);
                v[1] = DotProduct(p->vel, up) * (1.0f / 64.0f);
                particle_texcoord2f[0] = 1;particle_texcoord2f[1] = v[0];
@@ -2020,7 +2028,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)
@@ -2075,7 +2086,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)