Fixes/enhancements to particle scaling. Firstly, cvar is renamed to

gl_particles.  Secondly, setting it to 0 now removes particles completely.

Once I figure out how to do this for software, it will become r_particles.
This commit is contained in:
Dan Olson 2000-04-09 21:37:58 +00:00
parent 049119d9f8
commit 69be4092e4
4 changed files with 142 additions and 136 deletions

View file

@ -37,7 +37,7 @@
extern particle_t *active_particles, *free_particles; extern particle_t *active_particles, *free_particles;
extern int ramp1[8], ramp2[8], ramp3[8]; extern int ramp1[8], ramp2[8], ramp3[8];
extern cvar_t *gl_pscale; extern cvar_t *gl_particles;
/* /*
=============== ===============
@ -61,155 +61,158 @@ void R_DrawParticles (void)
float scale; float scale;
qboolean alphaTestEnabled; qboolean alphaTestEnabled;
GL_Bind(particletexture); if (gl_particles->value)
alphaTestEnabled = glIsEnabled(GL_ALPHA_TEST);
if (alphaTestEnabled)
glDisable(GL_ALPHA_TEST);
glEnable (GL_BLEND);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glBegin (GL_TRIANGLES);
VectorScale (vup, 1.5, up);
VectorScale (vright, 1.5, right);
#ifdef UQUAKE
frametime = cl.time - cl.oldtime;
#else
frametime = host_frametime;
#endif
time3 = frametime * 15;
time2 = frametime * 10; // 15;
time1 = frametime * 5;
#ifdef UQUAKE
grav = frametime * sv_gravity->value * 0.05;
#else
grav = frametime * 800 * 0.05;
#endif
dvel = 4*frametime;
for ( ;; )
{ {
kill = active_particles; GL_Bind(particletexture);
if (kill && kill->die < cl.time) alphaTestEnabled = glIsEnabled(GL_ALPHA_TEST);
{
active_particles = kill->next; if (alphaTestEnabled)
kill->next = free_particles; glDisable(GL_ALPHA_TEST);
free_particles = kill; glEnable (GL_BLEND);
continue; glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
} glBegin (GL_TRIANGLES);
break;
} VectorScale (vup, 1.5, up);
VectorScale (vright, 1.5, right);
#ifdef UQUAKE
frametime = cl.time - cl.oldtime;
#else
frametime = host_frametime;
#endif
time3 = frametime * 15;
time2 = frametime * 10; // 15;
time1 = frametime * 5;
#ifdef UQUAKE
grav = frametime * sv_gravity->value * 0.05;
#else
grav = frametime * 800 * 0.05;
#endif
dvel = 4*frametime;
for (p=active_particles ; p ; p=p->next)
{
for ( ;; ) for ( ;; )
{ {
kill = p->next; kill = active_particles;
if (kill && kill->die < cl.time) if (kill && kill->die < cl.time)
{ {
p->next = kill->next; active_particles = kill->next;
kill->next = free_particles; kill->next = free_particles;
free_particles = kill; free_particles = kill;
continue; continue;
} }
break; break;
} }
// hack a scale up to keep particles from disapearing for (p=active_particles ; p ; p=p->next)
scale = (p->org[0] - r_origin[0])*vpn[0]
+ (p->org[1] - r_origin[1])*vpn[1]
+ (p->org[2] - r_origin[2])*vpn[2];
if (scale < 20)
scale = gl_pscale->value;
else
scale = gl_pscale->value + scale * 0.004;
#if 0 // was in uquake, but give it a go
glColor3ubv ((byte *)&d_8to24table[(int)p->color]);
#else
at = (byte *)&d_8to24table[(int)p->color];
if (p->type==pt_fire)
theAlpha = 255*(6-p->ramp)/6;
// theAlpha = 192;
// else if (p->type==pt_explode || p->type==pt_explode2)
// theAlpha = 255*(8-p->ramp)/8;
else
theAlpha = 255;
glColor4ub (*at, *(at+1), *(at+2), theAlpha);
// glColor3ubv (at);
// glColor3ubv ((byte *)&d_8to24table[(int)p->color]);
#endif
glTexCoord2f (0,0);
glVertex3fv (p->org);
glTexCoord2f (1,0);
glVertex3f (p->org[0] + up[0]*scale, p->org[1] + up[1]*scale, p->org[2] + up[2]*scale);
glTexCoord2f (0,1);
glVertex3f (p->org[0] + right[0]*scale, p->org[1] + right[1]*scale, p->org[2] + right[2]*scale);
p->org[0] += p->vel[0]*frametime;
p->org[1] += p->vel[1]*frametime;
p->org[2] += p->vel[2]*frametime;
switch (p->type)
{ {
case pt_static: for ( ;; )
break; {
case pt_fire: kill = p->next;
p->ramp += time1; if (kill && kill->die < cl.time)
if (p->ramp >= 6) {
p->die = -1; p->next = kill->next;
kill->next = free_particles;
free_particles = kill;
continue;
}
break;
}
// hack a scale up to keep particles from disapearing
scale = (p->org[0] - r_origin[0])*vpn[0]
+ (p->org[1] - r_origin[1])*vpn[1]
+ (p->org[2] - r_origin[2])*vpn[2];
if (scale < 20)
scale = gl_particles->value;
else else
p->color = ramp3[(int)p->ramp]; scale = gl_particles->value + scale * 0.004;
p->vel[2] += grav; #if 0 // was in uquake, but give it a go
break; glColor3ubv ((byte *)&d_8to24table[(int)p->color]);
#else
case pt_explode: at = (byte *)&d_8to24table[(int)p->color];
p->ramp += time2; if (p->type==pt_fire)
if (p->ramp >=8) theAlpha = 255*(6-p->ramp)/6;
p->die = -1; // theAlpha = 192;
// else if (p->type==pt_explode || p->type==pt_explode2)
// theAlpha = 255*(8-p->ramp)/8;
else else
p->color = ramp1[(int)p->ramp]; theAlpha = 255;
for (i=0 ; i<3 ; i++) glColor4ub (*at, *(at+1), *(at+2), theAlpha);
p->vel[i] += p->vel[i]*dvel; // glColor3ubv (at);
p->vel[2] -= grav; // glColor3ubv ((byte *)&d_8to24table[(int)p->color]);
break; #endif
glTexCoord2f (0,0);
glVertex3fv (p->org);
glTexCoord2f (1,0);
glVertex3f (p->org[0] + up[0]*scale, p->org[1] + up[1]*scale, p->org[2] + up[2]*scale);
glTexCoord2f (0,1);
glVertex3f (p->org[0] + right[0]*scale, p->org[1] + right[1]*scale, p->org[2] + right[2]*scale);
case pt_explode2: p->org[0] += p->vel[0]*frametime;
p->ramp += time3; p->org[1] += p->vel[1]*frametime;
if (p->ramp >=8) p->org[2] += p->vel[2]*frametime;
p->die = -1;
else
p->color = ramp2[(int)p->ramp];
for (i=0 ; i<3 ; i++)
p->vel[i] -= p->vel[i]*frametime;
p->vel[2] -= grav;
break;
case pt_blob: switch (p->type)
for (i=0 ; i<3 ; i++) {
p->vel[i] += p->vel[i]*dvel; case pt_static:
p->vel[2] -= grav; break;
break; case pt_fire:
p->ramp += time1;
case pt_blob2: if (p->ramp >= 6)
for (i=0 ; i<2 ; i++) p->die = -1;
p->vel[i] -= p->vel[i]*dvel; else
p->vel[2] -= grav; p->color = ramp3[(int)p->ramp];
break; p->vel[2] += grav;
case pt_grav: break;
case pt_explode:
p->ramp += time2;
if (p->ramp >=8)
p->die = -1;
else
p->color = ramp1[(int)p->ramp];
for (i=0 ; i<3 ; i++)
p->vel[i] += p->vel[i]*dvel;
p->vel[2] -= grav;
break;
case pt_explode2:
p->ramp += time3;
if (p->ramp >=8)
p->die = -1;
else
p->color = ramp2[(int)p->ramp];
for (i=0 ; i<3 ; i++)
p->vel[i] -= p->vel[i]*frametime;
p->vel[2] -= grav;
break;
case pt_blob:
for (i=0 ; i<3 ; i++)
p->vel[i] += p->vel[i]*dvel;
p->vel[2] -= grav;
break;
case pt_blob2:
for (i=0 ; i<2 ; i++)
p->vel[i] -= p->vel[i]*dvel;
p->vel[2] -= grav;
break;
case pt_grav:
//ifdef QUAKE2 //ifdef QUAKE2
p->vel[2] -= grav * 20; p->vel[2] -= grav * 20;
break; break;
//endif //endif
case pt_slowgrav: case pt_slowgrav:
p->vel[2] -= grav; p->vel[2] -= grav;
break; break;
}
} }
}
glEnd (); glEnd ();
glDisable (GL_BLEND); glDisable (GL_BLEND);
if (alphaTestEnabled) if (alphaTestEnabled)
glEnable(GL_ALPHA_TEST); glEnable(GL_ALPHA_TEST);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
} // if (gl_particles->value)
} }

View file

@ -94,7 +94,7 @@ cvar_t *vid_mode;
cvar_t *vid_glx_fullscreen; cvar_t *vid_glx_fullscreen;
extern cvar_t *gl_triplebuffer; extern cvar_t *gl_triplebuffer;
extern cvar_t *vid_dga_mouseaccel; extern cvar_t *vid_dga_mouseaccel;
cvar_t *gl_pscale; cvar_t *gl_particles;
#ifdef HAS_DGA #ifdef HAS_DGA
static int nummodes; static int nummodes;
@ -568,7 +568,8 @@ void VID_Init(unsigned char *palette)
void VID_InitCvars() void VID_InitCvars()
{ {
gl_triplebuffer = Cvar_Get("gl_triplebuffer","1",CVAR_ARCHIVE,"None"); gl_triplebuffer = Cvar_Get("gl_triplebuffer","1",CVAR_ARCHIVE,"None");
gl_pscale = Cvar_Get("gl_pscale","1",0,"Sets the size of particles"); gl_particles = Cvar_Get("gl_particles","1",0,
"Sets the size of particles");
} }
void void

View file

@ -58,7 +58,7 @@ static cvar_t *vid_redrawfull;
static cvar_t *vid_waitforrefresh; static cvar_t *vid_waitforrefresh;
cvar_t *gl_ztrick; cvar_t *gl_ztrick;
extern cvar_t *gl_triplebuffer; extern cvar_t *gl_triplebuffer;
cvar_t *gl_pscale; cvar_t *gl_particles;
static fxMesaContext fc = NULL; static fxMesaContext fc = NULL;
static int scr_width, scr_height; static int scr_width, scr_height;
@ -519,7 +519,8 @@ void VID_ExtraOptionCmd(int option_cursor)
void VID_InitCvars () void VID_InitCvars ()
{ {
gl_triplebuffer = Cvar_Get ("gl_triplebuffer","1",CVAR_ARCHIVE,"None"); gl_triplebuffer = Cvar_Get ("gl_triplebuffer","1",CVAR_ARCHIVE,"None");
gl_pscale = Cvar_Get ("gl_pscale","1",0,"Sets the size of particles"); gl_particles = Cvar_Get ("gl_particles","1",0,
"Sets the size of particles");
} }
void void

View file

@ -158,7 +158,7 @@ qboolean gl_mtexable = false;
//==================================== //====================================
cvar_t *gl_ztrick; cvar_t *gl_ztrick;
cvar_t *gl_pscale; cvar_t *gl_particles;
cvar_t *vid_mode; cvar_t *vid_mode;
// Note that 0 is MODE_WINDOWED // Note that 0 is MODE_WINDOWED
@ -1626,7 +1626,8 @@ void VID_Init (unsigned char *palette)
"None"); "None");
_windowed_mouse = Cvar_Get ("_windowed_mouse","1",CVAR_ARCHIVE,"None"); _windowed_mouse = Cvar_Get ("_windowed_mouse","1",CVAR_ARCHIVE,"None");
gl_ztrick = Cvar_Get ("gl_ztrick","1",CVAR_ARCHIVE,"None"); gl_ztrick = Cvar_Get ("gl_ztrick","1",CVAR_ARCHIVE,"None");
gl_pscale = Cvar_Get ("gl_pscale","1",0,"Sets the size of particles"); gl_particles = Cvar_Get ("gl_particles","1",0,
"Sets the size of particles");
Cmd_AddCommand ("vid_nummodes", VID_NumModes_f); Cmd_AddCommand ("vid_nummodes", VID_NumModes_f);
Cmd_AddCommand ("vid_describecurrentmode", VID_DescribeCurrentMode_f); Cmd_AddCommand ("vid_describecurrentmode", VID_DescribeCurrentMode_f);