mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-17 22:50:51 +00:00
Kill r_particles->int_val testing in gl particle engine. Also merge a bit down to r_part.c/r_cvar.c. Properly declare cl_max_particles (how the heck was it working when only ever declared as exter cvar_t *cl_max_particles?).
Should be a minor speedup for gl, definitely a code cleanup.
This commit is contained in:
parent
0425afb190
commit
bb6796247c
5 changed files with 81 additions and 165 deletions
|
@ -54,16 +54,11 @@
|
|||
#include "r_shared.h"
|
||||
#include "varrays.h"
|
||||
|
||||
static particle_t *particles, **freeparticles;
|
||||
static short r_maxparticles, numparticles;
|
||||
|
||||
int ramp[8] = { 0x6f, 0x6d, 0x6b, 0x69, 0x67, 0x65, 0x63, 0x61 };
|
||||
|
||||
extern int part_tex_dot;
|
||||
extern int part_tex_spark;
|
||||
extern int part_tex_smoke[8];
|
||||
|
||||
extern cvar_t *cl_max_particles;
|
||||
extern int part_tex_dot, part_tex_spark, part_tex_smoke[8];
|
||||
extern short r_maxparticles, numparticles;
|
||||
extern particle_t *particles, **freeparticles;
|
||||
|
||||
|
||||
inline particle_t *
|
||||
|
@ -110,51 +105,9 @@ particle_new_random (ptype_t type, int texnum, vec3_t org, int org_fuzz,
|
|||
return particle_new (type, texnum, porg, scale, pvel, die, color, alpha);
|
||||
}
|
||||
|
||||
/*
|
||||
R_MaxParticlesCheck
|
||||
|
||||
Misty-chan: Dynamically change the maximum amount of particles on the fly.
|
||||
Thanks to a LOT of help from Taniwha, Deek, Mercury, Lordhavoc, and lots of
|
||||
others.
|
||||
*/
|
||||
void
|
||||
R_MaxParticlesCheck (cvar_t *var)
|
||||
{
|
||||
/*
|
||||
Catchall. If the user changed the setting to a number less than zero *or*
|
||||
if we had a wacky cfg get past the init code check, this will make sure we
|
||||
don't have problems. Also note that grabbing the var->int_val is IMPORTANT:
|
||||
|
||||
Prevents a segfault since if we grabbed the int_val of cl_max_particles
|
||||
we'd sig11 right here at startup.
|
||||
*/
|
||||
r_maxparticles = max(var->int_val, 0);
|
||||
|
||||
/*
|
||||
Be very careful the next time we do something like this. calloc/free are
|
||||
IMPORTANT and the compiler doesn't know when we do bad things with them.
|
||||
*/
|
||||
free (particles);
|
||||
free (freeparticles);
|
||||
|
||||
particles = (particle_t *) calloc (r_maxparticles, sizeof (particle_t));
|
||||
freeparticles = (particle_t **)
|
||||
calloc (r_maxparticles, sizeof (particle_t *));
|
||||
|
||||
R_ClearParticles();
|
||||
}
|
||||
|
||||
void
|
||||
R_Particles_Init_Cvars (void)
|
||||
{
|
||||
/*
|
||||
Misty-chan: This is a cvar that does callbacks. Whenever it
|
||||
changes, it calls the function R_MaxParticlesCheck and therefore
|
||||
is very nifty.
|
||||
*/
|
||||
Cvar_Get ("cl_max_particles", "2048", CVAR_ARCHIVE, R_MaxParticlesCheck,
|
||||
"Maximum amount of particles to display. No maximum, minimum "
|
||||
"is 0, although it's best to use r_particles 0 instead.");
|
||||
}
|
||||
|
||||
inline void
|
||||
|
@ -216,9 +169,6 @@ R_ParticleExplosion (vec3_t org)
|
|||
// int i;
|
||||
// int j = 1024;
|
||||
|
||||
if (!r_particles->int_val)
|
||||
return;
|
||||
|
||||
if (numparticles >= r_maxparticles)
|
||||
return;
|
||||
// else if (numparticles + j >= r_maxparticles)
|
||||
|
@ -242,9 +192,6 @@ R_ParticleExplosion2 (vec3_t org, int colorStart, int colorLength)
|
|||
int i;
|
||||
int colorMod = 0, j = 512;
|
||||
|
||||
if (!r_particles->int_val)
|
||||
return;
|
||||
|
||||
if (numparticles >= r_maxparticles)
|
||||
return;
|
||||
else if (numparticles + j >= r_maxparticles)
|
||||
|
@ -264,9 +211,6 @@ R_BlobExplosion (vec3_t org)
|
|||
int i;
|
||||
int j = 1024;
|
||||
|
||||
if (!r_particles->int_val)
|
||||
return;
|
||||
|
||||
if (numparticles >= r_maxparticles)
|
||||
return;
|
||||
else if (numparticles + j >= r_maxparticles)
|
||||
|
@ -317,7 +261,8 @@ R_BloodPuff (vec3_t org, int count)
|
|||
void
|
||||
R_RunPuffEffect (vec3_t org, particle_effect_t type, byte count)
|
||||
{
|
||||
if (!r_particles->int_val)
|
||||
// FIXME: Is this test worthwhile?
|
||||
if (numparticles >= r_maxparticles)
|
||||
return;
|
||||
|
||||
switch (type) {
|
||||
|
@ -362,9 +307,6 @@ R_RunParticleEffect (vec3_t org, int color, int count)
|
|||
int k = count;
|
||||
vec3_t porg;
|
||||
|
||||
if (!r_particles->int_val)
|
||||
return;
|
||||
|
||||
if (numparticles >= r_maxparticles)
|
||||
return;
|
||||
|
||||
|
@ -392,9 +334,6 @@ R_RunParticleEffect (vec3_t org, int color, int count)
|
|||
void
|
||||
R_RunSpikeEffect (vec3_t org, particle_effect_t type)
|
||||
{
|
||||
if (!r_particles->int_val)
|
||||
return;
|
||||
|
||||
switch (type) {
|
||||
case PE_SPIKE:
|
||||
R_RunSparkEffect (org, 5, 8);
|
||||
|
@ -421,9 +360,6 @@ R_LavaSplash (vec3_t org)
|
|||
int k = 256;
|
||||
vec3_t dir, porg, pvel;
|
||||
|
||||
if (!r_particles->int_val)
|
||||
return;
|
||||
|
||||
if (numparticles + k >= r_maxparticles) {
|
||||
return;
|
||||
} // else if (numparticles + k >= r_maxparticles) {
|
||||
|
@ -458,9 +394,6 @@ R_TeleportSplash (vec3_t org)
|
|||
int l = 896;
|
||||
vec3_t dir, porg, pvel;
|
||||
|
||||
if (!r_particles->int_val)
|
||||
return;
|
||||
|
||||
if (numparticles + l >= r_maxparticles) {
|
||||
return;
|
||||
} // else if (numparticles + l >= r_maxparticles) {
|
||||
|
@ -493,7 +426,7 @@ R_RocketTrail (entity_t *ent)
|
|||
float dist, len, pscale, pscalenext;
|
||||
vec3_t subtract, vec;
|
||||
|
||||
if (!r_particles->int_val)
|
||||
if (numparticles >= r_maxparticles)
|
||||
return;
|
||||
|
||||
R_AddFire (ent->old_origin, ent->origin, ent);
|
||||
|
@ -527,7 +460,7 @@ R_GrenadeTrail (entity_t *ent)
|
|||
float dist, len, pscale, pscalenext;
|
||||
vec3_t subtract, vec;
|
||||
|
||||
if (!r_particles->int_val)
|
||||
if (numparticles >= r_maxparticles)
|
||||
return;
|
||||
|
||||
VectorSubtract (ent->origin, ent->old_origin, vec);
|
||||
|
@ -560,7 +493,7 @@ R_BloodTrail (entity_t *ent)
|
|||
int j;
|
||||
vec3_t subtract, vec, porg, pvel;
|
||||
|
||||
if (!r_particles->int_val)
|
||||
if (numparticles >= r_maxparticles)
|
||||
return;
|
||||
|
||||
VectorSubtract (ent->origin, ent->old_origin, vec);
|
||||
|
@ -599,7 +532,7 @@ R_SlightBloodTrail (entity_t *ent)
|
|||
int j;
|
||||
vec3_t subtract, vec, porg, pvel;
|
||||
|
||||
if (!r_particles->int_val)
|
||||
if (numparticles >= r_maxparticles)
|
||||
return;
|
||||
|
||||
VectorSubtract (ent->origin, ent->old_origin, vec);
|
||||
|
@ -638,7 +571,7 @@ R_GreenTrail (entity_t *ent)
|
|||
static int tracercount;
|
||||
vec3_t subtract, vec, pvel;
|
||||
|
||||
if (!r_particles->int_val)
|
||||
if (numparticles >= r_maxparticles)
|
||||
return;
|
||||
|
||||
VectorSubtract (ent->origin, ent->old_origin, vec);
|
||||
|
@ -676,7 +609,7 @@ R_FlameTrail (entity_t *ent)
|
|||
static int tracercount;
|
||||
vec3_t subtract, vec, pvel;
|
||||
|
||||
if (!r_particles->int_val)
|
||||
if (numparticles >= r_maxparticles)
|
||||
return;
|
||||
|
||||
VectorSubtract (ent->origin, ent->old_origin, vec);
|
||||
|
@ -713,7 +646,7 @@ R_VoorTrail (entity_t *ent)
|
|||
int j;
|
||||
vec3_t subtract, vec, porg;
|
||||
|
||||
if (!r_particles->int_val)
|
||||
if (numparticles >= r_maxparticles)
|
||||
return;
|
||||
|
||||
VectorSubtract (ent->origin, ent->old_origin, vec);
|
||||
|
@ -746,7 +679,7 @@ R_DrawParticles (void)
|
|||
int activeparticles, maxparticle, j, k;
|
||||
particle_t *part;
|
||||
vec3_t up_scale, right_scale, up_right_scale, down_right_scale;
|
||||
|
||||
|
||||
if (!r_particles->int_val)
|
||||
return;
|
||||
|
||||
|
|
|
@ -39,11 +39,11 @@
|
|||
|
||||
#include "r_dynamic.h"
|
||||
|
||||
extern cvar_t *gl_sky_divide; // FIXME
|
||||
|
||||
cvar_t *cl_crossx;
|
||||
cvar_t *cl_crossy;
|
||||
cvar_t *cl_max_particles;
|
||||
cvar_t *cl_verstring;
|
||||
|
||||
cvar_t *crosshair;
|
||||
cvar_t *crosshaircolor;
|
||||
|
||||
|
@ -125,11 +125,19 @@ cvar_t *scr_showram;
|
|||
cvar_t *scr_showturtle;
|
||||
cvar_t *scr_viewsize;
|
||||
|
||||
extern short r_maxparticles;
|
||||
extern cvar_t *gl_sky_divide; // FIXME
|
||||
|
||||
extern void R_MaxParticlesCheck (cvar_t *var);
|
||||
|
||||
|
||||
static void
|
||||
r_particles_f (cvar_t *var)
|
||||
{
|
||||
if (!var->int_val)
|
||||
R_ClearParticles ();
|
||||
if (cl_max_particles)
|
||||
r_maxparticles = var->int_val * cl_max_particles->int_val;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -139,6 +147,10 @@ R_Init_Cvars (void)
|
|||
"Sets the position of the crosshair on the X-axis.");
|
||||
cl_crossy = Cvar_Get ("cl_crossy", "0", CVAR_ARCHIVE, NULL,
|
||||
"Sets the position of the crosshair on the Y-axis.");
|
||||
cl_max_particles = Cvar_Get ("cl_max_particles", "2048", CVAR_ARCHIVE,
|
||||
R_MaxParticlesCheck, "Maximum amount of "
|
||||
"particles to display. No maximum, minimum "
|
||||
"is 0.");
|
||||
cl_verstring = Cvar_Get ("cl_verstring", PROGRAM " " VERSION, CVAR_NONE,
|
||||
NULL, "Client version string");
|
||||
crosshair = Cvar_Get ("crosshair", "0", CVAR_ARCHIVE, NULL, "Crosshair "
|
||||
|
|
|
@ -32,16 +32,56 @@
|
|||
#endif
|
||||
|
||||
#include "QF/console.h"
|
||||
#include "QF/cvar.h"
|
||||
#include "QF/qargs.h"
|
||||
#include "QF/render.h"
|
||||
|
||||
#include "compat.h"
|
||||
#include "r_local.h"
|
||||
|
||||
particle_t *active_particles, *free_particles, *particles;
|
||||
vec3_t r_pright, r_pup, r_ppn;
|
||||
int r_maxparticles;
|
||||
short r_maxparticles, numparticles;
|
||||
particle_t *active_particles, *free_particles, *particles, **freeparticles;
|
||||
vec3_t r_pright, r_pup, r_ppn;
|
||||
|
||||
extern cvar_t *cl_max_particles;
|
||||
extern cvar_t *r_particles;
|
||||
|
||||
|
||||
/*
|
||||
R_MaxParticlesCheck
|
||||
|
||||
Misty-chan: Dynamically change the maximum amount of particles on the fly.
|
||||
Thanks to a LOT of help from Taniwha, Deek, Mercury, Lordhavoc, and lots of
|
||||
others.
|
||||
*/
|
||||
void
|
||||
R_MaxParticlesCheck (cvar_t *var)
|
||||
{
|
||||
/*
|
||||
Catchall. If the user changed the setting to a number less than zero *or*
|
||||
if we had a wacky cfg get past the init code check, this will make sure we
|
||||
don't have problems. Also note that grabbing the var->int_val is IMPORTANT:
|
||||
Prevents a segfault since if we grabbed the int_val of cl_max_particles
|
||||
we'd sig11 right here at startup.
|
||||
*/
|
||||
if (r_particles)
|
||||
r_maxparticles = max(var->int_val * r_particles->int_val, 0);
|
||||
else
|
||||
r_maxparticles = max(var->int_val, 0);
|
||||
|
||||
/*
|
||||
Be very careful the next time we do something like this. calloc/free are
|
||||
IMPORTANT and the compiler doesn't know when we do bad things with them.
|
||||
*/
|
||||
free (particles);
|
||||
free (freeparticles);
|
||||
|
||||
particles = (particle_t *) calloc (r_maxparticles, sizeof (particle_t));
|
||||
freeparticles = (particle_t **) calloc (r_maxparticles,
|
||||
sizeof (particle_t *));
|
||||
|
||||
R_ClearParticles();
|
||||
}
|
||||
|
||||
void
|
||||
R_DarkFieldParticles (entity_t *ent)
|
||||
|
|
|
@ -43,48 +43,19 @@
|
|||
#include "r_dynamic.h"
|
||||
#include "r_local.h"
|
||||
|
||||
int ramp1[8] = { 0x6f, 0x6d, 0x6b, 0x69, 0x67, 0x65, 0x63, 0x61 };
|
||||
int ramp2[8] = { 0x6f, 0x6e, 0x6d, 0x6c, 0x6b, 0x6a, 0x68, 0x66 };
|
||||
int ramp3[8] = { 0x6d, 0x6b, 6, 5, 4, 3 };
|
||||
int ramp1[8] = { 0x6f, 0x6d, 0x6b, 0x69, 0x67, 0x65, 0x63, 0x61 };
|
||||
int ramp2[8] = { 0x6f, 0x6e, 0x6d, 0x6c, 0x6b, 0x6a, 0x68, 0x66 };
|
||||
int ramp3[8] = { 0x6d, 0x6b, 6, 5, 4, 3 };
|
||||
|
||||
int r_maxparticles;
|
||||
particle_t *active_particles, *free_particles, *particles;
|
||||
vec3_t r_pright, r_pup, r_ppn;
|
||||
vec3_t r_pright, r_pup, r_ppn;
|
||||
|
||||
extern short r_maxparticles;
|
||||
extern particle_t *active_particles, *free_particles, *particles;
|
||||
|
||||
/*
|
||||
R_MaxParticlesCheck
|
||||
|
||||
Misty-chan: EXTREME heavy lifting and bugfixing thanks goes out to taniwha
|
||||
- I built this, and he got it working :)
|
||||
*/
|
||||
void
|
||||
R_MaxParticlesCheck (cvar_t *var)
|
||||
{
|
||||
// Do not use 0 in this! sw doesn't grok 0 and it'll segfault if we do!
|
||||
r_maxparticles = max(var->int_val, 1);
|
||||
|
||||
/*
|
||||
Debugging code. will print what the above was set to, and is also useful
|
||||
for checking if this is accidentally being run all the time.
|
||||
Con_Printf ("%d", r_maxparticles);
|
||||
*/
|
||||
|
||||
if (particles)
|
||||
free (particles);
|
||||
|
||||
particles = (particle_t *) calloc (r_maxparticles, sizeof (particle_t));
|
||||
|
||||
R_ClearParticles ();
|
||||
}
|
||||
|
||||
void
|
||||
R_Particles_Init_Cvars (void)
|
||||
{
|
||||
// Does a callback to R_MaxParticleCheck when the cvar changes. Neat trick.
|
||||
Cvar_Get ("cl_max_particles", "2048", CVAR_ARCHIVE, R_MaxParticlesCheck,
|
||||
"Maximum amount of particles to display. No maximum, minimum "
|
||||
"is 1.");
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -43,53 +43,21 @@
|
|||
#include "r_dynamic.h"
|
||||
#include "r_local.h"
|
||||
|
||||
int ramp1[8] = { 0x6f, 0x6d, 0x6b, 0x69, 0x67, 0x65, 0x63, 0x61 };
|
||||
int ramp2[8] = { 0x6f, 0x6e, 0x6d, 0x6c, 0x6b, 0x6a, 0x68, 0x66 };
|
||||
int ramp3[8] = { 0x6d, 0x6b, 6, 5, 4, 3 };
|
||||
|
||||
particle_t *active_particles, *free_particles;
|
||||
|
||||
particle_t *particles;
|
||||
int r_maxparticles;
|
||||
int ramp1[8] = { 0x6f, 0x6d, 0x6b, 0x69, 0x67, 0x65, 0x63, 0x61 };
|
||||
int ramp2[8] = { 0x6f, 0x6e, 0x6d, 0x6c, 0x6b, 0x6a, 0x68, 0x66 };
|
||||
int ramp3[8] = { 0x6d, 0x6b, 6, 5, 4, 3 };
|
||||
|
||||
vec3_t r_pright, r_pup, r_ppn;
|
||||
|
||||
/*
|
||||
R_MaxParticlesCheck
|
||||
|
||||
Misty-chan: EXTREME heavy lifting and bugfixing thanks goes out to taniwha
|
||||
- I built this, and he got it working :)
|
||||
*/
|
||||
void
|
||||
R_MaxParticlesCheck (cvar_t *var)
|
||||
{
|
||||
// Do not use 0 in this! sw doesn't grok 0 and it'll segfault if we do!
|
||||
r_maxparticles = max(var->int_val, 1);
|
||||
|
||||
/*
|
||||
Debugging code. will print what the above was set to, and is also useful
|
||||
for checking if this is accidentally being run all the time.
|
||||
Con_Printf ("%d", r_maxparticles);
|
||||
*/
|
||||
|
||||
if (particles)
|
||||
free (particles);
|
||||
|
||||
particles = (particle_t *) calloc (r_maxparticles, sizeof (particle_t));
|
||||
|
||||
R_ClearParticles ();
|
||||
}
|
||||
extern short r_maxparticles;
|
||||
extern particle_t *active_particles, *free_particles, *particles;
|
||||
|
||||
|
||||
void
|
||||
R_Particles_Init_Cvars (void)
|
||||
{
|
||||
// Does a callback to R_MaxParticleCheck when the cvar changes. Neat trick.
|
||||
Cvar_Get ("cl_max_particles", "2048", CVAR_ARCHIVE, R_MaxParticlesCheck,
|
||||
"Maximum amount of particles to display. No maximum, minimum is 1.");
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
R_ClearParticles (void)
|
||||
{
|
||||
|
@ -103,7 +71,6 @@ R_ClearParticles (void)
|
|||
particles[r_maxparticles - 1].next = NULL;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
R_ReadPointFile_f (void)
|
||||
{
|
||||
|
@ -153,7 +120,6 @@ R_ReadPointFile_f (void)
|
|||
Con_Printf ("%i points read\n", c);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
R_RunSpikeEffect (vec3_t pos, particle_effect_t type)
|
||||
{
|
||||
|
@ -175,7 +141,6 @@ R_RunSpikeEffect (vec3_t pos, particle_effect_t type)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
R_RunPuffEffect (vec3_t pos, particle_effect_t type, byte cnt)
|
||||
{
|
||||
|
@ -197,7 +162,6 @@ R_RunPuffEffect (vec3_t pos, particle_effect_t type, byte cnt)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
R_ParticleExplosion (vec3_t org)
|
||||
{
|
||||
|
@ -234,7 +198,6 @@ R_ParticleExplosion (vec3_t org)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
R_ParticleExplosion2 (vec3_t org, int colorStart, int colorLength)
|
||||
{
|
||||
|
@ -264,7 +227,6 @@ R_ParticleExplosion2 (vec3_t org, int colorStart, int colorLength)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
R_BlobExplosion (vec3_t org)
|
||||
{
|
||||
|
@ -302,7 +264,6 @@ R_BlobExplosion (vec3_t org)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
R_RunParticleEffect (vec3_t org, int color, int count)
|
||||
{
|
||||
|
@ -338,7 +299,6 @@ R_RunParticleEffect (vec3_t org, int color, int count)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
R_LavaSplash (vec3_t org)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue