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
diff options
context:
space:
mode:
authorAlexander Gavrilov <angavrilov@gmail.com>2018-10-07 18:25:51 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2020-03-18 11:55:44 +0300
commit084bf7daee3ebcd57696f5b2a0c83db1b1f3d472 (patch)
treee5f37d2e47d11a23730d90afb60f7cac633e0f8c /source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
parent82c51d0edbab45f014b4d0b4c0a96c000c46e232 (diff)
Weight Paint: Implement a new Lock-Relative mode.
This check box alters how weights are displayed and painted, similar to Multi Paint, but in a different way. Specifically, weights are presented as if all locked vertex groups were deleted, and the remaining deform groups normalized. The new feature is intended for use when balancing weights within a group of bones while all others are locked. Enabling the option presents weight as if the locked bones didn't exist, and their weight was proportionally redistributed to the editable bones. Conversely, the Multi-Paint feature allows balancing a group of bones as a whole against all unselected bones, while ignoring weight distribution within the selected group. This mode also allows temporarily viewing non-normalized weights as if they were normalized, without actually changing the values. Differential Revision: https://developer.blender.org/D3837
Diffstat (limited to 'source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c')
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c38
1 files changed, 29 insertions, 9 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
index 4b8990c1b5d..5c408933559 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
@@ -212,12 +212,22 @@ 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 = BKE_defvert_find_weight(&me->dvert[v_idx_best], vgroup_active);
+ const int defbase_tot = BLI_listbase_count(&vc.obact->defbase);
+ bool use_lock_relative = ts->wpaint_lock_relative;
+ bool *defbase_locked = NULL, *defbase_unlocked = NULL;
+
+ if (use_lock_relative) {
+ defbase_locked = BKE_object_defgroup_lock_flags_get(vc.obact, defbase_tot);
+ defbase_unlocked = BKE_object_defgroup_validmap_get(vc.obact, defbase_tot);
+
+ use_lock_relative = BKE_object_defgroup_check_lock_relative(
+ defbase_locked, defbase_unlocked, 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);
@@ -227,20 +237,30 @@ static int weight_sample_invoke(bContext *C, wmOperator *op, const wmEvent *even
vc.obact, defbase_tot, defbase_sel, defbase_sel, &defbase_tot_sel);
}
- vgroup_weight = BKE_defvert_multipaint_collective_weight(&me->dvert[v_idx_best],
- defbase_tot,
- defbase_sel,
- defbase_tot_sel,
- ts->auto_normalize);
+ use_lock_relative = use_lock_relative &&
+ BKE_object_defgroup_check_lock_relative_multi(
+ defbase_tot, defbase_locked, defbase_sel, defbase_tot_sel);
- /* If auto-normalize is enabled, but weights are not normalized,
- * the value can exceed 1. */
- CLAMP(vgroup_weight, 0.0f, 1.0f);
+ bool is_normalized = ts->auto_normalize || use_lock_relative;
+ vgroup_weight = BKE_defvert_multipaint_collective_weight(
+ &me->dvert[v_idx_best], defbase_tot, defbase_sel, defbase_tot_sel, is_normalized);
}
MEM_freeN(defbase_sel);
}
+ if (use_lock_relative) {
+ BKE_object_defgroup_split_locked_validmap(
+ defbase_tot, defbase_locked, defbase_unlocked, defbase_locked, defbase_unlocked);
+
+ vgroup_weight = BKE_defvert_lock_relative_weight(
+ vgroup_weight, &me->dvert[v_idx_best], defbase_tot, defbase_locked, defbase_unlocked);
+ }
+
+ MEM_SAFE_FREE(defbase_locked);
+ MEM_SAFE_FREE(defbase_unlocked);
+
+ CLAMP(vgroup_weight, 0.0f, 1.0f);
BKE_brush_weight_set(vc.scene, brush, vgroup_weight);
changed = true;
}