Merge pull request #7978 from RandomShaper/fix-sub-inheritance-2.1
Fix node duplication in scene sub-inheritance (2.1)
This commit is contained in:
commit
3c566fc552
3 changed files with 27 additions and 7 deletions
|
@ -1001,12 +1001,12 @@ int SceneState::find_node_by_path(const NodePath& p_node) const {
|
||||||
if (_get_base_scene_state().is_valid()) {
|
if (_get_base_scene_state().is_valid()) {
|
||||||
int idx = _get_base_scene_state()->find_node_by_path(p_node);
|
int idx = _get_base_scene_state()->find_node_by_path(p_node);
|
||||||
if (idx>=0) {
|
if (idx>=0) {
|
||||||
if (!base_scene_node_remap.has(idx)) {
|
int rkey=_find_base_scene_node_remap_key(idx);
|
||||||
int ridx = nodes.size() + base_scene_node_remap.size();
|
if (rkey==-1) {
|
||||||
base_scene_node_remap[ridx]=idx;
|
rkey=nodes.size() + base_scene_node_remap.size();
|
||||||
|
base_scene_node_remap[rkey]=idx;
|
||||||
}
|
}
|
||||||
|
return rkey;
|
||||||
return base_scene_node_remap[idx];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1019,12 +1019,24 @@ int SceneState::find_node_by_path(const NodePath& p_node) const {
|
||||||
//the node in the instanced scene, as a property may be missing
|
//the node in the instanced scene, as a property may be missing
|
||||||
//from the local one
|
//from the local one
|
||||||
int idx = _get_base_scene_state()->find_node_by_path(p_node);
|
int idx = _get_base_scene_state()->find_node_by_path(p_node);
|
||||||
|
if (idx!=-1) {
|
||||||
base_scene_node_remap[nid]=idx;
|
base_scene_node_remap[nid]=idx;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nid;
|
return nid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int SceneState::_find_base_scene_node_remap_key(int p_idx) const {
|
||||||
|
|
||||||
|
for (Map<int, int>::Element* E=base_scene_node_remap.front();E;E=E->next()) {
|
||||||
|
if (E->value()==p_idx) {
|
||||||
|
return E->key();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
Variant SceneState::get_property_value(int p_node, const StringName& p_property, bool &found) const {
|
Variant SceneState::get_property_value(int p_node, const StringName& p_property, bool &found) const {
|
||||||
|
|
||||||
found=false;
|
found=false;
|
||||||
|
|
|
@ -104,6 +104,8 @@ class SceneState : public Reference {
|
||||||
|
|
||||||
DVector<String> _get_node_groups(int p_idx) const;
|
DVector<String> _get_node_groups(int p_idx) const;
|
||||||
|
|
||||||
|
int _find_base_scene_node_remap_key(int p_idx) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
|
@ -1013,6 +1013,11 @@ void EditorNode::_save_scene(String p_file, int idx) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// force creation of node path cache
|
||||||
|
// (hacky but needed for the tree to update properly)
|
||||||
|
Node* dummy_scene=sdata->instance(true);
|
||||||
|
memdelete(dummy_scene);
|
||||||
|
|
||||||
sdata->set_import_metadata(editor_data.get_edited_scene_import_metadata(idx));
|
sdata->set_import_metadata(editor_data.get_edited_scene_import_metadata(idx));
|
||||||
int flg=0;
|
int flg=0;
|
||||||
if (EditorSettings::get_singleton()->get("on_save/compress_binary_resources"))
|
if (EditorSettings::get_singleton()->get("on_save/compress_binary_resources"))
|
||||||
|
@ -1023,6 +1028,7 @@ void EditorNode::_save_scene(String p_file, int idx) {
|
||||||
|
|
||||||
|
|
||||||
err = ResourceSaver::save(p_file,sdata,flg);
|
err = ResourceSaver::save(p_file,sdata,flg);
|
||||||
|
|
||||||
Map<RES,bool> processed;
|
Map<RES,bool> processed;
|
||||||
_save_edited_subresources(scene,processed,flg);
|
_save_edited_subresources(scene,processed,flg);
|
||||||
editor_data.save_editor_external_data();
|
editor_data.save_editor_external_data();
|
||||||
|
|
Loading…
Reference in a new issue