[Bf-blender-cvs] [8204261edec] blender2.8: Particle: Remove global RNG usage from distribution

Sergey Sharybin noreply at git.blender.org
Tue Jun 12 15:38:37 CEST 2018


Commit: 8204261edec6b28e3b990e6e66f7bcd4f6ee1886
Author: Sergey Sharybin
Date:   Tue Jun 12 15:26:37 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB8204261edec6b28e3b990e6e66f7bcd4f6ee1886

Particle: Remove global RNG usage from distribution

===================================================================

M	source/blender/blenkernel/intern/particle_distribute.c

===================================================================

diff --git a/source/blender/blenkernel/intern/particle_distribute.c b/source/blender/blenkernel/intern/particle_distribute.c
index 6c23036256b..05ce45e3900 100644
--- a/source/blender/blenkernel/intern/particle_distribute.c
+++ b/source/blender/blenkernel/intern/particle_distribute.c
@@ -433,7 +433,7 @@ static int distribute_binary_search(float *sum, int n, float value)
 
 /* the max number if calls to rng_* funcs within psys_thread_distribute_particle
  * be sure to keep up to date if this changes */
-#define PSYS_RND_DIST_SKIP 2
+#define PSYS_RND_DIST_SKIP 3
 
 /* note: this function must be thread safe, for from == PART_FROM_CHILD */
 #define ONLY_WORKING_WITH_PA_VERTS 0
@@ -487,8 +487,10 @@ static void distribute_from_verts_exec(ParticleTask *thread, ParticleData *pa, i
 	}
 #endif
 	
-	if (rng_skip_tot > 0) /* should never be below zero */
+	BLI_assert(rng_skip_tot > 0);  /* should never be below zero */
+	if (rng_skip_tot > 0) {
 		BLI_rng_skip(thread->rng, rng_skip_tot);
+	}
 }
 
 static void distribute_from_faces_exec(ParticleTask *thread, ParticleData *pa, int p) {
@@ -528,9 +530,11 @@ static void distribute_from_faces_exec(ParticleTask *thread, ParticleData *pa, i
 			break;
 	}
 	pa->foffset= 0.0f;
-	
-	if (rng_skip_tot > 0) /* should never be below zero */
+
+	BLI_assert(rng_skip_tot > 0);  /* should never be below zero */
+	if (rng_skip_tot > 0) {
 		BLI_rng_skip(thread->rng, rng_skip_tot);
+	}
 }
 
 static void distribute_from_volume_exec(ParticleTask *thread, ParticleData *pa, int p) {
@@ -618,13 +622,16 @@ static void distribute_from_volume_exec(ParticleTask *thread, ParticleData *pa,
 				pa->foffset *= ctx->jit[p % (2 * ctx->jitlevel)];
 				break;
 			case PART_DISTR_RAND:
-				pa->foffset *= BLI_frand();
+				pa->foffset *= BLI_rng_get_float(thread->rng);
+				rng_skip_tot--;
 				break;
 		}
 	}
 	
-	if (rng_skip_tot > 0) /* should never be below zero */
+	BLI_assert(rng_skip_tot > 0); /* should never be below zero */
+	if (rng_skip_tot > 0) {
 		BLI_rng_skip(thread->rng, rng_skip_tot);
+	}
 }
 
 static void distribute_children_exec(ParticleTask *thread, ChildParticle *cpa, int p) {



More information about the Bf-blender-cvs mailing list