fix [#33889] Unexpected weights after parenting with Empty Groups
out of range dvert's are now cleared before adding new-empty groups.
This commit is contained in:
@@ -4997,6 +4997,10 @@ void create_vgroups_from_armature(ReportList *reports, Scene *scene, Object *ob,
|
||||
bArmature *arm = par->data;
|
||||
|
||||
if (mode == ARM_GROUPS_NAME) {
|
||||
/* its possible there are DWeight's outside the range of the current
|
||||
* objects deform groups, in this case the new groups wont be empty [#33889] */
|
||||
ED_vgroup_data_clamp_range(ob->data, BLI_countlist(&ob->defbase));
|
||||
|
||||
/* Traverse the bone list, trying to create empty vertex
|
||||
* groups corresponding to the bone.
|
||||
*/
|
||||
|
||||
@@ -227,6 +227,7 @@ void ED_vgroup_delete(struct Object *ob, struct bDeformGroup *de
|
||||
void ED_vgroup_clear(struct Object *ob);
|
||||
void ED_vgroup_select_by_name(struct Object *ob, const char *name);
|
||||
int ED_vgroup_data_create(struct ID *id);
|
||||
void ED_vgroup_data_clamp_range(struct ID *id, const int total);
|
||||
int ED_vgroup_give_array(struct ID *id, struct MDeformVert **dvert_arr, int *dvert_tot);
|
||||
int ED_vgroup_copy_array(struct Object *ob, struct Object *ob_from);
|
||||
void ED_vgroup_mirror(struct Object *ob, const short mirror_weights, const short flip_vgroups, const short all_vgroups);
|
||||
|
||||
@@ -82,6 +82,7 @@ static void vgroup_remap_update_users(Object *ob, int *map);
|
||||
static void vgroup_delete_edit_mode(Object *ob, bDeformGroup *defgroup);
|
||||
static void vgroup_delete_object_mode(Object *ob, bDeformGroup *dg);
|
||||
static void vgroup_delete_all(Object *ob);
|
||||
static int ED_vgroup_give_parray(ID *id, MDeformVert ***dvert_arr, int *dvert_tot, const short use_vert_sel);
|
||||
|
||||
static int vertex_group_use_vert_sel(Object *ob)
|
||||
{
|
||||
@@ -183,6 +184,29 @@ int ED_vgroup_data_create(ID *id)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes out of range MDeformWeights
|
||||
*/
|
||||
void ED_vgroup_data_clamp_range(ID *id, const int total)
|
||||
{
|
||||
MDeformVert **dvert_arr;
|
||||
int dvert_tot;
|
||||
|
||||
if (ED_vgroup_give_parray(id, &dvert_arr, &dvert_tot, false)) {
|
||||
int i;
|
||||
for (i = 0; i < dvert_tot; i++) {
|
||||
MDeformVert *dv = dvert_arr[i];
|
||||
int j;
|
||||
for (j = 0; j < dv->totweight; j++) {
|
||||
if (dv->dw[j].def_nr >= total) {
|
||||
defvert_remove_group(dv, &dv->dw[j]);
|
||||
j--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int ED_vgroup_give_parray(ID *id, MDeformVert ***dvert_arr, int *dvert_tot, const short use_vert_sel)
|
||||
{
|
||||
*dvert_tot = 0;
|
||||
|
||||
Reference in New Issue
Block a user