summaryrefslogtreecommitdiff
path: root/scene/animation/animation_tree.h
diff options
context:
space:
mode:
Diffstat (limited to 'scene/animation/animation_tree.h')
-rw-r--r--scene/animation/animation_tree.h149
1 files changed, 69 insertions, 80 deletions
diff --git a/scene/animation/animation_tree.h b/scene/animation/animation_tree.h
index d558170f23..1e0267682e 100644
--- a/scene/animation/animation_tree.h
+++ b/scene/animation/animation_tree.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 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 */
@@ -52,69 +52,74 @@ public:
};
struct Input {
-
String name;
};
Vector<Input> inputs;
- float process_input(int p_input, float p_time, bool p_seek, float p_blend);
+ real_t process_input(int p_input, real_t p_time, bool p_seek, real_t p_blend);
friend class AnimationTree;
struct AnimationState {
-
Ref<Animation> animation;
- float time;
- float delta;
- const Vector<float> *track_blends;
- float blend;
- bool seeked;
+ double time = 0.0;
+ double delta = 0.0;
+ const Vector<real_t> *track_blends = nullptr;
+ real_t blend = 0.0;
+ bool seeked = false;
};
struct State {
-
- int track_count;
+ int track_count = 0;
HashMap<NodePath, int> track_map;
List<AnimationState> animation_states;
- bool valid;
- AnimationPlayer *player;
- AnimationTree *tree;
+ bool valid = false;
+ AnimationPlayer *player = nullptr;
+ AnimationTree *tree = nullptr;
String invalid_reasons;
- uint64_t last_pass;
+ uint64_t last_pass = 0;
};
- Vector<float> blends;
- State *state;
+ Vector<real_t> blends;
+ State *state = nullptr;
- float _pre_process(const StringName &p_base_path, AnimationNode *p_parent, State *p_state, float p_time, bool p_seek, const Vector<StringName> &p_connections);
+ real_t _pre_process(const StringName &p_base_path, AnimationNode *p_parent, State *p_state, real_t p_time, bool p_seek, const Vector<StringName> &p_connections);
void _pre_update_animations(HashMap<NodePath, int> *track_map);
//all this is temporary
StringName base_path;
Vector<StringName> connections;
- AnimationNode *parent;
+ AnimationNode *parent = nullptr;
HashMap<NodePath, bool> filter;
- bool filter_enabled;
+ bool filter_enabled = false;
Array _get_filters() const;
void _set_filters(const Array &p_filters);
friend class AnimationNodeBlendTree;
- float _blend_node(const StringName &p_subpath, const Vector<StringName> &p_connections, AnimationNode *p_new_parent, 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 = nullptr);
+ real_t _blend_node(const StringName &p_subpath, const Vector<StringName> &p_connections, AnimationNode *p_new_parent, Ref<AnimationNode> p_node, real_t p_time, bool p_seek, real_t p_blend, FilterAction p_filter = FILTER_IGNORE, bool p_optimize = true, real_t *r_max = nullptr);
protected:
- void blend_animation(const StringName &p_animation, float p_time, float p_delta, bool p_seeked, float p_blend);
- float blend_node(const StringName &p_sub_path, Ref<AnimationNode> p_node, float p_time, bool p_seek, float p_blend, FilterAction p_filter = FILTER_IGNORE, bool p_optimize = true);
- float blend_input(int p_input, float p_time, bool p_seek, float p_blend, FilterAction p_filter = FILTER_IGNORE, bool p_optimize = true);
+ void blend_animation(const StringName &p_animation, real_t p_time, real_t p_delta, bool p_seeked, real_t p_blend);
+ real_t blend_node(const StringName &p_sub_path, Ref<AnimationNode> p_node, real_t p_time, bool p_seek, real_t p_blend, FilterAction p_filter = FILTER_IGNORE, bool p_optimize = true);
+ real_t blend_input(int p_input, real_t p_time, bool p_seek, real_t p_blend, FilterAction p_filter = FILTER_IGNORE, bool p_optimize = true);
void make_invalid(const String &p_reason);
static void _bind_methods();
- void _validate_property(PropertyInfo &property) const;
+ void _validate_property(PropertyInfo &property) const override;
void _set_parent(Object *p_parent);
+ 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)
+ GDVIRTUAL2RC(double, _process, double, bool)
+ GDVIRTUAL0RC(String, _get_caption)
+ GDVIRTUAL0RC(bool, _has_filter)
+
public:
virtual void get_parameter_list(List<PropertyInfo> *r_list) const;
virtual Variant get_parameter_default_value(const StringName &p_parameter) const;
@@ -129,7 +134,7 @@ public:
virtual void get_child_nodes(List<ChildNode> *r_child_nodes);
- virtual float process(float p_time, bool p_seek);
+ virtual double process(double p_time, bool p_seek);
virtual String get_caption() const;
int get_input_count() const;
@@ -166,7 +171,7 @@ class AnimationTree : public Node {
GDCLASS(AnimationTree, Node);
public:
- enum AnimationProcessMode {
+ enum AnimationProcessCallback {
ANIMATION_PROCESS_PHYSICS,
ANIMATION_PROCESS_IDLE,
ANIMATION_PROCESS_MANUAL,
@@ -174,83 +179,67 @@ public:
private:
struct TrackCache {
-
- bool root_motion;
- uint64_t setup_pass;
- uint64_t process_pass;
- Animation::TrackType type;
- Object *object;
+ bool root_motion = false;
+ uint64_t setup_pass = 0;
+ uint64_t process_pass = 0;
+ Animation::TrackType type = Animation::TrackType::TYPE_ANIMATION;
+ Object *object = nullptr;
ObjectID object_id;
TrackCache() {
- root_motion = false;
- setup_pass = 0;
- process_pass = 0;
- object = nullptr;
}
virtual ~TrackCache() {}
};
struct TrackCacheTransform : public TrackCache {
- Node3D *spatial;
- Skeleton3D *skeleton;
- int bone_idx;
+#ifndef _3D_DISABLED
+ Node3D *node_3d = nullptr;
+ Skeleton3D *skeleton = nullptr;
+#endif // _3D_DISABLED
+ int bone_idx = -1;
Vector3 loc;
- Quat rot;
- float rot_blend_accum;
+ Quaternion rot;
+ real_t rot_blend_accum = 0.0;
Vector3 scale;
TrackCacheTransform() {
- type = Animation::TYPE_TRANSFORM;
- spatial = nullptr;
- bone_idx = -1;
- skeleton = nullptr;
+ type = Animation::TYPE_TRANSFORM3D;
}
};
struct TrackCacheValue : public TrackCache {
-
Variant value;
Vector<StringName> subpath;
TrackCacheValue() { type = Animation::TYPE_VALUE; }
};
struct TrackCacheMethod : public TrackCache {
-
TrackCacheMethod() { type = Animation::TYPE_METHOD; }
};
struct TrackCacheBezier : public TrackCache {
-
- float value;
+ real_t value = 0.0;
Vector<StringName> subpath;
TrackCacheBezier() {
type = Animation::TYPE_BEZIER;
- value = 0;
}
};
struct TrackCacheAudio : public TrackCache {
-
- bool playing;
- float start;
- float len;
+ bool playing = false;
+ real_t start = 0.0;
+ real_t len = 0.0;
TrackCacheAudio() {
type = Animation::TYPE_AUDIO;
- playing = false;
- start = 0;
- len = 0;
}
};
struct TrackCacheAnimation : public TrackCache {
-
- bool playing;
+ bool playing = false;
TrackCacheAnimation() {
type = Animation::TYPE_ANIMATION;
- playing = false;
}
};
@@ -259,29 +248,29 @@ private:
Ref<AnimationNode> root;
- AnimationProcessMode process_mode;
- bool active;
+ AnimationProcessCallback process_callback = ANIMATION_PROCESS_IDLE;
+ bool active = false;
NodePath animation_player;
AnimationNode::State state;
- bool cache_valid;
+ bool cache_valid = false;
void _node_removed(Node *p_node);
void _caches_cleared();
void _clear_caches();
bool _update_caches(AnimationPlayer *player);
- void _process_graph(float p_delta);
+ void _process_graph(real_t p_delta);
- uint64_t setup_pass;
- uint64_t process_pass;
+ uint64_t setup_pass = 1;
+ uint64_t process_pass = 1;
- bool started;
+ bool started = true;
NodePath root_motion_track;
- Transform root_motion_transform;
+ Transform3D root_motion_transform;
friend class AnimationNode;
- bool properties_dirty;
+ bool properties_dirty = true;
void _tree_changed();
void _update_properties();
List<PropertyInfo> properties;
@@ -289,8 +278,8 @@ private:
HashMap<StringName, Variant> property_map;
struct Activity {
- uint64_t last_pass;
- float activity;
+ uint64_t last_pass = 0;
+ real_t activity = 0.0;
};
HashMap<StringName, Vector<Activity>> input_activity_map;
@@ -315,13 +304,13 @@ public:
void set_active(bool p_active);
bool is_active() const;
- void set_process_mode(AnimationProcessMode p_mode);
- AnimationProcessMode get_process_mode() const;
+ void set_process_callback(AnimationProcessCallback p_mode);
+ AnimationProcessCallback get_process_callback() const;
void set_animation_player(const NodePath &p_player);
NodePath get_animation_player() const;
- virtual String get_configuration_warning() const;
+ TypedArray<String> get_configuration_warnings() const override;
bool is_state_invalid() const;
String get_invalid_state_reason() const;
@@ -329,10 +318,10 @@ public:
void set_root_motion_track(const NodePath &p_track);
NodePath get_root_motion_track() const;
- Transform get_root_motion_transform() const;
+ Transform3D get_root_motion_transform() const;
- float get_connection_activity(const StringName &p_path, int p_connection) const;
- void advance(float p_time);
+ real_t get_connection_activity(const StringName &p_path, int p_connection) const;
+ void advance(real_t p_time);
void rename_parameter(const String &p_base, const String &p_new_base);
@@ -341,6 +330,6 @@ public:
~AnimationTree();
};
-VARIANT_ENUM_CAST(AnimationTree::AnimationProcessMode)
+VARIANT_ENUM_CAST(AnimationTree::AnimationProcessCallback)
#endif // ANIMATION_GRAPH_PLAYER_H