stop adding groups from changing the active group with weight transfer, add BKE_defgroup_new function.

This commit is contained in:
2013-07-04 03:56:18 +00:00
parent a0cfa3e420
commit 70dc1d8cb6
4 changed files with 21 additions and 15 deletions

View 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);

View File

@@ -51,6 +51,22 @@
#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;

View 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 {

View 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