diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2016-01-19 18:57:52 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2016-01-20 23:11:56 +0300 |
commit | b88b73816a7b9070ae614f37a5538f7b7a9cddec (patch) | |
tree | d89c2995dfc14bf3ed065810434af01453174243 /source/blender/editors/sculpt_paint | |
parent | 754096e670a87a18cdcbdfeea7abd27bee4592a1 (diff) |
Weight Paint: 'Sample' now supports multi-paint
Since the coloring uses sum or average of the weights of all selected
groups, the weight pick tool should also use that instead of reading
the weight of the single active group that you can't see.
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_vertex.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 140c86a206a..572d19dc55c 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -1014,6 +1014,24 @@ static int weight_sample_invoke(bContext *C, wmOperator *op, const wmEvent *even Brush *brush = BKE_paint_brush(&ts->wpaint->paint); const int vgroup_active = vc.obact->actdef - 1; float vgroup_weight = defvert_find_weight(&me->dvert[v_idx_best], vgroup_active); + + /* use combined weight in multipaint mode, since that's what is displayed to the user in the colors */ + if (ts->multipaint) { + int defbase_tot_sel; + const int defbase_tot = BLI_listbase_count(&vc.obact->defbase); + bool *defbase_sel = BKE_object_defgroup_selected_get(vc.obact, defbase_tot, &defbase_tot_sel); + + if (defbase_tot_sel > 1) { + vgroup_weight = BKE_defvert_multipaint_collective_weight( + &me->dvert[v_idx_best], defbase_tot, defbase_sel, defbase_tot_sel, ts->auto_normalize); + + /* if autonormalize is enabled, but weights are not normalized, the value can exceed 1 */ + CLAMP(vgroup_weight, 0.0f, 1.0f); + } + + MEM_freeN(defbase_sel); + } + BKE_brush_weight_set(vc.scene, brush, vgroup_weight); changed = true; } |