diff options
Diffstat (limited to 'source/blender/blenlib/intern/rand.c')
-rw-r--r-- | source/blender/blenlib/intern/rand.c | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/source/blender/blenlib/intern/rand.c b/source/blender/blenlib/intern/rand.c index 110757ac3c0..9e56ce6b2cf 100644 --- a/source/blender/blenlib/intern/rand.c +++ b/source/blender/blenlib/intern/rand.c @@ -265,29 +265,6 @@ void BLI_rng_skip(RNG *rng, int n) /***/ -/* initialize with some non-zero seed */ -static RNG theBLI_rng = {611330372042337130}; - -void BLI_srandom(unsigned int seed) -{ - BLI_rng_srandom(&theBLI_rng, seed); -} - -int BLI_rand(void) -{ - return BLI_rng_get_int(&theBLI_rng); -} - -float BLI_frand(void) -{ - return BLI_rng_get_float(&theBLI_rng); -} - -void BLI_frand_unit_v3(float v[3]) -{ - BLI_rng_get_float_unit_v3(&theBLI_rng, v); -} - float BLI_hash_frand(unsigned int seed) { RNG rng; @@ -386,6 +363,8 @@ void BLI_halton_1D(unsigned int prime, double offset, int n, double *r) { const double invprime = 1.0 / (double)prime; + *r = 0.0; + for (int s = 0; s < n; s++) { *r = halton_ex(invprime, &offset); } @@ -395,6 +374,8 @@ void BLI_halton_2D(unsigned int prime[2], double offset[2], int n, double *r) { const double invprimes[2] = {1.0 / (double)prime[0], 1.0 / (double)prime[1]}; + r[0] = r[1] = 0.0; + for (int s = 0; s < n; s++) { for (int i = 0; i < 2; i++) { r[i] = halton_ex(invprimes[i], &offset[i]); @@ -406,6 +387,8 @@ void BLI_halton_3D(unsigned int prime[3], double offset[3], int n, double *r) { const double invprimes[3] = {1.0 / (double)prime[0], 1.0 / (double)prime[1], 1.0 / (double)prime[2]}; + r[0] = r[1] = r[2] = 0.0; + for (int s = 0; s < n; s++) { for (int i = 0; i < 3; i++) { r[i] = halton_ex(invprimes[i], &offset[i]); |