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 Editable Children issues with node renaming, moving, duplicating and instancing. #39533

Merged
merged 1 commit into from
Jan 18, 2021
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
1 change: 0 additions & 1 deletion editor/scene_tree_dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2146,7 +2146,6 @@ void SceneTreeDock::replace_node(Node *p_node, Node *p_by_node, bool p_keep_prop
if (n == edited_scene) {
edited_scene = newnode;
editor->set_edited_scene(newnode);
newnode->set_editable_instances(n->get_editable_instances());
}

//small hack to make collisionshapes and other kind of nodes to work
Expand Down
21 changes: 4 additions & 17 deletions scene/main/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1901,37 +1901,23 @@ String Node::get_editor_description() const {
}

void Node::set_editable_instance(Node *p_node, bool p_editable) {

ERR_FAIL_NULL(p_node);
ERR_FAIL_COND(!is_a_parent_of(p_node));
NodePath p = get_path_to(p_node);
if (!p_editable) {
data.editable_instances.erase(p);
p_node->data.editable_instance = false;
// Avoid this flag being needlessly saved;
// also give more visual feedback if editable children is re-enabled
set_display_folded(false);
} else {
data.editable_instances[p] = true;
p_node->data.editable_instance = true;
}
}

bool Node::is_editable_instance(const Node *p_node) const {

if (!p_node)
return false; //easier, null is never editable :)
ERR_FAIL_COND_V(!is_a_parent_of(p_node), false);
NodePath p = get_path_to(p_node);
return data.editable_instances.has(p);
}

void Node::set_editable_instances(const HashMap<NodePath, int> &p_editable_instances) {

data.editable_instances = p_editable_instances;
}

HashMap<NodePath, int> Node::get_editable_instances() const {

return data.editable_instances;
return p_node->data.editable_instance;
}

void Node::set_scene_instance_state(const Ref<SceneState> &p_state) {
Expand Down Expand Up @@ -2970,6 +2956,7 @@ Node::Node() {
data.use_placeholder = false;
data.display_folded = false;
data.ready_first = true;
data.editable_instance = false;

orphan_node_count++;
}
Expand Down
5 changes: 1 addition & 4 deletions scene/main/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ class Node : public Object {
Ref<SceneState> instance_state;
Ref<SceneState> inherited_state;

HashMap<NodePath, int> editable_instances;

Node *parent;
Node *owner;
Vector<Node *> children; // list of children
Expand Down Expand Up @@ -139,6 +137,7 @@ class Node : public Object {
bool use_placeholder;

bool display_folded;
bool editable_instance;

mutable NodePath *path_cache;

Expand Down Expand Up @@ -325,8 +324,6 @@ class Node : public Object {

void set_editable_instance(Node *p_node, bool p_editable);
bool is_editable_instance(const Node *p_node) const;
void set_editable_instances(const HashMap<NodePath, int> &p_editable_instances);
HashMap<NodePath, int> get_editable_instances() const;

/* NOTIFICATIONS */

Expand Down