From 784ff4abc01c72a88f73d8113b7ae8e655f6fb48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Mon, 22 Jan 2024 13:27:41 +0100 Subject: [PATCH] Anim: armature edit mode undo now also handles bone collection root count Armature Edit mode has its own undo handling, which didn't store the number of root bone collections in the armature. Now it does. An alternative would be to not store this in the undo step, but rather loop over all bone collections to find the minimum `child_index`. This would be linear in the number of bone collections, though, so I chose to use a few more bytes of memory to make the undo system a little faster. --- source/blender/editors/armature/editarmature_undo.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blender/editors/armature/editarmature_undo.cc b/source/blender/editors/armature/editarmature_undo.cc index 9dec2b6ce4f..d349fdaf224 100644 --- a/source/blender/editors/armature/editarmature_undo.cc +++ b/source/blender/editors/armature/editarmature_undo.cc @@ -75,6 +75,7 @@ struct UndoArmature { ListBase /* EditBone */ ebones; BoneCollection **collection_array; int collection_array_num; + int collection_root_count; size_t undo_size; }; @@ -103,6 +104,7 @@ static void undoarm_to_editarm(UndoArmature *uarm, bArmature *arm) uarm->collection_array, uarm->collection_array_num, true); + arm->collection_root_count = uarm->collection_root_count; /* Always do a lookup-by-name and assignment. Even when the name of the active collection is * still the same, the order may have changed and thus the index needs to be updated. */ @@ -137,6 +139,7 @@ static void *undoarm_from_editarm(UndoArmature *uarm, bArmature *arm) arm->collection_array_num, false); STRNCPY(uarm->active_collection_name, arm->active_collection_name); + uarm->collection_root_count = arm->collection_root_count; /* Point the new edit bones at the new collections. */ remap_ebone_bone_collection_references(&uarm->ebones, bcoll_map);