summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2018-06-21 18:08:11 -0300
committerJuan Linietsky <reduzio@gmail.com>2018-06-21 18:08:11 -0300
commitb80946ee0dbb7c28021c55d2623a35e89fc972f4 (patch)
treeaae498f78f1fc7df6f05869ac2b92cf8aea92478
parenta0719533bdc4e99a24bd02886fc77a29d5d30dfc (diff)
Fix crashes, ability to add blendpsace into blendtree, ability to delete with delete key
-rw-r--r--editor/editor_node.cpp8
-rw-r--r--editor/plugins/animation_blend_space_editor.cpp95
-rw-r--r--editor/plugins/animation_blend_space_editor.h4
-rw-r--r--editor/plugins/animation_blend_tree_editor_plugin.cpp45
-rw-r--r--editor/plugins/animation_blend_tree_editor_plugin.h4
-rw-r--r--scene/animation/animation_graph_player.cpp4
6 files changed, 112 insertions, 48 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index fb5a2b84d3..83f1cd40ba 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -1309,7 +1309,11 @@ bool EditorNode::item_has_editor(Object *p_object) {
void EditorNode::edit_item(Object *p_object) {
- Vector<EditorPlugin *> sub_plugins = editor_data.get_subeditors(p_object);
+ Vector<EditorPlugin *> sub_plugins;
+
+ if (p_object) {
+ sub_plugins = editor_data.get_subeditors(p_object);
+ }
if (!sub_plugins.empty()) {
_display_top_editors(false);
@@ -1317,6 +1321,8 @@ void EditorNode::edit_item(Object *p_object) {
_set_top_editors(sub_plugins);
_set_editing_top_editors(p_object);
_display_top_editors(true);
+ } else {
+ _hide_top_editors();
}
}
diff --git a/editor/plugins/animation_blend_space_editor.cpp b/editor/plugins/animation_blend_space_editor.cpp
index 0199e26282..9172d3a858 100644
--- a/editor/plugins/animation_blend_space_editor.cpp
+++ b/editor/plugins/animation_blend_space_editor.cpp
@@ -12,17 +12,35 @@
void AnimationNodeBlendSpaceEditor::edit(AnimationNodeBlendSpace *p_blend_space) {
- blend_space = p_blend_space;
+ if (blend_space.is_valid()) {
+ blend_space->disconnect("removed_from_graph", this, "_removed_from_graph");
+ }
- if (!blend_space) {
+ if (p_blend_space) {
+ blend_space = Ref<AnimationNodeBlendSpace>(p_blend_space);
+ } else {
+ blend_space.unref();
+ }
+
+ if (blend_space.is_null()) {
hide();
} else {
+ blend_space->connect("removed_from_graph", this, "_removed_from_graph");
+
_update_space();
}
}
void AnimationNodeBlendSpaceEditor::_blend_space_gui_input(const Ref<InputEvent> &p_event) {
+ Ref<InputEventKey> k = p_event;
+ if (tool_select->is_pressed() && k.is_valid() && k->is_pressed() && k->get_scancode() == KEY_DELETE && !k->is_echo()) {
+ if (selected_point != -1 || selected_triangle != -1) {
+ _erase_selected();
+ accept_event();
+ }
+ }
+
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid() && mb->is_pressed() && ((tool_select->is_pressed() && mb->get_button_index() == BUTTON_RIGHT) || (mb->get_button_index() == BUTTON_LEFT && tool_create->is_pressed()))) {
@@ -136,8 +154,8 @@ void AnimationNodeBlendSpaceEditor::_blend_space_gui_input(const Ref<InputEvent>
updating = true;
undo_redo->create_action("Add Triangle");
- undo_redo->add_do_method(blend_space, "add_triangle", making_triangle[0], making_triangle[1], making_triangle[2]);
- undo_redo->add_undo_method(blend_space, "remove_triangle", blend_space->get_triangle_count());
+ undo_redo->add_do_method(blend_space.ptr(), "add_triangle", making_triangle[0], making_triangle[1], making_triangle[2]);
+ undo_redo->add_undo_method(blend_space.ptr(), "remove_triangle", blend_space->get_triangle_count());
undo_redo->add_do_method(this, "_update_space");
undo_redo->add_undo_method(this, "_update_space");
undo_redo->commit_action();
@@ -161,8 +179,8 @@ void AnimationNodeBlendSpaceEditor::_blend_space_gui_input(const Ref<InputEvent>
updating = true;
undo_redo->create_action("Move Node Point");
- undo_redo->add_do_method(blend_space, "set_blend_point_position", selected_point, point);
- undo_redo->add_undo_method(blend_space, "set_blend_point_position", selected_point, blend_space->get_blend_point_position(selected_point));
+ undo_redo->add_do_method(blend_space.ptr(), "set_blend_point_position", selected_point, point);
+ undo_redo->add_undo_method(blend_space.ptr(), "set_blend_point_position", selected_point, blend_space->get_blend_point_position(selected_point));
undo_redo->add_do_method(this, "_update_space");
undo_redo->add_undo_method(this, "_update_space");
undo_redo->add_do_method(this, "_update_edited_point_pos");
@@ -189,6 +207,11 @@ void AnimationNodeBlendSpaceEditor::_blend_space_gui_input(const Ref<InputEvent>
Ref<InputEventMouseMotion> mm = p_event;
+ if (mm.is_valid() && !blend_space_draw->has_focus()) {
+ blend_space_draw->grab_focus();
+ blend_space_draw->update();
+ }
+
if (mm.is_valid() && dragging_selected_attempt) {
dragging_selected = true;
drag_ofs = ((mm->get_position() - drag_from) / blend_space_draw->get_size()) * (blend_space->get_max_space() - blend_space->get_min_space()) * Vector2(1, -1);
@@ -230,8 +253,8 @@ void AnimationNodeBlendSpaceEditor::_add_menu_type(int p_index) {
updating = true;
undo_redo->create_action("Add Node Point");
- undo_redo->add_do_method(blend_space, "add_blend_point", node, add_point_pos);
- undo_redo->add_undo_method(blend_space, "remove_blend_point", blend_space->get_blend_point_count());
+ undo_redo->add_do_method(blend_space.ptr(), "add_blend_point", node, add_point_pos);
+ undo_redo->add_undo_method(blend_space.ptr(), "remove_blend_point", blend_space->get_blend_point_count());
undo_redo->add_do_method(this, "_update_space");
undo_redo->add_undo_method(this, "_update_space");
undo_redo->commit_action();
@@ -249,8 +272,8 @@ void AnimationNodeBlendSpaceEditor::_add_animation_type(int p_index) {
updating = true;
undo_redo->create_action("Add Animation Point");
- undo_redo->add_do_method(blend_space, "add_blend_point", anim, add_point_pos);
- undo_redo->add_undo_method(blend_space, "remove_blend_point", blend_space->get_blend_point_count());
+ undo_redo->add_do_method(blend_space.ptr(), "add_blend_point", anim, add_point_pos);
+ undo_redo->add_undo_method(blend_space.ptr(), "remove_blend_point", blend_space->get_blend_point_count());
undo_redo->add_do_method(this, "_update_space");
undo_redo->add_undo_method(this, "_update_space");
undo_redo->commit_action();
@@ -299,8 +322,12 @@ void AnimationNodeBlendSpaceEditor::_blend_space_draw() {
Size2 s = blend_space_draw->get_size();
- blend_space_draw->draw_line(Point2(0, 0), Point2(0, s.height), linecolor);
- blend_space_draw->draw_line(Point2(0, s.height - 1), Point2(s.width, s.height - 1), linecolor);
+ if (blend_space_draw->has_focus()) {
+ Color color = get_color("accent_color", "Editor");
+ blend_space_draw->draw_rect(Rect2(Point2(), s), color, false);
+ }
+ blend_space_draw->draw_line(Point2(1, 0), Point2(1, s.height - 1), linecolor);
+ blend_space_draw->draw_line(Point2(1, s.height - 1), Point2(s.width - 1, s.height - 1), linecolor);
blend_space_draw->draw_line(Point2(0, 0), Point2(5 * EDSCALE, 0), linecolor);
if (blend_space->get_min_space().y < 0) {
@@ -514,12 +541,12 @@ void AnimationNodeBlendSpaceEditor::_config_changed(double) {
updating = true;
undo_redo->create_action("Change BlendSpace Limits");
- undo_redo->add_do_method(blend_space, "set_max_space", Vector2(max_x_value->get_value(), max_y_value->get_value()));
- undo_redo->add_undo_method(blend_space, "set_max_space", blend_space->get_max_space());
- undo_redo->add_do_method(blend_space, "set_min_space", Vector2(min_x_value->get_value(), min_y_value->get_value()));
- undo_redo->add_undo_method(blend_space, "set_min_space", blend_space->get_min_space());
- undo_redo->add_do_method(blend_space, "set_snap", Vector2(snap_x->get_value(), snap_y->get_value()));
- undo_redo->add_undo_method(blend_space, "set_snap", blend_space->get_snap());
+ undo_redo->add_do_method(blend_space.ptr(), "set_max_space", Vector2(max_x_value->get_value(), max_y_value->get_value()));
+ undo_redo->add_undo_method(blend_space.ptr(), "set_max_space", blend_space->get_max_space());
+ undo_redo->add_do_method(blend_space.ptr(), "set_min_space", Vector2(min_x_value->get_value(), min_y_value->get_value()));
+ undo_redo->add_undo_method(blend_space.ptr(), "set_min_space", blend_space->get_min_space());
+ undo_redo->add_do_method(blend_space.ptr(), "set_snap", Vector2(snap_x->get_value(), snap_y->get_value()));
+ undo_redo->add_undo_method(blend_space.ptr(), "set_snap", blend_space->get_snap());
undo_redo->add_do_method(this, "_update_space");
undo_redo->add_undo_method(this, "_update_space");
undo_redo->commit_action();
@@ -534,10 +561,10 @@ void AnimationNodeBlendSpaceEditor::_labels_changed(String) {
updating = true;
undo_redo->create_action("Change BlendSpace Labels", UndoRedo::MERGE_ENDS);
- undo_redo->add_do_method(blend_space, "set_x_label", label_x->get_text());
- undo_redo->add_undo_method(blend_space, "set_x_label", blend_space->get_x_label());
- undo_redo->add_do_method(blend_space, "set_y_label", label_y->get_text());
- undo_redo->add_undo_method(blend_space, "set_y_label", blend_space->get_y_label());
+ undo_redo->add_do_method(blend_space.ptr(), "set_x_label", label_x->get_text());
+ undo_redo->add_undo_method(blend_space.ptr(), "set_x_label", blend_space->get_x_label());
+ undo_redo->add_do_method(blend_space.ptr(), "set_y_label", label_y->get_text());
+ undo_redo->add_undo_method(blend_space.ptr(), "set_y_label", blend_space->get_y_label());
undo_redo->add_do_method(this, "_update_space");
undo_redo->add_undo_method(this, "_update_space");
undo_redo->commit_action();
@@ -550,14 +577,14 @@ void AnimationNodeBlendSpaceEditor::_erase_selected() {
updating = true;
undo_redo->create_action("Remove BlendSpace Point");
- undo_redo->add_do_method(blend_space, "remove_blend_point", selected_point);
- undo_redo->add_undo_method(blend_space, "add_blend_point", blend_space->get_blend_point_node(selected_point), blend_space->get_blend_point_position(selected_point), selected_point);
+ undo_redo->add_do_method(blend_space.ptr(), "remove_blend_point", selected_point);
+ undo_redo->add_undo_method(blend_space.ptr(), "add_blend_point", blend_space->get_blend_point_node(selected_point), blend_space->get_blend_point_position(selected_point), selected_point);
//restore triangles using this point
for (int i = 0; i < blend_space->get_triangle_count(); i++) {
for (int j = 0; j < 3; j++) {
if (blend_space->get_triangle_point(i, j) == selected_point) {
- undo_redo->add_undo_method(blend_space, "add_triangle", blend_space->get_triangle_point(i, 0), blend_space->get_triangle_point(i, 1), blend_space->get_triangle_point(i, 2), i);
+ undo_redo->add_undo_method(blend_space.ptr(), "add_triangle", blend_space->get_triangle_point(i, 0), blend_space->get_triangle_point(i, 1), blend_space->get_triangle_point(i, 2), i);
break;
}
}
@@ -573,8 +600,8 @@ void AnimationNodeBlendSpaceEditor::_erase_selected() {
updating = true;
undo_redo->create_action("Remove BlendSpace Triangle");
- undo_redo->add_do_method(blend_space, "remove_triangle", selected_triangle);
- undo_redo->add_undo_method(blend_space, "add_triangle", blend_space->get_triangle_point(selected_triangle, 0), blend_space->get_triangle_point(selected_triangle, 1), blend_space->get_triangle_point(selected_triangle, 2), selected_triangle);
+ undo_redo->add_do_method(blend_space.ptr(), "remove_triangle", selected_triangle);
+ undo_redo->add_undo_method(blend_space.ptr(), "add_triangle", blend_space->get_triangle_point(selected_triangle, 0), blend_space->get_triangle_point(selected_triangle, 1), blend_space->get_triangle_point(selected_triangle, 2), selected_triangle);
undo_redo->add_do_method(this, "_update_space");
undo_redo->add_undo_method(this, "_update_space");
@@ -610,8 +637,8 @@ void AnimationNodeBlendSpaceEditor::_edit_point_pos(double) {
return;
updating = true;
undo_redo->create_action("Move Node Point");
- undo_redo->add_do_method(blend_space, "set_blend_point_position", selected_point, Vector2(edit_x->get_value(), edit_y->get_value()));
- undo_redo->add_undo_method(blend_space, "set_blend_point_position", selected_point, blend_space->get_blend_point_position(selected_point));
+ undo_redo->add_do_method(blend_space.ptr(), "set_blend_point_position", selected_point, Vector2(edit_x->get_value(), edit_y->get_value()));
+ undo_redo->add_undo_method(blend_space.ptr(), "set_blend_point_position", selected_point, blend_space->get_blend_point_position(selected_point));
undo_redo->add_do_method(this, "_update_space");
undo_redo->add_undo_method(this, "_update_space");
undo_redo->add_do_method(this, "_update_edited_point_pos");
@@ -677,6 +704,10 @@ void AnimationNodeBlendSpaceEditor::_goto_parent() {
EditorNode::get_singleton()->edit_item(blend_space->get_parent().ptr());
}
+void AnimationNodeBlendSpaceEditor::_removed_from_graph() {
+ EditorNode::get_singleton()->edit_item(NULL);
+}
+
void AnimationNodeBlendSpaceEditor::_bind_methods() {
ClassDB::bind_method("_blend_space_gui_input", &AnimationNodeBlendSpaceEditor::_blend_space_gui_input);
@@ -697,6 +728,8 @@ void AnimationNodeBlendSpaceEditor::_bind_methods() {
ClassDB::bind_method("_open_editor", &AnimationNodeBlendSpaceEditor::_open_editor);
ClassDB::bind_method("_goto_parent", &AnimationNodeBlendSpaceEditor::_goto_parent);
+
+ ClassDB::bind_method("_removed_from_graph", &AnimationNodeBlendSpaceEditor::_removed_from_graph);
}
AnimationNodeBlendSpaceEditor *AnimationNodeBlendSpaceEditor::singleton = NULL;
@@ -706,8 +739,6 @@ AnimationNodeBlendSpaceEditor::AnimationNodeBlendSpaceEditor() {
singleton = this;
updating = false;
- blend_space = NULL;
-
HBoxContainer *top_hb = memnew(HBoxContainer);
add_child(top_hb);
@@ -844,6 +875,8 @@ AnimationNodeBlendSpaceEditor::AnimationNodeBlendSpaceEditor() {
blend_space_draw = memnew(Control);
blend_space_draw->connect("gui_input", this, "_blend_space_gui_input");
blend_space_draw->connect("draw", this, "_blend_space_draw");
+ blend_space_draw->set_focus_mode(FOCUS_ALL);
+
panel->add_child(blend_space_draw);
main_grid->add_child(memnew(Control)); //empty bottom left
diff --git a/editor/plugins/animation_blend_space_editor.h b/editor/plugins/animation_blend_space_editor.h
index bac80a4962..4514ecc430 100644
--- a/editor/plugins/animation_blend_space_editor.h
+++ b/editor/plugins/animation_blend_space_editor.h
@@ -17,7 +17,7 @@ class AnimationNodeBlendSpaceEditor : public VBoxContainer {
GDCLASS(AnimationNodeBlendSpaceEditor, VBoxContainer);
- AnimationNodeBlendSpace *blend_space;
+ Ref<AnimationNodeBlendSpace> blend_space;
HBoxContainer *goto_parent_hb;
ToolButton *goto_parent;
@@ -93,6 +93,8 @@ class AnimationNodeBlendSpaceEditor : public VBoxContainer {
void _goto_parent();
+ void _removed_from_graph();
+
protected:
void _notification(int p_what);
static void _bind_methods();
diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp
index a925a00aa3..0875c93a16 100644
--- a/editor/plugins/animation_blend_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp
@@ -11,11 +11,21 @@
void AnimationNodeBlendTreeEditor::edit(AnimationNodeBlendTree *p_blend_tree) {
- blend_tree = p_blend_tree;
+ if (blend_tree.is_valid()) {
+ blend_tree->disconnect("removed_from_graph", this, "_removed_from_graph");
+ }
+
+ if (p_blend_tree) {
+ blend_tree = Ref<AnimationNodeBlendTree>(p_blend_tree);
+ } else {
+ blend_tree.unref();
+ }
- if (!blend_tree) {
+ if (blend_tree.is_null()) {
hide();
} else {
+ blend_tree->connect("removed_from_graph", this, "_removed_from_graph");
+
_update_graph();
}
}
@@ -247,8 +257,8 @@ void AnimationNodeBlendTreeEditor::_add_node(int p_idx) {
}
undo_redo->create_action("Add Node to BlendTree");
- undo_redo->add_do_method(blend_tree, "add_node", name, anode);
- undo_redo->add_undo_method(blend_tree, "remove_node", name);
+ undo_redo->add_do_method(blend_tree.ptr(), "add_node", name, anode);
+ undo_redo->add_undo_method(blend_tree.ptr(), "remove_node", name);
undo_redo->add_do_method(this, "_update_graph");
undo_redo->add_undo_method(this, "_update_graph");
undo_redo->commit_action();
@@ -276,8 +286,8 @@ void AnimationNodeBlendTreeEditor::_connection_request(const String &p_from, int
}
undo_redo->create_action("Nodes Connected");
- undo_redo->add_do_method(blend_tree, "connect_node", p_to, p_to_index, p_from);
- undo_redo->add_undo_method(blend_tree, "disconnect_node", p_to, p_to_index, p_from);
+ undo_redo->add_do_method(blend_tree.ptr(), "connect_node", p_to, p_to_index, p_from);
+ undo_redo->add_undo_method(blend_tree.ptr(), "disconnect_node", p_to, p_to_index, p_from);
undo_redo->add_do_method(this, "_update_graph");
undo_redo->add_undo_method(this, "_update_graph");
undo_redo->commit_action();
@@ -289,8 +299,8 @@ void AnimationNodeBlendTreeEditor::_disconnection_request(const String &p_from,
updating = true;
undo_redo->create_action("Nodes Disconnected");
- undo_redo->add_do_method(blend_tree, "disconnect_node", p_to, p_to_index);
- undo_redo->add_undo_method(blend_tree, "connect_node", p_to, p_to_index, p_from);
+ undo_redo->add_do_method(blend_tree.ptr(), "disconnect_node", p_to, p_to_index);
+ undo_redo->add_undo_method(blend_tree.ptr(), "connect_node", p_to, p_to_index, p_from);
undo_redo->add_do_method(this, "_update_graph");
undo_redo->add_undo_method(this, "_update_graph");
undo_redo->commit_action();
@@ -315,15 +325,15 @@ void AnimationNodeBlendTreeEditor::_anim_selected(int p_index, Array p_options,
void AnimationNodeBlendTreeEditor::_delete_request(const String &p_which) {
undo_redo->create_action("Delete Node");
- undo_redo->add_do_method(blend_tree, "remove_node", p_which);
- undo_redo->add_undo_method(blend_tree, "add_node", p_which, blend_tree->get_node(p_which));
+ undo_redo->add_do_method(blend_tree.ptr(), "remove_node", p_which);
+ undo_redo->add_undo_method(blend_tree.ptr(), "add_node", p_which, blend_tree->get_node(p_which));
List<AnimationNodeBlendTree::NodeConnection> conns;
blend_tree->get_node_connections(&conns);
for (List<AnimationNodeBlendTree::NodeConnection>::Element *E = conns.front(); E; E = E->next()) {
if (E->get().output_node == p_which || E->get().input_node == p_which) {
- undo_redo->add_undo_method(blend_tree, "connect_node", E->get().input_node, E->get().input_index, E->get().output_node);
+ undo_redo->add_undo_method(blend_tree.ptr(), "connect_node", E->get().input_node, E->get().input_index, E->get().output_node);
}
}
@@ -573,6 +583,12 @@ void AnimationNodeBlendTreeEditor::_edit_filters(const String &p_which) {
filter_dialog->popup_centered_minsize(Size2(500, 500) * EDSCALE);
}
+void AnimationNodeBlendTreeEditor::_removed_from_graph() {
+ if (is_visible()) {
+ EditorNode::get_singleton()->edit_item(NULL);
+ }
+}
+
void AnimationNodeBlendTreeEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
@@ -674,6 +690,7 @@ void AnimationNodeBlendTreeEditor::_bind_methods() {
ClassDB::bind_method("_oneshot_start", &AnimationNodeBlendTreeEditor::_oneshot_start);
ClassDB::bind_method("_oneshot_stop", &AnimationNodeBlendTreeEditor::_oneshot_stop);
ClassDB::bind_method("_node_changed", &AnimationNodeBlendTreeEditor::_node_changed);
+ ClassDB::bind_method("_removed_from_graph", &AnimationNodeBlendTreeEditor::_removed_from_graph);
ClassDB::bind_method("_anim_selected", &AnimationNodeBlendTreeEditor::_anim_selected);
}
@@ -703,8 +720,8 @@ void AnimationNodeBlendTreeEditor::_node_renamed(const String &p_text, Ref<Anima
updating = true;
undo_redo->create_action("Node Renamed");
- undo_redo->add_do_method(blend_tree, "rename_node", prev_name, name);
- undo_redo->add_undo_method(blend_tree, "rename_node", name, prev_name);
+ undo_redo->add_do_method(blend_tree.ptr(), "rename_node", prev_name, name);
+ undo_redo->add_undo_method(blend_tree.ptr(), "rename_node", name, prev_name);
undo_redo->add_do_method(this, "_update_graph");
undo_redo->add_undo_method(this, "_update_graph");
undo_redo->commit_action();
@@ -722,7 +739,6 @@ AnimationNodeBlendTreeEditor::AnimationNodeBlendTreeEditor() {
singleton = this;
updating = false;
- blend_tree = NULL;
graph = memnew(GraphEdit);
add_child(graph);
graph->add_valid_right_disconnect_type(0);
@@ -758,6 +774,7 @@ AnimationNodeBlendTreeEditor::AnimationNodeBlendTreeEditor() {
add_options.push_back(AddOption("TimeScale", "AnimationNodeTimeScale"));
add_options.push_back(AddOption("Transition", "AnimationNodeTransition"));
add_options.push_back(AddOption("BlendTree", "AnimationNodeBlendTree"));
+ add_options.push_back(AddOption("BlendSpace", "AnimationNodeBlendSpace"));
_update_options_menu();
error_panel = memnew(PanelContainer);
diff --git a/editor/plugins/animation_blend_tree_editor_plugin.h b/editor/plugins/animation_blend_tree_editor_plugin.h
index 71efed6da6..deba3b2b0e 100644
--- a/editor/plugins/animation_blend_tree_editor_plugin.h
+++ b/editor/plugins/animation_blend_tree_editor_plugin.h
@@ -17,7 +17,7 @@ class AnimationNodeBlendTreeEditor : public VBoxContainer {
GDCLASS(AnimationNodeBlendTreeEditor, VBoxContainer);
- AnimationNodeBlendTree *blend_tree;
+ Ref<AnimationNodeBlendTree> blend_tree;
GraphEdit *graph;
MenuButton *add_node;
Button *goto_parent;
@@ -78,6 +78,8 @@ class AnimationNodeBlendTreeEditor : public VBoxContainer {
void _node_changed(ObjectID p_node);
+ void _removed_from_graph();
+
protected:
void _notification(int p_what);
static void _bind_methods();
diff --git a/scene/animation/animation_graph_player.cpp b/scene/animation/animation_graph_player.cpp
index ea41a20114..b8efecebe9 100644
--- a/scene/animation/animation_graph_player.cpp
+++ b/scene/animation/animation_graph_player.cpp
@@ -318,6 +318,9 @@ Vector2 AnimationNode::get_position() const {
void AnimationNode::set_graph_player(AnimationGraphPlayer *p_player) {
+ if (player != NULL && p_player == NULL) {
+ emit_signal("removed_from_graph");
+ }
player = p_player;
}
@@ -377,6 +380,7 @@ void AnimationNode::_bind_methods() {
BIND_VMETHOD(MethodInfo("process", PropertyInfo(Variant::REAL, "time"), PropertyInfo(Variant::BOOL, "seek")));
+ ADD_SIGNAL(MethodInfo("removed_from_graph"));
BIND_ENUM_CONSTANT(FILTER_IGNORE);
BIND_ENUM_CONSTANT(FILTER_PASS);
BIND_ENUM_CONSTANT(FILTER_STOP);