[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39915] branches/vgroup_modifiers/source/ blender/modifiers/intern/MOD_weightvgproximity.c: change proximity method since minimum distance of 0.0 wasnt working at all .

Campbell Barton ideasman42 at gmail.com
Mon Sep 5 05:53:27 CEST 2011


Revision: 39915
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39915
Author:   campbellbarton
Date:     2011-09-05 03:53:26 +0000 (Mon, 05 Sep 2011)
Log Message:
-----------
change proximity method since minimum distance of 0.0 wasnt working at all.

Modified Paths:
--------------
    branches/vgroup_modifiers/source/blender/modifiers/intern/MOD_weightvgproximity.c

Modified: branches/vgroup_modifiers/source/blender/modifiers/intern/MOD_weightvgproximity.c
===================================================================
--- branches/vgroup_modifiers/source/blender/modifiers/intern/MOD_weightvgproximity.c	2011-09-05 03:26:49 UTC (rev 39914)
+++ branches/vgroup_modifiers/source/blender/modifiers/intern/MOD_weightvgproximity.c	2011-09-05 03:53:26 UTC (rev 39915)
@@ -205,11 +205,13 @@
  */
 void do_map(float *weights, const int nidx, const float min_d, const float max_d)
 {
-	int i;
-	float b = min_d / (min_d - max_d);
-	float a = -b / min_d;
-	for (i = 0; i < nidx; i++)
-		weights[i] = a * weights[i] + b;
+	const float range_inv= 1.0f / (max_d - min_d); /* invert since multiplication is faster */
+	unsigned int i= nidx;
+	while (i-- > 0) {
+		if     (weights[i] >= max_d) weights[i]= 1.0f; /* most likely case first */
+		else if(weights[i] <= min_d) weights[i]= 0.0f;
+		else                         weights[i]= (weights[i] - min_d) * range_inv;
+	}
 }
 
 /*a min_d + b = 0.0*/




More information about the Bf-blender-cvs mailing list