Fix T104089: Removing greasepencil vertex group can leave no active
We should always have an active vertexgroup (making sure this is the case was just not happening on the greasepencil side). Now do this (similar to what is done for other object types in `object_defgroup_remove_common`). Maniphest Tasks: T104089 Differential Revision: https://developer.blender.org/D17091
This commit is contained in:
@@ -1861,6 +1861,18 @@ void BKE_gpencil_vgroup_remove(Object *ob, bDeformGroup *defgroup)
|
||||
|
||||
/* Remove the group */
|
||||
BLI_freelinkN(&gpd->vertex_group_names, defgroup);
|
||||
|
||||
/* Update the active deform index if necessary. */
|
||||
const int active_index = BKE_object_defgroup_active_index_get(ob);
|
||||
if (active_index > def_nr) {
|
||||
BKE_object_defgroup_active_index_set(ob, active_index - 1);
|
||||
}
|
||||
/* Keep a valid active index if we still have some vertex groups. */
|
||||
if (!BLI_listbase_is_empty(&gpd->vertex_group_names) &&
|
||||
BKE_object_defgroup_active_index_get(ob) < 1) {
|
||||
BKE_object_defgroup_active_index_set(ob, 1);
|
||||
}
|
||||
|
||||
DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user