Revamp the software particle rendering loop. Seems to work well.

This commit is contained in:
Bill Currie 2000-06-28 23:20:57 +00:00
parent 66e9bfd98c
commit d5ea4bc9bf

View file

@ -462,7 +462,7 @@ R_DrawParticles
*/ */
void R_DrawParticles (void) void R_DrawParticles (void)
{ {
particle_t *p, *kill; particle_t *p, **particle;
float grav; float grav;
int i; int i;
float time2, time3; float time2, time3;
@ -482,89 +482,73 @@ void R_DrawParticles (void)
grav = frametime * 800 * 0.05; grav = frametime * 800 * 0.05;
dvel = 4*frametime; dvel = 4*frametime;
while (1) { for (particle = &active_particles; *particle; ) {
kill = active_particles; if ((*particle)->die < cl.time) {
if (kill != NULL && kill->die < cl.time) { p = (*particle)->next;
active_particles = kill->next; (*particle)->next = free_particles;
kill->next = free_particles; free_particles = (*particle);
free_particles = kill; (*particle) = p;
continue; } else {
} p = *particle;
break; particle = &(*particle)->next;
}
for (p=active_particles ; p ; p=p->next) D_DrawParticle (p);
{
for ( ;; ) p->org[0] += p->vel[0]*frametime;
{ p->org[1] += p->vel[1]*frametime;
kill = p->next; p->org[2] += p->vel[2]*frametime;
if (kill && kill->die < cl.time)
{ switch (p->type) {
p->next = kill->next; case pt_static:
kill->next = free_particles; break;
free_particles = kill; case pt_fire:
continue; p->ramp += time1;
if (p->ramp >= 6)
p->die = -1;
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;
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_slowgrav:
case pt_grav:
p->vel[2] -= grav;
break;
} }
break;
}
D_DrawParticle (p);
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:
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_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_slowgrav:
case pt_grav:
p->vel[2] -= grav;
break;
} }
} }