renamed AnimationGraphPlayer to AnimationTree
This commit is contained in:
parent
87f48e7a3e
commit
8c7da84e1e
16 changed files with 124 additions and 119 deletions
5
editor/icons/icon_animation_tree.svg
Normal file
5
editor/icons/icon_animation_tree.svg
Normal file
|
@ -0,0 +1,5 @@
|
|||
<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
|
||||
<g transform="translate(0 -1036.4)">
|
||||
<path transform="translate(0 1036.4)" d="m1 1v14h1.166v-2h1.834v2h8v-2h2v2h1v-14h-1v2h-2v-2h-8v2h-1.834v-2h-1.166zm4 3h2v1 1h1 3v2h-2v1 1h1 1v2h-1-2a1.0001 1.0001 0 0 1 -1 -1v-1-2h-1a1.0001 1.0001 0 0 1 -1 -1v-1-1-1zm-2.834 1h1.834v2h-1.834v-2zm9.834 0h2v2h-2v-2zm-9.834 4h1.834v2h-1.834v-2zm9.834 0h2v2h-2v-2z" fill="#cea4f1"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 476 B |
|
@ -62,7 +62,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven
|
|||
|
||||
menu->add_submenu_item(TTR("Add Animation"), "animations");
|
||||
|
||||
AnimationGraphPlayer *gp = blend_space->get_graph_player();
|
||||
AnimationTree *gp = blend_space->get_tree();
|
||||
ERR_FAIL_COND(!gp);
|
||||
|
||||
if (gp->has_node(gp->get_animation_player())) {
|
||||
|
@ -519,12 +519,12 @@ void AnimationNodeBlendSpace1DEditor::_notification(int p_what) {
|
|||
if (p_what == NOTIFICATION_PROCESS) {
|
||||
String error;
|
||||
|
||||
if (!blend_space->get_graph_player()) {
|
||||
error = TTR("BlendSpace1D does not belong to an AnimationGraphPlayer node.");
|
||||
} else if (!blend_space->get_graph_player()->is_active()) {
|
||||
error = TTR("AnimationGraphPlayer is inactive.\nActivate to enable playback, check node warnings if activation fails.");
|
||||
} else if (blend_space->get_graph_player()->is_state_invalid()) {
|
||||
error = blend_space->get_graph_player()->get_invalid_state_reason();
|
||||
if (!blend_space->get_tree()) {
|
||||
error = TTR("BlendSpace1D does not belong to an AnimationTree node.");
|
||||
} else if (!blend_space->get_tree()->is_active()) {
|
||||
error = TTR("AnimationTree is inactive.\nActivate to enable playback, check node warnings if activation fails.");
|
||||
} else if (blend_space->get_tree()->is_state_invalid()) {
|
||||
error = blend_space->get_tree()->get_invalid_state_reason();
|
||||
}
|
||||
|
||||
if (error != error_label->get_text()) {
|
||||
|
|
|
@ -54,7 +54,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven
|
|||
ClassDB::get_inheriters_from_class("AnimationRootNode", &classes);
|
||||
menu->add_submenu_item(TTR("Add Animation"), "animations");
|
||||
|
||||
AnimationGraphPlayer *gp = blend_space->get_graph_player();
|
||||
AnimationTree *gp = blend_space->get_tree();
|
||||
ERR_FAIL_COND(!gp);
|
||||
if (gp && gp->has_node(gp->get_animation_player())) {
|
||||
AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(gp->get_node(gp->get_animation_player()));
|
||||
|
@ -693,12 +693,12 @@ void AnimationNodeBlendSpace2DEditor::_notification(int p_what) {
|
|||
|
||||
String error;
|
||||
|
||||
if (!blend_space->get_graph_player()) {
|
||||
error = TTR("BlendSpace2D does not belong to an AnimationGraphPlayer node.");
|
||||
} else if (!blend_space->get_graph_player()->is_active()) {
|
||||
error = TTR("AnimationGraphPlayer is inactive.\nActivate to enable playback, check node warnings if activation fails.");
|
||||
} else if (blend_space->get_graph_player()->is_state_invalid()) {
|
||||
error = blend_space->get_graph_player()->get_invalid_state_reason();
|
||||
if (!blend_space->get_tree()) {
|
||||
error = TTR("BlendSpace2D does not belong to an AnimationTree node.");
|
||||
} else if (!blend_space->get_tree()->is_active()) {
|
||||
error = TTR("AnimationTree is inactive.\nActivate to enable playback, check node warnings if activation fails.");
|
||||
} else if (blend_space->get_tree()->is_state_invalid()) {
|
||||
error = blend_space->get_tree()->get_invalid_state_reason();
|
||||
} else if (blend_space->get_triangle_count() == 0) {
|
||||
error = TTR("No triangles exist, so no blending can take place.");
|
||||
}
|
||||
|
|
|
@ -169,7 +169,7 @@ void AnimationNodeBlendTreeEditor::_update_graph() {
|
|||
|
||||
ProgressBar *pb = memnew(ProgressBar);
|
||||
|
||||
AnimationGraphPlayer *player = anim->get_graph_player();
|
||||
AnimationTree *player = anim->get_tree();
|
||||
if (player->has_node(player->get_animation_player())) {
|
||||
AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(player->get_node(player->get_animation_player()));
|
||||
if (ap) {
|
||||
|
@ -417,14 +417,14 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano
|
|||
if (updating || _filter_edit != anode)
|
||||
return false;
|
||||
|
||||
NodePath player_path = anode->get_graph_player()->get_animation_player();
|
||||
NodePath player_path = anode->get_tree()->get_animation_player();
|
||||
|
||||
if (!anode->get_graph_player()->has_node(player_path)) {
|
||||
if (!anode->get_tree()->has_node(player_path)) {
|
||||
EditorNode::get_singleton()->show_warning(TTR("No animation player set, so unable to retrieve track names."));
|
||||
return false;
|
||||
}
|
||||
|
||||
AnimationPlayer *player = Object::cast_to<AnimationPlayer>(anode->get_graph_player()->get_node(player_path));
|
||||
AnimationPlayer *player = Object::cast_to<AnimationPlayer>(anode->get_tree()->get_node(player_path));
|
||||
if (!player) {
|
||||
EditorNode::get_singleton()->show_warning(TTR("Player path set is invalid, so unable to retrieve track names."));
|
||||
return false;
|
||||
|
@ -603,12 +603,12 @@ void AnimationNodeBlendTreeEditor::_notification(int p_what) {
|
|||
|
||||
String error;
|
||||
|
||||
if (!blend_tree->get_graph_player()) {
|
||||
error = TTR("BlendTree does not belong to an AnimationGraphPlayer node.");
|
||||
} else if (!blend_tree->get_graph_player()->is_active()) {
|
||||
error = TTR("AnimationGraphPlayer is inactive.\nActivate to enable playback, check node warnings if activation fails.");
|
||||
} else if (blend_tree->get_graph_player()->is_state_invalid()) {
|
||||
error = blend_tree->get_graph_player()->get_invalid_state_reason();
|
||||
if (!blend_tree->get_tree()) {
|
||||
error = TTR("BlendTree does not belong to an AnimationTree node.");
|
||||
} else if (!blend_tree->get_tree()->is_active()) {
|
||||
error = TTR("AnimationTree is inactive.\nActivate to enable playback, check node warnings if activation fails.");
|
||||
} else if (blend_tree->get_tree()->is_state_invalid()) {
|
||||
error = blend_tree->get_tree()->get_invalid_state_reason();
|
||||
}
|
||||
|
||||
if (error != error_label->get_text()) {
|
||||
|
@ -624,13 +624,13 @@ void AnimationNodeBlendTreeEditor::_notification(int p_what) {
|
|||
blend_tree->get_node_connections(&conns);
|
||||
for (List<AnimationNodeBlendTree::NodeConnection>::Element *E = conns.front(); E; E = E->next()) {
|
||||
float activity = 0;
|
||||
if (blend_tree->get_graph_player() && !blend_tree->get_graph_player()->is_state_invalid()) {
|
||||
if (blend_tree->get_tree() && !blend_tree->get_tree()->is_state_invalid()) {
|
||||
activity = blend_tree->get_connection_activity(E->get().input_node, E->get().input_index);
|
||||
}
|
||||
graph->set_connection_activity(E->get().output_node, 0, E->get().input_node, E->get().input_index, activity);
|
||||
}
|
||||
|
||||
AnimationGraphPlayer *graph_player = blend_tree->get_graph_player();
|
||||
AnimationTree *graph_player = blend_tree->get_tree();
|
||||
AnimationPlayer *player = NULL;
|
||||
if (graph_player->has_node(graph_player->get_animation_player())) {
|
||||
player = Object::cast_to<AnimationPlayer>(graph_player->get_node(graph_player->get_animation_player()));
|
||||
|
|
|
@ -59,7 +59,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
|
|||
ClassDB::get_inheriters_from_class("AnimationRootNode", &classes);
|
||||
menu->add_submenu_item(TTR("Add Animation"), "animations");
|
||||
|
||||
AnimationGraphPlayer *gp = state_machine->get_graph_player();
|
||||
AnimationTree *gp = state_machine->get_tree();
|
||||
ERR_FAIL_COND(!gp);
|
||||
if (gp && gp->has_node(gp->get_animation_player())) {
|
||||
AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(gp->get_node(gp->get_animation_player()));
|
||||
|
@ -859,12 +859,12 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) {
|
|||
if (error_time > 0) {
|
||||
error = error_text;
|
||||
error_time -= get_process_delta_time();
|
||||
} else if (!state_machine->get_graph_player()) {
|
||||
error = TTR("StateMachine does not belong to an AnimationGraphPlayer node.");
|
||||
} else if (!state_machine->get_graph_player()->is_active()) {
|
||||
error = TTR("AnimationGraphPlayer is inactive.\nActivate to enable playback, check node warnings if activation fails.");
|
||||
} else if (state_machine->get_graph_player()->is_state_invalid()) {
|
||||
error = state_machine->get_graph_player()->get_invalid_state_reason();
|
||||
} else if (!state_machine->get_tree()) {
|
||||
error = TTR("StateMachine does not belong to an AnimationTree node.");
|
||||
} else if (!state_machine->get_tree()->is_active()) {
|
||||
error = TTR("AnimationTree is inactive.\nActivate to enable playback, check node warnings if activation fails.");
|
||||
} else if (state_machine->get_tree()->is_state_invalid()) {
|
||||
error = state_machine->get_tree()->get_invalid_state_reason();
|
||||
} 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()) {
|
||||
error = TTR("Start and end nodes are needed for a sub-transition.");
|
||||
|
|
|
@ -67,7 +67,7 @@ void AnimationNodeBlendSpace1D::add_blend_point(const Ref<AnimationRootNode> &p_
|
|||
blend_points[p_at_index].position = p_position;
|
||||
|
||||
blend_points[p_at_index].node->set_parent(this);
|
||||
blend_points[p_at_index].node->set_graph_player(get_graph_player());
|
||||
blend_points[p_at_index].node->set_tree(get_tree());
|
||||
|
||||
blend_points_used++;
|
||||
}
|
||||
|
@ -84,12 +84,12 @@ void AnimationNodeBlendSpace1D::set_blend_point_node(int p_point, const Ref<Anim
|
|||
|
||||
if (blend_points[p_point].node.is_valid()) {
|
||||
blend_points[p_point].node->set_parent(NULL);
|
||||
blend_points[p_point].node->set_graph_player(NULL);
|
||||
blend_points[p_point].node->set_tree(NULL);
|
||||
}
|
||||
|
||||
blend_points[p_point].node = p_node;
|
||||
blend_points[p_point].node->set_parent(this);
|
||||
blend_points[p_point].node->set_graph_player(get_graph_player());
|
||||
blend_points[p_point].node->set_tree(get_tree());
|
||||
}
|
||||
|
||||
float AnimationNodeBlendSpace1D::get_blend_point_position(int p_point) const {
|
||||
|
@ -106,7 +106,7 @@ void AnimationNodeBlendSpace1D::remove_blend_point(int p_point) {
|
|||
ERR_FAIL_INDEX(p_point, blend_points_used);
|
||||
|
||||
blend_points[p_point].node->set_parent(NULL);
|
||||
blend_points[p_point].node->set_graph_player(NULL);
|
||||
blend_points[p_point].node->set_tree(NULL);
|
||||
|
||||
for (int i = p_point; i < blend_points_used - 1; i++) {
|
||||
blend_points[i] = blend_points[i + 1];
|
||||
|
@ -267,6 +267,6 @@ AnimationNodeBlendSpace1D::~AnimationNodeBlendSpace1D() {
|
|||
|
||||
for (int i = 0; i < blend_points_used; i++) {
|
||||
blend_points[i].node->set_parent(this);
|
||||
blend_points[i].node->set_graph_player(get_graph_player());
|
||||
blend_points[i].node->set_tree(get_tree());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef ANIMATION_BLEND_SPACE_1D_H
|
||||
#define ANIMATION_BLEND_SPACE_1D_H
|
||||
|
||||
#include "scene/animation/animation_graph_player.h"
|
||||
#include "scene/animation/animation_tree.h"
|
||||
|
||||
class AnimationNodeBlendSpace1D : public AnimationRootNode {
|
||||
GDCLASS(AnimationNodeBlendSpace1D, AnimationRootNode)
|
||||
|
|
|
@ -25,7 +25,7 @@ void AnimationNodeBlendSpace2D::add_blend_point(const Ref<AnimationRootNode> &p_
|
|||
blend_points[p_at_index].position = p_position;
|
||||
|
||||
blend_points[p_at_index].node->set_parent(this);
|
||||
blend_points[p_at_index].node->set_graph_player(get_graph_player());
|
||||
blend_points[p_at_index].node->set_tree(get_tree());
|
||||
blend_points_used++;
|
||||
|
||||
if (auto_triangles) {
|
||||
|
@ -46,11 +46,11 @@ void AnimationNodeBlendSpace2D::set_blend_point_node(int p_point, const Ref<Anim
|
|||
|
||||
if (blend_points[p_point].node.is_valid()) {
|
||||
blend_points[p_point].node->set_parent(NULL);
|
||||
blend_points[p_point].node->set_graph_player(NULL);
|
||||
blend_points[p_point].node->set_tree(NULL);
|
||||
}
|
||||
blend_points[p_point].node = p_node;
|
||||
blend_points[p_point].node->set_parent(this);
|
||||
blend_points[p_point].node->set_graph_player(get_graph_player());
|
||||
blend_points[p_point].node->set_tree(get_tree());
|
||||
}
|
||||
Vector2 AnimationNodeBlendSpace2D::get_blend_point_position(int p_point) const {
|
||||
ERR_FAIL_INDEX_V(p_point, blend_points_used, Vector2());
|
||||
|
@ -64,7 +64,7 @@ void AnimationNodeBlendSpace2D::remove_blend_point(int p_point) {
|
|||
ERR_FAIL_INDEX(p_point, blend_points_used);
|
||||
|
||||
blend_points[p_point].node->set_parent(NULL);
|
||||
blend_points[p_point].node->set_graph_player(NULL);
|
||||
blend_points[p_point].node->set_tree(NULL);
|
||||
|
||||
for (int i = 0; i < triangles.size(); i++) {
|
||||
bool erase = false;
|
||||
|
@ -553,6 +553,6 @@ AnimationNodeBlendSpace2D::~AnimationNodeBlendSpace2D() {
|
|||
|
||||
for (int i = 0; i < blend_points_used; i++) {
|
||||
blend_points[i].node->set_parent(this);
|
||||
blend_points[i].node->set_graph_player(get_graph_player());
|
||||
blend_points[i].node->set_tree(get_tree());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef ANIMATION_BLEND_SPACE_2D_H
|
||||
#define ANIMATION_BLEND_SPACE_2D_H
|
||||
|
||||
#include "scene/animation/animation_graph_player.h"
|
||||
#include "scene/animation/animation_tree.h"
|
||||
|
||||
class AnimationNodeBlendSpace2D : public AnimationRootNode {
|
||||
GDCLASS(AnimationNodeBlendSpace2D, AnimationRootNode)
|
||||
|
|
|
@ -16,7 +16,7 @@ float AnimationNodeAnimation::get_playback_time() const {
|
|||
void AnimationNodeAnimation::_validate_property(PropertyInfo &property) const {
|
||||
|
||||
if (property.name == "animation") {
|
||||
AnimationGraphPlayer *gp = get_graph_player();
|
||||
AnimationTree *gp = get_tree();
|
||||
if (gp && gp->has_node(gp->get_animation_player())) {
|
||||
AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(gp->get_node(gp->get_animation_player()));
|
||||
if (ap) {
|
||||
|
@ -762,13 +762,13 @@ void AnimationNodeBlendTree::add_node(const StringName &p_name, Ref<AnimationNod
|
|||
ERR_FAIL_COND(nodes.has(p_name));
|
||||
ERR_FAIL_COND(p_node.is_null());
|
||||
ERR_FAIL_COND(p_node->get_parent().is_valid());
|
||||
ERR_FAIL_COND(p_node->get_graph_player() != NULL);
|
||||
ERR_FAIL_COND(p_node->get_tree() != NULL);
|
||||
ERR_FAIL_COND(p_name == SceneStringNames::get_singleton()->output);
|
||||
ERR_FAIL_COND(String(p_name).find("/") != -1);
|
||||
nodes[p_name] = p_node;
|
||||
|
||||
p_node->set_parent(this);
|
||||
p_node->set_graph_player(get_graph_player());
|
||||
p_node->set_tree(get_tree());
|
||||
|
||||
emit_changed();
|
||||
}
|
||||
|
@ -804,7 +804,7 @@ void AnimationNodeBlendTree::remove_node(const StringName &p_name) {
|
|||
node->set_input_connection(i, StringName());
|
||||
}
|
||||
node->set_parent(NULL);
|
||||
node->set_graph_player(NULL);
|
||||
node->set_tree(NULL);
|
||||
}
|
||||
|
||||
nodes.erase(p_name);
|
||||
|
@ -965,13 +965,13 @@ Vector2 AnimationNodeBlendTree::get_graph_offset() const {
|
|||
return graph_offset;
|
||||
}
|
||||
|
||||
void AnimationNodeBlendTree::set_graph_player(AnimationGraphPlayer *p_player) {
|
||||
void AnimationNodeBlendTree::set_tree(AnimationTree *p_player) {
|
||||
|
||||
AnimationNode::set_graph_player(p_player);
|
||||
AnimationNode::set_tree(p_player);
|
||||
|
||||
for (Map<StringName, Ref<AnimationNode> >::Element *E = nodes.front(); E; E = E->next()) {
|
||||
Ref<AnimationNode> node = E->get();
|
||||
node->set_graph_player(p_player);
|
||||
node->set_tree(p_player);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1107,6 +1107,6 @@ AnimationNodeBlendTree::~AnimationNodeBlendTree() {
|
|||
|
||||
for (Map<StringName, Ref<AnimationNode> >::Element *E = nodes.front(); E; E = E->next()) {
|
||||
E->get()->set_parent(NULL);
|
||||
E->get()->set_graph_player(NULL);
|
||||
E->get()->set_tree(NULL);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef ANIMATION_BLEND_TREE_H
|
||||
#define ANIMATION_BLEND_TREE_H
|
||||
|
||||
#include "scene/animation/animation_graph_player.h"
|
||||
#include "scene/animation/animation_tree.h"
|
||||
|
||||
class AnimationNodeAnimation : public AnimationRootNode {
|
||||
|
||||
|
@ -318,7 +318,7 @@ public:
|
|||
void set_graph_offset(const Vector2 &p_graph_offset);
|
||||
Vector2 get_graph_offset() const;
|
||||
|
||||
virtual void set_graph_player(AnimationGraphPlayer *p_player);
|
||||
virtual void set_tree(AnimationTree *p_player);
|
||||
AnimationNodeBlendTree();
|
||||
~AnimationNodeBlendTree();
|
||||
};
|
||||
|
|
|
@ -91,12 +91,12 @@ void AnimationNodeStateMachine::add_node(const StringName &p_name, Ref<Animation
|
|||
ERR_FAIL_COND(states.has(p_name));
|
||||
ERR_FAIL_COND(p_node.is_null());
|
||||
ERR_FAIL_COND(p_node->get_parent().is_valid());
|
||||
ERR_FAIL_COND(p_node->get_graph_player() != NULL);
|
||||
ERR_FAIL_COND(p_node->get_tree() != NULL);
|
||||
ERR_FAIL_COND(String(p_name).find("/") != -1);
|
||||
states[p_name] = p_node;
|
||||
|
||||
p_node->set_parent(this);
|
||||
p_node->set_graph_player(get_graph_player());
|
||||
p_node->set_tree(get_tree());
|
||||
|
||||
emit_changed();
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ void AnimationNodeStateMachine::remove_node(const StringName &p_name) {
|
|||
node->set_input_connection(i, StringName());
|
||||
}
|
||||
node->set_parent(NULL);
|
||||
node->set_graph_player(NULL);
|
||||
node->set_tree(NULL);
|
||||
}
|
||||
|
||||
states.erase(p_name);
|
||||
|
@ -623,13 +623,13 @@ String AnimationNodeStateMachine::get_caption() const {
|
|||
void AnimationNodeStateMachine::_notification(int p_what) {
|
||||
}
|
||||
|
||||
void AnimationNodeStateMachine::set_graph_player(AnimationGraphPlayer *p_player) {
|
||||
void AnimationNodeStateMachine::set_tree(AnimationTree *p_player) {
|
||||
|
||||
AnimationNode::set_graph_player(p_player);
|
||||
AnimationNode::set_tree(p_player);
|
||||
|
||||
for (Map<StringName, Ref<AnimationRootNode> >::Element *E = states.front(); E; E = E->next()) {
|
||||
Ref<AnimationRootNode> node = E->get();
|
||||
node->set_graph_player(p_player);
|
||||
node->set_tree(p_player);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef ANIMATION_NODE_STATE_MACHINE_H
|
||||
#define ANIMATION_NODE_STATE_MACHINE_H
|
||||
|
||||
#include "scene/animation/animation_graph_player.h"
|
||||
#include "scene/animation/animation_tree.h"
|
||||
|
||||
class AnimationNodeStateMachineTransition : public Resource {
|
||||
GDCLASS(AnimationNodeStateMachineTransition, Resource)
|
||||
|
@ -134,7 +134,7 @@ public:
|
|||
float get_current_play_pos() const;
|
||||
float get_current_length() const;
|
||||
|
||||
virtual void set_graph_player(AnimationGraphPlayer *p_player);
|
||||
virtual void set_tree(AnimationTree *p_player);
|
||||
|
||||
AnimationNodeStateMachine();
|
||||
};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "animation_graph_player.h"
|
||||
#include "animation_tree.h"
|
||||
#include "animation_blend_tree.h"
|
||||
#include "core/method_bind_ext.gen.inc"
|
||||
#include "engine.h"
|
||||
|
@ -56,11 +56,11 @@ void AnimationNode::make_invalid(const String &p_reason) {
|
|||
float AnimationNode::blend_input(int p_input, float p_time, bool p_seek, float p_blend, FilterAction p_filter, bool p_optimize) {
|
||||
ERR_FAIL_INDEX_V(p_input, inputs.size(), 0);
|
||||
ERR_FAIL_COND_V(!state, 0);
|
||||
ERR_FAIL_COND_V(!get_graph_player(), 0); //should not happen, but used to catch bugs
|
||||
ERR_FAIL_COND_V(!get_tree(), 0); //should not happen, but used to catch bugs
|
||||
|
||||
Ref<AnimationNodeBlendTree> tree = get_parent();
|
||||
|
||||
if (!tree.is_valid() && get_graph_player()->get_graph_root().ptr() != this) {
|
||||
if (!tree.is_valid() && get_tree()->get_graph_root().ptr() != this) {
|
||||
make_invalid(RTR("Can't blend input because node is not in a tree"));
|
||||
return 0;
|
||||
}
|
||||
|
@ -204,10 +204,10 @@ String AnimationNode::get_input_name(int p_input) {
|
|||
float AnimationNode::get_input_activity(int p_input) const {
|
||||
|
||||
ERR_FAIL_INDEX_V(p_input, inputs.size(), 0);
|
||||
if (!get_graph_player())
|
||||
if (!get_tree())
|
||||
return 0;
|
||||
|
||||
if (get_graph_player()->get_last_process_pass() != inputs[p_input].last_pass) {
|
||||
if (get_tree()->get_last_process_pass() != inputs[p_input].last_pass) {
|
||||
return 0;
|
||||
}
|
||||
return inputs[p_input].activity;
|
||||
|
@ -265,7 +265,7 @@ Ref<AnimationNode> AnimationNode::get_parent() const {
|
|||
return Ref<AnimationNode>();
|
||||
}
|
||||
|
||||
AnimationGraphPlayer *AnimationNode::get_graph_player() const {
|
||||
AnimationTree *AnimationNode::get_tree() const {
|
||||
|
||||
return player;
|
||||
}
|
||||
|
@ -316,7 +316,7 @@ Vector2 AnimationNode::get_position() const {
|
|||
return position;
|
||||
}
|
||||
|
||||
void AnimationNode::set_graph_player(AnimationGraphPlayer *p_player) {
|
||||
void AnimationNode::set_tree(AnimationTree *p_player) {
|
||||
|
||||
if (player != NULL && p_player == NULL) {
|
||||
emit_signal("removed_from_graph");
|
||||
|
@ -398,10 +398,10 @@ AnimationNode::AnimationNode() {
|
|||
|
||||
////////////////////
|
||||
|
||||
void AnimationGraphPlayer::set_graph_root(const Ref<AnimationNode> &p_root) {
|
||||
void AnimationTree::set_graph_root(const Ref<AnimationNode> &p_root) {
|
||||
|
||||
if (root.is_valid()) {
|
||||
root->set_graph_player(NULL);
|
||||
root->set_tree(NULL);
|
||||
}
|
||||
if (p_root.is_valid()) {
|
||||
ERR_EXPLAIN("root node already set to another player");
|
||||
|
@ -410,17 +410,17 @@ void AnimationGraphPlayer::set_graph_root(const Ref<AnimationNode> &p_root) {
|
|||
root = p_root;
|
||||
|
||||
if (root.is_valid()) {
|
||||
root->set_graph_player(this);
|
||||
root->set_tree(this);
|
||||
}
|
||||
|
||||
update_configuration_warning();
|
||||
}
|
||||
|
||||
Ref<AnimationNode> AnimationGraphPlayer::get_graph_root() const {
|
||||
Ref<AnimationNode> AnimationTree::get_graph_root() const {
|
||||
return root;
|
||||
}
|
||||
|
||||
void AnimationGraphPlayer::set_active(bool p_active) {
|
||||
void AnimationTree::set_active(bool p_active) {
|
||||
|
||||
if (active == p_active)
|
||||
return;
|
||||
|
@ -447,12 +447,12 @@ void AnimationGraphPlayer::set_active(bool p_active) {
|
|||
}
|
||||
}
|
||||
|
||||
bool AnimationGraphPlayer::is_active() const {
|
||||
bool AnimationTree::is_active() const {
|
||||
|
||||
return active;
|
||||
}
|
||||
|
||||
void AnimationGraphPlayer::set_process_mode(AnimationProcessMode p_mode) {
|
||||
void AnimationTree::set_process_mode(AnimationProcessMode p_mode) {
|
||||
|
||||
if (process_mode == p_mode)
|
||||
return;
|
||||
|
@ -469,20 +469,20 @@ void AnimationGraphPlayer::set_process_mode(AnimationProcessMode p_mode) {
|
|||
}
|
||||
}
|
||||
|
||||
AnimationGraphPlayer::AnimationProcessMode AnimationGraphPlayer::get_process_mode() const {
|
||||
AnimationTree::AnimationProcessMode AnimationTree::get_process_mode() const {
|
||||
return process_mode;
|
||||
}
|
||||
|
||||
void AnimationGraphPlayer::_node_removed(Node *p_node) {
|
||||
void AnimationTree::_node_removed(Node *p_node) {
|
||||
cache_valid = false;
|
||||
}
|
||||
|
||||
bool AnimationGraphPlayer::_update_caches(AnimationPlayer *player) {
|
||||
bool AnimationTree::_update_caches(AnimationPlayer *player) {
|
||||
|
||||
setup_pass++;
|
||||
|
||||
if (!player->has_node(player->get_root())) {
|
||||
ERR_PRINT("AnimationGraphPlayer: AnimationPlayer root is invalid.");
|
||||
ERR_PRINT("AnimationTree: AnimationPlayer root is invalid.");
|
||||
set_active(false);
|
||||
return false;
|
||||
}
|
||||
|
@ -517,7 +517,7 @@ bool AnimationGraphPlayer::_update_caches(AnimationPlayer *player) {
|
|||
Node *child = parent->get_node_and_resource(path, resource, leftover_path);
|
||||
|
||||
if (!child) {
|
||||
ERR_PRINTS("AnimationGraphPlayer: '" + String(E->get()) + "', couldn't resolve track: '" + String(path) + "'");
|
||||
ERR_PRINTS("AnimationTree: '" + String(E->get()) + "', couldn't resolve track: '" + String(path) + "'");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -547,7 +547,7 @@ bool AnimationGraphPlayer::_update_caches(AnimationPlayer *player) {
|
|||
Spatial *spatial = Object::cast_to<Spatial>(child);
|
||||
|
||||
if (!spatial) {
|
||||
ERR_PRINTS("AnimationGraphPlayer: '" + String(E->get()) + "', transform track does not point to spatial: '" + String(path) + "'");
|
||||
ERR_PRINTS("AnimationTree: '" + String(E->get()) + "', transform track does not point to spatial: '" + String(path) + "'");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -666,7 +666,7 @@ bool AnimationGraphPlayer::_update_caches(AnimationPlayer *player) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void AnimationGraphPlayer::_clear_caches() {
|
||||
void AnimationTree::_clear_caches() {
|
||||
|
||||
const NodePath *K = NULL;
|
||||
while ((K = track_cache.next(K))) {
|
||||
|
@ -678,19 +678,19 @@ void AnimationGraphPlayer::_clear_caches() {
|
|||
cache_valid = false;
|
||||
}
|
||||
|
||||
void AnimationGraphPlayer::_process_graph(float p_delta) {
|
||||
void AnimationTree::_process_graph(float p_delta) {
|
||||
|
||||
//check all tracks, see if they need modification
|
||||
|
||||
if (!root.is_valid()) {
|
||||
ERR_PRINT("AnimationGraphPlayer: root AnimationNode is not set, disabling playback.");
|
||||
ERR_PRINT("AnimationTree: root AnimationNode is not set, disabling playback.");
|
||||
set_active(false);
|
||||
cache_valid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!has_node(animation_player)) {
|
||||
ERR_PRINT("AnimationGraphPlayer: no valid AnimationPlayer path set, disabling playback");
|
||||
ERR_PRINT("AnimationTree: no valid AnimationPlayer path set, disabling playback");
|
||||
set_active(false);
|
||||
cache_valid = false;
|
||||
return;
|
||||
|
@ -699,7 +699,7 @@ void AnimationGraphPlayer::_process_graph(float p_delta) {
|
|||
AnimationPlayer *player = Object::cast_to<AnimationPlayer>(get_node(animation_player));
|
||||
|
||||
if (!player) {
|
||||
ERR_PRINT("AnimationGraphPlayer: path points to a node not an AnimationPlayer, disabling playback");
|
||||
ERR_PRINT("AnimationTree: path points to a node not an AnimationPlayer, disabling playback");
|
||||
set_active(false);
|
||||
cache_valid = false;
|
||||
return;
|
||||
|
@ -1093,7 +1093,7 @@ void AnimationGraphPlayer::_process_graph(float p_delta) {
|
|||
}
|
||||
}
|
||||
|
||||
void AnimationGraphPlayer::_notification(int p_what) {
|
||||
void AnimationTree::_notification(int p_what) {
|
||||
|
||||
if (active && p_what == NOTIFICATION_INTERNAL_PHYSICS_PROCESS && process_mode == ANIMATION_PROCESS_PHYSICS) {
|
||||
_process_graph(get_physics_process_delta_time());
|
||||
|
@ -1108,29 +1108,29 @@ void AnimationGraphPlayer::_notification(int p_what) {
|
|||
}
|
||||
}
|
||||
|
||||
void AnimationGraphPlayer::set_animation_player(const NodePath &p_player) {
|
||||
void AnimationTree::set_animation_player(const NodePath &p_player) {
|
||||
animation_player = p_player;
|
||||
update_configuration_warning();
|
||||
}
|
||||
|
||||
NodePath AnimationGraphPlayer::get_animation_player() const {
|
||||
NodePath AnimationTree::get_animation_player() const {
|
||||
return animation_player;
|
||||
}
|
||||
|
||||
bool AnimationGraphPlayer::is_state_invalid() const {
|
||||
bool AnimationTree::is_state_invalid() const {
|
||||
|
||||
return !state.valid;
|
||||
}
|
||||
String AnimationGraphPlayer::get_invalid_state_reason() const {
|
||||
String AnimationTree::get_invalid_state_reason() const {
|
||||
|
||||
return state.invalid_reasons;
|
||||
}
|
||||
|
||||
uint64_t AnimationGraphPlayer::get_last_process_pass() const {
|
||||
uint64_t AnimationTree::get_last_process_pass() const {
|
||||
return process_pass;
|
||||
}
|
||||
|
||||
String AnimationGraphPlayer::get_configuration_warning() const {
|
||||
String AnimationTree::get_configuration_warning() const {
|
||||
|
||||
String warning = Node::get_configuration_warning();
|
||||
|
||||
|
@ -1174,20 +1174,20 @@ String AnimationGraphPlayer::get_configuration_warning() const {
|
|||
return warning;
|
||||
}
|
||||
|
||||
void AnimationGraphPlayer::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_active", "active"), &AnimationGraphPlayer::set_active);
|
||||
ClassDB::bind_method(D_METHOD("is_active"), &AnimationGraphPlayer::is_active);
|
||||
void AnimationTree::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_active", "active"), &AnimationTree::set_active);
|
||||
ClassDB::bind_method(D_METHOD("is_active"), &AnimationTree::is_active);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_graph_root", "root"), &AnimationGraphPlayer::set_graph_root);
|
||||
ClassDB::bind_method(D_METHOD("get_graph_root"), &AnimationGraphPlayer::get_graph_root);
|
||||
ClassDB::bind_method(D_METHOD("set_graph_root", "root"), &AnimationTree::set_graph_root);
|
||||
ClassDB::bind_method(D_METHOD("get_graph_root"), &AnimationTree::get_graph_root);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_process_mode", "mode"), &AnimationGraphPlayer::set_process_mode);
|
||||
ClassDB::bind_method(D_METHOD("get_process_mode"), &AnimationGraphPlayer::get_process_mode);
|
||||
ClassDB::bind_method(D_METHOD("set_process_mode", "mode"), &AnimationTree::set_process_mode);
|
||||
ClassDB::bind_method(D_METHOD("get_process_mode"), &AnimationTree::get_process_mode);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_animation_player", "root"), &AnimationGraphPlayer::set_animation_player);
|
||||
ClassDB::bind_method(D_METHOD("get_animation_player"), &AnimationGraphPlayer::get_animation_player);
|
||||
ClassDB::bind_method(D_METHOD("set_animation_player", "root"), &AnimationTree::set_animation_player);
|
||||
ClassDB::bind_method(D_METHOD("get_animation_player"), &AnimationTree::get_animation_player);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_node_removed"), &AnimationGraphPlayer::_node_removed);
|
||||
ClassDB::bind_method(D_METHOD("_node_removed"), &AnimationTree::_node_removed);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "graph_root", PROPERTY_HINT_RESOURCE_TYPE, "AnimationRootNode", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_DO_NOT_SHARE_ON_DUPLICATE), "set_graph_root", "get_graph_root");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "anim_player"), "set_animation_player", "get_animation_player");
|
||||
|
@ -1195,7 +1195,7 @@ void AnimationGraphPlayer::_bind_methods() {
|
|||
ADD_PROPERTY(PropertyInfo(Variant::INT, "process_mode", PROPERTY_HINT_ENUM, "Physics,Idle"), "set_process_mode", "get_process_mode");
|
||||
}
|
||||
|
||||
AnimationGraphPlayer::AnimationGraphPlayer() {
|
||||
AnimationTree::AnimationTree() {
|
||||
|
||||
process_mode = ANIMATION_PROCESS_IDLE;
|
||||
active = false;
|
||||
|
@ -1204,7 +1204,7 @@ AnimationGraphPlayer::AnimationGraphPlayer() {
|
|||
started = true;
|
||||
}
|
||||
|
||||
AnimationGraphPlayer::~AnimationGraphPlayer() {
|
||||
AnimationTree::~AnimationTree() {
|
||||
if (root.is_valid()) {
|
||||
root->player = NULL;
|
||||
}
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
class AnimationNodeBlendTree;
|
||||
class AnimationPlayer;
|
||||
class AnimationGraphPlayer;
|
||||
class AnimationTree;
|
||||
|
||||
class AnimationNode : public Resource {
|
||||
GDCLASS(AnimationNode, Resource)
|
||||
|
@ -32,7 +32,7 @@ public:
|
|||
|
||||
float process_input(int p_input, float p_time, bool p_seek, float p_blend);
|
||||
|
||||
friend class AnimationGraphPlayer;
|
||||
friend class AnimationTree;
|
||||
|
||||
struct AnimationState {
|
||||
|
||||
|
@ -62,7 +62,7 @@ public:
|
|||
Vector2 position;
|
||||
|
||||
AnimationNode *parent;
|
||||
AnimationGraphPlayer *player;
|
||||
AnimationTree *player;
|
||||
|
||||
float _blend_node(Ref<AnimationNode> p_node, float p_time, bool p_seek, float p_blend, FilterAction p_filter = FILTER_IGNORE, bool p_optimize = true, float *r_max = NULL);
|
||||
|
||||
|
@ -85,8 +85,8 @@ protected:
|
|||
public:
|
||||
void set_parent(AnimationNode *p_parent);
|
||||
Ref<AnimationNode> get_parent() const;
|
||||
virtual void set_graph_player(AnimationGraphPlayer *p_player);
|
||||
AnimationGraphPlayer *get_graph_player() const;
|
||||
virtual void set_tree(AnimationTree *p_player);
|
||||
AnimationTree *get_tree() const;
|
||||
AnimationPlayer *get_player() const;
|
||||
|
||||
virtual float process(float p_time, bool p_seek);
|
||||
|
@ -125,8 +125,8 @@ public:
|
|||
AnimationRootNode() {}
|
||||
};
|
||||
|
||||
class AnimationGraphPlayer : public Node {
|
||||
GDCLASS(AnimationGraphPlayer, Node)
|
||||
class AnimationTree : public Node {
|
||||
GDCLASS(AnimationTree, Node)
|
||||
public:
|
||||
enum AnimationProcessMode {
|
||||
ANIMATION_PROCESS_PHYSICS,
|
||||
|
@ -258,10 +258,10 @@ public:
|
|||
String get_invalid_state_reason() const;
|
||||
|
||||
uint64_t get_last_process_pass() const;
|
||||
AnimationGraphPlayer();
|
||||
~AnimationGraphPlayer();
|
||||
AnimationTree();
|
||||
~AnimationTree();
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(AnimationGraphPlayer::AnimationProcessMode)
|
||||
VARIANT_ENUM_CAST(AnimationTree::AnimationProcessMode)
|
||||
|
||||
#endif // ANIMATION_GRAPH_PLAYER_H
|
|
@ -66,7 +66,7 @@
|
|||
#include "scene/animation/animation_blend_space_1d.h"
|
||||
#include "scene/animation/animation_blend_space_2d.h"
|
||||
#include "scene/animation/animation_blend_tree.h"
|
||||
#include "scene/animation/animation_graph_player.h"
|
||||
#include "scene/animation/animation_tree.h"
|
||||
#include "scene/animation/animation_node_state_machine.h"
|
||||
#include "scene/animation/animation_player.h"
|
||||
#include "scene/animation/animation_tree_player.h"
|
||||
|
@ -387,7 +387,7 @@ void register_scene_types() {
|
|||
ClassDB::register_class<NavigationMesh>();
|
||||
ClassDB::register_class<Navigation>();
|
||||
|
||||
ClassDB::register_class<AnimationGraphPlayer>();
|
||||
ClassDB::register_class<AnimationTree>();
|
||||
ClassDB::register_class<AnimationNode>();
|
||||
ClassDB::register_class<AnimationRootNode>();
|
||||
ClassDB::register_class<AnimationNodeBlendTree>();
|
||||
|
|
Loading…
Reference in a new issue