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:
@ -132,6 +132,9 @@ public:
|
||||
#ifdef DEBUG_ENABLED
|
||||
static SafeNumeric<uint64_t> total_node_count;
|
||||
#endif
|
||||
enum {
|
||||
UNIQUE_SCENE_ID_UNASSIGNED = 0
|
||||
};
|
||||
|
||||
void _update_process(bool p_enable, bool p_for_children);
|
||||
|
||||
@ -281,6 +284,8 @@ private:
|
||||
mutable bool is_translation_domain_inherited : 1;
|
||||
mutable bool is_translation_domain_dirty : 1;
|
||||
|
||||
int32_t unique_scene_id = UNIQUE_SCENE_ID_UNASSIGNED;
|
||||
|
||||
mutable NodePath *path_cache = nullptr;
|
||||
|
||||
} data;
|
||||
@ -527,6 +532,9 @@ public:
|
||||
Node *get_parent() const;
|
||||
Node *find_parent(const String &p_pattern) const;
|
||||
|
||||
void set_unique_scene_id(int32_t p_unique_id);
|
||||
int32_t get_unique_scene_id() const;
|
||||
|
||||
Window *get_window() const;
|
||||
Window *get_non_popup_window() const;
|
||||
Window *get_last_exclusive_window() const;
|
||||
|
||||
Reference in New Issue
Block a user