From 664c640e42ef7dee7ef36c17cb64c9c198b864f4 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Fri, 18 May 2001 19:58:49 +0000 Subject: [PATCH] total merge of the particle system (except r_part.c isn't in qw yet) --- nq/include/client.h | 1 + nq/include/render.h | 1 - nq/source/cl_parse.c | 2 +- nq/source/cl_tent.c | 27 +++++++++++++++++++++ nq/source/gl_dyn_part.c | 24 +++++++++++-------- nq/source/r_part.c | 53 ++--------------------------------------- nq/source/sw_rmain.c | 2 -- qw/source/d_part.c | 1 + 8 files changed, 46 insertions(+), 65 deletions(-) diff --git a/nq/include/client.h b/nq/include/client.h index 2c517dc18..1256f4c48 100644 --- a/nq/include/client.h +++ b/nq/include/client.h @@ -319,6 +319,7 @@ void CL_InitInput (void); void CL_SendCmd (void); void CL_SendMove (usercmd_t *cmd); +void CL_ParseParticleEffect (void); void CL_ParseTEnt (void); void CL_UpdateTEnts (void); diff --git a/nq/include/render.h b/nq/include/render.h index 1858d2688..34d7a14fd 100644 --- a/nq/include/render.h +++ b/nq/include/render.h @@ -139,7 +139,6 @@ void R_RemoveEfrags (entity_t *ent); void R_NewMap (void); -void R_ParseParticleEffect (void); struct entity_s; void R_RocketTrail (int type, struct entity_s *ent); void R_RunParticleEffect (vec3_t org, int color, int count); diff --git a/nq/source/cl_parse.c b/nq/source/cl_parse.c index 1a0627919..e4888e445 100644 --- a/nq/source/cl_parse.c +++ b/nq/source/cl_parse.c @@ -790,7 +790,7 @@ CL_ParseServerMessage (void) break; case svc_particle: - R_ParseParticleEffect (); + CL_ParseParticleEffect (); break; case svc_spawnbaseline: diff --git a/nq/source/cl_tent.c b/nq/source/cl_tent.c index 7c844a92f..d6b194713 100644 --- a/nq/source/cl_tent.c +++ b/nq/source/cl_tent.c @@ -524,3 +524,30 @@ CL_UpdateTEnts (void) CL_UpdateBeams (); CL_UpdateExplosions (); } + + +/* + CL_ParseParticleEffect + + Parse an effect out of the server message +*/ +void +CL_ParseParticleEffect (void) +{ + vec3_t org, dir; + int i, count, msgcount, color; + + for (i = 0; i < 3; i++) + org[i] = MSG_ReadCoord (net_message); + for (i = 0; i < 3; i++) + dir[i] = MSG_ReadChar (net_message) * (1.0 / 16); + msgcount = MSG_ReadByte (net_message); + color = MSG_ReadByte (net_message); + + if (msgcount == 255) + count = 1024; + else + count = msgcount; + + R_RunParticleEffect (org, color, count); +} diff --git a/nq/source/gl_dyn_part.c b/nq/source/gl_dyn_part.c index a76c353d9..e3bdc73d5 100644 --- a/nq/source/gl_dyn_part.c +++ b/nq/source/gl_dyn_part.c @@ -299,7 +299,6 @@ R_RunGunshotEffect (vec3_t org, int count) } -/* static void R_BloodPuff (vec3_t org, int count) { @@ -310,7 +309,6 @@ R_BloodPuff (vec3_t org, int count) vec3_origin, cl.time + 99, 68 + (rand () & 3), 128, vec3_origin, vec3_origin); } -*/ void @@ -323,6 +321,12 @@ R_RunPuffEffect (vec3_t org, byte type, byte count) case TE_GUNSHOT: R_RunGunshotEffect (org, count); break; + case TE_BLOOD: + R_BloodPuff (org, count); + break; + case TE_LIGHTNINGBLOOD: + R_BloodPuff (org, 5 + (rand () & 1)); + break; } } @@ -448,12 +452,12 @@ R_RocketTrail (int type, entity_t *ent) byte palpha, pcolor; if (type == 0) - R_AddFire (ent->msg_origins[1], ent->origin, ent); + R_AddFire (ent->old_origin, ent->origin, ent); if (!r_particles->int_val) return; - VectorSubtract (ent->origin, ent->msg_origins[1], vec); + VectorSubtract (ent->origin, ent->old_origin, vec); len = VectorNormalize (vec); while (len > 0) { VectorCopy (vec3_origin, up); @@ -477,7 +481,7 @@ R_RocketTrail (int type, entity_t *ent) pcolor = (rand () & 3) + 12; palpha = 128 + (rand () & 31); // VectorVectors(vec, right, up); // Mercury's Rings - VectorCopy (ent->msg_origins[1], porg); + VectorCopy (ent->old_origin, porg); // ptex = part_tex_smoke_ring[rand () & 7]; // Mercury's Rings ptex = part_tex_smoke[rand () & 7]; break; @@ -487,7 +491,7 @@ R_RocketTrail (int type, entity_t *ent) // pcolor = (rand () & 255); // Misty-chan's Easter Egg pcolor = (rand () & 3); palpha = 128 + (rand () & 31); - VectorCopy (ent->msg_origins[1], porg); + VectorCopy (ent->old_origin, porg); ptex = part_tex_smoke[rand () & 7]; break; case 2: // blood @@ -498,7 +502,7 @@ R_RocketTrail (int type, entity_t *ent) pcolor = 68 + (rand () & 3); for (j = 0; j < 3; j++) { pvel[j] = lhrandom (-3, 3) * type; - porg[j] = ent->msg_origins[1][j] + lhrandom (-1.5, 1.5); + porg[j] = ent->old_origin[j] + lhrandom (-1.5, 1.5); } ptype = pt_grav; break; @@ -510,7 +514,7 @@ R_RocketTrail (int type, entity_t *ent) pscale = lhrandom (.75, 1.5); pdie = cl.time + 0.3; for (j = 0; j < 3; j++) - porg[j] = ent->msg_origins[1][j] + lhrandom (-8, 8); + porg[j] = ent->old_origin[j] + lhrandom (-8, 8); break; case 3: case 5: // tracer @@ -528,7 +532,7 @@ R_RocketTrail (int type, entity_t *ent) tracercount++; - VectorCopy (ent->msg_origins[1], porg); + VectorCopy (ent->old_origin, porg); if (tracercount & 1) { pvel[0] = 30 * vec[1]; pvel[1] = 30 * -vec[0]; @@ -541,7 +545,7 @@ R_RocketTrail (int type, entity_t *ent) } VectorScale (vec, min(dist, len), subtract); - VectorAdd (ent->msg_origins[1], subtract, ent->msg_origins[1]); + VectorAdd (ent->old_origin, subtract, ent->old_origin); len -= dist; particle_new (ptype, ptex, porg, pscale, pvel, pdie, pcolor, palpha, diff --git a/nq/source/r_part.c b/nq/source/r_part.c index 686170cd2..c8864b441 100644 --- a/nq/source/r_part.c +++ b/nq/source/r_part.c @@ -34,10 +34,10 @@ #include "QF/qargs.h" #include "QF/compat.h" #include "QF/console.h" -#include "QF/msg.h" +#include "client.h" #include "r_local.h" -#include "server.h" +#include "render.h" #define MAX_PARTICLES 2048 // default max # of particles at one // time @@ -53,26 +53,6 @@ int r_numparticles; vec3_t r_pright, r_pup, r_ppn; - -void -R_InitParticles (void) -{ - int i; - - i = COM_CheckParm ("-particles"); - - if (i) { - r_numparticles = (int) (atoi (com_argv[i + 1])); - if (r_numparticles < ABSOLUTE_MIN_PARTICLES) - r_numparticles = ABSOLUTE_MIN_PARTICLES; - } else { - r_numparticles = MAX_PARTICLES; - } - - particles = (particle_t *) - Hunk_AllocName (r_numparticles * sizeof (particle_t), "particles"); -} - #ifdef QUAKE2 void R_DarkFieldParticles (entity_t *ent) @@ -181,32 +161,3 @@ R_EntityParticles (entity_t *ent) forward[2] * beamlength; } } - - -/* -=============== -R_ParseParticleEffect - -Parse an effect out of the server message -=============== -*/ -void -R_ParseParticleEffect (void) -{ - vec3_t org, dir; - int i, count, msgcount, color; - - for (i = 0; i < 3; i++) - org[i] = MSG_ReadCoord (net_message); - for (i = 0; i < 3; i++) - dir[i] = MSG_ReadChar (net_message) * (1.0 / 16); - msgcount = MSG_ReadByte (net_message); - color = MSG_ReadByte (net_message); - - if (msgcount == 255) - count = 1024; - else - count = msgcount; - - R_RunParticleEffect (org, color, count); -} diff --git a/nq/source/sw_rmain.c b/nq/source/sw_rmain.c index b65c77de4..dce471919 100644 --- a/nq/source/sw_rmain.c +++ b/nq/source/sw_rmain.c @@ -173,8 +173,6 @@ R_Init (void) r_refdef.xOrigin = XCENTERING; r_refdef.yOrigin = YCENTERING; - R_InitParticles (); - // TODO: collect 386-specific code in one place #ifdef USE_INTEL_ASM Sys_MakeCodeWriteable ((long) R_EdgeCodeStart, diff --git a/qw/source/d_part.c b/qw/source/d_part.c index 907d1035c..3457951cc 100644 --- a/qw/source/d_part.c +++ b/qw/source/d_part.c @@ -66,6 +66,7 @@ D_DrawParticle (particle_t *pparticle) if (transformed[2] < PARTICLE_Z_CLIP) return; + // project the point // FIXME: preadjust xcenter and ycenter zi = 1.0 / transformed[2];