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 int ramp1[8], ramp2[8], ramp3[8];
extern cvar_t *gl_pscale;
extern cvar_t *gl_particles;
/*
===============
@ -61,53 +61,40 @@ void R_DrawParticles (void)
float scale;
qboolean alphaTestEnabled;
GL_Bind(particletexture);
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 ( ;; )
if (gl_particles->value)
{
kill = active_particles;
if (kill && kill->die < cl.time)
{
active_particles = kill->next;
kill->next = free_particles;
free_particles = kill;
continue;
}
break;
}
GL_Bind(particletexture);
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 (p=active_particles ; p ; p=p->next)
{
for ( ;; )
{
kill = p->next;
kill = active_particles;
if (kill && kill->die < cl.time)
{
p->next = kill->next;
active_particles = kill->next;
kill->next = free_particles;
free_particles = kill;
continue;
@ -115,101 +102,117 @@ void R_DrawParticles (void)
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_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)
for (p=active_particles ; p ; p=p->next)
{
case pt_static:
break;
case pt_fire:
p->ramp += time1;
if (p->ramp >= 6)
p->die = -1;
for ( ;; )
{
kill = p->next;
if (kill && kill->die < cl.time)
{
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
p->color = ramp3[(int)p->ramp];
p->vel[2] += grav;
break;
case pt_explode:
p->ramp += time2;
if (p->ramp >=8)
p->die = -1;
scale = gl_particles->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
p->color = ramp1[(int)p->ramp];
for (i=0 ; i<3 ; i++)
p->vel[i] += p->vel[i]*dvel;
p->vel[2] -= grav;
break;
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);
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;
p->org[0] += p->vel[0]*frametime;
p->org[1] += p->vel[1]*frametime;
p->org[2] += p->vel[2]*frametime;
case pt_blob:
for (i=0 ; i<3 ; i++)
p->vel[i] += p->vel[i]*dvel;
p->vel[2] -= grav;
break;
switch (p->type)
{
case pt_static:
break;
case pt_fire:
p->ramp += time1;
if (p->ramp >= 6)
p->die = -1;
else
p->color = ramp3[(int)p->ramp];
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:
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
p->vel[2] -= grav * 20;
break;
p->vel[2] -= grav * 20;
break;
//endif
case pt_slowgrav:
p->vel[2] -= grav;
break;
case pt_slowgrav:
p->vel[2] -= grav;
break;
}
}
}
glEnd ();
glDisable (GL_BLEND);
if (alphaTestEnabled)
glEnable(GL_ALPHA_TEST);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glEnd ();
glDisable (GL_BLEND);
if (alphaTestEnabled)
glEnable(GL_ALPHA_TEST);
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;
extern cvar_t *gl_triplebuffer;
extern cvar_t *vid_dga_mouseaccel;
cvar_t *gl_pscale;
cvar_t *gl_particles;
#ifdef HAS_DGA
static int nummodes;
@ -568,7 +568,8 @@ void VID_Init(unsigned char *palette)
void VID_InitCvars()
{
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

View file

@ -58,7 +58,7 @@ static cvar_t *vid_redrawfull;
static cvar_t *vid_waitforrefresh;
cvar_t *gl_ztrick;
extern cvar_t *gl_triplebuffer;
cvar_t *gl_pscale;
cvar_t *gl_particles;
static fxMesaContext fc = NULL;
static int scr_width, scr_height;
@ -519,7 +519,8 @@ void VID_ExtraOptionCmd(int option_cursor)
void VID_InitCvars ()
{
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

View file

@ -158,7 +158,7 @@ qboolean gl_mtexable = false;
//====================================
cvar_t *gl_ztrick;
cvar_t *gl_pscale;
cvar_t *gl_particles;
cvar_t *vid_mode;
// Note that 0 is MODE_WINDOWED
@ -1626,7 +1626,8 @@ void VID_Init (unsigned char *palette)
"None");
_windowed_mouse = Cvar_Get ("_windowed_mouse","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_describecurrentmode", VID_DescribeCurrentMode_f);