mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-17 22:50:51 +00:00
Reduce number of rand() calls in teleport and lava splash effects. Also preserves entropy, and we all know how important that is!
This commit is contained in:
parent
cb4ce6a634
commit
f2f8513141
1 changed files with 33 additions and 32 deletions
|
@ -60,8 +60,7 @@ static const char rcsid[] =
|
||||||
int ramp[8] = { 0x6f, 0x6d, 0x6b, 0x69, 0x67, 0x65, 0x63, 0x61 };
|
int ramp[8] = { 0x6f, 0x6d, 0x6b, 0x69, 0x67, 0x65, 0x63, 0x61 };
|
||||||
|
|
||||||
|
|
||||||
|
inline static void
|
||||||
inline particle_t *
|
|
||||||
particle_new (ptype_t type, int texnum, vec3_t org, float scale, vec3_t vel,
|
particle_new (ptype_t type, int texnum, vec3_t org, float scale, vec3_t vel,
|
||||||
float die, byte color, byte alpha)
|
float die, byte color, byte alpha)
|
||||||
{
|
{
|
||||||
|
@ -84,11 +83,9 @@ particle_new (ptype_t type, int texnum, vec3_t org, float scale, vec3_t vel,
|
||||||
part->alpha = alpha;
|
part->alpha = alpha;
|
||||||
part->tex = texnum;
|
part->tex = texnum;
|
||||||
part->scale = scale;
|
part->scale = scale;
|
||||||
|
|
||||||
return part;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline particle_t *
|
inline static void
|
||||||
particle_new_random (ptype_t type, int texnum, vec3_t org, int org_fuzz,
|
particle_new_random (ptype_t type, int texnum, vec3_t org, int org_fuzz,
|
||||||
float scale, int vel_fuzz, float die, byte color,
|
float scale, int vel_fuzz, float die, byte color,
|
||||||
byte alpha)
|
byte alpha)
|
||||||
|
@ -102,7 +99,7 @@ particle_new_random (ptype_t type, int texnum, vec3_t org, int org_fuzz,
|
||||||
if (vel_fuzz)
|
if (vel_fuzz)
|
||||||
pvel[j] = qfrandom (vel_fuzz * 2) - vel_fuzz;
|
pvel[j] = qfrandom (vel_fuzz * 2) - vel_fuzz;
|
||||||
}
|
}
|
||||||
return particle_new (type, texnum, porg, scale, pvel, die, color, alpha);
|
particle_new (type, texnum, porg, scale, pvel, die, color, alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -336,7 +333,7 @@ void
|
||||||
R_LavaSplash (vec3_t org)
|
R_LavaSplash (vec3_t org)
|
||||||
{
|
{
|
||||||
float vel;
|
float vel;
|
||||||
int i, j;
|
int rnd, i, j;
|
||||||
int k = 256;
|
int k = 256;
|
||||||
vec3_t dir, porg, pvel;
|
vec3_t dir, porg, pvel;
|
||||||
|
|
||||||
|
@ -349,19 +346,21 @@ R_LavaSplash (vec3_t org)
|
||||||
dir[2] = 256;
|
dir[2] = 256;
|
||||||
for (i = -128; i < 128; i += 16) {
|
for (i = -128; i < 128; i += 16) {
|
||||||
for (j = -128; j < 128; j += 16) {
|
for (j = -128; j < 128; j += 16) {
|
||||||
dir[0] = j + (rand () & 7);
|
rnd = rand ();
|
||||||
dir[1] = i + (rand () & 7);
|
dir[0] = j + (rnd & 7);
|
||||||
|
dir[1] = i + ((rnd >> 6) & 7);
|
||||||
|
|
||||||
porg[0] = org[0] + dir[0];
|
porg[0] = org[0] + dir[0];
|
||||||
porg[1] = org[1] + dir[1];
|
porg[1] = org[1] + dir[1];
|
||||||
porg[2] = org[2] + (rand () & 63);
|
porg[2] = org[2] + ((rnd >> 9) & 63);
|
||||||
|
|
||||||
VectorNormalize (dir);
|
VectorNormalize (dir);
|
||||||
vel = 50 + (rand () & 63);
|
rnd = rand ();
|
||||||
|
vel = 50 + (rnd & 63);
|
||||||
VectorScale (dir, vel, pvel);
|
VectorScale (dir, vel, pvel);
|
||||||
particle_new (pt_grav, part_tex_dot, porg, 3, pvel,
|
particle_new (pt_grav, part_tex_dot, porg, 3, pvel,
|
||||||
(r_realtime + 2 + (rand () & 31) * 0.02),
|
(r_realtime + 2 + ((rnd >> 7) & 31) * 0.02),
|
||||||
(224 + (rand () & 7)), 193);
|
(224 + ((rnd >> 12) & 7)), 193);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -370,7 +369,7 @@ void
|
||||||
R_TeleportSplash (vec3_t org)
|
R_TeleportSplash (vec3_t org)
|
||||||
{
|
{
|
||||||
float vel;
|
float vel;
|
||||||
int i, j, k;
|
int rnd, i, j, k;
|
||||||
int l = 896;
|
int l = 896;
|
||||||
vec3_t dir, porg, pvel;
|
vec3_t dir, porg, pvel;
|
||||||
|
|
||||||
|
@ -386,17 +385,18 @@ R_TeleportSplash (vec3_t org)
|
||||||
dir[0] = j * 8;
|
dir[0] = j * 8;
|
||||||
for (k = -24; k < 32; k += 4) {
|
for (k = -24; k < 32; k += 4) {
|
||||||
dir[2] = k * 8;
|
dir[2] = k * 8;
|
||||||
|
|
||||||
porg[0] = org[0] + i + (rand () & 3);
|
rnd = rand ();
|
||||||
porg[1] = org[1] + j + (rand () & 3);
|
porg[0] = org[0] + i + (rnd & 3);
|
||||||
porg[2] = org[2] + k + (rand () & 3);
|
porg[1] = org[1] + j + ((rnd >> 2) & 3);
|
||||||
|
porg[2] = org[2] + k + ((rnd >> 4) & 3);
|
||||||
|
|
||||||
VectorNormalize (dir);
|
VectorNormalize (dir);
|
||||||
vel = 50 + (rand () & 63);
|
vel = 50 + ((rnd >> 6) & 63);
|
||||||
VectorScale (dir, vel, pvel);
|
VectorScale (dir, vel, pvel);
|
||||||
particle_new (pt_grav, part_tex_spark, porg, 0.6, pvel,
|
particle_new (pt_grav, part_tex_spark, porg, 0.6, pvel,
|
||||||
(r_realtime + 0.2 + (rand () & 15) * 0.01),
|
(r_realtime + 0.2 + (rand () & 15) * 0.01),
|
||||||
(7 + (rand () & 7)), 255);
|
(7 + ((rnd >> 12) & 7)), 255);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -501,7 +501,7 @@ R_BloodTrail (entity_t *ent)
|
||||||
dist = (pscale + pscalenext) * 1.5;
|
dist = (pscale + pscalenext) * 1.5;
|
||||||
|
|
||||||
for (j = 0; j < 3; j++) {
|
for (j = 0; j < 3; j++) {
|
||||||
pvel[j] = (qfrandom (24.0) - 12.0);
|
pvel[j] = qfrandom (24.0) - 12.0;
|
||||||
porg[j] = ent->old_origin[j] + qfrandom (3.0) - 1.5;
|
porg[j] = ent->old_origin[j] + qfrandom (3.0) - 1.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -676,7 +676,7 @@ R_VoorTrail (entity_t *ent)
|
||||||
void
|
void
|
||||||
R_DrawParticles (void)
|
R_DrawParticles (void)
|
||||||
{
|
{
|
||||||
byte i;
|
// byte i;
|
||||||
unsigned char *at;
|
unsigned char *at;
|
||||||
float dvel, grav, fast_grav, minparticledist, scale,
|
float dvel, grav, fast_grav, minparticledist, scale,
|
||||||
bloodcloud_alpha, bloodcloud_scale, fallfadespark_alpha,
|
bloodcloud_alpha, bloodcloud_scale, fallfadespark_alpha,
|
||||||
|
@ -693,10 +693,14 @@ R_DrawParticles (void)
|
||||||
// LordHavoc: particles should not affect zbuffer
|
// LordHavoc: particles should not affect zbuffer
|
||||||
qfglDepthMask (GL_FALSE);
|
qfglDepthMask (GL_FALSE);
|
||||||
|
|
||||||
varray[0].texcoord[0] = 0; varray[0].texcoord[1] = 1;
|
varray[0].texcoord[0] = 0;
|
||||||
varray[1].texcoord[0] = 0; varray[1].texcoord[1] = 0;
|
varray[0].texcoord[1] = 1;
|
||||||
varray[2].texcoord[0] = 1; varray[2].texcoord[1] = 0;
|
varray[1].texcoord[0] = 0;
|
||||||
varray[3].texcoord[0] = 1; varray[3].texcoord[1] = 1;
|
varray[1].texcoord[1] = 0;
|
||||||
|
varray[2].texcoord[0] = 1;
|
||||||
|
varray[2].texcoord[1] = 0;
|
||||||
|
varray[3].texcoord[0] = 1;
|
||||||
|
varray[3].texcoord[1] = 1;
|
||||||
|
|
||||||
grav = (fast_grav = r_frametime * 800) * 0.05;
|
grav = (fast_grav = r_frametime * 800) * 0.05;
|
||||||
dvel = bloodcloud_scale = smoke_scale = r_frametime * 4;
|
dvel = bloodcloud_scale = smoke_scale = r_frametime * 4;
|
||||||
|
@ -757,20 +761,17 @@ R_DrawParticles (void)
|
||||||
qfglDrawArrays (GL_QUADS, 0, 4);
|
qfglDrawArrays (GL_QUADS, 0, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 3; i++)
|
VectorMA (part->org, r_frametime, part->vel, part->org);
|
||||||
part->org[i] += part->vel[i] * r_frametime;
|
|
||||||
|
|
||||||
switch (part->type) {
|
switch (part->type) {
|
||||||
case pt_static:
|
case pt_static:
|
||||||
break;
|
break;
|
||||||
case pt_blob:
|
case pt_blob:
|
||||||
for (i = 0; i < 3; i++)
|
VectorMA (part->vel, dvel, part->vel, part->vel);
|
||||||
part->vel[i] += part->vel[i] * dvel;
|
|
||||||
part->vel[2] -= grav;
|
part->vel[2] -= grav;
|
||||||
break;
|
break;
|
||||||
case pt_blob2:
|
case pt_blob2:
|
||||||
for (i = 0; i < 2; i++)
|
VectorMA (part->vel, dvel, part->vel, part->vel);
|
||||||
part->vel[i] -= part->vel[i] * dvel;
|
|
||||||
part->vel[2] -= grav;
|
part->vel[2] -= grav;
|
||||||
break;
|
break;
|
||||||
case pt_grav:
|
case pt_grav:
|
||||||
|
|
Loading…
Reference in a new issue