[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28740] branches/render25/source/blender: Three optimizations for hair sim effectors:

Brecht Van Lommel brecht at blender.org
Wed May 12 21:31:06 CEST 2010


Revision: 28740
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28740
Author:   blendix
Date:     2010-05-12 21:31:06 +0200 (Wed, 12 May 2010)

Log Message:
-----------
Three optimizations for hair sim effectors:

* Multithread calculating effector forces on vertices.
* Avoid unnecessary where_is_object_time call.
* Avoid perlin noise macro that might expand into slow code.

If only we were actually using effectors more, then this might have
been a significant optimization :).

Modified Paths:
--------------
    branches/render25/source/blender/blenkernel/intern/effect.c
    branches/render25/source/blender/blenkernel/intern/implicit.c
    branches/render25/source/blender/blenlib/intern/noise.c

Modified: branches/render25/source/blender/blenkernel/intern/effect.c
===================================================================
--- branches/render25/source/blender/blenkernel/intern/effect.c	2010-05-12 18:51:36 UTC (rev 28739)
+++ branches/render25/source/blender/blenkernel/intern/effect.c	2010-05-12 19:31:06 UTC (rev 28740)
@@ -659,12 +659,7 @@
 	else {
 		/* use center of object for distance calculus */
 		Object *ob = eff->ob;
-		Object obcopy = *ob;
 
-		/* XXX this is not thread-safe, but used from multiple threads by
-		   particle system */
-		where_is_object_time(eff->scene, ob, cfra);
-
 		/* use z-axis as normal*/
 		VECCOPY(efd->nor, ob->obmat[2]);
 		normalize_v3(efd->nor);
@@ -682,15 +677,19 @@
 		}
 
 		if(real_velocity) {
+			Object obcopy = *ob;
+
 			VECCOPY(efd->vel, ob->obmat[3]);
 
+			/* XXX this is not thread-safe, but used from multiple threads by
+			   particle system */
 			where_is_object_time(eff->scene, ob, cfra - 1.0);
 
 			sub_v3_v3v3(efd->vel, efd->vel, ob->obmat[3]);
+
+			*ob = obcopy;
 		}
 
-		*eff->ob = obcopy;
-
 		efd->size = 0.0f;
 
 		ret = 1;

Modified: branches/render25/source/blender/blenkernel/intern/implicit.c
===================================================================
--- branches/render25/source/blender/blenkernel/intern/implicit.c	2010-05-12 18:51:36 UTC (rev 28739)
+++ branches/render25/source/blender/blenkernel/intern/implicit.c	2010-05-12 19:31:06 UTC (rev 28740)
@@ -1597,6 +1597,7 @@
 			printf("winvec: out of memory in implicit.c\n");
 		
 		// precalculate wind forces
+		#pragma omp parallel for private(i)
 		for(i = 0; i < cloth->numverts; i++)
 		{	
 			pd_point_from_loc(clmd->scene, (float*)lX[i], (float*)lV[i], i, &epoint);

Modified: branches/render25/source/blender/blenlib/intern/noise.c
===================================================================
--- branches/render25/source/blender/blenlib/intern/noise.c	2010-05-12 18:51:36 UTC (rev 28739)
+++ branches/render25/source/blender/blenlib/intern/noise.c	2010-05-12 19:31:06 UTC (rev 28740)
@@ -199,9 +199,16 @@
 /*  IMPROVED PERLIN NOISE */
 /**************************/
 
-#define lerp(t, a, b) ((a)+(t)*((b)-(a)))
-#define npfade(t) ((t)*(t)*(t)*((t)*((t)*6-15)+10))
+static float lerp(float t, float a, float b)
+{
+	return (a+t*(b-a));
+}
 
+static float npfade(float t)
+{
+	return (t*t*t*(t*(t*6.0f-15.0f)+10.0f));
+}
+
 static float grad(int hash, float x, float y, float z)
 {
 	int h = hash & 15;                     // CONVERT LO 4 BITS OF HASH CODE





More information about the Bf-blender-cvs mailing list