Fix T48387: Mirror weights keeps groups assigned
authorCampbell Barton <ideasman42@gmail.com>
Tue, 10 May 2016 15:32:26 +0000 (01:32 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 10 May 2016 16:47:38 +0000 (02:47 +1000)
Swapping the weights kept zero weight verts assigned.

source/blender/editors/object/object_vgroup.c

index bf626aa1af9c67b158f564a9ea12cc43ef1623bd..414cc476be57350768f6f1000c1b1f3a772fa160 100644 (file)
@@ -2096,14 +2096,19 @@ static void dvert_mirror_op(MDeformVert *dvert, MDeformVert *dvert_mirr,
                                MDeformWeight *dw =      defvert_find_index(dvert, act_vgroup);
                                MDeformWeight *dw_mirr = defvert_find_index(dvert_mirr, act_vgroup);
 
-                               if (dw || dw_mirr) {
-                                       if (dw_mirr == NULL)
-                                               dw_mirr = defvert_verify_index(dvert_mirr, act_vgroup);
-                                       if (dw == NULL)
-                                               dw = defvert_verify_index(dvert, act_vgroup);
-
+                               if (dw && dw_mirr) {
                                        SWAP(float, dw->weight, dw_mirr->weight);
                                }
+                               else if (dw) {
+                                       dw_mirr = defvert_verify_index(dvert_mirr, act_vgroup);
+                                       dw_mirr->weight = dw->weight;
+                                       defvert_remove_group(dvert, dw);
+                               }
+                               else if (dw_mirr) {
+                                       dw = defvert_verify_index(dvert, act_vgroup);
+                                       dw->weight = dw_mirr->weight;
+                                       defvert_remove_group(dvert_mirr, dw_mirr);
+                               }
                        }
                }