diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2016-02-08 16:18:45 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2016-02-08 16:19:28 +0300 |
commit | c6afa36f477573b0c074e6667904ff7d54143f19 (patch) | |
tree | 09a43111ad8383ac05daa9fb8292b7655d2b020e /source/blender/editors/object | |
parent | 172143d4f8f570068ad7de6f86a2c184b50cf094 (diff) |
Fix group flipping when syncing mirror weights
Corrects mirror syncing for invert, levels & smooth.
Note that the code changed to process mirroring even if both verts are selected,
since group flipping can mean that is still meaningful.
Diffstat (limited to 'source/blender/editors/object')
-rw-r--r-- | source/blender/editors/object/object_vgroup.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index da1173f363a..cc147464445 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -257,7 +257,6 @@ void ED_vgroup_parray_mirror_sync(Object *ob, BMEditMesh *em = BKE_editmesh_from_object(ob); MDeformVert **dvert_array_all = NULL; int dvert_tot_all; - int i; /* get an array of all verts, not only selected */ if (ED_vgroup_parray_alloc(ob->data, &dvert_array_all, &dvert_tot_all, false) == false) { @@ -268,22 +267,26 @@ void ED_vgroup_parray_mirror_sync(Object *ob, BM_mesh_elem_table_ensure(em->bm, BM_VERT); } - for (i = 0; i < dvert_tot; i++) { - if (dvert_array[i] == NULL) { - /* its unselected, check if its mirror is */ - int i_sel = ED_mesh_mirror_get_vert(ob, i); - if ((i_sel != -1) && (i_sel != i) && (dvert_array[i_sel])) { + int flip_map_len; + const int *flip_map = defgroup_flip_map(ob, &flip_map_len, true); + + for (int i_src = 0; i_src < dvert_tot; i_src++) { + if (dvert_array[i_src] != NULL) { + /* its selected, check if its mirror exists */ + int i_dst = ED_mesh_mirror_get_vert(ob, i_src); + if (i_dst != -1 && dvert_array_all[i_dst] != NULL) { /* we found a match! */ - MDeformVert *dv_src = dvert_array[i_sel]; - MDeformVert *dv_dst = dvert_array_all[i]; + const MDeformVert *dv_src = dvert_array[i_src]; + MDeformVert *dv_dst = dvert_array_all[i_dst]; - defvert_copy_subset(dv_dst, dv_src, vgroup_validmap, vgroup_tot); + defvert_mirror_subset(dv_dst, dv_src, vgroup_validmap, vgroup_tot, flip_map, flip_map_len); - dvert_array[i] = dvert_array_all[i]; + dvert_array[i_dst] = dvert_array_all[i_dst]; } } } + MEM_freeN((void *)flip_map); MEM_freeN(dvert_array_all); } @@ -2123,7 +2126,7 @@ static void dvert_mirror_op(MDeformVert *dvert, MDeformVert *dvert_mirr, defvert_copy(dvert, dvert_mirr); } else { - defvert_copy_index(dvert, dvert_mirr, act_vgroup); + defvert_copy_index(dvert, act_vgroup, dvert_mirr, act_vgroup); } } |