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:
authorNate Rupsis <nrupsis>2022-09-09 08:55:51 +0300
committerCampbell Barton <campbell@blender.org>2022-09-09 08:58:49 +0300
commit43b1624eee17f8e329450d5ac49791e69b1985a2 (patch)
tree62a86af85e51277438b3bcfb4ca5996f904c828c /source/blender/blenkernel
parentfb07bbb751223ddfa25ad326ae31004e5e5b96fb (diff)
Fix T96787: Edit mode normalize fails to respect locked groups
Add BKE_object_defgroup_flip_map_unlocked which excludes locked groups from the flip-map. Reviewed By: zanqdo, campbellbarton Ref D15317
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_deform.h9
-rw-r--r--source/blender/blenkernel/intern/deform.c28
2 files changed, 33 insertions, 4 deletions
diff --git a/source/blender/blenkernel/BKE_deform.h b/source/blender/blenkernel/BKE_deform.h
index f58a5502788..08f7e7f3c96 100644
--- a/source/blender/blenkernel/BKE_deform.h
+++ b/source/blender/blenkernel/BKE_deform.h
@@ -53,6 +53,15 @@ struct bDeformGroup *BKE_object_defgroup_find_name(const struct Object *ob, cons
* \note caller must free.
*/
int *BKE_object_defgroup_flip_map(const struct Object *ob, int *flip_map_len, bool use_default);
+
+/**
+ * Returns flip map for only unlocked defgroups.
+ * \note caller must free.
+ */
+int *BKE_object_defgroup_flip_map_unlocked(const struct Object *ob,
+ int *flip_map_len,
+ bool use_default);
+
/**
* \note caller must free.
*/
diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c
index f928079f3ea..d784dfb020d 100644
--- a/source/blender/blenkernel/intern/deform.c
+++ b/source/blender/blenkernel/intern/deform.c
@@ -572,7 +572,10 @@ void BKE_object_defgroup_active_index_set(Object *ob, const int new_index)
*index = new_index;
}
-int *BKE_object_defgroup_flip_map(const Object *ob, int *flip_map_len, const bool use_default)
+static int *object_defgroup_unlocked_flip_map_ex(const Object *ob,
+ int *flip_map_len,
+ const bool use_default,
+ const bool use_only_unlocked)
{
const ListBase *defbase = BKE_object_defgroup_list(ob);
int defbase_tot = *flip_map_len = BLI_listbase_count(defbase);
@@ -583,9 +586,10 @@ int *BKE_object_defgroup_flip_map(const Object *ob, int *flip_map_len, const boo
bDeformGroup *dg;
char name_flip[sizeof(dg->name)];
- int i, flip_num, *map = MEM_mallocN(defbase_tot * sizeof(int), __func__);
+ int i, flip_num;
+ int *map = MEM_mallocN(defbase_tot * sizeof(int), __func__);
- for (i = 0; i < defbase_tot; i++) {
+ for (int i = 0; i < defbase_tot; i++) {
map[i] = -1;
}
@@ -597,11 +601,15 @@ int *BKE_object_defgroup_flip_map(const Object *ob, int *flip_map_len, const boo
map[i] = i;
}
+ if (use_only_unlocked && (dg->flag & DG_LOCK_WEIGHT)) {
+ continue;
+ }
+
BLI_string_flip_side_name(name_flip, dg->name, false, sizeof(name_flip));
if (!STREQ(name_flip, dg->name)) {
flip_num = BKE_object_defgroup_name_index(ob, name_flip);
- if (flip_num >= 0) {
+ if (flip_num != -1) {
map[i] = flip_num;
map[flip_num] = i; /* save an extra lookup */
}
@@ -611,6 +619,18 @@ int *BKE_object_defgroup_flip_map(const Object *ob, int *flip_map_len, const boo
return map;
}
+int *BKE_object_defgroup_flip_map(const Object *ob, int *flip_map_len, const bool use_default)
+{
+ return object_defgroup_unlocked_flip_map_ex(ob, flip_map_len, use_default, false);
+}
+
+int *BKE_object_defgroup_flip_map_unlocked(const Object *ob,
+ int *flip_map_len,
+ const bool use_default)
+{
+ return object_defgroup_unlocked_flip_map_ex(ob, flip_map_len, use_default, true);
+}
+
int *BKE_object_defgroup_flip_map_single(const Object *ob,
int *flip_map_len,
const bool use_default,