Add unique Node IDs to support base and instantiated scene refactorings

The main goal of this PR is to safeguard when a base or instantiated scene changes (nodes renamed, moved or readded),
that the hierarchy is still maintained and the node and its overridden properties can be preserved.

What it does:
* Implements unique node IDs.
* These IDs act as a fallback to names when saving.
* The IDs are **USED AS A FALLBACK**, so they are just an addition. It should not break any current existing scene.
* If a scene renames or moves a node, inherited or instantiated scenes will no longer lose reference to it.

Unlike the previous approach, this one is intended to be a fallback, only used if the node is not found.
This makes it safer to implement and ensure that, at worst case, we fail to find the node, but nothing breaks.
This commit is contained in:
Juan
2025-05-26 20:01:34 +02:00
committed by Rémi Verschelde
parent 60b7b8b16e
commit faddd60c40
6 changed files with 370 additions and 28 deletions

View File

@ -2082,6 +2082,14 @@ Node *Node::find_parent(const String &p_pattern) const {
return nullptr;
}
void Node::set_unique_scene_id(int32_t p_unique_id) {
data.unique_scene_id = p_unique_id;
}
int32_t Node::get_unique_scene_id() const {
return data.unique_scene_id;
}
Window *Node::get_window() const {
ERR_THREAD_GUARD_V(nullptr);
Viewport *vp = get_viewport();