stop adding groups from changing the active group with weight transfer, add BKE_defgroup_new function.
This commit is contained in:
@@ -40,6 +40,7 @@ struct ListBase;
|
|||||||
struct bDeformGroup;
|
struct bDeformGroup;
|
||||||
struct MDeformVert;
|
struct MDeformVert;
|
||||||
|
|
||||||
|
struct bDeformGroup *BKE_defgroup_new(struct Object *ob, const char *name);
|
||||||
void defgroup_copy_list(struct ListBase *lb1, struct ListBase *lb2);
|
void defgroup_copy_list(struct ListBase *lb1, struct ListBase *lb2);
|
||||||
struct bDeformGroup *defgroup_duplicate(struct bDeformGroup *ingroup);
|
struct bDeformGroup *defgroup_duplicate(struct bDeformGroup *ingroup);
|
||||||
struct bDeformGroup *defgroup_find_name(struct Object *ob, const char *name);
|
struct bDeformGroup *defgroup_find_name(struct Object *ob, const char *name);
|
||||||
|
@@ -51,6 +51,22 @@
|
|||||||
|
|
||||||
#include "BKE_deform.h" /* own include */
|
#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)
|
void defgroup_copy_list(ListBase *outbase, ListBase *inbase)
|
||||||
{
|
{
|
||||||
bDeformGroup *defgroup, *defgroupn;
|
bDeformGroup *defgroup, *defgroupn;
|
||||||
|
@@ -125,13 +125,8 @@ bDeformGroup *ED_vgroup_add_name(Object *ob, const char *name)
|
|||||||
|
|
||||||
if (!ob || !OB_TYPE_SUPPORT_VGROUP(ob->type))
|
if (!ob || !OB_TYPE_SUPPORT_VGROUP(ob->type))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
defgroup = MEM_callocN(sizeof(bDeformGroup), "add deformGroup");
|
|
||||||
|
|
||||||
BLI_strncpy(defgroup->name, name, sizeof(defgroup->name));
|
defgroup = BKE_defgroup_new(ob, name);
|
||||||
|
|
||||||
BLI_addtail(&ob->defbase, defgroup);
|
|
||||||
defgroup_unique_name(defgroup, ob);
|
|
||||||
|
|
||||||
ob->actdef = BLI_countlist(&ob->defbase);
|
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);
|
const int use_vert_sel = vertex_group_use_vert_sel(ob_dst);
|
||||||
|
|
||||||
/* Ensure vertex group on target.*/
|
/* Ensure vertex group on target.*/
|
||||||
if (!defgroup_find_name(ob_dst, dg_src->name)) {
|
if ((dg_dst = defgroup_find_name(ob_dst, dg_src->name)) == NULL) {
|
||||||
ED_vgroup_add_name(ob_dst, dg_src->name);
|
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.*/
|
/* Get meshes.*/
|
||||||
dmesh_src = mesh_get_derived_deform(scene, ob_src, CD_MASK_BAREMESH);
|
dmesh_src = mesh_get_derived_deform(scene, ob_src, CD_MASK_BAREMESH);
|
||||||
me_dst = ob_dst->data;
|
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.*/
|
/* Event notifiers for correct display of data.*/
|
||||||
DAG_id_tag_update(&ob_act->id, OB_RECALC_DATA);
|
DAG_id_tag_update(&ob_act->id, OB_RECALC_DATA);
|
||||||
WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob_act);
|
WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob_act);
|
||||||
|
|
||||||
return OPERATOR_FINISHED;
|
return OPERATOR_FINISHED;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@@ -380,11 +380,9 @@ static int wpaint_mirror_vgroup_ensure(Object *ob, const int vgroup_active)
|
|||||||
flip_side_name(name, defgroup->name, FALSE);
|
flip_side_name(name, defgroup->name, FALSE);
|
||||||
mirrdef = defgroup_name_index(ob, name);
|
mirrdef = defgroup_name_index(ob, name);
|
||||||
if (mirrdef == -1) {
|
if (mirrdef == -1) {
|
||||||
int olddef = ob->actdef; /* tsk, ED_vgroup_add sets the active defgroup */
|
if (BKE_defgroup_new(ob, name)) {
|
||||||
if (ED_vgroup_add_name(ob, name)) {
|
|
||||||
mirrdef = BLI_countlist(&ob->defbase) - 1;
|
mirrdef = BLI_countlist(&ob->defbase) - 1;
|
||||||
}
|
}
|
||||||
ob->actdef = olddef;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* curdef should never be NULL unless this is
|
/* curdef should never be NULL unless this is
|
||||||
|
Reference in New Issue
Block a user