diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2018-10-07 18:25:51 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2020-03-18 11:55:44 +0300 |
commit | 084bf7daee3ebcd57696f5b2a0c83db1b1f3d472 (patch) | |
tree | e5f37d2e47d11a23730d90afb60f7cac633e0f8c /source/blender/draw/intern/draw_cache_extract_mesh.c | |
parent | 82c51d0edbab45f014b4d0b4c0a96c000c46e232 (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/draw/intern/draw_cache_extract_mesh.c')
-rw-r--r-- | source/blender/draw/intern/draw_cache_extract_mesh.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.c b/source/blender/draw/intern/draw_cache_extract_mesh.c index b385facd9aa..274a5492533 100644 --- a/source/blender/draw/intern/draw_cache_extract_mesh.c +++ b/source/blender/draw/intern/draw_cache_extract_mesh.c @@ -2407,12 +2407,13 @@ static float evaluate_vertex_weight(const MDeformVert *dvert, const DRW_MeshWeig float input = 0.0f; if (wstate->flags & DRW_MESH_WEIGHT_STATE_MULTIPAINT) { /* Multi-Paint feature */ - input = BKE_defvert_multipaint_collective_weight( - dvert, - wstate->defgroup_len, - wstate->defgroup_sel, - wstate->defgroup_sel_count, - (wstate->flags & DRW_MESH_WEIGHT_STATE_AUTO_NORMALIZE) != 0); + bool is_normalized = (wstate->flags & (DRW_MESH_WEIGHT_STATE_AUTO_NORMALIZE | + DRW_MESH_WEIGHT_STATE_LOCK_RELATIVE)); + input = BKE_defvert_multipaint_collective_weight(dvert, + wstate->defgroup_len, + wstate->defgroup_sel, + wstate->defgroup_sel_count, + is_normalized); /* make it black if the selected groups have no weight on a vertex */ if (input == 0.0f) { return -1.0f; @@ -2435,6 +2436,13 @@ static float evaluate_vertex_weight(const MDeformVert *dvert, const DRW_MeshWeig } } } + + /* Lock-Relative: display the fraction of current weight vs total unlocked weight. */ + if (wstate->flags & DRW_MESH_WEIGHT_STATE_LOCK_RELATIVE) { + input = BKE_defvert_lock_relative_weight( + input, dvert, wstate->defgroup_len, wstate->defgroup_locked, wstate->defgroup_unlocked); + } + CLAMP(input, 0.0f, 1.0f); return input; } |