|
@@ -99,6 +99,9 @@ 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_animation_tree();
|
|
AnimationTree *tree = AnimationTreeEditor::get_singleton()->get_animation_tree();
|
|
|
|
+ if (!tree) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
updating = true;
|
|
updating = true;
|
|
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
|
Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo();
|
|
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);
|
|
@@ -115,6 +118,11 @@ void AnimationNodeBlendTreeEditor::update_graph() {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ AnimationTree *tree = AnimationTreeEditor::get_singleton()->get_animation_tree();
|
|
|
|
+ if (!tree) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
visible_properties.clear();
|
|
visible_properties.clear();
|
|
|
|
|
|
graph->set_scroll_ofs(blend_tree->get_graph_offset() * EDSCALE);
|
|
graph->set_scroll_ofs(blend_tree->get_graph_offset() * EDSCALE);
|
|
@@ -177,10 +185,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_animation_tree(), F.type, base_path, F.hint, F.hint_string, F.usage);
|
|
|
|
|
|
+ EditorProperty *prop = EditorInspector::instantiate_property_editor(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_animation_tree(), base_path);
|
|
|
|
|
|
+ prop->set_object_and_property(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));
|
|
@@ -228,9 +236,8 @@ void AnimationNodeBlendTreeEditor::update_graph() {
|
|
|
|
|
|
ProgressBar *pb = memnew(ProgressBar);
|
|
ProgressBar *pb = memnew(ProgressBar);
|
|
|
|
|
|
- AnimationTree *player = AnimationTreeEditor::get_singleton()->get_animation_tree();
|
|
|
|
- if (player->has_node(player->get_animation_player())) {
|
|
|
|
- AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(player->get_node(player->get_animation_player()));
|
|
|
|
|
|
+ if (tree->has_node(tree->get_animation_player())) {
|
|
|
|
+ AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(tree->get_node(tree->get_animation_player()));
|
|
if (ap) {
|
|
if (ap) {
|
|
List<StringName> anims;
|
|
List<StringName> anims;
|
|
ap->get_animation_list(&anims);
|
|
ap->get_animation_list(&anims);
|
|
@@ -601,14 +608,19 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
- NodePath player_path = AnimationTreeEditor::get_singleton()->get_animation_tree()->get_animation_player();
|
|
|
|
|
|
+ AnimationTree *tree = AnimationTreeEditor::get_singleton()->get_animation_tree();
|
|
|
|
+ if (!tree) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ NodePath player_path = tree->get_animation_player();
|
|
|
|
|
|
- if (!AnimationTreeEditor::get_singleton()->get_animation_tree()->has_node(player_path)) {
|
|
|
|
|
|
+ if (!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_animation_tree()->get_node(player_path));
|
|
|
|
|
|
+ AnimationPlayer *player = Object::cast_to<AnimationPlayer>(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;
|
|
@@ -839,12 +851,17 @@ void AnimationNodeBlendTreeEditor::_notification(int p_what) {
|
|
} break;
|
|
} break;
|
|
|
|
|
|
case NOTIFICATION_PROCESS: {
|
|
case NOTIFICATION_PROCESS: {
|
|
|
|
+ AnimationTree *tree = AnimationTreeEditor::get_singleton()->get_animation_tree();
|
|
|
|
+ if (!tree) {
|
|
|
|
+ return; // Node has been changed.
|
|
|
|
+ }
|
|
|
|
+
|
|
String error;
|
|
String error;
|
|
|
|
|
|
- if (!AnimationTreeEditor::get_singleton()->get_animation_tree()->is_active()) {
|
|
|
|
|
|
+ if (!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_animation_tree()->is_state_invalid()) {
|
|
|
|
- error = AnimationTreeEditor::get_singleton()->get_animation_tree()->get_invalid_state_reason();
|
|
|
|
|
|
+ } else if (tree->is_state_invalid()) {
|
|
|
|
+ error = tree->get_invalid_state_reason();
|
|
}
|
|
}
|
|
|
|
|
|
if (error != error_label->get_text()) {
|
|
if (error != error_label->get_text()) {
|
|
@@ -861,16 +878,15 @@ 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_animation_tree() && !AnimationTreeEditor::get_singleton()->get_animation_tree()->is_state_invalid()) {
|
|
|
|
- activity = AnimationTreeEditor::get_singleton()->get_animation_tree()->get_connection_activity(path, E.input_index);
|
|
|
|
|
|
+ if (!tree->is_state_invalid()) {
|
|
|
|
+ activity = 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_animation_tree();
|
|
|
|
AnimationPlayer *player = nullptr;
|
|
AnimationPlayer *player = nullptr;
|
|
- if (graph_player->has_node(graph_player->get_animation_player())) {
|
|
|
|
- player = Object::cast_to<AnimationPlayer>(graph_player->get_node(graph_player->get_animation_player()));
|
|
|
|
|
|
+ if (tree->has_node(tree->get_animation_player())) {
|
|
|
|
+ player = Object::cast_to<AnimationPlayer>(tree->get_node(tree->get_animation_player()));
|
|
}
|
|
}
|
|
|
|
|
|
if (player) {
|
|
if (player) {
|
|
@@ -883,7 +899,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_animation_tree()->get(time_path));
|
|
|
|
|
|
+ E.value->set_value(tree->get(time_path));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -937,6 +953,11 @@ void AnimationNodeBlendTreeEditor::_node_renamed(const String &p_text, Ref<Anima
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ AnimationTree *tree = AnimationTreeEditor::get_singleton()->get_animation_tree();
|
|
|
|
+ if (!tree) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
String prev_name = blend_tree->get_node_name(p_node);
|
|
String prev_name = blend_tree->get_node_name(p_node);
|
|
ERR_FAIL_COND(prev_name.is_empty());
|
|
ERR_FAIL_COND(prev_name.is_empty());
|
|
GraphNode *gn = Object::cast_to<GraphNode>(graph->get_node(prev_name));
|
|
GraphNode *gn = Object::cast_to<GraphNode>(graph->get_node(prev_name));
|
|
@@ -965,8 +986,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_animation_tree(), "rename_parameter", base_path + prev_name, base_path + 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(tree, "rename_parameter", base_path + prev_name, base_path + name);
|
|
|
|
+ undo_redo->add_undo_method(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();
|