2023-01-05 13:25:55 +01:00
|
|
|
/**************************************************************************/
|
|
|
|
/* animation_tree.h */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* https://godotengine.org */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
|
|
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* */
|
|
|
|
/* 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. */
|
|
|
|
/**************************************************************************/
|
2018-08-29 22:38:13 +02:00
|
|
|
|
2022-07-23 23:41:51 +02:00
|
|
|
#ifndef ANIMATION_TREE_H
|
|
|
|
#define ANIMATION_TREE_H
|
2018-06-19 03:10:48 +02:00
|
|
|
|
|
|
|
#include "animation_player.h"
|
2020-03-26 22:49:16 +01:00
|
|
|
#include "scene/3d/node_3d.h"
|
|
|
|
#include "scene/3d/skeleton_3d.h"
|
2018-06-19 03:10:48 +02:00
|
|
|
#include "scene/resources/animation.h"
|
2023-01-27 19:25:49 +01:00
|
|
|
#include "scene/resources/audio_stream_polyphonic.h"
|
2018-06-19 03:10:48 +02:00
|
|
|
|
|
|
|
class AnimationNodeBlendTree;
|
2018-12-16 15:43:20 +01:00
|
|
|
class AnimationNodeStartState;
|
|
|
|
class AnimationNodeEndState;
|
2018-06-19 03:10:48 +02:00
|
|
|
class AnimationPlayer;
|
2018-06-25 23:40:24 +02:00
|
|
|
class AnimationTree;
|
2018-06-19 03:10:48 +02:00
|
|
|
|
|
|
|
class AnimationNode : public Resource {
|
2019-03-19 19:35:57 +01:00
|
|
|
GDCLASS(AnimationNode, Resource);
|
|
|
|
|
2018-06-19 03:10:48 +02:00
|
|
|
public:
|
|
|
|
enum FilterAction {
|
|
|
|
FILTER_IGNORE,
|
|
|
|
FILTER_PASS,
|
|
|
|
FILTER_STOP,
|
|
|
|
FILTER_BLEND
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Input {
|
|
|
|
String name;
|
|
|
|
};
|
|
|
|
|
|
|
|
Vector<Input> inputs;
|
|
|
|
|
2018-06-25 23:40:24 +02:00
|
|
|
friend class AnimationTree;
|
2018-06-19 03:10:48 +02:00
|
|
|
|
|
|
|
struct AnimationState {
|
|
|
|
Ref<Animation> animation;
|
2021-05-21 08:42:37 +02:00
|
|
|
double time = 0.0;
|
|
|
|
double delta = 0.0;
|
2021-08-10 00:15:17 +02:00
|
|
|
const Vector<real_t> *track_blends = nullptr;
|
|
|
|
real_t blend = 0.0;
|
2021-02-07 22:29:31 +01:00
|
|
|
bool seeked = false;
|
2022-11-21 20:30:55 +01:00
|
|
|
bool is_external_seeking = false;
|
2022-11-29 10:51:45 +01:00
|
|
|
Animation::LoopedFlag looped_flag = Animation::LOOPED_FLAG_NONE;
|
2018-06-19 03:10:48 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct State {
|
2021-02-07 22:29:31 +01:00
|
|
|
int track_count = 0;
|
2018-06-19 03:10:48 +02:00
|
|
|
HashMap<NodePath, int> track_map;
|
|
|
|
List<AnimationState> animation_states;
|
2021-02-07 22:29:31 +01:00
|
|
|
bool valid = false;
|
|
|
|
AnimationPlayer *player = nullptr;
|
|
|
|
AnimationTree *tree = nullptr;
|
2018-06-19 03:10:48 +02:00
|
|
|
String invalid_reasons;
|
2021-02-07 22:29:31 +01:00
|
|
|
uint64_t last_pass = 0;
|
2018-06-19 03:10:48 +02:00
|
|
|
};
|
|
|
|
|
2021-08-10 00:15:17 +02:00
|
|
|
Vector<real_t> blends;
|
2021-02-07 22:29:31 +01:00
|
|
|
State *state = nullptr;
|
2018-08-23 21:44:10 +02:00
|
|
|
|
2022-11-21 20:30:55 +01:00
|
|
|
double _pre_process(const StringName &p_base_path, AnimationNode *p_parent, State *p_state, double p_time, bool p_seek, bool p_is_external_seeking, const Vector<StringName> &p_connections);
|
2018-06-19 03:10:48 +02:00
|
|
|
|
2018-08-20 18:38:18 +02:00
|
|
|
//all this is temporary
|
|
|
|
StringName base_path;
|
|
|
|
Vector<StringName> connections;
|
2021-02-07 22:29:31 +01:00
|
|
|
AnimationNode *parent = nullptr;
|
2018-06-19 03:10:48 +02:00
|
|
|
|
|
|
|
HashMap<NodePath, bool> filter;
|
2021-02-07 22:29:31 +01:00
|
|
|
bool filter_enabled = false;
|
2018-06-19 03:10:48 +02:00
|
|
|
|
|
|
|
Array _get_filters() const;
|
|
|
|
void _set_filters(const Array &p_filters);
|
2018-08-20 18:38:18 +02:00
|
|
|
friend class AnimationNodeBlendTree;
|
2022-11-21 20:30:55 +01:00
|
|
|
double _blend_node(const StringName &p_subpath, const Vector<StringName> &p_connections, AnimationNode *p_new_parent, Ref<AnimationNode> p_node, double p_time, bool p_seek, bool p_is_external_seeking, real_t p_blend, FilterAction p_filter = FILTER_IGNORE, bool p_sync = true, real_t *r_max = nullptr);
|
2018-06-19 03:10:48 +02:00
|
|
|
|
|
|
|
protected:
|
2022-11-29 10:51:45 +01:00
|
|
|
void blend_animation(const StringName &p_animation, double p_time, double p_delta, bool p_seeked, bool p_is_external_seeking, real_t p_blend, Animation::LoopedFlag p_looped_flag = Animation::LOOPED_FLAG_NONE);
|
2022-11-21 20:30:55 +01:00
|
|
|
double blend_node(const StringName &p_sub_path, Ref<AnimationNode> p_node, double p_time, bool p_seek, bool p_is_external_seeking, real_t p_blend, FilterAction p_filter = FILTER_IGNORE, bool p_sync = true);
|
|
|
|
double blend_input(int p_input, double p_time, bool p_seek, bool p_is_external_seeking, real_t p_blend, FilterAction p_filter = FILTER_IGNORE, bool p_sync = true);
|
2021-10-15 15:25:00 +02:00
|
|
|
|
2018-06-19 03:10:48 +02:00
|
|
|
void make_invalid(const String &p_reason);
|
2022-04-20 12:36:54 +02:00
|
|
|
AnimationTree *get_animation_tree() const;
|
2018-06-19 03:10:48 +02:00
|
|
|
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2022-08-12 22:57:11 +02:00
|
|
|
void _validate_property(PropertyInfo &p_property) const;
|
2018-06-19 03:10:48 +02:00
|
|
|
|
2021-08-22 03:52:44 +02:00
|
|
|
GDVIRTUAL0RC(Dictionary, _get_child_nodes)
|
|
|
|
GDVIRTUAL0RC(Array, _get_parameter_list)
|
|
|
|
GDVIRTUAL1RC(Ref<AnimationNode>, _get_child_by_name, StringName)
|
|
|
|
GDVIRTUAL1RC(Variant, _get_parameter_default_value, StringName)
|
2023-01-12 13:51:03 +01:00
|
|
|
GDVIRTUAL1RC(bool, _is_parameter_read_only, StringName)
|
2022-05-04 20:53:48 +02:00
|
|
|
GDVIRTUAL3RC(double, _process, double, bool, bool)
|
2021-08-22 03:52:44 +02:00
|
|
|
GDVIRTUAL0RC(String, _get_caption)
|
|
|
|
GDVIRTUAL0RC(bool, _has_filter)
|
|
|
|
|
2018-06-19 03:10:48 +02:00
|
|
|
public:
|
2018-08-20 18:38:18 +02:00
|
|
|
virtual void get_parameter_list(List<PropertyInfo> *r_list) const;
|
|
|
|
virtual Variant get_parameter_default_value(const StringName &p_parameter) const;
|
2023-01-12 13:51:03 +01:00
|
|
|
virtual bool is_parameter_read_only(const StringName &p_parameter) const;
|
2018-08-20 18:38:18 +02:00
|
|
|
|
|
|
|
void set_parameter(const StringName &p_name, const Variant &p_value);
|
|
|
|
Variant get_parameter(const StringName &p_name) const;
|
|
|
|
|
|
|
|
struct ChildNode {
|
|
|
|
StringName name;
|
|
|
|
Ref<AnimationNode> node;
|
|
|
|
};
|
|
|
|
|
|
|
|
virtual void get_child_nodes(List<ChildNode> *r_child_nodes);
|
2018-06-19 03:10:48 +02:00
|
|
|
|
2022-11-21 20:30:55 +01:00
|
|
|
virtual double process(double p_time, bool p_seek, bool p_is_external_seeking);
|
2018-06-21 20:45:44 +02:00
|
|
|
virtual String get_caption() const;
|
2018-06-19 03:10:48 +02:00
|
|
|
|
2023-01-29 15:54:13 +01:00
|
|
|
virtual bool add_input(const String &p_name);
|
|
|
|
virtual void remove_input(int p_index);
|
|
|
|
virtual bool set_input_name(int p_input, const String &p_name);
|
|
|
|
virtual String get_input_name(int p_input) const;
|
2018-06-19 03:10:48 +02:00
|
|
|
int get_input_count() const;
|
2023-01-29 15:54:13 +01:00
|
|
|
int find_input(const String &p_name) const;
|
2018-06-19 03:10:48 +02:00
|
|
|
|
|
|
|
void set_filter_path(const NodePath &p_path, bool p_enable);
|
|
|
|
bool is_path_filtered(const NodePath &p_path) const;
|
|
|
|
|
|
|
|
void set_filter_enabled(bool p_enable);
|
|
|
|
bool is_filter_enabled() const;
|
|
|
|
|
|
|
|
virtual bool has_filter() const;
|
|
|
|
|
2018-08-20 18:38:18 +02:00
|
|
|
virtual Ref<AnimationNode> get_child_by_name(const StringName &p_name);
|
2018-06-19 03:10:48 +02:00
|
|
|
|
|
|
|
AnimationNode();
|
|
|
|
};
|
|
|
|
|
|
|
|
VARIANT_ENUM_CAST(AnimationNode::FilterAction)
|
|
|
|
|
2018-06-21 20:45:44 +02:00
|
|
|
//root node does not allow inputs
|
|
|
|
class AnimationRootNode : public AnimationNode {
|
2019-03-19 19:35:57 +01:00
|
|
|
GDCLASS(AnimationRootNode, AnimationNode);
|
|
|
|
|
2018-06-21 20:45:44 +02:00
|
|
|
public:
|
|
|
|
AnimationRootNode() {}
|
|
|
|
};
|
|
|
|
|
2018-12-16 15:43:20 +01:00
|
|
|
class AnimationNodeStartState : public AnimationRootNode {
|
|
|
|
GDCLASS(AnimationNodeStartState, AnimationRootNode);
|
|
|
|
};
|
|
|
|
|
|
|
|
class AnimationNodeEndState : public AnimationRootNode {
|
|
|
|
GDCLASS(AnimationNodeEndState, AnimationRootNode);
|
|
|
|
};
|
|
|
|
|
2018-06-25 23:40:24 +02:00
|
|
|
class AnimationTree : public Node {
|
2019-03-19 19:35:57 +01:00
|
|
|
GDCLASS(AnimationTree, Node);
|
|
|
|
|
2018-06-19 03:10:48 +02:00
|
|
|
public:
|
2021-02-18 19:52:29 +01:00
|
|
|
enum AnimationProcessCallback {
|
2018-06-19 03:10:48 +02:00
|
|
|
ANIMATION_PROCESS_PHYSICS,
|
|
|
|
ANIMATION_PROCESS_IDLE,
|
2018-08-02 09:22:24 +02:00
|
|
|
ANIMATION_PROCESS_MANUAL,
|
2018-06-19 03:10:48 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct TrackCache {
|
2021-02-07 22:29:31 +01:00
|
|
|
bool root_motion = false;
|
|
|
|
uint64_t setup_pass = 0;
|
|
|
|
Animation::TrackType type = Animation::TrackType::TYPE_ANIMATION;
|
|
|
|
Object *object = nullptr;
|
2018-06-19 03:10:48 +02:00
|
|
|
ObjectID object_id;
|
|
|
|
|
|
|
|
TrackCache() {
|
|
|
|
}
|
|
|
|
virtual ~TrackCache() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TrackCacheTransform : public TrackCache {
|
2021-03-18 00:35:42 +01:00
|
|
|
#ifndef _3D_DISABLED
|
|
|
|
Node3D *node_3d = nullptr;
|
2021-02-07 22:29:31 +01:00
|
|
|
Skeleton3D *skeleton = nullptr;
|
2021-03-18 00:35:42 +01:00
|
|
|
#endif // _3D_DISABLED
|
2021-02-07 22:29:31 +01:00
|
|
|
int bone_idx = -1;
|
Remove animation 3D transform track, replace by loc/rot/scale tracks.
* `Animation.TYPE_TRANSFORM3D` track is gone.
* Added POSITION_3D, ROTATION_3D, SCALE_3D tracks.
* GLTF2, Collada, FBX importers will only import the track types found.
* Skeleton3D bone poses are now Pos/Rot/Scale, pose matrix removed.
* AnimationPlayer and AnimationTree animate these tracks separately, only when found.
* Removed BakeReset code, is useless with these changes.
This is the first in a series of commits designed to make the animation system in Godot more useful, which includes:
* Better compatibility with Autodesk products
* Better reusability of animations across models (including retargeting).
* Proper animation compression.
* etc.
*Note* GLTF2 animation saving went broken with this PR, needs to be fixed in a subsequent one.
2021-10-12 00:20:58 +02:00
|
|
|
bool loc_used = false;
|
|
|
|
bool rot_used = false;
|
|
|
|
bool scale_used = false;
|
2022-03-15 17:35:25 +01:00
|
|
|
Vector3 init_loc = Vector3(0, 0, 0);
|
2022-04-16 21:34:28 +02:00
|
|
|
Quaternion init_rot = Quaternion(0, 0, 0, 1);
|
2022-03-15 17:35:25 +01:00
|
|
|
Vector3 init_scale = Vector3(1, 1, 1);
|
2018-06-19 03:10:48 +02:00
|
|
|
Vector3 loc;
|
2021-01-20 08:02:02 +01:00
|
|
|
Quaternion rot;
|
2018-06-19 03:10:48 +02:00
|
|
|
Vector3 scale;
|
|
|
|
|
|
|
|
TrackCacheTransform() {
|
Remove animation 3D transform track, replace by loc/rot/scale tracks.
* `Animation.TYPE_TRANSFORM3D` track is gone.
* Added POSITION_3D, ROTATION_3D, SCALE_3D tracks.
* GLTF2, Collada, FBX importers will only import the track types found.
* Skeleton3D bone poses are now Pos/Rot/Scale, pose matrix removed.
* AnimationPlayer and AnimationTree animate these tracks separately, only when found.
* Removed BakeReset code, is useless with these changes.
This is the first in a series of commits designed to make the animation system in Godot more useful, which includes:
* Better compatibility with Autodesk products
* Better reusability of animations across models (including retargeting).
* Proper animation compression.
* etc.
*Note* GLTF2 animation saving went broken with this PR, needs to be fixed in a subsequent one.
2021-10-12 00:20:58 +02:00
|
|
|
type = Animation::TYPE_POSITION_3D;
|
2018-06-19 03:10:48 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-10-16 00:04:35 +02:00
|
|
|
struct TrackCacheBlendShape : public TrackCache {
|
|
|
|
MeshInstance3D *mesh_3d = nullptr;
|
2022-02-05 06:16:43 +01:00
|
|
|
float init_value = 0;
|
2021-10-16 00:04:35 +02:00
|
|
|
float value = 0;
|
|
|
|
int shape_index = -1;
|
|
|
|
TrackCacheBlendShape() { type = Animation::TYPE_BLEND_SHAPE; }
|
|
|
|
};
|
|
|
|
|
2018-06-19 03:10:48 +02:00
|
|
|
struct TrackCacheValue : public TrackCache {
|
2022-02-05 06:16:43 +01:00
|
|
|
Variant init_value;
|
2018-06-19 03:10:48 +02:00
|
|
|
Variant value;
|
|
|
|
Vector<StringName> subpath;
|
2022-11-22 07:10:38 +01:00
|
|
|
bool is_discrete = false;
|
2022-08-26 04:42:00 +02:00
|
|
|
bool is_using_angle = false;
|
2018-06-19 03:10:48 +02:00
|
|
|
TrackCacheValue() { type = Animation::TYPE_VALUE; }
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TrackCacheMethod : public TrackCache {
|
|
|
|
TrackCacheMethod() { type = Animation::TYPE_METHOD; }
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TrackCacheBezier : public TrackCache {
|
2022-02-05 06:16:43 +01:00
|
|
|
real_t init_value = 0.0;
|
2021-08-10 00:15:17 +02:00
|
|
|
real_t value = 0.0;
|
2018-06-19 03:10:48 +02:00
|
|
|
Vector<StringName> subpath;
|
|
|
|
TrackCacheBezier() {
|
|
|
|
type = Animation::TYPE_BEZIER;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-01-28 16:24:52 +01:00
|
|
|
// Audio stream information for each audio stream placed on the track.
|
2023-01-27 19:25:49 +01:00
|
|
|
struct PlayingAudioStreamInfo {
|
2023-01-28 16:24:52 +01:00
|
|
|
AudioStreamPlaybackPolyphonic::ID index = -1; // ID retrieved from AudioStreamPlaybackPolyphonic.
|
2022-01-28 21:07:30 +01:00
|
|
|
double start = 0.0;
|
|
|
|
double len = 0.0;
|
2023-01-27 19:25:49 +01:00
|
|
|
};
|
|
|
|
|
2023-01-28 16:24:52 +01:00
|
|
|
// Audio track information for mixng and ending.
|
2023-01-27 19:25:49 +01:00
|
|
|
struct PlayingAudioTrackInfo {
|
|
|
|
HashMap<int, PlayingAudioStreamInfo> stream_info;
|
|
|
|
double length = 0.0;
|
|
|
|
double time = 0.0;
|
|
|
|
real_t volume = 0.0;
|
|
|
|
bool loop = false;
|
|
|
|
bool backward = false;
|
|
|
|
bool use_blend = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TrackCacheAudio : public TrackCache {
|
|
|
|
Ref<AudioStreamPolyphonic> audio_stream;
|
|
|
|
Ref<AudioStreamPlaybackPolyphonic> audio_stream_playback;
|
2023-01-28 16:24:52 +01:00
|
|
|
HashMap<ObjectID, PlayingAudioTrackInfo> playing_streams; // Key is Animation resource ObjectID.
|
2018-06-19 03:10:48 +02:00
|
|
|
|
|
|
|
TrackCacheAudio() {
|
|
|
|
type = Animation::TYPE_AUDIO;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TrackCacheAnimation : public TrackCache {
|
2021-02-07 22:29:31 +01:00
|
|
|
bool playing = false;
|
2018-06-19 03:10:48 +02:00
|
|
|
|
|
|
|
TrackCacheAnimation() {
|
|
|
|
type = Animation::TYPE_ANIMATION;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
HashMap<NodePath, TrackCache *> track_cache;
|
2022-05-19 17:00:06 +02:00
|
|
|
HashSet<TrackCache *> playing_caches;
|
2023-01-27 19:25:49 +01:00
|
|
|
Vector<Node *> playing_audio_stream_players;
|
2018-06-19 03:10:48 +02:00
|
|
|
|
|
|
|
Ref<AnimationNode> root;
|
2022-04-20 12:36:54 +02:00
|
|
|
NodePath advance_expression_base_node = NodePath(String("."));
|
2018-06-19 03:10:48 +02:00
|
|
|
|
2021-02-18 19:52:29 +01:00
|
|
|
AnimationProcessCallback process_callback = ANIMATION_PROCESS_IDLE;
|
2021-02-07 22:29:31 +01:00
|
|
|
bool active = false;
|
2018-06-19 03:10:48 +02:00
|
|
|
NodePath animation_player;
|
2023-01-27 19:25:49 +01:00
|
|
|
int audio_max_polyphony = 32;
|
2018-06-19 03:10:48 +02:00
|
|
|
|
|
|
|
AnimationNode::State state;
|
2021-02-07 22:29:31 +01:00
|
|
|
bool cache_valid = false;
|
2018-06-19 03:10:48 +02:00
|
|
|
void _node_removed(Node *p_node);
|
|
|
|
|
2022-09-01 16:00:55 +02:00
|
|
|
void _setup_animation_player();
|
|
|
|
void _animation_player_changed();
|
2018-06-19 03:10:48 +02:00
|
|
|
void _clear_caches();
|
2023-01-27 19:25:49 +01:00
|
|
|
void _clear_playing_caches();
|
|
|
|
void _clear_audio_streams();
|
2018-06-19 03:10:48 +02:00
|
|
|
bool _update_caches(AnimationPlayer *player);
|
2022-01-28 21:07:30 +01:00
|
|
|
void _process_graph(double p_delta);
|
2018-06-19 03:10:48 +02:00
|
|
|
|
2021-02-07 22:29:31 +01:00
|
|
|
uint64_t setup_pass = 1;
|
|
|
|
uint64_t process_pass = 1;
|
2018-06-19 03:10:48 +02:00
|
|
|
|
2021-02-07 22:29:31 +01:00
|
|
|
bool started = true;
|
2018-06-19 03:10:48 +02:00
|
|
|
|
2018-06-27 00:05:11 +02:00
|
|
|
NodePath root_motion_track;
|
2022-11-26 08:04:15 +01:00
|
|
|
Vector3 root_motion_position = Vector3(0, 0, 0);
|
|
|
|
Quaternion root_motion_rotation = Quaternion(0, 0, 0, 1);
|
|
|
|
Vector3 root_motion_scale = Vector3(0, 0, 0);
|
2018-06-27 00:05:11 +02:00
|
|
|
|
2018-08-20 18:38:18 +02:00
|
|
|
friend class AnimationNode;
|
2021-02-07 22:29:31 +01:00
|
|
|
bool properties_dirty = true;
|
2018-08-20 18:38:18 +02:00
|
|
|
void _tree_changed();
|
|
|
|
void _update_properties();
|
|
|
|
List<PropertyInfo> properties;
|
2020-03-17 07:33:00 +01:00
|
|
|
HashMap<StringName, HashMap<StringName, StringName>> property_parent_map;
|
2023-01-12 13:51:03 +01:00
|
|
|
HashMap<StringName, Pair<Variant, bool>> property_map; // Property value and read-only flag.
|
2018-08-20 18:38:18 +02:00
|
|
|
|
2018-08-23 21:44:10 +02:00
|
|
|
struct Activity {
|
2021-02-07 22:29:31 +01:00
|
|
|
uint64_t last_pass = 0;
|
2021-08-10 00:15:17 +02:00
|
|
|
real_t activity = 0.0;
|
2018-08-23 21:44:10 +02:00
|
|
|
};
|
|
|
|
|
2020-03-17 07:33:00 +01:00
|
|
|
HashMap<StringName, Vector<Activity>> input_activity_map;
|
2018-08-23 21:44:10 +02:00
|
|
|
HashMap<StringName, Vector<Activity> *> input_activity_map_get;
|
|
|
|
|
2018-08-20 18:38:18 +02:00
|
|
|
void _update_properties_for_node(const String &p_base_path, Ref<AnimationNode> node);
|
|
|
|
|
2018-08-24 16:41:04 +02:00
|
|
|
ObjectID last_animation_player;
|
|
|
|
|
2018-06-19 03:10:48 +02:00
|
|
|
protected:
|
2018-08-20 18:38:18 +02:00
|
|
|
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;
|
|
|
|
|
2018-06-19 03:10:48 +02:00
|
|
|
void _notification(int p_what);
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2023-01-19 16:43:37 +01:00
|
|
|
GDVIRTUAL5RC(Variant, _post_process_key_value, Ref<Animation>, int, Variant, Object *, int);
|
|
|
|
Variant post_process_key_value(const Ref<Animation> &p_anim, int p_track, Variant p_value, const Object *p_object, int p_object_idx = -1);
|
2022-07-26 11:48:08 +02:00
|
|
|
virtual Variant _post_process_key_value(const Ref<Animation> &p_anim, int p_track, Variant p_value, const Object *p_object, int p_object_idx = -1);
|
|
|
|
|
2018-06-19 03:10:48 +02:00
|
|
|
public:
|
2018-06-27 08:00:08 +02:00
|
|
|
void set_tree_root(const Ref<AnimationNode> &p_root);
|
|
|
|
Ref<AnimationNode> get_tree_root() const;
|
2018-06-19 03:10:48 +02:00
|
|
|
|
|
|
|
void set_active(bool p_active);
|
|
|
|
bool is_active() const;
|
|
|
|
|
2021-02-18 19:52:29 +01:00
|
|
|
void set_process_callback(AnimationProcessCallback p_mode);
|
|
|
|
AnimationProcessCallback get_process_callback() const;
|
2018-06-19 03:10:48 +02:00
|
|
|
|
|
|
|
void set_animation_player(const NodePath &p_player);
|
|
|
|
NodePath get_animation_player() const;
|
|
|
|
|
2022-04-20 12:36:54 +02:00
|
|
|
void set_advance_expression_base_node(const NodePath &p_advance_expression_base_node);
|
|
|
|
NodePath get_advance_expression_base_node() const;
|
|
|
|
|
2023-01-27 19:25:49 +01:00
|
|
|
void set_audio_max_polyphony(int p_audio_max_polyphony);
|
|
|
|
int get_audio_max_polyphony() const;
|
|
|
|
|
2022-09-19 17:43:15 +02:00
|
|
|
PackedStringArray get_configuration_warnings() const override;
|
2018-06-19 03:10:48 +02:00
|
|
|
|
|
|
|
bool is_state_invalid() const;
|
|
|
|
String get_invalid_state_reason() const;
|
|
|
|
|
2018-06-27 00:05:11 +02:00
|
|
|
void set_root_motion_track(const NodePath &p_track);
|
|
|
|
NodePath get_root_motion_track() const;
|
|
|
|
|
2022-11-26 08:04:15 +01:00
|
|
|
Vector3 get_root_motion_position() const;
|
|
|
|
Quaternion get_root_motion_rotation() const;
|
|
|
|
Vector3 get_root_motion_scale() const;
|
2018-06-27 00:05:11 +02:00
|
|
|
|
2021-08-10 00:15:17 +02:00
|
|
|
real_t get_connection_activity(const StringName &p_path, int p_connection) const;
|
2022-09-22 15:54:15 +02:00
|
|
|
void advance(double p_time);
|
2018-08-02 09:22:24 +02:00
|
|
|
|
2018-06-19 03:10:48 +02:00
|
|
|
uint64_t get_last_process_pass() const;
|
2018-06-25 23:40:24 +02:00
|
|
|
AnimationTree();
|
|
|
|
~AnimationTree();
|
2018-06-19 03:10:48 +02:00
|
|
|
};
|
|
|
|
|
2021-02-18 19:52:29 +01:00
|
|
|
VARIANT_ENUM_CAST(AnimationTree::AnimationProcessCallback)
|
2018-06-19 03:10:48 +02:00
|
|
|
|
2022-07-23 23:41:51 +02:00
|
|
|
#endif // ANIMATION_TREE_H
|