Fix AnimationTree crash & rename get_tree() to get_animation_tree()

This commit is contained in:
Silc Renew 2022-11-20 23:53:17 +09:00
parent 895428c805
commit d595b27467
6 changed files with 56 additions and 43 deletions

View file

@ -69,7 +69,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven
menu->add_submenu_item(TTR("Add Animation"), "animations"); menu->add_submenu_item(TTR("Add Animation"), "animations");
AnimationTree *gp = AnimationTreeEditor::get_singleton()->get_tree(); AnimationTree *gp = AnimationTreeEditor::get_singleton()->get_animation_tree();
ERR_FAIL_COND(!gp); ERR_FAIL_COND(!gp);
if (gp->has_node(gp->get_animation_player())) { if (gp->has_node(gp->get_animation_player())) {
@ -177,7 +177,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven
blend_pos *= blend_space->get_max_space() - blend_space->get_min_space(); blend_pos *= blend_space->get_max_space() - blend_space->get_min_space();
blend_pos += blend_space->get_min_space(); blend_pos += blend_space->get_min_space();
AnimationTreeEditor::get_singleton()->get_tree()->set(get_blend_position_path(), blend_pos); AnimationTreeEditor::get_singleton()->get_animation_tree()->set(get_blend_position_path(), blend_pos);
blend_space_draw->queue_redraw(); blend_space_draw->queue_redraw();
} }
@ -200,7 +200,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven
blend_pos *= blend_space->get_max_space() - blend_space->get_min_space(); blend_pos *= blend_space->get_max_space() - blend_space->get_min_space();
blend_pos += blend_space->get_min_space(); blend_pos += blend_space->get_min_space();
AnimationTreeEditor::get_singleton()->get_tree()->set(get_blend_position_path(), blend_pos); AnimationTreeEditor::get_singleton()->get_animation_tree()->set(get_blend_position_path(), blend_pos);
blend_space_draw->queue_redraw(); blend_space_draw->queue_redraw();
} }
@ -298,7 +298,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_draw() {
color.a *= 0.5; color.a *= 0.5;
} }
float point = AnimationTreeEditor::get_singleton()->get_tree()->get(get_blend_position_path()); float point = AnimationTreeEditor::get_singleton()->get_animation_tree()->get(get_blend_position_path());
point = (point - blend_space->get_min_space()) / (blend_space->get_max_space() - blend_space->get_min_space()); point = (point - blend_space->get_min_space()) / (blend_space->get_max_space() - blend_space->get_min_space());
point *= s.width; point *= s.width;
@ -568,10 +568,10 @@ void AnimationNodeBlendSpace1DEditor::_notification(int p_what) {
case NOTIFICATION_PROCESS: { case NOTIFICATION_PROCESS: {
String error; String error;
if (!AnimationTreeEditor::get_singleton()->get_tree()->is_active()) { if (!AnimationTreeEditor::get_singleton()->get_animation_tree()->is_active()) {
error = TTR("AnimationTree is inactive.\nActivate to enable playback, check node warnings if activation fails."); error = TTR("AnimationTree is inactive.\nActivate to enable playback, check node warnings if activation fails.");
} else if (AnimationTreeEditor::get_singleton()->get_tree()->is_state_invalid()) { } else if (AnimationTreeEditor::get_singleton()->get_animation_tree()->is_state_invalid()) {
error = AnimationTreeEditor::get_singleton()->get_tree()->get_invalid_state_reason(); error = AnimationTreeEditor::get_singleton()->get_animation_tree()->get_invalid_state_reason();
} }
if (error != error_label->get_text()) { if (error != error_label->get_text()) {

View file

@ -115,7 +115,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven
ClassDB::get_inheriters_from_class("AnimationRootNode", &classes); ClassDB::get_inheriters_from_class("AnimationRootNode", &classes);
menu->add_submenu_item(TTR("Add Animation"), "animations"); menu->add_submenu_item(TTR("Add Animation"), "animations");
AnimationTree *gp = AnimationTreeEditor::get_singleton()->get_tree(); AnimationTree *gp = AnimationTreeEditor::get_singleton()->get_animation_tree();
ERR_FAIL_COND(!gp); ERR_FAIL_COND(!gp);
if (gp && gp->has_node(gp->get_animation_player())) { if (gp && gp->has_node(gp->get_animation_player())) {
AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(gp->get_node(gp->get_animation_player())); AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(gp->get_node(gp->get_animation_player()));
@ -270,7 +270,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven
blend_pos *= (blend_space->get_max_space() - blend_space->get_min_space()); blend_pos *= (blend_space->get_max_space() - blend_space->get_min_space());
blend_pos += blend_space->get_min_space(); blend_pos += blend_space->get_min_space();
AnimationTreeEditor::get_singleton()->get_tree()->set(get_blend_position_path(), blend_pos); AnimationTreeEditor::get_singleton()->get_animation_tree()->set(get_blend_position_path(), blend_pos);
blend_space_draw->queue_redraw(); blend_space_draw->queue_redraw();
} }
@ -306,7 +306,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven
blend_pos *= (blend_space->get_max_space() - blend_space->get_min_space()); blend_pos *= (blend_space->get_max_space() - blend_space->get_min_space());
blend_pos += blend_space->get_min_space(); blend_pos += blend_space->get_min_space();
AnimationTreeEditor::get_singleton()->get_tree()->set(get_blend_position_path(), blend_pos); AnimationTreeEditor::get_singleton()->get_animation_tree()->set(get_blend_position_path(), blend_pos);
blend_space_draw->queue_redraw(); blend_space_draw->queue_redraw();
} }
@ -589,7 +589,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() {
color.a *= 0.5; color.a *= 0.5;
} }
Vector2 blend_pos = AnimationTreeEditor::get_singleton()->get_tree()->get(get_blend_position_path()); Vector2 blend_pos = AnimationTreeEditor::get_singleton()->get_animation_tree()->get(get_blend_position_path());
Vector2 point = blend_pos; Vector2 point = blend_pos;
point = (point - blend_space->get_min_space()) / (blend_space->get_max_space() - blend_space->get_min_space()); point = (point - blend_space->get_min_space()) / (blend_space->get_max_space() - blend_space->get_min_space());
@ -797,12 +797,12 @@ void AnimationNodeBlendSpace2DEditor::_notification(int p_what) {
case NOTIFICATION_PROCESS: { case NOTIFICATION_PROCESS: {
String error; String error;
if (!AnimationTreeEditor::get_singleton()->get_tree()) { if (!AnimationTreeEditor::get_singleton()->get_animation_tree()) {
error = TTR("BlendSpace2D does not belong to an AnimationTree node."); error = TTR("BlendSpace2D does not belong to an AnimationTree node.");
} else if (!AnimationTreeEditor::get_singleton()->get_tree()->is_active()) { } else if (!AnimationTreeEditor::get_singleton()->get_animation_tree()->is_active()) {
error = TTR("AnimationTree is inactive.\nActivate to enable playback, check node warnings if activation fails."); error = TTR("AnimationTree is inactive.\nActivate to enable playback, check node warnings if activation fails.");
} else if (AnimationTreeEditor::get_singleton()->get_tree()->is_state_invalid()) { } else if (AnimationTreeEditor::get_singleton()->get_animation_tree()->is_state_invalid()) {
error = AnimationTreeEditor::get_singleton()->get_tree()->get_invalid_state_reason(); error = AnimationTreeEditor::get_singleton()->get_animation_tree()->get_invalid_state_reason();
} else if (blend_space->get_triangle_count() == 0) { } else if (blend_space->get_triangle_count() == 0) {
error = TTR("No triangles exist, so no blending can take place."); error = TTR("No triangles exist, so no blending can take place.");
} }

View file

@ -96,7 +96,7 @@ Size2 AnimationNodeBlendTreeEditor::get_minimum_size() const {
} }
void AnimationNodeBlendTreeEditor::_property_changed(const StringName &p_property, const Variant &p_value, const String &p_field, bool p_changing) { void AnimationNodeBlendTreeEditor::_property_changed(const StringName &p_property, const Variant &p_value, const String &p_field, bool p_changing) {
AnimationTree *tree = AnimationTreeEditor::get_singleton()->get_tree(); AnimationTree *tree = AnimationTreeEditor::get_singleton()->get_animation_tree();
updating = true; updating = true;
undo_redo->create_action(TTR("Parameter Changed:") + " " + String(p_property), UndoRedo::MERGE_ENDS); undo_redo->create_action(TTR("Parameter Changed:") + " " + String(p_property), UndoRedo::MERGE_ENDS);
undo_redo->add_do_property(tree, p_property, p_value); undo_redo->add_do_property(tree, p_property, p_value);
@ -174,10 +174,10 @@ void AnimationNodeBlendTreeEditor::update_graph() {
continue; continue;
} }
String base_path = AnimationTreeEditor::get_singleton()->get_base_path() + String(E) + "/" + F.name; String base_path = AnimationTreeEditor::get_singleton()->get_base_path() + String(E) + "/" + F.name;
EditorProperty *prop = EditorInspector::instantiate_property_editor(AnimationTreeEditor::get_singleton()->get_tree(), F.type, base_path, F.hint, F.hint_string, F.usage); EditorProperty *prop = EditorInspector::instantiate_property_editor(AnimationTreeEditor::get_singleton()->get_animation_tree(), F.type, base_path, F.hint, F.hint_string, F.usage);
if (prop) { if (prop) {
prop->set_read_only(read_only); prop->set_read_only(read_only);
prop->set_object_and_property(AnimationTreeEditor::get_singleton()->get_tree(), base_path); prop->set_object_and_property(AnimationTreeEditor::get_singleton()->get_animation_tree(), base_path);
prop->update_property(); prop->update_property();
prop->set_name_split_ratio(0); prop->set_name_split_ratio(0);
prop->connect("property_changed", callable_mp(this, &AnimationNodeBlendTreeEditor::_property_changed)); prop->connect("property_changed", callable_mp(this, &AnimationNodeBlendTreeEditor::_property_changed));
@ -225,7 +225,7 @@ void AnimationNodeBlendTreeEditor::update_graph() {
ProgressBar *pb = memnew(ProgressBar); ProgressBar *pb = memnew(ProgressBar);
AnimationTree *player = AnimationTreeEditor::get_singleton()->get_tree(); AnimationTree *player = AnimationTreeEditor::get_singleton()->get_animation_tree();
if (player->has_node(player->get_animation_player())) { if (player->has_node(player->get_animation_player())) {
AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(player->get_node(player->get_animation_player())); AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(player->get_node(player->get_animation_player()));
if (ap) { if (ap) {
@ -589,14 +589,14 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano
return false; return false;
} }
NodePath player_path = AnimationTreeEditor::get_singleton()->get_tree()->get_animation_player(); NodePath player_path = AnimationTreeEditor::get_singleton()->get_animation_tree()->get_animation_player();
if (!AnimationTreeEditor::get_singleton()->get_tree()->has_node(player_path)) { if (!AnimationTreeEditor::get_singleton()->get_animation_tree()->has_node(player_path)) {
EditorNode::get_singleton()->show_warning(TTR("No animation player set, so unable to retrieve track names.")); EditorNode::get_singleton()->show_warning(TTR("No animation player set, so unable to retrieve track names."));
return false; return false;
} }
AnimationPlayer *player = Object::cast_to<AnimationPlayer>(AnimationTreeEditor::get_singleton()->get_tree()->get_node(player_path)); AnimationPlayer *player = Object::cast_to<AnimationPlayer>(AnimationTreeEditor::get_singleton()->get_animation_tree()->get_node(player_path));
if (!player) { if (!player) {
EditorNode::get_singleton()->show_warning(TTR("Player path set is invalid, so unable to retrieve track names.")); EditorNode::get_singleton()->show_warning(TTR("Player path set is invalid, so unable to retrieve track names."));
return false; return false;
@ -829,10 +829,10 @@ void AnimationNodeBlendTreeEditor::_notification(int p_what) {
case NOTIFICATION_PROCESS: { case NOTIFICATION_PROCESS: {
String error; String error;
if (!AnimationTreeEditor::get_singleton()->get_tree()->is_active()) { if (!AnimationTreeEditor::get_singleton()->get_animation_tree()->is_active()) {
error = TTR("AnimationTree is inactive.\nActivate to enable playback, check node warnings if activation fails."); error = TTR("AnimationTree is inactive.\nActivate to enable playback, check node warnings if activation fails.");
} else if (AnimationTreeEditor::get_singleton()->get_tree()->is_state_invalid()) { } else if (AnimationTreeEditor::get_singleton()->get_animation_tree()->is_state_invalid()) {
error = AnimationTreeEditor::get_singleton()->get_tree()->get_invalid_state_reason(); error = AnimationTreeEditor::get_singleton()->get_animation_tree()->get_invalid_state_reason();
} }
if (error != error_label->get_text()) { if (error != error_label->get_text()) {
@ -849,13 +849,13 @@ void AnimationNodeBlendTreeEditor::_notification(int p_what) {
for (const AnimationNodeBlendTree::NodeConnection &E : conns) { for (const AnimationNodeBlendTree::NodeConnection &E : conns) {
float activity = 0; float activity = 0;
StringName path = AnimationTreeEditor::get_singleton()->get_base_path() + E.input_node; StringName path = AnimationTreeEditor::get_singleton()->get_base_path() + E.input_node;
if (AnimationTreeEditor::get_singleton()->get_tree() && !AnimationTreeEditor::get_singleton()->get_tree()->is_state_invalid()) { if (AnimationTreeEditor::get_singleton()->get_animation_tree() && !AnimationTreeEditor::get_singleton()->get_animation_tree()->is_state_invalid()) {
activity = AnimationTreeEditor::get_singleton()->get_tree()->get_connection_activity(path, E.input_index); activity = AnimationTreeEditor::get_singleton()->get_animation_tree()->get_connection_activity(path, E.input_index);
} }
graph->set_connection_activity(E.output_node, 0, E.input_node, E.input_index, activity); graph->set_connection_activity(E.output_node, 0, E.input_node, E.input_index, activity);
} }
AnimationTree *graph_player = AnimationTreeEditor::get_singleton()->get_tree(); AnimationTree *graph_player = AnimationTreeEditor::get_singleton()->get_animation_tree();
AnimationPlayer *player = nullptr; AnimationPlayer *player = nullptr;
if (graph_player->has_node(graph_player->get_animation_player())) { if (graph_player->has_node(graph_player->get_animation_player())) {
player = Object::cast_to<AnimationPlayer>(graph_player->get_node(graph_player->get_animation_player())); player = Object::cast_to<AnimationPlayer>(graph_player->get_node(graph_player->get_animation_player()));
@ -871,7 +871,7 @@ void AnimationNodeBlendTreeEditor::_notification(int p_what) {
E.value->set_max(anim->get_length()); E.value->set_max(anim->get_length());
//StringName path = AnimationTreeEditor::get_singleton()->get_base_path() + E.input_node; //StringName path = AnimationTreeEditor::get_singleton()->get_base_path() + E.input_node;
StringName time_path = AnimationTreeEditor::get_singleton()->get_base_path() + String(E.key) + "/time"; StringName time_path = AnimationTreeEditor::get_singleton()->get_base_path() + String(E.key) + "/time";
E.value->set_value(AnimationTreeEditor::get_singleton()->get_tree()->get(time_path)); E.value->set_value(AnimationTreeEditor::get_singleton()->get_animation_tree()->get(time_path));
} }
} }
} }
@ -952,8 +952,8 @@ void AnimationNodeBlendTreeEditor::_node_renamed(const String &p_text, Ref<Anima
undo_redo->create_action(TTR("Node Renamed")); undo_redo->create_action(TTR("Node Renamed"));
undo_redo->add_do_method(blend_tree.ptr(), "rename_node", prev_name, 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_undo_method(blend_tree.ptr(), "rename_node", name, prev_name);
undo_redo->add_do_method(AnimationTreeEditor::get_singleton()->get_tree(), "rename_parameter", base_path + prev_name, base_path + name); undo_redo->add_do_method(AnimationTreeEditor::get_singleton()->get_animation_tree(), "rename_parameter", base_path + prev_name, base_path + name);
undo_redo->add_undo_method(AnimationTreeEditor::get_singleton()->get_tree(), "rename_parameter", base_path + name, base_path + prev_name); undo_redo->add_undo_method(AnimationTreeEditor::get_singleton()->get_animation_tree(), "rename_parameter", base_path + name, base_path + prev_name);
undo_redo->add_do_method(this, "update_graph"); undo_redo->add_do_method(this, "update_graph");
undo_redo->add_undo_method(this, "update_graph"); undo_redo->add_undo_method(this, "update_graph");
undo_redo->commit_action(); undo_redo->commit_action();

View file

@ -76,7 +76,7 @@ void AnimationNodeStateMachineEditor::edit(const Ref<AnimationNode> &p_node) {
} }
void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEvent> &p_event) { void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEvent> &p_event) {
Ref<AnimationNodeStateMachinePlayback> playback = AnimationTreeEditor::get_singleton()->get_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + "playback"); Ref<AnimationNodeStateMachinePlayback> playback = AnimationTreeEditor::get_singleton()->get_animation_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + "playback");
if (playback.is_null()) { if (playback.is_null()) {
return; return;
} }
@ -739,7 +739,7 @@ void AnimationNodeStateMachineEditor::_open_menu(const Vector2 &p_position) {
ClassDB::get_inheriters_from_class("AnimationRootNode", &classes); ClassDB::get_inheriters_from_class("AnimationRootNode", &classes);
menu->add_submenu_item(TTR("Add Animation"), "animations"); menu->add_submenu_item(TTR("Add Animation"), "animations");
AnimationTree *gp = AnimationTreeEditor::get_singleton()->get_tree(); AnimationTree *gp = AnimationTreeEditor::get_singleton()->get_animation_tree();
ERR_FAIL_COND(!gp); ERR_FAIL_COND(!gp);
if (gp && gp->has_node(gp->get_animation_player())) { if (gp && gp->has_node(gp->get_animation_player())) {
AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(gp->get_node(gp->get_animation_player())); AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(gp->get_node(gp->get_animation_player()));
@ -1181,7 +1181,7 @@ void AnimationNodeStateMachineEditor::_clip_dst_line_to_rect(const Vector2 &p_fr
} }
void AnimationNodeStateMachineEditor::_state_machine_draw() { void AnimationNodeStateMachineEditor::_state_machine_draw() {
Ref<AnimationNodeStateMachinePlayback> playback = AnimationTreeEditor::get_singleton()->get_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + "playback"); Ref<AnimationNodeStateMachinePlayback> playback = AnimationTreeEditor::get_singleton()->get_animation_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + "playback");
Ref<StyleBoxFlat> style = get_theme_stylebox(SNAME("state_machine_frame"), SNAME("GraphNode")); Ref<StyleBoxFlat> style = get_theme_stylebox(SNAME("state_machine_frame"), SNAME("GraphNode"));
Ref<StyleBoxFlat> style_selected = get_theme_stylebox(SNAME("state_machine_selected_frame"), SNAME("GraphNode")); Ref<StyleBoxFlat> style_selected = get_theme_stylebox(SNAME("state_machine_selected_frame"), SNAME("GraphNode"));
@ -1369,7 +1369,7 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() {
} }
StringName fullpath = AnimationTreeEditor::get_singleton()->get_base_path() + String(tl.advance_condition_name); StringName fullpath = AnimationTreeEditor::get_singleton()->get_base_path() + String(tl.advance_condition_name);
if (tl.advance_condition_name != StringName() && bool(AnimationTreeEditor::get_singleton()->get_tree()->get(fullpath))) { if (tl.advance_condition_name != StringName() && bool(AnimationTreeEditor::get_singleton()->get_animation_tree()->get(fullpath))) {
tl.advance_condition_state = true; tl.advance_condition_state = true;
tl.auto_advance = true; tl.auto_advance = true;
} }
@ -1484,7 +1484,7 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() {
} }
void AnimationNodeStateMachineEditor::_state_machine_pos_draw() { void AnimationNodeStateMachineEditor::_state_machine_pos_draw() {
Ref<AnimationNodeStateMachinePlayback> playback = AnimationTreeEditor::get_singleton()->get_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + "playback"); Ref<AnimationNodeStateMachinePlayback> playback = AnimationTreeEditor::get_singleton()->get_animation_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + "playback");
if (!playback.is_valid() || !playback->is_playing()) { if (!playback.is_valid() || !playback->is_playing()) {
return; return;
@ -1578,15 +1578,15 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) {
case NOTIFICATION_PROCESS: { case NOTIFICATION_PROCESS: {
String error; String error;
Ref<AnimationNodeStateMachinePlayback> playback = AnimationTreeEditor::get_singleton()->get_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + "playback"); Ref<AnimationNodeStateMachinePlayback> playback = AnimationTreeEditor::get_singleton()->get_animation_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + "playback");
if (error_time > 0) { if (error_time > 0) {
error = error_text; error = error_text;
error_time -= get_process_delta_time(); error_time -= get_process_delta_time();
} else if (!AnimationTreeEditor::get_singleton()->get_tree()->is_active()) { } else if (!AnimationTreeEditor::get_singleton()->get_animation_tree()->is_active()) {
error = TTR("AnimationTree is inactive.\nActivate to enable playback, check node warnings if activation fails."); error = TTR("AnimationTree is inactive.\nActivate to enable playback, check node warnings if activation fails.");
} else if (AnimationTreeEditor::get_singleton()->get_tree()->is_state_invalid()) { } else if (AnimationTreeEditor::get_singleton()->get_animation_tree()->is_state_invalid()) {
error = AnimationTreeEditor::get_singleton()->get_tree()->get_invalid_state_reason(); error = AnimationTreeEditor::get_singleton()->get_animation_tree()->get_invalid_state_reason();
/*} else if (state_machine->get_parent().is_valid() && state_machine->get_parent()->is_class("AnimationNodeStateMachine")) { /*} else if (state_machine->get_parent().is_valid() && state_machine->get_parent()->is_class("AnimationNodeStateMachine")) {
if (state_machine->get_start_node() == StringName() || state_machine->get_end_node() == StringName()) { if (state_machine->get_start_node() == StringName() || state_machine->get_end_node() == StringName()) {
error = TTR("Start and end nodes are needed for a sub-transition."); error = TTR("Start and end nodes are needed for a sub-transition.");
@ -1638,7 +1638,7 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) {
break; break;
} }
bool acstate = transition_lines[i].advance_condition_name != StringName() && bool(AnimationTreeEditor::get_singleton()->get_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + String(transition_lines[i].advance_condition_name))); bool acstate = transition_lines[i].advance_condition_name != StringName() && bool(AnimationTreeEditor::get_singleton()->get_animation_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + String(transition_lines[i].advance_condition_name)));
if (transition_lines[i].advance_condition_state != acstate) { if (transition_lines[i].advance_condition_state != acstate) {
state_machine_draw->queue_redraw(); state_machine_draw->queue_redraw();
@ -1693,7 +1693,7 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) {
Ref<AnimationNodeStateMachinePlayback> current_node_playback; Ref<AnimationNodeStateMachinePlayback> current_node_playback;
while (anodesm.is_valid()) { while (anodesm.is_valid()) {
current_node_playback = AnimationTreeEditor::get_singleton()->get_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + next + "/playback"); current_node_playback = AnimationTreeEditor::get_singleton()->get_animation_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + next + "/playback");
next += "/" + current_node_playback->get_current_node(); next += "/" + current_node_playback->get_current_node();
anodesm = anodesm->get_node(current_node_playback->get_current_node()); anodesm = anodesm->get_node(current_node_playback->get_current_node());
} }

View file

@ -74,6 +74,12 @@ void AnimationTreeEditor::edit(AnimationTree *p_tree) {
edit_path(path); edit_path(path);
} }
void AnimationTreeEditor::_node_removed(Node *p_node) {
if (p_node == tree) {
tree = nullptr;
}
}
void AnimationTreeEditor::_path_button_pressed(int p_path) { void AnimationTreeEditor::_path_button_pressed(int p_path) {
edited_path.clear(); edited_path.clear();
for (int i = 0; i <= p_path; i++) { for (int i = 0; i <= p_path; i++) {
@ -167,6 +173,9 @@ void AnimationTreeEditor::enter_editor(const String &p_path) {
void AnimationTreeEditor::_notification(int p_what) { void AnimationTreeEditor::_notification(int p_what) {
switch (p_what) { switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
get_tree()->connect("node_removed", callable_mp(this, &AnimationTreeEditor::_node_removed));
} break;
case NOTIFICATION_PROCESS: { case NOTIFICATION_PROCESS: {
ObjectID root; ObjectID root;
if (tree && tree->get_tree_root().is_valid()) { if (tree && tree->get_tree_root().is_valid()) {
@ -181,6 +190,9 @@ void AnimationTreeEditor::_notification(int p_what) {
edit_path(edited_path); edit_path(edited_path);
} }
} break; } break;
case NOTIFICATION_EXIT_TREE: {
get_tree()->disconnect("node_removed", callable_mp(this, &AnimationTreeEditor::_node_removed));
} break;
} }
} }

View file

@ -69,12 +69,13 @@ class AnimationTreeEditor : public VBoxContainer {
protected: protected:
void _notification(int p_what); void _notification(int p_what);
void _node_removed(Node *p_node);
static void _bind_methods(); static void _bind_methods();
static AnimationTreeEditor *singleton; static AnimationTreeEditor *singleton;
public: public:
AnimationTree *get_tree() { return tree; } AnimationTree *get_animation_tree() { return tree; }
void add_plugin(AnimationTreeNodeEditorPlugin *p_editor); void add_plugin(AnimationTreeNodeEditorPlugin *p_editor);
void remove_plugin(AnimationTreeNodeEditorPlugin *p_editor); void remove_plugin(AnimationTreeNodeEditorPlugin *p_editor);