1
0
mirror of https://github.com/godotengine/godot.git synced 2025-12-31 18:41:20 +00:00

Merge pull request #113789 from Rindbee/Use-ObjectID-for-comparison-in-SceneTreeEditor

Use `ObjectID` in `SceneTreeEditor` to compare the old and new scene roots
This commit is contained in:
Rémi Verschelde
2025-12-09 17:18:07 +01:00
2 changed files with 13 additions and 13 deletions

View File

@@ -322,8 +322,8 @@ void SceneTreeEditor::_update_node_subtree(Node *p_node, TreeItem *p_parent, boo
item = tree->get_root(); item = tree->get_root();
if (!item) { if (!item) {
item = tree->create_item(nullptr); item = tree->create_item(nullptr);
index = 0;
} }
index = 0;
} else { } else {
index = p_node->get_index(false); index = p_node->get_index(false);
item = tree->create_item(p_parent, index); item = tree->create_item(p_parent, index);
@@ -926,19 +926,19 @@ void SceneTreeEditor::_update_tree(bool p_scroll_to_selected) {
return; return;
} }
Node *scene_node = get_scene_node();
if (node_cache.current_scene_node != scene_node) {
_reset();
marked.clear();
node_cache.current_scene_node = scene_node;
node_cache.force_update = true;
}
if (!update_when_invisible && !is_visible_in_tree()) { if (!update_when_invisible && !is_visible_in_tree()) {
return; return;
} }
Node *scene_node = get_scene_node();
const ObjectID scene_id = scene_node ? scene_node->get_instance_id() : ObjectID();
if (node_cache.current_scene_id != scene_id) {
_reset();
marked.clear();
node_cache.current_scene_id = scene_id;
node_cache.force_update = true;
}
if (tree->is_editing()) { if (tree->is_editing()) {
return; return;
} }
@@ -947,7 +947,7 @@ void SceneTreeEditor::_update_tree(bool p_scroll_to_selected) {
last_hash = hash_djb2_one_64(0); last_hash = hash_djb2_one_64(0);
if (node_cache.current_scene_node) { if (node_cache.current_scene_id.is_valid()) {
// Handle pinning/unpinning the animation player only do this once per iteration. // Handle pinning/unpinning the animation player only do this once per iteration.
Node *pinned_node = AnimationPlayerEditor::get_singleton()->get_editing_node(); Node *pinned_node = AnimationPlayerEditor::get_singleton()->get_editing_node();
// If pinned state changed, update the currently pinned node. // If pinned state changed, update the currently pinned node.
@@ -2481,7 +2481,7 @@ void SceneTreeEditor::NodeCache::remove(Node *p_node, bool p_recursive) {
} }
} }
if (current_scene_node != p_node) { if (current_scene_id != p_node->get_instance_id()) {
// Do not remove from the Tree control here. See delete_pending below. // Do not remove from the Tree control here. See delete_pending below.
I->value.item->deselect(0); I->value.item->deselect(0);
I->value.delete_serial = delete_serial; I->value.delete_serial = delete_serial;

View File

@@ -100,7 +100,7 @@ class SceneTreeEditor : public Control {
SceneTreeEditor *editor; SceneTreeEditor *editor;
HashMap<Node *, CachedNode> cache; HashMap<Node *, CachedNode> cache;
HashSet<CachedNode *> to_delete; HashSet<CachedNode *> to_delete;
Node *current_scene_node = nullptr; ObjectID current_scene_id;
Node *current_pinned_node = nullptr; Node *current_pinned_node = nullptr;
bool current_has_pin = false; bool current_has_pin = false;
bool force_update = false; bool force_update = false;