mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
[particles] Merge physics code
The particle physics is called by the renderer.
This commit is contained in:
parent
8d2791752e
commit
372c89b479
6 changed files with 40 additions and 147 deletions
|
@ -51,6 +51,7 @@ void R_InitEfrags (void);
|
|||
void R_ClearState (void);
|
||||
void R_InitSky (struct texture_s *mt); // called at level load
|
||||
void R_Textures_Init (void);
|
||||
void R_RunParticles (float dT);
|
||||
void R_RenderView (void); // must set r_refdef first
|
||||
void R_ViewChanged (void); // must set r_refdef first
|
||||
// called whenever r_refdef or vid change
|
||||
|
|
|
@ -124,6 +124,8 @@ gl_R_DrawParticles (void)
|
|||
if (!r_particles->int_val)
|
||||
return;
|
||||
|
||||
R_RunParticles (vr_data.frametime);
|
||||
|
||||
qfglBindTexture (GL_TEXTURE_2D, gl_part_tex);
|
||||
// LordHavoc: particles should not affect zbuffer
|
||||
qfglDepthMask (GL_FALSE);
|
||||
|
@ -135,27 +137,8 @@ gl_R_DrawParticles (void)
|
|||
vacount = 0;
|
||||
VA = particleVertexArray;
|
||||
|
||||
vec4f_t gravity = {0, 0, -vr_data.gravity, 0};
|
||||
|
||||
unsigned j = 0;
|
||||
for (unsigned i = 0; i < numparticles; i++) {
|
||||
particle_t *p = &particles[i];
|
||||
partparm_t *parm = &partparams[i];
|
||||
|
||||
if (p->live <= 0 || p->ramp >= parm->ramp_max
|
||||
|| p->alpha <= 0 || p->scale <= 0) {
|
||||
continue;
|
||||
}
|
||||
const int *ramp = partramps[j];
|
||||
if (i > j) {
|
||||
particles[j] = *p;
|
||||
partparams[j] = *parm;
|
||||
partramps[j] = ramp;
|
||||
}
|
||||
p = &particles[j];
|
||||
parm = &partparams[j];
|
||||
j += 1;
|
||||
|
||||
// Don't render particles too close to us.
|
||||
// Note, we must still do physics and such on them.
|
||||
if (!(DotProduct (p->pos, vpn) < minparticledist)) {
|
||||
|
@ -224,19 +207,7 @@ gl_R_DrawParticles (void)
|
|||
VA = particleVertexArray;
|
||||
}
|
||||
}
|
||||
|
||||
float dT = vr_data.frametime;
|
||||
p->pos += dT * p->vel;
|
||||
p->vel += dT * (p->vel * parm->drag + gravity * parm->drag[3]);
|
||||
p->ramp += dT * parm->ramp;
|
||||
p->live -= dT;
|
||||
p->alpha -= dT * parm->alpha_rate;
|
||||
p->scale += dT * parm->scale_rate;
|
||||
if (ramp) {
|
||||
p->icolor = ramp[(int)p->ramp];
|
||||
}
|
||||
}
|
||||
numparticles = j;
|
||||
|
||||
if (vacount) {
|
||||
if (partUseVA) {
|
||||
|
|
|
@ -256,27 +256,8 @@ draw_qf_particles (void)
|
|||
vacount = 0;
|
||||
VA = particleVertexArray;
|
||||
|
||||
vec4f_t gravity = {0, 0, -vr_data.gravity, 0};
|
||||
|
||||
unsigned j = 0;
|
||||
for (unsigned i = 0; i < numparticles; i++) {
|
||||
particle_t *p = &particles[i];
|
||||
partparm_t *parm = &partparams[i];
|
||||
|
||||
if (p->live <= 0 || p->ramp >= parm->ramp_max
|
||||
|| p->alpha <= 0 || p->scale <= 0) {
|
||||
continue;
|
||||
}
|
||||
const int *ramp = partramps[j];
|
||||
if (i > j) {
|
||||
particles[j] = *p;
|
||||
partparams[j] = *parm;
|
||||
partramps[j] = ramp;
|
||||
}
|
||||
p = &particles[j];
|
||||
parm = &partparams[j];
|
||||
j += 1;
|
||||
|
||||
// Don't render particles too close to us.
|
||||
// Note, we must still do physics and such on them.
|
||||
if (!(DotProduct (p->pos, vpn) < minparticledist)) {
|
||||
|
@ -338,19 +319,7 @@ draw_qf_particles (void)
|
|||
VA += 4;
|
||||
vacount += 6;
|
||||
}
|
||||
|
||||
float dT = vr_data.frametime;
|
||||
p->pos += dT * p->vel;
|
||||
p->vel += dT * (p->vel * parm->drag + gravity * parm->drag[3]);
|
||||
p->ramp += dT * parm->ramp;
|
||||
p->live -= dT;
|
||||
p->alpha -= dT * parm->alpha_rate;
|
||||
p->scale += dT * parm->scale_rate;
|
||||
if (ramp) {
|
||||
p->icolor = ramp[(int)p->ramp];
|
||||
}
|
||||
}
|
||||
numparticles = j;
|
||||
|
||||
qfeglVertexAttribPointer (quake_part.vertex.location, 3, GL_FLOAT,
|
||||
0, sizeof (partvert_t),
|
||||
|
@ -406,27 +375,8 @@ draw_id_particles (void)
|
|||
vacount = 0;
|
||||
VA = particleVertexArray;
|
||||
|
||||
vec4f_t gravity = {0, 0, -vr_data.gravity, 0};
|
||||
|
||||
unsigned j = 0;
|
||||
for (unsigned i = 0; i < numparticles; i++) {
|
||||
particle_t *p = &particles[i];
|
||||
partparm_t *parm = &partparams[i];
|
||||
|
||||
if (p->live <= 0 || p->ramp >= parm->ramp_max
|
||||
|| p->alpha <= 0 || p->scale <= 0) {
|
||||
continue;
|
||||
}
|
||||
const int *ramp = partramps[j];
|
||||
if (i > j) {
|
||||
particles[j] = *p;
|
||||
partparams[j] = *parm;
|
||||
partramps[j] = ramp;
|
||||
}
|
||||
p = &particles[j];
|
||||
parm = &partparams[j];
|
||||
j += 1;
|
||||
|
||||
// Don't render particles too close to us.
|
||||
// Note, we must still do physics and such on them.
|
||||
if (!(DotProduct (p->pos, vpn) < minparticledist)) {
|
||||
|
@ -435,19 +385,7 @@ draw_id_particles (void)
|
|||
VA++;
|
||||
vacount++;
|
||||
}
|
||||
|
||||
float dT = vr_data.frametime;
|
||||
p->pos += dT * p->vel;
|
||||
p->vel += dT * (p->vel * parm->drag + gravity * parm->drag[3]);
|
||||
p->ramp += dT * parm->ramp;
|
||||
p->live -= dT;
|
||||
p->alpha -= dT * parm->alpha_rate;
|
||||
p->scale += dT * parm->scale_rate;
|
||||
if (ramp) {
|
||||
p->icolor = ramp[(int)p->ramp];
|
||||
}
|
||||
}
|
||||
numparticles = j;
|
||||
|
||||
qfeglVertexAttribPointer (quake_point.vertex.location, 3, GL_FLOAT,
|
||||
0, sizeof (partvert_t),
|
||||
|
@ -469,6 +407,7 @@ glsl_R_DrawParticles (void)
|
|||
{
|
||||
if (!r_particles->int_val || !numparticles)
|
||||
return;
|
||||
R_RunParticles (vr_data.frametime);
|
||||
if (0/*FIXME r_particles_style->int_val*/) {
|
||||
draw_qf_particles ();
|
||||
} else {
|
||||
|
|
|
@ -85,3 +85,37 @@ R_ClearParticles (void)
|
|||
{
|
||||
numparticles = 0;
|
||||
}
|
||||
|
||||
void
|
||||
R_RunParticles (float dT)
|
||||
{
|
||||
vec4f_t gravity = {0, 0, -vr_data.gravity, 0};
|
||||
|
||||
unsigned j = 0;
|
||||
for (unsigned i = 0; i < numparticles; i++) {
|
||||
particle_t *p = &particles[i];
|
||||
partparm_t *parm = &partparams[i];
|
||||
|
||||
if (p->live <= 0 || p->ramp >= parm->ramp_max) {
|
||||
continue;
|
||||
}
|
||||
const int *ramp = partramps[j];
|
||||
if (i > j) {
|
||||
particles[j] = *p;
|
||||
partparams[j] = *parm;
|
||||
partramps[j] = ramp;
|
||||
}
|
||||
p = &particles[j];
|
||||
parm = &partparams[j];
|
||||
j += 1;
|
||||
|
||||
p->pos += dT * p->vel;
|
||||
p->vel += dT * (p->vel * parm->drag + gravity * parm->drag[3]);
|
||||
p->ramp += dT * parm->ramp;
|
||||
p->live -= dT;
|
||||
if (ramp) {
|
||||
p->icolor = ramp[(int)p->ramp];
|
||||
}
|
||||
}
|
||||
numparticles = j;
|
||||
}
|
||||
|
|
|
@ -56,39 +56,13 @@ R_DrawParticles (void)
|
|||
VectorScale (vup, yscaleshrink, r_pup);
|
||||
VectorCopy (vpn, r_ppn);
|
||||
|
||||
vec4f_t gravity = {0, 0, -vr_data.gravity, 0};
|
||||
R_RunParticles (vr_data.frametime);
|
||||
|
||||
unsigned j = 0;
|
||||
for (unsigned i = 0; i < numparticles; i++) {
|
||||
particle_t *p = &particles[i];
|
||||
partparm_t *parm = &partparams[i];
|
||||
|
||||
if (p->live <= 0 || p->ramp >= parm->ramp_max) {
|
||||
continue;
|
||||
}
|
||||
const int *ramp = partramps[j];
|
||||
if (i > j) {
|
||||
particles[j] = *p;
|
||||
partparams[j] = *parm;
|
||||
partramps[j] = ramp;
|
||||
}
|
||||
p = &particles[j];
|
||||
parm = &partparams[j];
|
||||
j += 1;
|
||||
|
||||
D_DrawParticle (p);
|
||||
|
||||
float dT = vr_data.frametime;
|
||||
p->pos += dT * p->vel;
|
||||
p->vel += dT * (p->vel * parm->drag + gravity * parm->drag[3]);
|
||||
p->ramp += dT * parm->ramp;
|
||||
p->live -= dT;
|
||||
if (ramp) {
|
||||
p->icolor = ramp[(int)p->ramp];
|
||||
}
|
||||
}
|
||||
numparticles = j;
|
||||
}
|
||||
|
||||
static void
|
||||
r_particles_nearclip_f (cvar_t *var)
|
||||
|
|
|
@ -59,39 +59,13 @@ sw32_R_DrawParticles (void)
|
|||
VectorScale (vup, yscaleshrink, r_pup);
|
||||
VectorCopy (vpn, r_ppn);
|
||||
|
||||
vec4f_t gravity = {0, 0, -vr_data.gravity, 0};
|
||||
R_RunParticles (vr_data.frametime);
|
||||
|
||||
unsigned j = 0;
|
||||
for (unsigned i = 0; i < numparticles; i++) {
|
||||
particle_t *p = &particles[i];
|
||||
partparm_t *parm = &partparams[i];
|
||||
|
||||
if (p->live <= 0 || p->ramp >= parm->ramp_max) {
|
||||
continue;
|
||||
}
|
||||
const int *ramp = partramps[j];
|
||||
if (i > j) {
|
||||
particles[j] = *p;
|
||||
partparams[j] = *parm;
|
||||
partramps[j] = ramp;
|
||||
}
|
||||
p = &particles[j];
|
||||
parm = &partparams[j];
|
||||
j += 1;
|
||||
|
||||
sw32_D_DrawParticle (p);
|
||||
|
||||
float dT = vr_data.frametime;
|
||||
p->pos += dT * p->vel;
|
||||
p->vel += dT * (p->vel * parm->drag + gravity * parm->drag[3]);
|
||||
p->ramp += dT * parm->ramp;
|
||||
p->live -= dT;
|
||||
if (ramp) {
|
||||
p->icolor = ramp[(int)p->ramp];
|
||||
}
|
||||
}
|
||||
numparticles = j;
|
||||
}
|
||||
|
||||
static void
|
||||
r_particles_nearclip_f (cvar_t *var)
|
||||
|
|
Loading…
Reference in a new issue