Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenlib/intern/rand.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/rand.c b/source/blender/blenlib/intern/rand.c
index 700524965f0..8d6f55c9ae5 100644
--- a/source/blender/blenlib/intern/rand.c
+++ b/source/blender/blenlib/intern/rand.c
@@ -268,23 +268,38 @@ void BLI_rng_skip(RNG *rng, int n)
/* initialize with some non-zero seed */
static RNG theBLI_rng = {611330372042337130};
+static void ensure_rng_thread_safe(void)
+{
+ /* TODO(sergey): Ideally we will get rid of all rng functions which
+ * are using global generator. But for until then we need some way to
+ * catch "bad" calls at runtime.
+ *
+ * NOTE: Lots of areas are not ported, so we keep check disabled for now.
+ */
+ // 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);
}