diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-06-12 16:46:50 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-06-12 16:51:43 +0300 |
commit | b236400ff5b6b18f0b81fb326b95719be7ebe379 (patch) | |
tree | 40f26df0afe11f2193ae686422089b0e82e3e915 /source/blender/blenlib | |
parent | 6231a077ac96b546d41404ef423fc23e1fa01803 (diff) |
Math: Remove unused functions which are not safe for threading
All areas are toy use "local" number generator, in order to keep
behavior predictable and threadable. This is what BLI_rng_() API
is for.
There are still lots of usages of BLI_frand(), which are to be
ported to BLI_rng_get_float(). but that is somewhat involved.
For the time being, remove unsafe API, so new areas have zero
chance using it.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_rand.h | 8 | ||||
-rw-r--r-- | source/blender/blenlib/intern/rand.c | 18 |
2 files changed, 1 insertions, 25 deletions
diff --git a/source/blender/blenlib/BLI_rand.h b/source/blender/blenlib/BLI_rand.h index 69b23b2473f..811a6ba1768 100644 --- a/source/blender/blenlib/BLI_rand.h +++ b/source/blender/blenlib/BLI_rand.h @@ -64,15 +64,9 @@ void BLI_rng_shuffle_array(struct RNG *rng, void *data, unsigned int elem /** Note that skipping is as slow as generating n numbers! */ void BLI_rng_skip(struct RNG *rng, int n) ATTR_NONNULL(1); -/** Seed for the random number generator, using noise.c hash[] */ -void BLI_srandom(unsigned int seed); - -/** Return a pseudo-random number N where 0<=N<(2^31) */ -int BLI_rand(void) ATTR_WARN_UNUSED_RESULT; - /** Return a pseudo-random number N where 0.0f<=N<1.0f */ +/* !!!!! NOTE: DO NOT USE IT IN NEW CODE !!!!! */ float BLI_frand(void) ATTR_WARN_UNUSED_RESULT; -void BLI_frand_unit_v3(float v[3]); /** Return a pseudo-random (hash) float from an integer value */ float BLI_hash_frand(unsigned int seed) ATTR_WARN_UNUSED_RESULT; diff --git a/source/blender/blenlib/intern/rand.c b/source/blender/blenlib/intern/rand.c index 8d6f55c9ae5..557f0d79270 100644 --- a/source/blender/blenlib/intern/rand.c +++ b/source/blender/blenlib/intern/rand.c @@ -279,30 +279,12 @@ static void ensure_rng_thread_safe(void) // BLI_assert(BLI_thread_is_main()); } -void BLI_srandom(unsigned int seed) -{ - ensure_rng_thread_safe(); - BLI_rng_srandom(&theBLI_rng, seed); -} - -int BLI_rand(void) -{ - ensure_rng_thread_safe(); - return BLI_rng_get_int(&theBLI_rng); -} - float BLI_frand(void) { ensure_rng_thread_safe(); return BLI_rng_get_float(&theBLI_rng); } -void BLI_frand_unit_v3(float v[3]) -{ - ensure_rng_thread_safe(); - BLI_rng_get_float_unit_v3(&theBLI_rng, v); -} - float BLI_hash_frand(unsigned int seed) { RNG rng; |