[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43341] trunk/blender/source/blender/ editors/sculpt_paint/paint_vertex.c: another minor weightpaint change, dont pass do_auto_normalize as a bool arg to do_weight_paint_normalize_all (), just check before calling.

Campbell Barton ideasman42 at gmail.com
Fri Jan 13 03:25:17 CET 2012


Revision: 43341
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43341
Author:   campbellbarton
Date:     2012-01-13 02:25:15 +0000 (Fri, 13 Jan 2012)
Log Message:
-----------
another minor weightpaint change, dont pass do_auto_normalize as a bool arg to do_weight_paint_normalize_all(), just check before calling.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c	2012-01-13 02:17:29 UTC (rev 43340)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c	2012-01-13 02:25:15 UTC (rev 43341)
@@ -1062,76 +1062,32 @@
 	ot->prop= prop;
 }
 
-
-#if 0 /* UNUSED */
-static void do_weight_paint_auto_normalize(MDeformVert *dvert, 
-					   int paint_nr, char *map)
+/* the active group should be involved in auto normalize */
+static void do_weight_paint_normalize_all(MDeformVert *dvert, const int defbase_tot, const char *vgroup_validmap)
 {
-//	MDeformWeight *dw = dvert->dw;
-	float sum=0.0f, fac=0.0f, paintw=0.0f;
-	int i, tot=0;
+	float sum= 0.0f, fac;
+	unsigned int i, tot=0;
+	MDeformWeight *dw;
 
-	if (!map)
-		return;
-
-	for (i=0; i<dvert->totweight; i++) {
-		if (dvert->dw[i].def_nr == paint_nr)
-			paintw = dvert->dw[i].weight;
-
-		if (map[dvert->dw[i].def_nr]) {
-			tot += 1;
-			if (dvert->dw[i].def_nr != paint_nr)
-				sum += dvert->dw[i].weight;
+	for (i= dvert->totweight, dw= dvert->dw; i != 0; i--, dw++) {
+		if (dw->def_nr < defbase_tot) {
+			if (vgroup_validmap[dw->def_nr]) {
+				tot++;
+				sum += dw->weight;
+			}
 		}
 	}
-	
-	if (!tot || sum <= (1.0f - paintw))
-		return;
 
-	fac = sum / (1.0f - paintw);
-	fac = fac==0.0f ? 1.0f : 1.0f / fac;
-
-	for (i=0; i<dvert->totweight; i++) {
-		if (map[dvert->dw[i].def_nr]) {
-			if (dvert->dw[i].def_nr != paint_nr)
-				dvert->dw[i].weight *= fac;
-		}
-	}
-}
-#endif
-
-/* the active group should be involved in auto normalize */
-static void do_weight_paint_auto_normalize_all_groups(MDeformVert *dvert, const int defbase_tot,
-                                                      const char *vgroup_validmap, char do_auto_normalize)
-{
-	if (do_auto_normalize == FALSE) {
+	if ((tot == 0) || (sum == 1.0f) || (sum == 0.0f)) {
 		return;
 	}
-	else {
-		float sum= 0.0f, fac;
-		unsigned int i, tot=0;
-		MDeformWeight *dw;
 
-		for (i= dvert->totweight, dw= dvert->dw; i != 0; i--, dw++) {
-			if (dw->def_nr < defbase_tot) {
-				if (vgroup_validmap[dw->def_nr]) {
-					tot++;
-					sum += dw->weight;
-				}
-			}
-		}
+	fac= 1.0f / sum;
 
-		if ((tot == 0) || (sum == 1.0f) || (sum == 0.0f)) {
-			return;
-		}
-
-		fac= 1.0f / sum;
-
-		for (i= dvert->totweight, dw= dvert->dw; i != 0; i--, dw++) {
-			if (dw->def_nr < defbase_tot) {
-				if (vgroup_validmap[dw->def_nr]) {
-					dw->weight *= fac;
-				}
+	for (i= dvert->totweight, dw= dvert->dw; i != 0; i--, dw++) {
+		if (dw->def_nr < defbase_tot) {
+			if (vgroup_validmap[dw->def_nr]) {
+				dw->weight *= fac;
 			}
 		}
 	}
@@ -1526,7 +1482,9 @@
 
 	enforce_locks(&dv_test, dv, wpi->defbase_tot, wpi->defbase_sel, wpi->lock_flags, wpi->vgroup_validmap, wpi->do_auto_normalize, wpi->do_multipaint);
 
-	do_weight_paint_auto_normalize_all_groups(dv, wpi->defbase_tot, wpi->vgroup_validmap, wpi->do_auto_normalize);
+	if (wpi->do_auto_normalize) {
+		do_weight_paint_normalize_all(dv, wpi->defbase_tot, wpi->vgroup_validmap);
+	}
 
 	if(oldChange && wpi->do_multipaint && wpi->defbase_tot_sel > 1) {
 		if(tdw->weight != oldw) {
@@ -1629,7 +1587,9 @@
 		 * which has already been scaled down in relation to other weights,
 		 * then scales a second time [#26193]. Tricky multi-paint code doesn't
 		 * suffer from this problem - campbell */
-		do_weight_paint_auto_normalize_all_groups(dv, wpi->defbase_tot, wpi->vgroup_validmap, wpi->do_auto_normalize);
+		if (wpi->do_auto_normalize) {
+			do_weight_paint_normalize_all(dv, wpi->defbase_tot, wpi->vgroup_validmap);
+		}
 	}
 	else {
 		/* use locks and/or multipaint */



More information about the Bf-blender-cvs mailing list