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/blenkernel/intern/object_deform.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/blenkernel/intern/object_deform.c')
-rw-r--r--source/blender/blenkernel/intern/object_deform.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/object_deform.c b/source/blender/blenkernel/intern/object_deform.c
index 00be25d5210..573573f20ed 100644
--- a/source/blender/blenkernel/intern/object_deform.c
+++ b/source/blender/blenkernel/intern/object_deform.c
@@ -694,6 +694,72 @@ bool *BKE_object_defgroup_selected_get(Object *ob, int defbase_tot, int *r_dg_fl
}
/**
+ * Checks if the lock relative mode is applicable.
+ *
+ * \return true if an unlocked deform group is active.
+ */
+bool BKE_object_defgroup_check_lock_relative(const bool *lock_flags,
+ const bool *validmap,
+ int index)
+{
+ return validmap && validmap[index] && !(lock_flags && lock_flags[index]);
+}
+
+/**
+ * Additional check for whether the lock relative mode is applicable in multipaint mode.
+ *
+ * @return true if none of the selected groups are locked.
+ */
+bool BKE_object_defgroup_check_lock_relative_multi(int defbase_tot,
+ const bool *lock_flags,
+ const bool *selected,
+ int sel_tot)
+{
+ if (lock_flags == NULL) {
+ return true;
+ }
+
+ if (selected == NULL || sel_tot <= 1) {
+ return true;
+ }
+
+ for (int i = 0; i < defbase_tot; i++) {
+ if (selected[i] && lock_flags[i]) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+/**
+ * Takes a pair of boolean masks of all locked and all deform groups, and computes
+ * a pair of masks for locked deform and unlocked deform groups. Output buffers may
+ * reuse the input ones.
+ */
+void BKE_object_defgroup_split_locked_validmap(
+ int defbase_tot, const bool *locked, const bool *deform, bool *r_locked, bool *r_unlocked)
+{
+ if (!locked) {
+ if (r_unlocked != deform) {
+ memcpy(r_unlocked, deform, sizeof(bool) * defbase_tot);
+ }
+ if (r_locked) {
+ memset(r_locked, 0, sizeof(bool) * defbase_tot);
+ }
+ return;
+ }
+
+ for (int i = 0; i < defbase_tot; i++) {
+ bool is_locked = locked[i];
+ bool is_deform = deform[i];
+
+ r_locked[i] = is_deform && is_locked;
+ r_unlocked[i] = is_deform && !is_locked;
+ }
+}
+
+/**
* Marks mirror vgroups in output and counts them.
* Output and counter assumed to be already initialized.
* Designed to be usable after BKE_object_defgroup_selected_get to extend selection to mirror.