Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix node duplication in scene sub-inheritance (2.1) #7978

Merged
merged 1 commit into from
Mar 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions scene/resources/packed_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1001,12 +1001,12 @@ int SceneState::find_node_by_path(const NodePath& p_node) const {
if (_get_base_scene_state().is_valid()) {
int idx = _get_base_scene_state()->find_node_by_path(p_node);
if (idx>=0) {
if (!base_scene_node_remap.has(idx)) {
int ridx = nodes.size() + base_scene_node_remap.size();
base_scene_node_remap[ridx]=idx;
int rkey=_find_base_scene_node_remap_key(idx);
if (rkey==-1) {
rkey=nodes.size() + base_scene_node_remap.size();
base_scene_node_remap[rkey]=idx;
}

return base_scene_node_remap[idx];
return rkey;
}
}
return -1;
Expand All @@ -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
//from the local one
int idx = _get_base_scene_state()->find_node_by_path(p_node);
base_scene_node_remap[nid]=idx;

if (idx!=-1) {
base_scene_node_remap[nid]=idx;
}
}

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 {

found=false;
Expand Down
2 changes: 2 additions & 0 deletions scene/resources/packed_scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ class SceneState : public Reference {

DVector<String> _get_node_groups(int p_idx) const;

int _find_base_scene_node_remap_key(int p_idx) const;

protected:

static void _bind_methods();
Expand Down
6 changes: 6 additions & 0 deletions tools/editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,11 @@ void EditorNode::_save_scene(String p_file, int idx) {
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));
int flg=0;
if (EditorSettings::get_singleton()->get("on_save/compress_binary_resources"))
Expand All @@ -1023,6 +1028,7 @@ void EditorNode::_save_scene(String p_file, int idx) {


err = ResourceSaver::save(p_file,sdata,flg);

Map<RES,bool> processed;
_save_edited_subresources(scene,processed,flg);
editor_data.save_editor_external_data();
Expand Down