From 80b2fc59d11d5814afe7e219c535525a8d494c17 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Fri, 22 Jul 2022 15:49:53 -0500 Subject: Fix T99873: Use evaluated vertex groups in armature modifier Geometry nodes has added the ability to modify mesh vertex groups during evaluation (see 3b6ee8cee7080af2). However, the armature modifier always uses the vertex groups from the original object. This is wrong for the modifier stack, where each modifier is meant to use the output of the previous. This commit makes the armature modifier use the evaluated vertex groups if they are available. Otherwise it uses the originals like before. Differential Revision: https://developer.blender.org/D15515 --- source/blender/blenkernel/intern/armature_deform.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'source/blender/blenkernel/intern/armature_deform.c') diff --git a/source/blender/blenkernel/intern/armature_deform.c b/source/blender/blenkernel/intern/armature_deform.c index 8532c7d1c15..cc1bfcc087c 100644 --- a/source/blender/blenkernel/intern/armature_deform.c +++ b/source/blender/blenkernel/intern/armature_deform.c @@ -483,14 +483,11 @@ static void armature_deform_coords_impl(const Object *ob_arm, } if (BKE_object_supports_vertex_groups(ob_target)) { - /* get the def_nr for the overall armature vertex group if present */ - armature_def_nr = BKE_object_defgroup_name_index(ob_target, defgrp_name); - - defbase_len = BKE_object_defgroup_count(ob_target); - + const ID *target_data_id = NULL; if (ob_target->type == OB_MESH) { + target_data_id = me_target == NULL ? (const ID *)ob_target->data : &me_target->id; if (em_target == NULL) { - const Mesh *me = ob_target->data; + const Mesh *me = (const Mesh *)target_data_id; dverts = me->dvert; if (dverts) { dverts_len = me->totvert; @@ -499,18 +496,25 @@ static void armature_deform_coords_impl(const Object *ob_arm, } else if (ob_target->type == OB_LATTICE) { const Lattice *lt = ob_target->data; + target_data_id = (const ID *)ob_target->data; dverts = lt->dvert; if (dverts) { dverts_len = lt->pntsu * lt->pntsv * lt->pntsw; } } else if (ob_target->type == OB_GPENCIL) { + target_data_id = (const ID *)ob_target->data; dverts = gps_target->dvert; if (dverts) { dverts_len = gps_target->totpoints; } } + /* Collect the vertex group names from the evaluated data. */ + armature_def_nr = BKE_id_defgroup_name_index(target_data_id, defgrp_name); + const ListBase *defbase = BKE_id_defgroup_list_get(target_data_id); + defbase_len = BLI_listbase_count(defbase); + /* get a vertex-deform-index to posechannel array */ if (deformflag & ARM_DEF_VGROUP) { /* if we have a Mesh, only use dverts if it has them */ @@ -531,7 +535,6 @@ static void armature_deform_coords_impl(const Object *ob_arm, * * - Check whether keeping this consistent across frames gives speedup. */ - const ListBase *defbase = BKE_object_defgroup_list(ob_target); int i; LISTBASE_FOREACH_INDEX (bDeformGroup *, dg, defbase, i) { pchan_from_defbase[i] = BKE_pose_channel_find_name(ob_arm->pose, dg->name); -- cgit v1.2.3