From db4c8fadc5c48011ed0106085b9db24bbb4d8ed7 Mon Sep 17 00:00:00 2001 From: TimeServ Date: Thu, 25 Nov 2004 06:57:30 +0000 Subject: [PATCH] part 1 of the entity particle fiasco git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@532 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/r_part.c | 132 ++++++++++++++++++++++++---------------- engine/server/sv_ents.c | 8 +++ 2 files changed, 89 insertions(+), 51 deletions(-) diff --git a/engine/client/r_part.c b/engine/client/r_part.c index 03e757480..e7acc95d2 100644 --- a/engine/client/r_part.c +++ b/engine/client/r_part.c @@ -181,7 +181,7 @@ typedef struct part_type_s { float offsetup; // make this into a vec3_t later with dir, possibly for mdls - enum {SM_BOX, SM_CIRCLE, SM_BALL, SM_SPIRAL, SM_TRACER, SM_TELEBOX, SM_LAVASPLASH, SM_UNICIRCLE} spawnmode; + enum {SM_BOX, SM_CIRCLE, SM_BALL, SM_SPIRAL, SM_TRACER, SM_TELEBOX, SM_LAVASPLASH, SM_UNICIRCLE, SM_FIELD} spawnmode; //box = even spread within the area //circle = around edge of a circle //ball = filled sphere @@ -190,6 +190,7 @@ typedef struct part_type_s { //telebox = q1-style telebox //lavasplash = q1-style lavasplash //unicircle = uniform circle + //field = synced field (brightfield, etc) float gravity; vec3_t friction; @@ -530,6 +531,8 @@ void R_ParticleEffect_f(void) ptype->spawnmode = SM_LAVASPLASH; else if (!strcmp(value, "uniformcircle")) ptype->spawnmode = SM_UNICIRCLE; + else if (!strcmp(value, "syncfield")) + ptype->spawnmode = SM_FIELD; else ptype->spawnmode = SM_BOX; @@ -1340,54 +1343,19 @@ R_EntityParticles float r_avertexnormals[NUMVERTEXNORMALS][3] = { #include "anorms.h" }; -vec3_t avelocities[NUMVERTEXNORMALS]; -float beamlength = 16; -vec3_t avelocity = {23, 7, 3}; -float partstep = 0.01; -float timescale = 0.01; +vec2_t avelocities[NUMVERTEXNORMALS]; +#define BEAMLENGTH 16 +// vec3_t avelocity = {23, 7, 3}; +// float partstep = 0.01; +// float timescale = 0.01; void R_EntityParticles (float *org, qbyte colour, float *radius) { - int count; - int i; - float angle; - float sr, sp, sy, cr, cp, cy; - vec3_t forward, norg; - - count = 50; + part_type[pt_entityparticles].areaspread = radius[0]*0.5 + radius[1]*0.5; + part_type[pt_entityparticles].areaspreadvert = radius[2]; + part_type[pt_entityparticles].colorindex = colour; -if (!avelocities[0][0]) -{ -for (i=0 ; iareaspread; break; + case SM_FIELD: + if (!avelocities[0][0]) + { + for (j=0 ; jareaspread, arsvec); break; + case SM_FIELD: + arsvec[0] = cl.time * (avelocities[i][0] + m); + arsvec[1] = cl.time * (avelocities[i][1] + m); + arsvec[2] = cos(arsvec[1]); + + ofsvec[0] = arsvec[2]*cos(arsvec[0]); + ofsvec[1] = arsvec[2]*sin(arsvec[0]); + ofsvec[2] = -sin(arsvec[1]); + + arsvec[0] = r_avertexnormals[j][0]*ptype->areaspread + ofsvec[0]*BEAMLENGTH; + arsvec[1] = r_avertexnormals[j][1]*ptype->areaspread + ofsvec[1]*BEAMLENGTH; + arsvec[2] = r_avertexnormals[j][2]*ptype->areaspreadvert + ofsvec[2]*BEAMLENGTH; + + VectorNormalize(ofsvec); + + j++; + if (j >= NUMVERTEXNORMALS) + { + j = 0; + m += 0.1762891; // some BS number to try to "randomize" things + } + break; default: // SM_BALL, SM_CIRCLE ofsvec[0] = hrandom(); ofsvec[1] = hrandom(); @@ -1795,11 +1795,21 @@ void R_RunParticleEffect2 (vec3_t org, vec3_t dmin, vec3_t dmax, int color, int { int i, j; float num; + float invcount; vec3_t nvel; int ptype = FindParticleType(va("pe2_%i_%i", effect, color)); if (ptype < 0) - return; + { + ptype = FindParticleType(va("pe2_%i", effect)); + if (ptype < 0) + ptype = pe_default; + + part_type[ptype].colorindex = color; + } + + invcount = 1/part_type[ptype].count; // using this to get R_RPET to always spawn 1 + count = count * part_type[ptype].count; for (i=0 ; iefnum = 1<entnum = en; ef->colour = ent->v.seefcolour; + if (!ef->colour) + ef->colour = 111; ef->offset = ent->v.seefoffset; ef->size[0] = ent->v.seefsizex; + if (!ef->size[0]) + ef->offset = 64; ef->size[1] = ent->v.seefsizey; + if (!ef->size[1]) + ef->offset = 64; ef->size[2] = ent->v.seefsizez; + if (!ef->size[2]) + ef->offset = 64; ClientReliableWrite_Begin(to, svc_temp_entity, 20); ClientReliableWrite_Byte(to, TE_SEEF_BRIGHTFIELD+seefno);