/** * @brief CG_AddParticles */ void CG_AddParticles(void) { cparticle_t *p, *next; float alpha; float time, time2; vec3_t org; cparticle_t *active = NULL, *tail = NULL; vec3_t rotate_ang; if (!initparticles) { CG_ClearParticles(); } VectorCopy(cg.refdef_current->viewaxis[0], vforward); VectorCopy(cg.refdef_current->viewaxis[1], vright); VectorCopy(cg.refdef_current->viewaxis[2], vup); vectoangles(cg.refdef_current->viewaxis[0], rotate_ang); roll += ((cg.time - oldtime) * 0.1f) ; rotate_ang[ROLL] += (roll * 0.9f); AngleVectors(rotate_ang, rforward, rright, rup); oldtime = cg.time; for (p = active_particles ; p ; p = next) { next = p->next; time = (cg.time - p->time) * 0.001f; alpha = p->alpha + time * p->alphavel; if (alpha <= 0) // faded out { p->next = free_particles; free_particles = p; p->type = 0; p->color = 0; p->alpha = 0; continue; } switch (p->type) { case P_SMOKE: case P_ANIM: case P_DLIGHT_ANIM: case P_BLEED: case P_SMOKE_IMPACT: case P_WEATHER_FLURRY: case P_FLAT_SCALEUP_FADE: if (cg.time > p->endtime) { p->next = free_particles; free_particles = p; p->type = 0; p->color = 0; p->alpha = 0; continue; } break; case P_SPRITE: if (p->endtime < 0) { // temporary sprite CG_AddParticleToScene(p, p->org, alpha); p->next = free_particles; free_particles = p; p->type = 0; p->color = 0; p->alpha = 0; continue; } break; default: // P_NONE // P_WEATHER // P_FLAT // P_ROTATE // P_WEATHER_TURBULENT // P_FLAT_SCALEUP // P_BUBBLE // P_BUBBLE_TURBULENT break; } p->next = NULL; if (!tail) { active = tail = p; } else { tail->next = p; tail = p; } if (alpha > 1.0f) { alpha = 1; } time2 = time * time; org[0] = p->org[0] + p->vel[0] * time + p->accel[0] * time2; org[1] = p->org[1] + p->vel[1] * time + p->accel[1] * time2; org[2] = p->org[2] + p->vel[2] * time + p->accel[2] * time2; CG_AddParticleToScene(p, org, alpha); } active_particles = active; }
/* =============== CG_AddParticles =============== */ void CG_AddParticles(void) { cparticle_t *p, *next; float alpha; float time, time2; vec3_t org; cparticle_t *active, *tail; vec3_t rotate_ang; if (!initparticles) { CG_ClearParticles(); } VectorCopy(cg.refdef_current->viewaxis[0], vforward); VectorCopy(cg.refdef_current->viewaxis[1], vright); VectorCopy(cg.refdef_current->viewaxis[2], vup); vectoangles(cg.refdef_current->viewaxis[0], rotate_ang); roll += ((cg.time - oldtime) * 0.1) ; rotate_ang[ROLL] += (roll * 0.9); AngleVectors(rotate_ang, rforward, rright, rup); oldtime = cg.time; active = NULL; tail = NULL; for (p = active_particles ; p ; p = next) { next = p->next; time = (cg.time - p->time) * 0.001; alpha = p->alpha + time * p->alphavel; if (alpha <= 0) { // faded out p->next = free_particles; free_particles = p; p->type = 0; p->color = 0; p->alpha = 0; continue; } if ((p->type == P_SMOKE || p->type == P_ANIM || p->type == P_DLIGHT_ANIM || p->type == P_SMOKE_IMPACT) && cg.time > p->endtime) { p->next = free_particles; free_particles = p; p->type = 0; p->color = 0; p->alpha = 0; continue; } if (p->type == P_WEATHER_FLURRY && cg.time > p->endtime) { p->next = free_particles; free_particles = p; p->type = 0; p->color = 0; p->alpha = 0; continue; } if (p->type == P_FLAT_SCALEUP_FADE && cg.time > p->endtime) { p->next = free_particles; free_particles = p; p->type = 0; p->color = 0; p->alpha = 0; continue; } if (p->type == P_SPRITE && p->endtime < 0) { // temporary sprite CG_AddParticleToScene(p, p->org); p->next = free_particles; free_particles = p; p->type = 0; p->color = 0; p->alpha = 0; continue; } p->next = NULL; if (!tail) { active = tail = p; } else { tail->next = p; tail = p; } if (alpha > 1.0) { alpha = 1; } time2 = time * time; org[0] = p->org[0] + p->vel[0] * time + p->accel[0] * time2; org[1] = p->org[1] + p->vel[1] * time + p->accel[1] * time2; org[2] = p->org[2] + p->vel[2] * time + p->accel[2] * time2; CG_AddParticleToScene(p, org); } active_particles = active; }
/* =============== CG_AddParticles =============== */ void CG_AddParticles (void) { cparticle_t *p, *next; float alpha; float time, time2; vector3 org; int color; cparticle_t *active, *tail; int type; vector3 rotate_ang; refdef_t *refdef = CG_GetRefdef(); if (!initparticles) CG_ClearParticles (); VectorCopy( &refdef->viewaxis[0], &pvforward ); VectorCopy( &refdef->viewaxis[1], &pvright ); VectorCopy( &refdef->viewaxis[2], &pvup ); vectoangles( &refdef->viewaxis[0], &rotate_ang ); roll += ((cg.time - oldtime) * 0.1) ; rotate_ang.roll += (roll*0.9); AngleVectors ( &rotate_ang, &rforward, &rright, &rup); oldtime = cg.time; active = NULL; tail = NULL; for (p=active_particles ; p ; p=next) { next = p->next; time = (cg.time - p->time)*0.001; alpha = p->alpha + time*p->alphavel; if (alpha <= 0) { // faded out p->next = free_particles; free_particles = p; p->type = 0; p->color = 0; p->alpha = 0; continue; } if (p->type == P_SMOKE || p->type == P_ANIM || p->type == P_BLEED || p->type == P_SMOKE_IMPACT) { if (cg.time > p->endtime) { p->next = free_particles; free_particles = p; p->type = 0; p->color = 0; p->alpha = 0; continue; } } if (p->type == P_WEATHER_FLURRY) { if (cg.time > p->endtime) { p->next = free_particles; free_particles = p; p->type = 0; p->color = 0; p->alpha = 0; continue; } } if (p->type == P_FLAT_SCALEUP_FADE) { if (cg.time > p->endtime) { p->next = free_particles; free_particles = p; p->type = 0; p->color = 0; p->alpha = 0; continue; } } if ((p->type == P_BAT || p->type == P_SPRITE) && p->endtime < 0) { // temporary sprite CG_AddParticleToScene (p, &p->org, alpha); p->next = free_particles; free_particles = p; p->type = 0; p->color = 0; p->alpha = 0; continue; } p->next = NULL; if (!tail) active = tail = p; else { tail->next = p; tail = p; } if (alpha > 1.0) alpha = 1; color = p->color; time2 = time*time; org.x = p->org.x + p->vel.x*time + p->accel.x*time2; org.y = p->org.y + p->vel.y*time + p->accel.y*time2; org.z = p->org.z + p->vel.z*time + p->accel.z*time2; type = p->type; CG_AddParticleToScene (p, &org, alpha); } active_particles = active; }