Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorJason Hays <jason_hays22@mymail.eku.edu>2011-11-10 06:09:58 +0400
committerJason Hays <jason_hays22@mymail.eku.edu>2011-11-10 06:09:58 +0400
commit08cc1c6bb96084bcd9e70b19edf9048fffe1fd3d (patch)
tree5374fce021ec9884c3f5192094cec935f6949a10 /source
parentce15c0c943cb2ebf998ea77b15973a5118435be4 (diff)
While reviewing this part of the code for a Blender Proceedings article, I noticed that the lock enforcer was taking several improper steps to redistribute evenly with multi-paint.
Beforehand, a few problems were in view: some of the indexing was changed towards the end to use the more efficient stack structure, but needed to use the correct def group indices. Also, the designated selected group would use its own value to acquire the standard to base change distributed to the others. Lastly, the total_change was used rather than -left_overs in the formula to compute the new designated weight within the means of the locks' allowed changes. Now, while maintaining the ratios of the selection, it correctly returns left over change that could not be redistributed to the unlocked groups.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 57f926b0612..e55438a30b8 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -1342,16 +1342,16 @@ static void enforce_locks(MDeformVert *odv, MDeformVert *ndv, int defbase_tot,
if(vgroup_validmap && total_changed < 0 && total_valid) {
totchange_allowed = total_valid;
}
+ /* the way you modify the unlocked+unchanged groups is different depending
+ * on whether or not you are painting the weight(s) up or down */
+ if(totchange < 0) {
+ totchange_allowed = total_valid - totchange_allowed;
+ }
+ else {
+ totchange_allowed *= -1;
+ }
/* there needs to be change allowed, or you should not bother */
if(totchange_allowed) {
- /* the way you modify the unlocked+unchanged groups is different depending
- * on whether or not you are painting the weight(s) up or down */
- if(totchange < 0) {
- totchange_allowed = total_valid - totchange_allowed;
- }
- else {
- totchange_allowed *= -1;
- }
left_over = 0;
if(fabsf(totchange_allowed) < fabsf(totchange)) {
/* this amount goes back onto the changed, unlocked weights */
@@ -1375,11 +1375,15 @@ static void enforce_locks(MDeformVert *odv, MDeformVert *ndv, int defbase_tot,
odw = defvert_find_index(odv, designatedw);
storedw = ndw->weight;
for(i = 0; i < ndv->totweight; i++) {
- if(change_status[ndw->def_nr] == 2) {
+ if(ndv->dw[i].def_nr == designatedw) {
+ continue;
+ }
+ ndw2 = &ndv->dw[i];
+ if(change_status[ndw2->def_nr] == 2) {
odw2 = &odv->dw[i];
- ndw2 = &ndv->dw[i];
+
if(!designatedw_changed) {
- ndw->weight = (totchange_allowed + odw->weight + odw2->weight)/(1.0f + ndw2->weight/ndw->weight);
+ ndw->weight = (-left_over + odw->weight + odw2->weight)/(1.0f + ndw2->weight/ndw->weight);
designatedw_changed = TRUE;
}
ndw2->weight = ndw->weight * ndw2->weight / storedw;