[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37080] branches/soc-2011-radish/source/ blender/editors/sculpt_paint/paint_vertex.c: Fixed the redistribute_weight_change() function so that it spreads the change evenly and cannot /0.
Jason Hays
jason_hays22 at mymail.eku.edu
Wed Jun 1 21:21:37 CEST 2011
Revision: 37080
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37080
Author: jason_hays22
Date: 2011-06-01 19:21:36 +0000 (Wed, 01 Jun 2011)
Log Message:
-----------
Fixed the redistribute_weight_change() function so that it spreads the change evenly and cannot /0.
Modified Paths:
--------------
branches/soc-2011-radish/source/blender/editors/sculpt_paint/paint_vertex.c
Modified: branches/soc-2011-radish/source/blender/editors/sculpt_paint/paint_vertex.c
===================================================================
--- branches/soc-2011-radish/source/blender/editors/sculpt_paint/paint_vertex.c 2011-06-01 17:04:32 UTC (rev 37079)
+++ branches/soc-2011-radish/source/blender/editors/sculpt_paint/paint_vertex.c 2011-06-01 19:21:36 UTC (rev 37080)
@@ -1211,6 +1211,8 @@
float change;
char was_a_change;
int groups_left_that_can_change = 0;
+ // make sure there is no case for division by 0, and make the redistribution the same per loop.
+ int groups_currently_left;
char* change_status = MEM_mallocN(defcnt*sizeof(char), "defflags");
MDeformWeight *dw;
//printf("start\n");
@@ -1227,6 +1229,7 @@
}
//printf("\n");
if(groups_left_that_can_change > 0) {
+ groups_currently_left = groups_left_that_can_change;
do {
was_a_change = FALSE;
for(i = 0; i < dvert->totweight; i++) {
@@ -1245,18 +1248,19 @@
change_left += dw->weight-1.0f;
dw->weight = 1.0f;
- groups_left_that_can_change--;
+ groups_currently_left--;
change_status[dw->def_nr] = FALSE;
}else if(dw->weight <= 0.0f) {
change_left += dw->weight;
dw->weight = 0.0f;
- groups_left_that_can_change--;
+ groups_currently_left--;
change_status[dw->def_nr] = FALSE;
}
was_a_change = TRUE;
}
+ groups_left_that_can_change = groups_currently_left;
} while(groups_left_that_can_change > 0 && change_left != 0.0f && was_a_change);
}
// add any remaining change back to the original weight
More information about the Bf-blender-cvs
mailing list