diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2018-06-12 18:00:07 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2018-06-12 18:00:31 +0300 |
commit | a9cfd8c910687e5e18e34339a5a33fb73f167421 (patch) | |
tree | 48704f13374b62423f9fb96ad5f294dad7d355a2 /source/blender/editors/transform/transform_generics.c | |
parent | 8826a004825761175c2a08bf51a655be02cfcee6 (diff) |
Cleanup: get rid of global RNG usage in transform code.
Diffstat (limited to 'source/blender/editors/transform/transform_generics.c')
-rw-r--r-- | source/blender/editors/transform/transform_generics.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 8bef63dba1a..5ff1ddb6ac5 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -58,6 +58,8 @@ #include "BLI_rand.h" #include "BLI_utildefines.h" +#include "PIL_time.h" + #include "BLT_translation.h" #include "RNA_access.h" @@ -1695,6 +1697,10 @@ void postTrans(bContext *C, TransInfo *t) MEM_freeN(t->mouse.data); } + if (t->rng != NULL) { + BLI_rng_free(t->rng); + } + freeSnapping(t); } @@ -2163,7 +2169,12 @@ void calculatePropRatio(TransInfo *t) td->factor = sqrtf(2 * dist - dist * dist); break; case PROP_RANDOM: - td->factor = BLI_frand() * dist; + if (t->rng == NULL) { + /* Lazy initialization. */ + uint rng_seed = (uint)(PIL_check_seconds_timer_i() & UINT_MAX); + t->rng = BLI_rng_new(rng_seed); + } + td->factor = BLI_rng_get_float(t->rng) * dist; break; case PROP_INVSQUARE: td->factor = dist * (2.0f - dist); |