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:
authorAntony Riakiotakis <kalast@gmail.com>2013-03-19 18:25:12 +0400
committerAntony Riakiotakis <kalast@gmail.com>2013-03-19 18:25:12 +0400
commit526d79d6883ec3589e821780c69cb22e0a2206dc (patch)
tree8ec1c051131163af6676c4fc23a6687f754daa32 /source/blender/blenkernel/intern/brush.c
parent8fe0c0eb45fae46acd3325a5101d4c7bea3c17b5 (diff)
Fix: jittered brushes are not jittered, reported by kursad karatas.
Issue is sharing using global random generator which is shared with particle system which resets the seed due to some scene/option combination. Since it may be desirable to get predictable results with particles, made sure brushes allocate their own random number generator on startup and use that for jittering.
Diffstat (limited to 'source/blender/blenkernel/intern/brush.c')
-rw-r--r--source/blender/blenkernel/intern/brush.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index c594e19b960..819d20d4770 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -55,6 +55,18 @@
#include "RE_render_ext.h" /* externtex */
#include "RE_shader_ext.h"
+static RNG *brush_rng;
+
+void BKE_brush_system_init(void) {
+ brush_rng = BLI_rng_new(0);
+ BLI_rng_srandom(brush_rng, 31415682);
+}
+
+void BKE_brush_system_exit(void) {
+ BLI_rng_free(brush_rng);
+}
+
+
static void brush_defaults(Brush *brush)
{
brush->blend = 0;
@@ -877,8 +889,8 @@ void BKE_brush_jitter_pos(const Scene *scene, Brush *brush, const float pos[2],
int diameter;
do {
- rand_pos[0] = BLI_frand() - 0.5f;
- rand_pos[1] = BLI_frand() - 0.5f;
+ rand_pos[0] = BLI_rng_get_float(brush_rng) - 0.5f;
+ rand_pos[1] = BLI_rng_get_float(brush_rng) - 0.5f;
} while (len_v2(rand_pos) > 0.5f);