1
1

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
This commit is contained in:
Nate Rupsis
2022-09-09 15:55:51 +10:00
committed by Campbell Barton
parent fb07bbb751
commit 43b1624eee
3 changed files with 34 additions and 5 deletions

View File

@@ -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.
*/

View File

@@ -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,

View File

@@ -506,7 +506,7 @@ static void mesh_defvert_mirror_update_internal(Object *ob,
if (def_nr == -1) {
/* All vgroups, add groups where needed. */
int flip_map_len;
int *flip_map = BKE_object_defgroup_flip_map(ob, &flip_map_len, true);
int *flip_map = BKE_object_defgroup_flip_map_unlocked(ob, &flip_map_len, true);
BKE_defvert_sync_mapped(dvert_dst, dvert_src, flip_map, flip_map_len, true);
MEM_freeN(flip_map);
}