-#define particle(ptype, porientation, pcolor1, pcolor2, ptex, plight, padditive, pscalex, pscaley, palpha, palphafade, ptime, pgravity, pbounce, px, py, pz, pvx, pvy, pvz, ptime2, pvx2, pvy2, pvz2, pfriction, ppressure)\
-{\
- if (cl_numparticles >= cl_maxparticles)\
- return;\
- {\
- particle_t *part;\
- int tempcolor, tempcolor2, cr1, cg1, cb1, cr2, cg2, cb2;\
- unsigned int partflags;\
- partflags = ((porientation) << P_ORIENTATION_FIRSTBIT) | ((ptex) << P_TEXNUM_FIRSTBIT);\
- if (padditive)\
- partflags |= P_ADDITIVE;\
- /*if (plight)*/\
- /* partflags |= P_DYNLIGHT;*/\
- tempcolor = (pcolor1);\
- tempcolor2 = (pcolor2);\
- cr2 = ((tempcolor2) >> 16) & 0xFF;\
- cg2 = ((tempcolor2) >> 8) & 0xFF;\
- cb2 = (tempcolor2) & 0xFF;\
- if (tempcolor != tempcolor2)\
- {\
- cr1 = ((tempcolor) >> 16) & 0xFF;\
- cg1 = ((tempcolor) >> 8) & 0xFF;\
- cb1 = (tempcolor) & 0xFF;\
- tempcolor = rand() & 0xFF;\
- cr2 = (((cr2 - cr1) * tempcolor) >> 8) + cr1;\
- cg2 = (((cg2 - cg1) * tempcolor) >> 8) + cg1;\
- cb2 = (((cb2 - cb1) * tempcolor) >> 8) + cb1;\
- }\
- part = &particles[cl_numparticles++];\
- part->type = (ptype);\
- part->color[0] = cr2;\
- part->color[1] = cg2;\
- part->color[2] = cb2;\
- part->color[3] = 0xFF;\
- part->flags = partflags;\
- part->scalex = (pscalex);\
- part->scaley = (pscaley);\
- part->alpha = (palpha);\
- part->alphafade = (palphafade);\
- part->die = cl.time + (ptime);\
- part->gravity = (pgravity);\
- part->bounce = (pbounce);\
- part->org[0] = (px);\
- part->org[1] = (py);\
- part->org[2] = (pz);\
- part->vel[0] = (pvx);\
- part->vel[1] = (pvy);\
- part->vel[2] = (pvz);\
- part->time2 = (ptime2);\
- part->vel2[0] = (pvx2);\
- part->vel2[1] = (pvy2);\
- part->vel2[2] = (pvz2);\
- part->friction = (pfriction);\
- part->pressure = (ppressure);\
- }\
+particle_t *particle(int ptype, int porientation, int pcolor1, int pcolor2, int ptex, int plight, int pblendmode, float pscalex, float pscaley, float palpha, float palphafade, float ptime, float pgravity, float pbounce, float px, float py, float pz, float pvx, float pvy, float pvz, float ptime2, float pvx2, float pvy2, float pvz2, float pfriction, float ppressure)
+{
+ if (cl_numparticles < cl_maxparticles)
+ {
+ particle_t *part;
+ int ptempcolor, ptempcolor2, pcr1, pcg1, pcb1, pcr2, pcg2, pcb2;
+ ptempcolor = (pcolor1);
+ ptempcolor2 = (pcolor2);
+ pcr2 = ((ptempcolor2) >> 16) & 0xFF;
+ pcg2 = ((ptempcolor2) >> 8) & 0xFF;
+ pcb2 = (ptempcolor2) & 0xFF;
+ if (ptempcolor != ptempcolor2)
+ {
+ pcr1 = ((ptempcolor) >> 16) & 0xFF;
+ pcg1 = ((ptempcolor) >> 8) & 0xFF;
+ pcb1 = (ptempcolor) & 0xFF;
+ ptempcolor = rand() & 0xFF;
+ pcr2 = (((pcr2 - pcr1) * ptempcolor) >> 8) + pcr1;
+ pcg2 = (((pcg2 - pcg1) * ptempcolor) >> 8) + pcg1;
+ pcb2 = (((pcb2 - pcb1) * ptempcolor) >> 8) + pcb1;
+ }
+ part = &particles[cl_numparticles++];
+ memset(part, 0, sizeof(*part));
+ part->type = (ptype);
+ part->color[0] = pcr2;
+ part->color[1] = pcg2;
+ part->color[2] = pcb2;
+ part->color[3] = 0xFF;
+ part->orientation = porientation;
+ part->texnum = ptex;
+ part->blendmode = pblendmode;
+ part->scalex = (pscalex);
+ part->scaley = (pscaley);
+ part->alpha = (palpha);
+ part->alphafade = (palphafade);
+ part->die = cl.time + (ptime);
+ part->gravity = (pgravity);
+ part->bounce = (pbounce);
+ part->org[0] = (px);
+ part->org[1] = (py);
+ part->org[2] = (pz);
+ part->vel[0] = (pvx);
+ part->vel[1] = (pvy);
+ part->vel[2] = (pvz);
+ part->time2 = (ptime2);
+ part->vel2[0] = (pvx2);
+ part->vel2[1] = (pvy2);
+ part->vel2[2] = (pvz2);
+ part->friction = (pfriction);
+ part->pressure = (ppressure);
+ return part;
+ }
+ return NULL;
+}
+
+void CL_SpawnDecalParticleForSurface(void *hitent, const vec3_t org, const vec3_t normal, int color1, int color2, int texnum, float size, float alpha)
+{
+ particle_t *p;
+ if (!cl_decals.integer)
+ return;
+ p = particle(pt_decal, PARTICLE_ORIENTED_DOUBLESIDED, color1, color2, texnum, false, PBLEND_MOD, size, size, alpha, 0, cl_decals_time.value + cl_decals_fadetime.value, 0, 0, org[0] + normal[0], org[1] + normal[1], org[2] + normal[2], 0, 0, 0, cl.time + cl_decals_time.value, normal[0], normal[1], normal[2], 0, 0);
+#ifndef WORKINGLQUAKE
+ if (p)
+ {
+ p->owner = hitent;
+ p->ownermodel = p->owner->model;
+ Matrix4x4_Transform(&p->owner->inversematrix, org, p->relativeorigin);
+ Matrix4x4_Transform3x3(&p->owner->inversematrix, normal, p->relativedirection);
+ VectorAdd(p->relativeorigin, p->relativedirection, p->relativeorigin);
+ }
+#endif
+}
+
+void CL_SpawnDecalParticleForPoint(const vec3_t org, float maxdist, float size, float alpha, int texnum, int color1, int color2)
+{
+ int i;
+ float bestfrac, bestorg[3], bestnormal[3];
+ float frac, v[3], normal[3], org2[3];
+#ifdef WORKINGLQUAKE
+ void *besthitent = NULL, *hitent;
+#else
+ entity_render_t *besthitent = NULL, *hitent;
+#endif
+ bestfrac = 10;
+ for (i = 0;i < 32;i++)
+ {
+ VectorRandom(org2);
+ VectorMA(org, maxdist, org2, org2);
+ frac = CL_TraceLine(org, org2, v, normal, true, &hitent, SUPERCONTENTS_SOLID);
+ if (bestfrac > frac)
+ {
+ bestfrac = frac;
+ besthitent = hitent;
+ VectorCopy(v, bestorg);
+ VectorCopy(normal, bestnormal);
+ }
+ }
+ if (bestfrac < 1)
+ CL_SpawnDecalParticleForSurface(besthitent, bestorg, bestnormal, color1, color2, texnum, size, alpha);