+void R_CompleteLightPoint (vec3_t color, vec3_t p);
+
+void R_DrawParticles (void)
+{
+ particle_t *p;
+ int i, r,g,b,a;
+ float scale, scale2, minparticledist;
+ byte *color24;
+ vec3_t up, right, uprightangles, forward2, up2, right2, tempcolor;
+
+ // LordHavoc: early out condition
+ if (!numparticles)
+ return;
+
+ c_particles += numparticles;
+
+ VectorScale (vup, 1.5, up);
+ VectorScale (vright, 1.5, right);
+
+ uprightangles[0] = 0;
+ uprightangles[1] = r_refdef.viewangles[1];
+ uprightangles[2] = 0;
+ AngleVectors (uprightangles, forward2, right2, up2);
+
+ minparticledist = DotProduct(r_refdef.vieworg, vpn) + 16.0f;
+
+ for (i = 0, p = particles;i < numparticles;i++, p++)
+ {
+ // LordHavoc: unnecessary (array was already compacted)
+// if (p->die < cl.time)
+// continue;
+
+ // LordHavoc: only render if not too close
+ if (DotProduct(p->org, vpn) < minparticledist)
+ continue;
+
+ color24 = (byte *) &d_8to24table[(int)p->color];
+ r = color24[0];
+ g = color24[1];
+ b = color24[2];
+ a = p->alpha;
+ if (r_dynamicparticles.value)
+ {
+ R_CompleteLightPoint(tempcolor, p->org);
+ r = (r * (int) tempcolor[0]) >> 7;
+ g = (g * (int) tempcolor[1]) >> 7;
+ b = (b * (int) tempcolor[2]) >> 7;
+ }
+ transpolybegin(p->texnum, 0, p->texnum, TPOLYTYPE_ALPHA);
+ scale = p->scale * -0.5;scale2 = p->scale * 0.5;
+ if (p->texnum == rainparticletexture) // rain streak
+ {
+ transpolyvert(p->org[0] + up2[0]*scale + right2[0]*scale , p->org[1] + up2[1]*scale + right2[1]*scale , p->org[2] + up2[2]*scale + right2[2]*scale , 0,1,r,g,b,a);
+ transpolyvert(p->org[0] + up2[0]*scale2 + right2[0]*scale , p->org[1] + up2[1]*scale2 + right2[1]*scale , p->org[2] + up2[2]*scale2 + right2[2]*scale , 0,0,r,g,b,a);
+ transpolyvert(p->org[0] + up2[0]*scale2 + right2[0]*scale2, p->org[1] + up2[1]*scale2 + right2[1]*scale2, p->org[2] + up2[2]*scale2 + right2[2]*scale2, 1,0,r,g,b,a);
+ transpolyvert(p->org[0] + up2[0]*scale + right2[0]*scale2, p->org[1] + up2[1]*scale + right2[1]*scale2, p->org[2] + up2[2]*scale + right2[2]*scale2, 1,1,r,g,b,a);
+ }
+ else
+ {
+ transpolyvert(p->org[0] + up[0]*scale + right[0]*scale , p->org[1] + up[1]*scale + right[1]*scale , p->org[2] + up[2]*scale + right[2]*scale , 0,1,r,g,b,a);
+ transpolyvert(p->org[0] + up[0]*scale2 + right[0]*scale , p->org[1] + up[1]*scale2 + right[1]*scale , p->org[2] + up[2]*scale2 + right[2]*scale , 0,0,r,g,b,a);
+ transpolyvert(p->org[0] + up[0]*scale2 + right[0]*scale2, p->org[1] + up[1]*scale2 + right[1]*scale2, p->org[2] + up[2]*scale2 + right[2]*scale2, 1,0,r,g,b,a);
+ transpolyvert(p->org[0] + up[0]*scale + right[0]*scale2, p->org[1] + up[1]*scale + right[1]*scale2, p->org[2] + up[2]*scale + right[2]*scale2, 1,1,r,g,b,a);
+ }
+ transpolyend();
+ }
+}