Removed AnimationTreePlayer, as it was deprecated (and also practically unusable).

This commit is contained in:
Relintai 2022-08-11 23:01:27 +02:00
parent ab86ae7c2c
commit 4b939998a7
9 changed files with 1 additions and 4305 deletions

View File

@ -1,448 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="AnimationTreePlayer" inherits="Node" version="3.5">
<brief_description>
[i]Deprecated.[/i] Animation player that uses a node graph for blending animations. Superseded by [AnimationTree].
</brief_description>
<description>
[i]Deprecated.[/i] A node graph tool for blending multiple animations bound to an [AnimationPlayer]. Especially useful for animating characters or other skeleton-based rigs. It can combine several animations to form a desired pose.
It takes [Animation]s from an [AnimationPlayer] node and mixes them depending on the graph.
See [AnimationTree] for a more full-featured replacement of this node.
</description>
<tutorials>
<link>$DOCS_URL/tutorials/animation/animation_tree.html</link>
</tutorials>
<methods>
<method name="add_node">
<return type="void" />
<argument index="0" name="type" type="int" enum="AnimationTreePlayer.NodeType" />
<argument index="1" name="id" type="StringName" />
<description>
</description>
</method>
<method name="advance">
<return type="void" />
<argument index="0" name="delta" type="float" />
<description>
Shifts position in the animation timeline. [code]delta[/code] is the time in seconds to shift. Events between the current frame and [code]delta[/code] are handled.
</description>
</method>
<method name="animation_node_get_animation" qualifiers="const">
<return type="Animation" />
<argument index="0" name="id" type="StringName" />
<description>
</description>
</method>
<method name="animation_node_get_master_animation" qualifiers="const">
<return type="String" />
<argument index="0" name="id" type="StringName" />
<description>
</description>
</method>
<method name="animation_node_get_position" qualifiers="const">
<return type="float" />
<argument index="0" name="id" type="StringName" />
<description>
</description>
</method>
<method name="animation_node_set_animation">
<return type="void" />
<argument index="0" name="id" type="StringName" />
<argument index="1" name="animation" type="Animation" />
<description>
</description>
</method>
<method name="animation_node_set_filter_path">
<return type="void" />
<argument index="0" name="id" type="StringName" />
<argument index="1" name="path" type="NodePath" />
<argument index="2" name="enable" type="bool" />
<description>
</description>
</method>
<method name="animation_node_set_master_animation">
<return type="void" />
<argument index="0" name="id" type="StringName" />
<argument index="1" name="source" type="String" />
<description>
</description>
</method>
<method name="are_nodes_connected" qualifiers="const">
<return type="bool" />
<argument index="0" name="id" type="StringName" />
<argument index="1" name="dst_id" type="StringName" />
<argument index="2" name="dst_input_idx" type="int" />
<description>
</description>
</method>
<method name="blend2_node_get_amount" qualifiers="const">
<return type="float" />
<argument index="0" name="id" type="StringName" />
<description>
</description>
</method>
<method name="blend2_node_set_amount">
<return type="void" />
<argument index="0" name="id" type="StringName" />
<argument index="1" name="blend" type="float" />
<description>
</description>
</method>
<method name="blend2_node_set_filter_path">
<return type="void" />
<argument index="0" name="id" type="StringName" />
<argument index="1" name="path" type="NodePath" />
<argument index="2" name="enable" type="bool" />
<description>
</description>
</method>
<method name="blend3_node_get_amount" qualifiers="const">
<return type="float" />
<argument index="0" name="id" type="StringName" />
<description>
</description>
</method>
<method name="blend3_node_set_amount">
<return type="void" />
<argument index="0" name="id" type="StringName" />
<argument index="1" name="blend" type="float" />
<description>
</description>
</method>
<method name="blend4_node_get_amount" qualifiers="const">
<return type="Vector2" />
<argument index="0" name="id" type="StringName" />
<description>
</description>
</method>
<method name="blend4_node_set_amount">
<return type="void" />
<argument index="0" name="id" type="StringName" />
<argument index="1" name="blend" type="Vector2" />
<description>
</description>
</method>
<method name="connect_nodes">
<return type="int" enum="Error" />
<argument index="0" name="id" type="StringName" />
<argument index="1" name="dst_id" type="StringName" />
<argument index="2" name="dst_input_idx" type="int" />
<description>
</description>
</method>
<method name="disconnect_nodes">
<return type="void" />
<argument index="0" name="id" type="StringName" />
<argument index="1" name="dst_input_idx" type="int" />
<description>
</description>
</method>
<method name="get_node_list">
<return type="PoolStringArray" />
<description>
Returns a [PoolStringArray] containing the name of all nodes.
</description>
</method>
<method name="mix_node_get_amount" qualifiers="const">
<return type="float" />
<argument index="0" name="id" type="StringName" />
<description>
</description>
</method>
<method name="mix_node_set_amount">
<return type="void" />
<argument index="0" name="id" type="StringName" />
<argument index="1" name="ratio" type="float" />
<description>
</description>
</method>
<method name="node_exists" qualifiers="const">
<return type="bool" />
<argument index="0" name="node" type="StringName" />
<description>
</description>
</method>
<method name="node_get_input_count" qualifiers="const">
<return type="int" />
<argument index="0" name="id" type="StringName" />
<description>
</description>
</method>
<method name="node_get_input_source" qualifiers="const">
<return type="StringName" />
<argument index="0" name="id" type="StringName" />
<argument index="1" name="idx" type="int" />
<description>
</description>
</method>
<method name="node_get_position" qualifiers="const">
<return type="Vector2" />
<argument index="0" name="id" type="StringName" />
<description>
</description>
</method>
<method name="node_get_type" qualifiers="const">
<return type="int" enum="AnimationTreePlayer.NodeType" />
<argument index="0" name="id" type="StringName" />
<description>
</description>
</method>
<method name="node_rename">
<return type="int" enum="Error" />
<argument index="0" name="node" type="StringName" />
<argument index="1" name="new_name" type="StringName" />
<description>
</description>
</method>
<method name="node_set_position">
<return type="void" />
<argument index="0" name="id" type="StringName" />
<argument index="1" name="screen_position" type="Vector2" />
<description>
</description>
</method>
<method name="oneshot_node_get_autorestart_delay" qualifiers="const">
<return type="float" />
<argument index="0" name="id" type="StringName" />
<description>
</description>
</method>
<method name="oneshot_node_get_autorestart_random_delay" qualifiers="const">
<return type="float" />
<argument index="0" name="id" type="StringName" />
<description>
</description>
</method>
<method name="oneshot_node_get_fadein_time" qualifiers="const">
<return type="float" />
<argument index="0" name="id" type="StringName" />
<description>
</description>
</method>
<method name="oneshot_node_get_fadeout_time" qualifiers="const">
<return type="float" />
<argument index="0" name="id" type="StringName" />
<description>
</description>
</method>
<method name="oneshot_node_has_autorestart" qualifiers="const">
<return type="bool" />
<argument index="0" name="id" type="StringName" />
<description>
</description>
</method>
<method name="oneshot_node_is_active" qualifiers="const">
<return type="bool" />
<argument index="0" name="id" type="StringName" />
<description>
</description>
</method>
<method name="oneshot_node_set_autorestart">
<return type="void" />
<argument index="0" name="id" type="StringName" />
<argument index="1" name="enable" type="bool" />
<description>
</description>
</method>
<method name="oneshot_node_set_autorestart_delay">
<return type="void" />
<argument index="0" name="id" type="StringName" />
<argument index="1" name="delay_sec" type="float" />
<description>
</description>
</method>
<method name="oneshot_node_set_autorestart_random_delay">
<return type="void" />
<argument index="0" name="id" type="StringName" />
<argument index="1" name="rand_sec" type="float" />
<description>
</description>
</method>
<method name="oneshot_node_set_fadein_time">
<return type="void" />
<argument index="0" name="id" type="StringName" />
<argument index="1" name="time_sec" type="float" />
<description>
</description>
</method>
<method name="oneshot_node_set_fadeout_time">
<return type="void" />
<argument index="0" name="id" type="StringName" />
<argument index="1" name="time_sec" type="float" />
<description>
</description>
</method>
<method name="oneshot_node_set_filter_path">
<return type="void" />
<argument index="0" name="id" type="StringName" />
<argument index="1" name="path" type="NodePath" />
<argument index="2" name="enable" type="bool" />
<description>
</description>
</method>
<method name="oneshot_node_start">
<return type="void" />
<argument index="0" name="id" type="StringName" />
<description>
</description>
</method>
<method name="oneshot_node_stop">
<return type="void" />
<argument index="0" name="id" type="StringName" />
<description>
</description>
</method>
<method name="recompute_caches">
<return type="void" />
<description>
Manually recalculates the cache of track information generated from animation nodes. Needed when external sources modify the animation nodes' state.
</description>
</method>
<method name="remove_node">
<return type="void" />
<argument index="0" name="id" type="StringName" />
<description>
</description>
</method>
<method name="reset">
<return type="void" />
<description>
Resets this [AnimationTreePlayer].
</description>
</method>
<method name="timescale_node_get_scale" qualifiers="const">
<return type="float" />
<argument index="0" name="id" type="StringName" />
<description>
</description>
</method>
<method name="timescale_node_set_scale">
<return type="void" />
<argument index="0" name="id" type="StringName" />
<argument index="1" name="scale" type="float" />
<description>
</description>
</method>
<method name="timeseek_node_seek">
<return type="void" />
<argument index="0" name="id" type="StringName" />
<argument index="1" name="seconds" type="float" />
<description>
</description>
</method>
<method name="transition_node_delete_input">
<return type="void" />
<argument index="0" name="id" type="StringName" />
<argument index="1" name="input_idx" type="int" />
<description>
</description>
</method>
<method name="transition_node_get_current" qualifiers="const">
<return type="int" />
<argument index="0" name="id" type="StringName" />
<description>
</description>
</method>
<method name="transition_node_get_input_count" qualifiers="const">
<return type="int" />
<argument index="0" name="id" type="StringName" />
<description>
</description>
</method>
<method name="transition_node_get_xfade_time" qualifiers="const">
<return type="float" />
<argument index="0" name="id" type="StringName" />
<description>
</description>
</method>
<method name="transition_node_has_input_auto_advance" qualifiers="const">
<return type="bool" />
<argument index="0" name="id" type="StringName" />
<argument index="1" name="input_idx" type="int" />
<description>
</description>
</method>
<method name="transition_node_set_current">
<return type="void" />
<argument index="0" name="id" type="StringName" />
<argument index="1" name="input_idx" type="int" />
<description>
</description>
</method>
<method name="transition_node_set_input_auto_advance">
<return type="void" />
<argument index="0" name="id" type="StringName" />
<argument index="1" name="input_idx" type="int" />
<argument index="2" name="enable" type="bool" />
<description>
</description>
</method>
<method name="transition_node_set_input_count">
<return type="void" />
<argument index="0" name="id" type="StringName" />
<argument index="1" name="count" type="int" />
<description>
</description>
</method>
<method name="transition_node_set_xfade_time">
<return type="void" />
<argument index="0" name="id" type="StringName" />
<argument index="1" name="time_sec" type="float" />
<description>
</description>
</method>
</methods>
<members>
<member name="active" type="bool" setter="set_active" getter="is_active" default="false">
If [code]true[/code], the [AnimationTreePlayer] is able to play animations.
</member>
<member name="base_path" type="NodePath" setter="set_base_path" getter="get_base_path" default="NodePath(&quot;..&quot;)">
The node from which to relatively access other nodes.
It accesses the bones, so it should point to the same node the [AnimationPlayer] would point its Root Node at.
</member>
<member name="master_player" type="NodePath" setter="set_master_player" getter="get_master_player" default="NodePath(&quot;&quot;)">
The path to the [AnimationPlayer] from which this [AnimationTreePlayer] binds animations to animation nodes.
Once set, [Animation] nodes can be added to the [AnimationTreePlayer].
</member>
<member name="playback_process_mode" type="int" setter="set_animation_process_mode" getter="get_animation_process_mode" enum="AnimationTreePlayer.AnimationProcessMode" default="1">
The thread in which to update animations.
</member>
</members>
<constants>
<constant name="NODE_OUTPUT" value="0" enum="NodeType">
Output node.
</constant>
<constant name="NODE_ANIMATION" value="1" enum="NodeType">
Animation node.
</constant>
<constant name="NODE_ONESHOT" value="2" enum="NodeType">
OneShot node.
</constant>
<constant name="NODE_MIX" value="3" enum="NodeType">
Mix node.
</constant>
<constant name="NODE_BLEND2" value="4" enum="NodeType">
Blend2 node.
</constant>
<constant name="NODE_BLEND3" value="5" enum="NodeType">
Blend3 node.
</constant>
<constant name="NODE_BLEND4" value="6" enum="NodeType">
Blend4 node.
</constant>
<constant name="NODE_TIMESCALE" value="7" enum="NodeType">
TimeScale node.
</constant>
<constant name="NODE_TIMESEEK" value="8" enum="NodeType">
TimeSeek node.
</constant>
<constant name="NODE_TRANSITION" value="9" enum="NodeType">
Transition node.
</constant>
<constant name="ANIMATION_PROCESS_PHYSICS" value="0" enum="AnimationProcessMode">
Process animation during the physics process. This is especially useful when animating physics bodies.
</constant>
<constant name="ANIMATION_PROCESS_IDLE" value="1" enum="AnimationProcessMode">
Process animation during the idle process.
</constant>
</constants>
</class>

View File

@ -104,7 +104,6 @@
#include "editor/plugin_config_dialog.h" #include "editor/plugin_config_dialog.h"
#include "editor/plugins/animation_player_editor_plugin.h" #include "editor/plugins/animation_player_editor_plugin.h"
#include "editor/plugins/animation_tree_editor_plugin.h" #include "editor/plugins/animation_tree_editor_plugin.h"
#include "editor/plugins/animation_tree_player_editor_plugin.h"
#include "editor/plugins/audio_stream_editor_plugin.h" #include "editor/plugins/audio_stream_editor_plugin.h"
#include "editor/plugins/bit_map_editor_plugin.h" #include "editor/plugins/bit_map_editor_plugin.h"
#include "editor/plugins/camera_editor_plugin.h" #include "editor/plugins/camera_editor_plugin.h"
@ -6784,7 +6783,6 @@ EditorNode::EditorNode() {
add_editor_plugin(memnew(MultiMeshEditorPlugin(this))); add_editor_plugin(memnew(MultiMeshEditorPlugin(this)));
add_editor_plugin(memnew(MeshInstanceEditorPlugin(this))); add_editor_plugin(memnew(MeshInstanceEditorPlugin(this)));
add_editor_plugin(memnew(AnimationTreeEditorPlugin(this))); add_editor_plugin(memnew(AnimationTreeEditorPlugin(this)));
add_editor_plugin(memnew(AnimationTreePlayerEditorPlugin(this)));
add_editor_plugin(memnew(StyleBoxEditorPlugin(this))); add_editor_plugin(memnew(StyleBoxEditorPlugin(this)));
add_editor_plugin(memnew(SpriteEditorPlugin(this))); add_editor_plugin(memnew(SpriteEditorPlugin(this)));
add_editor_plugin(memnew(Skeleton2DEditorPlugin(this))); add_editor_plugin(memnew(Skeleton2DEditorPlugin(this)));

View File

@ -1 +0,0 @@
<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m1 1v14h1.166v-2h1.834v2h8v-2h2v2h1v-14h-1v2h-2v-2h-8v2h-1.834v-2zm4 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-1zm-2.834 1h1.834v2h-1.834zm9.834 0h2v2h-2zm-9.834 4h1.834v2h-1.834zm9.834 0h2v2h-2z" fill="#cea4f1"/></svg>

Before

Width:  |  Height:  |  Size: 363 B

File diff suppressed because it is too large Load Diff

View File

@ -1,202 +0,0 @@
#ifndef ANIMATION_TREE_PLAYER_EDITOR_PLUGIN_H
#define ANIMATION_TREE_PLAYER_EDITOR_PLUGIN_H
/*************************************************************************/
/* animation_tree_player_editor_plugin.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "editor/editor_plugin.h"
#include "scene/gui/control.h"
#include "core/list.h"
#include "core/math/vector2.h"
#include "core/object.h"
#include "core/reference.h"
#include "core/set.h"
#include "core/string_name.h"
#include "core/ustring.h"
class AcceptDialog;
class AnimationTreePlayer;
class Button;
class CheckButton;
class CustomPropertyEditor;
class EditorFileDialog;
class EditorNode;
class HScrollBar;
class HSlider;
class InputEvent;
class Label;
class LineEdit;
class MenuButton;
class OptionButton;
class Popup;
class PopupMenu;
class Tree;
class VScrollBar;
struct Color;
class AnimationTreePlayerEditor : public Control {
GDCLASS(AnimationTreePlayerEditor, Control);
static const char *_node_type_names[];
enum ClickType {
CLICK_NONE,
CLICK_NAME,
CLICK_NODE,
CLICK_INPUT_SLOT,
CLICK_OUTPUT_SLOT,
CLICK_PARAMETER
};
enum {
MENU_GRAPH_CLEAR = 100,
MENU_IMPORT_ANIMATIONS = 101,
NODE_DISCONNECT,
NODE_RENAME,
NODE_ERASE,
NODE_ADD_INPUT,
NODE_DELETE_INPUT,
NODE_SET_AUTOADVANCE,
NODE_CLEAR_AUTOADVANCE
};
bool renaming_edit;
StringName edited_node;
bool updating_edit;
Popup *edit_dialog;
HSlider *edit_scroll[2];
LineEdit *edit_line[4];
OptionButton *edit_option;
Label *edit_label[4];
Button *edit_button;
Button *filter_button;
CheckButton *edit_check;
EditorFileDialog *file_dialog;
int file_op;
void _popup_edit_dialog();
PopupMenu *master_anim_popup;
PopupMenu *node_popup;
PopupMenu *add_popup;
HScrollBar *h_scroll;
VScrollBar *v_scroll;
MenuButton *add_menu;
CustomPropertyEditor *property_editor;
AnimationTreePlayer *anim_tree;
List<StringName> order;
Set<StringName> active_nodes;
int last_x, last_y;
Point2 offset;
ClickType click_type;
Point2 click_pos;
StringName click_node;
int click_slot;
Point2 click_motion;
ClickType rclick_type;
StringName rclick_node;
int rclick_slot;
Button *play_button;
Size2 _get_maximum_size();
Size2 get_node_size(const StringName &p_node) const;
void _draw_node(const StringName &p_node);
AcceptDialog *filter_dialog;
Tree *filter;
void _draw_cos_line(const Vector2 &p_from, const Vector2 &p_to, const Color &p_color);
void _update_scrollbars();
void _scroll_moved(float);
void _play_toggled();
/*
void _node_param_changed();
void _node_add_callback();
void _node_add(VisualServer::AnimationTreeNodeType p_type);
void _node_edit_property(const StringName& p_node);
*/
void _master_anim_menu_item(int p_item);
void _node_menu_item(int p_item);
void _add_menu_item(int p_item);
void _filter_edited();
void _find_paths_for_filter(const StringName &p_node, Set<String> &paths);
void _edit_filters();
void _edit_oneshot_start();
void _edit_dialog_animation_changed();
void _edit_dialog_edit_animation();
void _edit_dialog_changeds(String);
void _edit_dialog_changede(String);
void _edit_dialog_changedf(float);
void _edit_dialog_changed();
ClickType _locate_click(const Point2 &p_click, StringName *p_node_id, int *p_slot_index) const;
Point2 _get_slot_pos(const StringName &p_node_id, bool p_input, int p_slot);
StringName _add_node(int p_item);
void _file_dialog_selected(String p_path);
protected:
void _notification(int p_what);
void _gui_input(Ref<InputEvent> p_event);
static void _bind_methods();
public:
virtual Size2 get_minimum_size() const;
void edit(AnimationTreePlayer *p_anim_tree);
AnimationTreePlayerEditor();
};
class AnimationTreePlayerEditorPlugin : public EditorPlugin {
GDCLASS(AnimationTreePlayerEditorPlugin, EditorPlugin);
AnimationTreePlayerEditor *anim_tree_editor;
EditorNode *editor;
Button *button;
public:
virtual String get_name() const { return "AnimTree"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_object);
virtual bool handles(Object *p_object) const;
virtual void make_visible(bool p_visible);
AnimationTreePlayerEditorPlugin(EditorNode *p_node);
~AnimationTreePlayerEditorPlugin();
};
#endif // ANIMATION_TREE_EDITOR_PLUGIN_H

View File

@ -35,7 +35,6 @@
#include "scene/3d/physics_body.h" #include "scene/3d/physics_body.h"
#include "scene/animation/animation_player.h" #include "scene/animation/animation_player.h"
#include "scene/animation/animation_tree.h" #include "scene/animation/animation_tree.h"
#include "scene/animation/animation_tree_player.h"
#include "scene/resources/shape.h" #include "scene/resources/shape.h"
#include "scene/resources/world.h" #include "scene/resources/world.h"
#include "scene/scene_string_names.h" #include "scene/scene_string_names.h"
@ -260,7 +259,7 @@ void VisibilityEnabler::_find_nodes(Node *p_node) {
} }
} }
if (Object::cast_to<AnimationPlayer>(p_node) || Object::cast_to<AnimationTree>(p_node) || Object::cast_to<AnimationTreePlayer>(p_node)) { if (Object::cast_to<AnimationPlayer>(p_node) || Object::cast_to<AnimationTree>(p_node)) {
add = true; add = true;
} }
@ -271,13 +270,6 @@ void VisibilityEnabler::_find_nodes(Node *p_node) {
} }
} }
{
AnimationTreePlayer *atp = Object::cast_to<AnimationTreePlayer>(p_node);
if (atp) {
add = true;
}
}
if (add) { if (add) {
p_node->connect(SceneStringNames::get_singleton()->tree_exiting, this, "_node_removed", varray(p_node), CONNECT_ONESHOT); p_node->connect(SceneStringNames::get_singleton()->tree_exiting, this, "_node_removed", varray(p_node), CONNECT_ONESHOT);
nodes[p_node] = meta; nodes[p_node] = meta;
@ -343,11 +335,6 @@ void VisibilityEnabler::_change_node_state(Node *p_node, bool p_enabled) {
AnimationTree *at = Object::cast_to<AnimationTree>(p_node); AnimationTree *at = Object::cast_to<AnimationTree>(p_node);
if (at) { if (at) {
at->set_active(p_enabled); at->set_active(p_enabled);
} else {
AnimationTreePlayer *atp = Object::cast_to<AnimationTreePlayer>(p_node);
if (atp) {
atp->set_active(p_enabled);
}
} }
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,473 +0,0 @@
#ifndef ANIMATION_TREE_PLAYER_H
#define ANIMATION_TREE_PLAYER_H
/*************************************************************************/
/* animation_tree_player.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "scene/main/node.h"
#include "scene/resources/animation.h"
class Spatial;
class Skeleton;
class Animation;
class AnimationTreePlayer : public Node {
GDCLASS(AnimationTreePlayer, Node);
OBJ_CATEGORY("Animation Nodes");
public:
enum AnimationProcessMode {
ANIMATION_PROCESS_PHYSICS,
ANIMATION_PROCESS_IDLE,
};
enum NodeType {
NODE_OUTPUT,
NODE_ANIMATION,
NODE_ONESHOT,
NODE_MIX,
NODE_BLEND2,
NODE_BLEND3,
NODE_BLEND4,
NODE_TIMESCALE,
NODE_TIMESEEK,
NODE_TRANSITION,
NODE_MAX,
};
enum ConnectError {
CONNECT_OK,
CONNECT_INCOMPLETE,
CONNECT_CYCLE
};
private:
enum {
DISCONNECTED = -1,
};
struct TrackKey {
uint32_t id;
StringName subpath_concatenated;
int bone_idx;
inline bool operator<(const TrackKey &p_right) const {
if (id == p_right.id) {
if (bone_idx == p_right.bone_idx) {
return subpath_concatenated < p_right.subpath_concatenated;
} else {
return bone_idx < p_right.bone_idx;
}
} else {
return id < p_right.id;
}
}
};
struct Track {
uint32_t id;
Object *object;
Spatial *spatial;
Skeleton *skeleton;
int bone_idx;
Vector<StringName> subpath;
Vector3 loc;
Quat rot;
Vector3 scale;
Variant value;
bool skip;
Track() :
id(0),
object(nullptr),
spatial(nullptr),
skeleton(nullptr),
bone_idx(-1),
skip(false) {}
};
typedef Map<TrackKey, Track> TrackMap;
TrackMap track_map;
struct Input {
StringName node;
//Input() { node=-1; }
};
struct NodeBase {
bool cycletest;
NodeType type;
Point2 pos;
Vector<Input> inputs;
NodeBase() { cycletest = false; };
virtual ~NodeBase() { cycletest = false; }
};
struct NodeOut : public NodeBase {
NodeOut() {
type = NODE_OUTPUT;
inputs.resize(1);
}
};
struct AnimationNode : public NodeBase {
Ref<Animation> animation;
struct TrackRef {
int local_track;
Track *track;
float weight;
};
uint64_t last_version;
List<TrackRef> tref;
AnimationNode *next;
float time;
float step;
String from;
bool skip;
HashMap<NodePath, bool> filter;
AnimationNode() {
type = NODE_ANIMATION;
next = nullptr;
last_version = 0;
skip = false;
}
};
struct OneShotNode : public NodeBase {
bool active;
bool start;
float fade_in;
float fade_out;
bool autorestart;
float autorestart_delay;
float autorestart_random_delay;
bool mix;
float time;
float remaining;
float autorestart_remaining;
HashMap<NodePath, bool> filter;
OneShotNode() {
type = NODE_ONESHOT;
fade_in = 0;
fade_out = 0;
inputs.resize(2);
autorestart = false;
autorestart_delay = 1;
autorestart_remaining = 0;
mix = false;
active = false;
start = false;
}
};
struct MixNode : public NodeBase {
float amount;
MixNode() {
type = NODE_MIX;
inputs.resize(2);
}
};
struct Blend2Node : public NodeBase {
float value;
HashMap<NodePath, bool> filter;
Blend2Node() {
type = NODE_BLEND2;
value = 0;
inputs.resize(2);
}
};
struct Blend3Node : public NodeBase {
float value;
Blend3Node() {
type = NODE_BLEND3;
value = 0;
inputs.resize(3);
}
};
struct Blend4Node : public NodeBase {
Point2 value;
Blend4Node() {
type = NODE_BLEND4;
inputs.resize(4);
}
};
struct TimeScaleNode : public NodeBase {
float scale;
TimeScaleNode() {
type = NODE_TIMESCALE;
scale = 1;
inputs.resize(1);
}
};
struct TimeSeekNode : public NodeBase {
float seek_pos;
TimeSeekNode() {
type = NODE_TIMESEEK;
inputs.resize(1);
seek_pos = -1;
}
};
struct TransitionNode : public NodeBase {
struct InputData {
bool auto_advance;
InputData() { auto_advance = false; }
};
Vector<InputData> input_data;
float prev_time;
float prev_xfading;
int prev;
bool switched;
float time;
int current;
float xfade;
TransitionNode() {
type = NODE_TRANSITION;
xfade = 0;
inputs.resize(1);
input_data.resize(1);
current = 0;
prev = -1;
prev_time = 0;
prev_xfading = 0;
switched = false;
}
void set_current(int p_current);
};
void _update_sources();
StringName out_name;
NodeOut *out;
NodePath base_path;
NodePath master;
ConnectError last_error;
AnimationNode *active_list;
AnimationProcessMode animation_process_mode;
bool processing;
bool active;
bool dirty_caches;
Map<StringName, NodeBase *> node_map;
// return time left to finish animation
float _process_node(const StringName &p_node, AnimationNode **r_prev_anim, float p_time, bool p_seek = false, float p_fallback_weight = 1.0, HashMap<NodePath, float> *p_weights = nullptr);
void _process_animation(float p_delta);
bool reset_request;
ConnectError _cycle_test(const StringName &p_at_node);
void _clear_cycle_test();
Track *_find_track(const NodePath &p_path);
void _recompute_caches();
void _recompute_caches(const StringName &p_node);
PoolVector<String> _get_node_list();
void _compute_weights(float *p_fallback_weight, HashMap<NodePath, float> *p_weights, float p_coeff, const HashMap<NodePath, bool> *p_filter = nullptr, float p_filtered_coeff = 0);
protected:
bool _set(const StringName &p_name, const Variant &p_value);
bool _get(const StringName &p_name, Variant &r_ret) const;
void _get_property_list(List<PropertyInfo> *p_list) const;
void _notification(int p_what);
static void _bind_methods();
public:
void add_node(NodeType p_type, const StringName &p_node); // nodes must be >0 node 0 is built-in (exit)
bool node_exists(const StringName &p_name) const;
Error node_rename(const StringName &p_node, const StringName &p_new_name);
int node_get_input_count(const StringName &p_node) const;
StringName node_get_input_source(const StringName &p_node, int p_input) const;
String get_configuration_warning() const;
/* ANIMATION NODE */
void animation_node_set_animation(const StringName &p_node, const Ref<Animation> &p_animation);
Ref<Animation> animation_node_get_animation(const StringName &p_node) const;
void animation_node_set_master_animation(const StringName &p_node, const String &p_master_animation);
String animation_node_get_master_animation(const StringName &p_node) const;
float animation_node_get_position(const StringName &p_node) const;
void animation_node_set_filter_path(const StringName &p_node, const NodePath &p_track_path, bool p_filter);
void animation_node_set_get_filtered_paths(const StringName &p_node, List<NodePath> *r_paths) const;
bool animation_node_is_path_filtered(const StringName &p_node, const NodePath &p_path) const;
/* ONE SHOT NODE */
void oneshot_node_set_fadein_time(const StringName &p_node, float p_time);
void oneshot_node_set_fadeout_time(const StringName &p_node, float p_time);
float oneshot_node_get_fadein_time(const StringName &p_node) const;
float oneshot_node_get_fadeout_time(const StringName &p_node) const;
void oneshot_node_set_autorestart(const StringName &p_node, bool p_active);
void oneshot_node_set_autorestart_delay(const StringName &p_node, float p_time);
void oneshot_node_set_autorestart_random_delay(const StringName &p_node, float p_time);
bool oneshot_node_has_autorestart(const StringName &p_node) const;
float oneshot_node_get_autorestart_delay(const StringName &p_node) const;
float oneshot_node_get_autorestart_random_delay(const StringName &p_node) const;
void oneshot_node_set_mix_mode(const StringName &p_node, bool p_mix);
bool oneshot_node_get_mix_mode(const StringName &p_node) const;
void oneshot_node_start(const StringName &p_node);
void oneshot_node_stop(const StringName &p_node);
bool oneshot_node_is_active(const StringName &p_node) const;
void oneshot_node_set_filter_path(const StringName &p_node, const NodePath &p_filter, bool p_enable);
void oneshot_node_set_get_filtered_paths(const StringName &p_node, List<NodePath> *r_paths) const;
bool oneshot_node_is_path_filtered(const StringName &p_node, const NodePath &p_path) const;
/* MIX/BLEND NODES */
void mix_node_set_amount(const StringName &p_node, float p_amount);
float mix_node_get_amount(const StringName &p_node) const;
void blend2_node_set_amount(const StringName &p_node, float p_amount);
float blend2_node_get_amount(const StringName &p_node) const;
void blend2_node_set_filter_path(const StringName &p_node, const NodePath &p_filter, bool p_enable);
void blend2_node_set_get_filtered_paths(const StringName &p_node, List<NodePath> *r_paths) const;
bool blend2_node_is_path_filtered(const StringName &p_node, const NodePath &p_path) const;
void blend3_node_set_amount(const StringName &p_node, float p_amount);
float blend3_node_get_amount(const StringName &p_node) const;
void blend4_node_set_amount(const StringName &p_node, const Point2 &p_amount);
Point2 blend4_node_get_amount(const StringName &p_node) const;
/* TIMESCALE/TIMESEEK NODES */
void timescale_node_set_scale(const StringName &p_node, float p_scale);
float timescale_node_get_scale(const StringName &p_node) const;
void timeseek_node_seek(const StringName &p_node, float p_pos);
/* TRANSITION NODE */
void transition_node_set_input_count(const StringName &p_node, int p_inputs); // used for transition node
int transition_node_get_input_count(const StringName &p_node) const;
void transition_node_delete_input(const StringName &p_node, int p_input); // used for transition node
void transition_node_set_input_auto_advance(const StringName &p_node, int p_input, bool p_auto_advance); // used for transition node
bool transition_node_has_input_auto_advance(const StringName &p_node, int p_input) const;
void transition_node_set_xfade_time(const StringName &p_node, float p_time); // used for transition node
float transition_node_get_xfade_time(const StringName &p_node) const;
void transition_node_set_current(const StringName &p_node, int p_current);
int transition_node_get_current(const StringName &p_node) const;
void node_set_position(const StringName &p_node, const Vector2 &p_pos); //for display
/* GETS */
Point2 node_get_position(const StringName &p_node) const; //for display
NodeType node_get_type(const StringName &p_node) const;
void get_node_list(List<StringName> *p_node_list) const;
void remove_node(const StringName &p_node);
Error connect_nodes(const StringName &p_src_node, const StringName &p_dst_node, int p_dst_input);
bool are_nodes_connected(const StringName &p_src_node, const StringName &p_dst_node, int p_dst_input) const;
void disconnect_nodes(const StringName &p_node, int p_input);
void set_base_path(const NodePath &p_path);
NodePath get_base_path() const;
void set_master_player(const NodePath &p_path);
NodePath get_master_player() const;
struct Connection {
StringName src_node;
StringName dst_node;
int dst_input;
};
void get_connection_list(List<Connection> *p_connections) const;
/* playback */
void set_active(bool p_active);
bool is_active() const;
void reset();
void recompute_caches();
ConnectError get_last_error() const;
void set_animation_process_mode(AnimationProcessMode p_mode);
AnimationProcessMode get_animation_process_mode() const;
void _set_process(bool p_process, bool p_force = false);
void advance(float p_time);
AnimationTreePlayer();
~AnimationTreePlayer();
};
VARIANT_ENUM_CAST(AnimationTreePlayer::NodeType);
VARIANT_ENUM_CAST(AnimationTreePlayer::AnimationProcessMode);
#endif // ANIMATION_TREE_PLAYER_H

View File

@ -76,7 +76,6 @@
#include "scene/animation/animation_node_state_machine.h" #include "scene/animation/animation_node_state_machine.h"
#include "scene/animation/animation_player.h" #include "scene/animation/animation_player.h"
#include "scene/animation/animation_tree.h" #include "scene/animation/animation_tree.h"
#include "scene/animation/animation_tree_player.h"
#include "scene/animation/root_motion_view.h" #include "scene/animation/root_motion_view.h"
#include "scene/animation/scene_tree_tween.h" #include "scene/animation/scene_tree_tween.h"
#include "scene/animation/tween.h" #include "scene/animation/tween.h"
@ -406,7 +405,6 @@ void register_scene_types() {
ClassDB::register_class<CallbackTweener>(); ClassDB::register_class<CallbackTweener>();
ClassDB::register_class<MethodTweener>(); ClassDB::register_class<MethodTweener>();
ClassDB::register_class<AnimationTreePlayer>();
ClassDB::register_class<AnimationTree>(); ClassDB::register_class<AnimationTree>();
ClassDB::register_class<AnimationNode>(); ClassDB::register_class<AnimationNode>();
ClassDB::register_class<AnimationRootNode>(); ClassDB::register_class<AnimationRootNode>();