stop adding groups from changing the active group with weight transfer, add BKE_defgr...
authorCampbell Barton <ideasman42@gmail.com>
Thu, 4 Jul 2013 03:56:18 +0000 (03:56 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 4 Jul 2013 03:56:18 +0000 (03:56 +0000)
source/blender/blenkernel/BKE_deform.h
source/blender/blenkernel/intern/deform.c
source/blender/editors/object/object_vgroup.c
source/blender/editors/sculpt_paint/paint_vertex.c

index 07bdbc1009b52fa292fd29806d14a446e5cb5977..a43a243106d85c45751a720b218c42a34a854370 100644 (file)
@@ -40,6 +40,7 @@ struct ListBase;
 struct bDeformGroup;
 struct MDeformVert;
 
+struct bDeformGroup *BKE_defgroup_new(struct Object *ob, const char *name);
 void                 defgroup_copy_list(struct ListBase *lb1, struct ListBase *lb2);
 struct bDeformGroup *defgroup_duplicate(struct bDeformGroup *ingroup);
 struct bDeformGroup *defgroup_find_name(struct Object *ob, const char *name);
index b82e89d1af65f2fb24b2a34d0ed759acba64199a..a492b227815c630297a1f1ca79eb4c98331f1c5f 100644 (file)
 
 #include "BKE_deform.h"  /* own include */
 
+bDeformGroup *BKE_defgroup_new(Object *ob, const char *name)
+{
+       bDeformGroup *defgroup;
+
+       BLI_assert(OB_TYPE_SUPPORT_VGROUP(ob->type));
+
+       defgroup = MEM_callocN(sizeof(bDeformGroup), __func__);
+
+       BLI_strncpy(defgroup->name, name, sizeof(defgroup->name));
+
+       BLI_addtail(&ob->defbase, defgroup);
+       defgroup_unique_name(defgroup, ob);
+
+       return defgroup;
+}
+
 void defgroup_copy_list(ListBase *outbase, ListBase *inbase)
 {
        bDeformGroup *defgroup, *defgroupn;
index da46001bde98ae26d62440f73b1fffaba3335d0c..7e87068a7bbdeeaa1cf6a05e8e49a0b8c070fc5c 100644 (file)
@@ -125,13 +125,8 @@ bDeformGroup *ED_vgroup_add_name(Object *ob, const char *name)
 
        if (!ob || !OB_TYPE_SUPPORT_VGROUP(ob->type))
                return NULL;
-       
-       defgroup = MEM_callocN(sizeof(bDeformGroup), "add deformGroup");
-
-       BLI_strncpy(defgroup->name, name, sizeof(defgroup->name));
 
-       BLI_addtail(&ob->defbase, defgroup);
-       defgroup_unique_name(defgroup, ob);
+       defgroup = BKE_defgroup_new(ob, name);
 
        ob->actdef = BLI_countlist(&ob->defbase);
 
@@ -756,13 +751,10 @@ static bool ed_vgroup_transfer_weight(Object *ob_dst, Object *ob_src, bDeformGro
        const int use_vert_sel = vertex_group_use_vert_sel(ob_dst);
 
        /* Ensure vertex group on target.*/
-       if (!defgroup_find_name(ob_dst, dg_src->name)) {
-               ED_vgroup_add_name(ob_dst, dg_src->name);
+       if ((dg_dst = defgroup_find_name(ob_dst, dg_src->name)) == NULL) {
+               dg_dst = BKE_defgroup_new(ob_dst, dg_src->name);
        }
 
-       /* Get destination deformgroup.*/
-       dg_dst = defgroup_find_name(ob_dst, dg_src->name);
-
        /* Get meshes.*/
        dmesh_src = mesh_get_derived_deform(scene, ob_src, CD_MASK_BAREMESH);
        me_dst = ob_dst->data;
@@ -3811,7 +3803,6 @@ static int vertex_group_transfer_weight_exec(bContext *C, wmOperator *op)
                /* Event notifiers for correct display of data.*/
                DAG_id_tag_update(&ob_act->id, OB_RECALC_DATA);
                WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob_act);
-
                return OPERATOR_FINISHED;
        }
        else {
index 173a76a54e89a163f80a3c251dc987f7258ead18..a891524b5c6f30db1229150005425335d385fe55 100644 (file)
@@ -380,11 +380,9 @@ static int wpaint_mirror_vgroup_ensure(Object *ob, const int vgroup_active)
                flip_side_name(name, defgroup->name, FALSE);
                mirrdef = defgroup_name_index(ob, name);
                if (mirrdef == -1) {
-                       int olddef = ob->actdef;  /* tsk, ED_vgroup_add sets the active defgroup */
-                       if (ED_vgroup_add_name(ob, name)) {
+                       if (BKE_defgroup_new(ob, name)) {
                                mirrdef = BLI_countlist(&ob->defbase) - 1;
                        }
-                       ob->actdef = olddef;
                }
 
                /* curdef should never be NULL unless this is