From 3de67589a335c8c80708640832ac91030dc0a233 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 21 Jan 2013 14:53:13 +0900 Subject: [PATCH] Fix random particle origin/velocity z component. This is a quick fix until I get a random number generator into QF. Mingw's RAND_MAX is only 0x7fff and so the (((rnd >> 10) & 63) - 31.5) / 63.0 used for the z component of origin and velocity would never go positive. For now, change the 10 to 9 (reusing another bit from Y). I plan on implementing a full 32-bit PRNG in QF so we always have a reliable generator. --- libs/video/renderer/gl/gl_dyn_part.c | 4 ++-- libs/video/renderer/glsl/glsl_particles.c | 4 ++-- libs/video/renderer/sw/sw_rpart.c | 4 ++-- libs/video/renderer/sw32/sw32_rpart.c | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libs/video/renderer/gl/gl_dyn_part.c b/libs/video/renderer/gl/gl_dyn_part.c index bedaa7f37..f8e3ab923 100644 --- a/libs/video/renderer/gl/gl_dyn_part.c +++ b/libs/video/renderer/gl/gl_dyn_part.c @@ -113,11 +113,11 @@ particle_new_random (ptype_t type, int texnum, const vec3_t org, int org_fuzz, rnd = rand (); porg[0] = o_fuzz * ((rnd & 63) - 31.5) / 63.0 + org[0]; porg[1] = o_fuzz * (((rnd >> 5) & 63) - 31.5) / 63.0 + org[1]; - porg[2] = o_fuzz * (((rnd >> 10) & 63) - 31.5) / 63.0 + org[2]; + porg[2] = o_fuzz * (((rnd >> 9) & 63) - 31.5) / 63.0 + org[2]; rnd = rand (); pvel[0] = v_fuzz * ((rnd & 63) - 31.5) / 63.0; pvel[1] = v_fuzz * (((rnd >> 5) & 63) - 31.5) / 63.0; - pvel[2] = v_fuzz * (((rnd >> 10) & 63) - 31.5) / 63.0; + pvel[2] = v_fuzz * (((rnd >> 9) & 63) - 31.5) / 63.0; particle_new (type, texnum, porg, scale, pvel, die, color, alpha, ramp); } diff --git a/libs/video/renderer/glsl/glsl_particles.c b/libs/video/renderer/glsl/glsl_particles.c index 2b2517511..a74e8d2c9 100644 --- a/libs/video/renderer/glsl/glsl_particles.c +++ b/libs/video/renderer/glsl/glsl_particles.c @@ -171,11 +171,11 @@ particle_new_random (ptype_t type, int texnum, const vec3_t org, int org_fuzz, rnd = rand (); porg[0] = o_fuzz * ((rnd & 63) - 31.5) / 63.0 + org[0]; porg[1] = o_fuzz * (((rnd >> 5) & 63) - 31.5) / 63.0 + org[1]; - porg[2] = o_fuzz * (((rnd >> 10) & 63) - 31.5) / 63.0 + org[2]; + porg[2] = o_fuzz * (((rnd >> 9) & 63) - 31.5) / 63.0 + org[2]; rnd = rand (); pvel[0] = v_fuzz * ((rnd & 63) - 31.5) / 63.0; pvel[1] = v_fuzz * (((rnd >> 5) & 63) - 31.5) / 63.0; - pvel[2] = v_fuzz * (((rnd >> 10) & 63) - 31.5) / 63.0; + pvel[2] = v_fuzz * (((rnd >> 9) & 63) - 31.5) / 63.0; particle_new (type, texnum, porg, scale, pvel, die, color, alpha, ramp); } diff --git a/libs/video/renderer/sw/sw_rpart.c b/libs/video/renderer/sw/sw_rpart.c index e4ec19921..708c1181d 100644 --- a/libs/video/renderer/sw/sw_rpart.c +++ b/libs/video/renderer/sw/sw_rpart.c @@ -908,11 +908,11 @@ R_Particle_NewRandom (ptype_t type, int texnum, const vec3_t org, int org_fuzz, rnd = rand (); porg[0] = o_fuzz * ((rnd & 63) - 31.5) / 63.0 + org[0]; porg[1] = o_fuzz * (((rnd >> 5) & 63) - 31.5) / 63.0 + org[1]; - porg[2] = o_fuzz * (((rnd >> 10) & 63) - 31.5) / 63.0 + org[2]; + porg[2] = o_fuzz * (((rnd >> 9) & 63) - 31.5) / 63.0 + org[2]; rnd = rand (); pvel[0] = v_fuzz * ((rnd & 63) - 31.5) / 63.0; pvel[1] = v_fuzz * (((rnd >> 5) & 63) - 31.5) / 63.0; - pvel[2] = v_fuzz * (((rnd >> 10) & 63) - 31.5) / 63.0; + pvel[2] = v_fuzz * (((rnd >> 9) & 63) - 31.5) / 63.0; R_Particle_New (type, texnum, porg, scale, pvel, die, color, alpha, ramp); } diff --git a/libs/video/renderer/sw32/sw32_rpart.c b/libs/video/renderer/sw32/sw32_rpart.c index b64438b4b..4f2829fb2 100644 --- a/libs/video/renderer/sw32/sw32_rpart.c +++ b/libs/video/renderer/sw32/sw32_rpart.c @@ -921,11 +921,11 @@ sw32_R_Particle_NewRandom (ptype_t type, int texnum, const vec3_t org, rnd = rand (); porg[0] = o_fuzz * ((rnd & 63) - 31.5) / 63.0 + org[0]; porg[1] = o_fuzz * (((rnd >> 5) & 63) - 31.5) / 63.0 + org[1]; - porg[2] = o_fuzz * (((rnd >> 10) & 63) - 31.5) / 63.0 + org[2]; + porg[2] = o_fuzz * (((rnd >> 9) & 63) - 31.5) / 63.0 + org[2]; rnd = rand (); pvel[0] = v_fuzz * ((rnd & 63) - 31.5) / 63.0; pvel[1] = v_fuzz * (((rnd >> 5) & 63) - 31.5) / 63.0; - pvel[2] = v_fuzz * (((rnd >> 10) & 63) - 31.5) / 63.0; + pvel[2] = v_fuzz * (((rnd >> 9) & 63) - 31.5) / 63.0; sw32_R_Particle_New (type, texnum, porg, scale, pvel, die, color, alpha, ramp); }