[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28770] trunk/blender/source/blender/ blenkernel/intern/particle_system.c: fix for hair distrobution changing when rendered with a different number of threads (manifested flickering hair back from renderfarm)

Campbell Barton ideasman42 at gmail.com
Fri May 14 20:09:59 CEST 2010


Revision: 28770
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28770
Author:   campbellbarton
Date:     2010-05-14 20:09:59 +0200 (Fri, 14 May 2010)

Log Message:
-----------
fix for hair distrobution changing when rendered with a different number of threads (manifested flickering hair back from renderfarm)

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/particle_system.c

Modified: trunk/blender/source/blender/blenkernel/intern/particle_system.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/particle_system.c	2010-05-14 16:33:58 UTC (rev 28769)
+++ trunk/blender/source/blender/blenkernel/intern/particle_system.c	2010-05-14 18:09:59 UTC (rev 28770)
@@ -617,6 +617,10 @@
 	return low;
 }
 
+/* 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
+
 /* note: this function must be thread safe, for from == PART_FROM_CHILD */
 #define ONLY_WORKING_WITH_PA_VERTS 0
 static void psys_thread_distribute_particle(ParticleThread *thread, ParticleData *pa, ChildParticle *cpa, int p)
@@ -632,6 +636,7 @@
 	int cfrom= ctx->cfrom;
 	int distr= ctx->distr;
 	int i, intersect, tot;
+	int rng_skip_tot= PSYS_RND_DIST_SKIP; /* count how many rng_* calls wont need skipping */
 
 	if(from == PART_FROM_VERT) {
 		/* TODO_PARTICLE - use original index */
@@ -669,6 +674,8 @@
 		case PART_DISTR_RAND:
 			randu= rng_getFloat(thread->rng);
 			randv= rng_getFloat(thread->rng);
+			rng_skip_tot -= 2;
+
 			psys_uv_to_w(randu, randv, mface->v4, pa->fuv);
 			break;
 		}
@@ -751,6 +758,8 @@
 
 		randu= rng_getFloat(thread->rng);
 		randv= rng_getFloat(thread->rng);
+		rng_skip_tot -= 2;
+
 		psys_uv_to_w(randu, randv, mf->v4, cpa->fuv);
 
 		cpa->num = ctx->index[p];
@@ -859,6 +868,9 @@
 			cpa->parent=cpa->pa[0];
 		}
 	}
+
+	if(rng_skip_tot > 0) /* should never be below zero */
+		rng_skip(thread->rng, rng_skip_tot);
 }
 
 static void *exec_distribution(void *data)
@@ -875,12 +887,12 @@
 
 		for(p=0; p<totpart; p++, cpa++) {
 			if(thread->ctx->skip) /* simplification skip */
-				rng_skip(thread->rng, 5*thread->ctx->skip[p]);
+				rng_skip(thread->rng, PSYS_RND_DIST_SKIP * thread->ctx->skip[p]);
 
 			if((p+thread->num) % thread->tot == 0)
 				psys_thread_distribute_particle(thread, NULL, cpa, p);
 			else /* thread skip */
-				rng_skip(thread->rng, 5);
+				rng_skip(thread->rng, PSYS_RND_DIST_SKIP);
 		}
 	}
 	else {





More information about the Bf-blender-cvs mailing list