diff options
-rw-r--r-- | source/blender/blenkernel/BKE_deform.h | 9 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/deform.c | 28 | ||||
-rw-r--r-- | source/blender/editors/object/object_vgroup.cc | 2 |
3 files changed, 34 insertions, 5 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, diff --git a/source/blender/editors/object/object_vgroup.cc b/source/blender/editors/object/object_vgroup.cc index d2cb7ad4b43..c9f96166e31 100644 --- a/source/blender/editors/object/object_vgroup.cc +++ b/source/blender/editors/object/object_vgroup.cc @@ -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); } |