From bad5e93945cba77016becc95eaf3fdc69eeb69ba Mon Sep 17 00:00:00 2001 From: Chia-Hsiang Cheng <88014292+garychia@users.noreply.github.com> Date: Thu, 14 Sep 2023 21:48:04 +0800 Subject: [PATCH] Remove animation tracks with correct indices (cherry picked from commit 3d7facd21c8c80ae6aefe334011c10db88162738) --- editor/scene_tree_dock.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index b366d7c9962..297cfd97c6a 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -1738,6 +1738,8 @@ void SceneTreeDock::perform_node_renames(Node *p_base, HashMap continue; } + int tracks_removed = 0; + for (int i = 0; i < anim->get_track_count(); i++) { NodePath track_np = anim->track_get_path(i); Node *n = root->get_node_or_null(track_np); @@ -1755,14 +1757,8 @@ void SceneTreeDock::perform_node_renames(Node *p_base, HashMap if (found_path->value.is_empty()) { //will be erased - int idx = 0; - HashSet::Iterator EI = ran.begin(); - ERR_FAIL_COND(!EI); //bug - while (*EI != i) { - idx++; - ++EI; - ERR_FAIL_COND(!EI); //another bug - } + int idx = i - tracks_removed; + tracks_removed++; undo_redo->add_do_method(anim.ptr(), "remove_track", idx); undo_redo->add_undo_method(anim.ptr(), "add_track", anim->track_get_type(i), idx);