summaryrefslogtreecommitdiff
path: root/scene/animation
diff options
context:
space:
mode:
Diffstat (limited to 'scene/animation')
-rw-r--r--scene/animation/animation_blend_space_1d.h14
-rw-r--r--scene/animation/animation_blend_space_2d.h14
-rw-r--r--scene/animation/animation_blend_tree.h94
-rw-r--r--scene/animation/animation_node_state_machine.h12
-rw-r--r--scene/animation/animation_player.cpp4
-rw-r--r--scene/animation/animation_player.h4
-rw-r--r--scene/animation/animation_tree.cpp36
-rw-r--r--scene/animation/animation_tree.h4
-rw-r--r--scene/animation/root_motion_view.h4
-rw-r--r--scene/animation/tween.cpp14
10 files changed, 95 insertions, 105 deletions
diff --git a/scene/animation/animation_blend_space_1d.h b/scene/animation/animation_blend_space_1d.h
index da3608e06d..816d3c9d4e 100644
--- a/scene/animation/animation_blend_space_1d.h
+++ b/scene/animation/animation_blend_space_1d.h
@@ -63,14 +63,14 @@ class AnimationNodeBlendSpace1D : public AnimationRootNode {
StringName blend_position;
protected:
- virtual void _validate_property(PropertyInfo &property) const;
+ virtual void _validate_property(PropertyInfo &property) const override;
static void _bind_methods();
public:
- virtual void get_parameter_list(List<PropertyInfo> *r_list) const;
- virtual Variant get_parameter_default_value(const StringName &p_parameter) const;
+ virtual void get_parameter_list(List<PropertyInfo> *r_list) const override;
+ virtual Variant get_parameter_default_value(const StringName &p_parameter) const override;
- virtual void get_child_nodes(List<ChildNode> *r_child_nodes);
+ virtual void get_child_nodes(List<ChildNode> *r_child_nodes) override;
void add_blend_point(const Ref<AnimationRootNode> &p_node, float p_position, int p_at_index = -1);
void set_blend_point_position(int p_point, float p_position);
@@ -93,10 +93,10 @@ public:
void set_value_label(const String &p_label);
String get_value_label() const;
- float process(float p_time, bool p_seek);
- String get_caption() const;
+ float process(float p_time, bool p_seek) override;
+ String get_caption() const override;
- Ref<AnimationNode> get_child_by_name(const StringName &p_name);
+ Ref<AnimationNode> get_child_by_name(const StringName &p_name) override;
AnimationNodeBlendSpace1D();
~AnimationNodeBlendSpace1D();
diff --git a/scene/animation/animation_blend_space_2d.h b/scene/animation/animation_blend_space_2d.h
index 7d197ef920..2aff678aad 100644
--- a/scene/animation/animation_blend_space_2d.h
+++ b/scene/animation/animation_blend_space_2d.h
@@ -88,14 +88,14 @@ protected:
void _tree_changed();
protected:
- virtual void _validate_property(PropertyInfo &property) const;
+ virtual void _validate_property(PropertyInfo &property) const override;
static void _bind_methods();
public:
- virtual void get_parameter_list(List<PropertyInfo> *r_list) const;
- virtual Variant get_parameter_default_value(const StringName &p_parameter) const;
+ virtual void get_parameter_list(List<PropertyInfo> *r_list) const override;
+ virtual Variant get_parameter_default_value(const StringName &p_parameter) const override;
- virtual void get_child_nodes(List<ChildNode> *r_child_nodes);
+ virtual void get_child_nodes(List<ChildNode> *r_child_nodes) override;
void add_blend_point(const Ref<AnimationRootNode> &p_node, const Vector2 &p_position, int p_at_index = -1);
void set_blend_point_position(int p_point, const Vector2 &p_position);
@@ -126,8 +126,8 @@ public:
void set_y_label(const String &p_label);
String get_y_label() const;
- virtual float process(float p_time, bool p_seek);
- virtual String get_caption() const;
+ virtual float process(float p_time, bool p_seek) override;
+ virtual String get_caption() const override;
Vector2 get_closest_point(const Vector2 &p_point);
@@ -137,7 +137,7 @@ public:
void set_blend_mode(BlendMode p_blend_mode);
BlendMode get_blend_mode() const;
- virtual Ref<AnimationNode> get_child_by_name(const StringName &p_name);
+ virtual Ref<AnimationNode> get_child_by_name(const StringName &p_name) override;
AnimationNodeBlendSpace2D();
~AnimationNodeBlendSpace2D();
diff --git a/scene/animation/animation_blend_tree.h b/scene/animation/animation_blend_tree.h
index 5c722d00f9..7241a6bc13 100644
--- a/scene/animation/animation_blend_tree.h
+++ b/scene/animation/animation_blend_tree.h
@@ -43,17 +43,17 @@ class AnimationNodeAnimation : public AnimationRootNode {
bool skip;
protected:
- void _validate_property(PropertyInfo &property) const;
+ void _validate_property(PropertyInfo &property) const override;
static void _bind_methods();
public:
- void get_parameter_list(List<PropertyInfo> *r_list) const;
+ void get_parameter_list(List<PropertyInfo> *r_list) const override;
static Vector<String> (*get_editable_animation_list)();
- virtual String get_caption() const;
- virtual float process(float p_time, bool p_seek);
+ virtual String get_caption() const override;
+ virtual float process(float p_time, bool p_seek) override;
void set_animation(const StringName &p_name);
StringName get_animation() const;
@@ -96,10 +96,10 @@ protected:
static void _bind_methods();
public:
- virtual void get_parameter_list(List<PropertyInfo> *r_list) const;
- virtual Variant get_parameter_default_value(const StringName &p_parameter) const;
+ virtual void get_parameter_list(List<PropertyInfo> *r_list) const override;
+ virtual Variant get_parameter_default_value(const StringName &p_parameter) const override;
- virtual String get_caption() const;
+ virtual String get_caption() const override;
void set_fadein_time(float p_time);
void set_fadeout_time(float p_time);
@@ -121,8 +121,8 @@ public:
void set_use_sync(bool p_sync);
bool is_using_sync() const;
- virtual bool has_filter() const;
- virtual float process(float p_time, bool p_seek);
+ virtual bool has_filter() const override;
+ virtual float process(float p_time, bool p_seek) override;
AnimationNodeOneShot();
};
@@ -139,16 +139,16 @@ protected:
static void _bind_methods();
public:
- void get_parameter_list(List<PropertyInfo> *r_list) const;
- virtual Variant get_parameter_default_value(const StringName &p_parameter) const;
+ void get_parameter_list(List<PropertyInfo> *r_list) const override;
+ virtual Variant get_parameter_default_value(const StringName &p_parameter) const override;
- virtual String get_caption() const;
+ virtual String get_caption() const override;
void set_use_sync(bool p_sync);
bool is_using_sync() const;
- virtual bool has_filter() const;
- virtual float process(float p_time, bool p_seek);
+ virtual bool has_filter() const override;
+ virtual float process(float p_time, bool p_seek) override;
AnimationNodeAdd2();
};
@@ -163,16 +163,16 @@ protected:
static void _bind_methods();
public:
- void get_parameter_list(List<PropertyInfo> *r_list) const;
- virtual Variant get_parameter_default_value(const StringName &p_parameter) const;
+ void get_parameter_list(List<PropertyInfo> *r_list) const override;
+ virtual Variant get_parameter_default_value(const StringName &p_parameter) const override;
- virtual String get_caption() const;
+ virtual String get_caption() const override;
void set_use_sync(bool p_sync);
bool is_using_sync() const;
- virtual bool has_filter() const;
- virtual float process(float p_time, bool p_seek);
+ virtual bool has_filter() const override;
+ virtual float process(float p_time, bool p_seek) override;
AnimationNodeAdd3();
};
@@ -187,16 +187,16 @@ protected:
static void _bind_methods();
public:
- virtual void get_parameter_list(List<PropertyInfo> *r_list) const;
- virtual Variant get_parameter_default_value(const StringName &p_parameter) const;
+ virtual void get_parameter_list(List<PropertyInfo> *r_list) const override;
+ virtual Variant get_parameter_default_value(const StringName &p_parameter) const override;
- virtual String get_caption() const;
- virtual float process(float p_time, bool p_seek);
+ virtual String get_caption() const override;
+ virtual float process(float p_time, bool p_seek) override;
void set_use_sync(bool p_sync);
bool is_using_sync() const;
- virtual bool has_filter() const;
+ virtual bool has_filter() const override;
AnimationNodeBlend2();
};
@@ -210,15 +210,15 @@ protected:
static void _bind_methods();
public:
- virtual void get_parameter_list(List<PropertyInfo> *r_list) const;
- virtual Variant get_parameter_default_value(const StringName &p_parameter) const;
+ virtual void get_parameter_list(List<PropertyInfo> *r_list) const override;
+ virtual Variant get_parameter_default_value(const StringName &p_parameter) const override;
- virtual String get_caption() const;
+ virtual String get_caption() const override;
void set_use_sync(bool p_sync);
bool is_using_sync() const;
- float process(float p_time, bool p_seek);
+ float process(float p_time, bool p_seek) override;
AnimationNodeBlend3();
};
@@ -231,12 +231,12 @@ protected:
static void _bind_methods();
public:
- virtual void get_parameter_list(List<PropertyInfo> *r_list) const;
- virtual Variant get_parameter_default_value(const StringName &p_parameter) const;
+ virtual void get_parameter_list(List<PropertyInfo> *r_list) const override;
+ virtual Variant get_parameter_default_value(const StringName &p_parameter) const override;
- virtual String get_caption() const;
+ virtual String get_caption() const override;
- float process(float p_time, bool p_seek);
+ float process(float p_time, bool p_seek) override;
AnimationNodeTimeScale();
};
@@ -250,12 +250,12 @@ protected:
static void _bind_methods();
public:
- virtual void get_parameter_list(List<PropertyInfo> *r_list) const;
- virtual Variant get_parameter_default_value(const StringName &p_parameter) const;
+ virtual void get_parameter_list(List<PropertyInfo> *r_list) const override;
+ virtual Variant get_parameter_default_value(const StringName &p_parameter) const override;
- virtual String get_caption() const;
+ virtual String get_caption() const override;
- float process(float p_time, bool p_seek);
+ float process(float p_time, bool p_seek) override;
AnimationNodeTimeSeek();
};
@@ -294,13 +294,13 @@ class AnimationNodeTransition : public AnimationNode {
protected:
static void _bind_methods();
- void _validate_property(PropertyInfo &property) const;
+ void _validate_property(PropertyInfo &property) const override;
public:
- virtual void get_parameter_list(List<PropertyInfo> *r_list) const;
- virtual Variant get_parameter_default_value(const StringName &p_parameter) const;
+ virtual void get_parameter_list(List<PropertyInfo> *r_list) const override;
+ virtual Variant get_parameter_default_value(const StringName &p_parameter) const override;
- virtual String get_caption() const;
+ virtual String get_caption() const override;
void set_enabled_inputs(int p_inputs);
int get_enabled_inputs();
@@ -314,7 +314,7 @@ public:
void set_cross_fade_time(float p_fade);
float get_cross_fade_time() const;
- float process(float p_time, bool p_seek);
+ float process(float p_time, bool p_seek) override;
AnimationNodeTransition();
};
@@ -323,8 +323,8 @@ class AnimationNodeOutput : public AnimationNode {
GDCLASS(AnimationNodeOutput, AnimationNode);
public:
- virtual String get_caption() const;
- virtual float process(float p_time, bool p_seek);
+ virtual String get_caption() const override;
+ virtual float process(float p_time, bool p_seek) override;
AnimationNodeOutput();
};
@@ -374,7 +374,7 @@ public:
void set_node_position(const StringName &p_node, const Vector2 &p_position);
Vector2 get_node_position(const StringName &p_node) const;
- virtual void get_child_nodes(List<ChildNode> *r_child_nodes);
+ virtual void get_child_nodes(List<ChildNode> *r_child_nodes) override;
void connect_node(const StringName &p_input_node, int p_input_index, const StringName &p_output_node);
void disconnect_node(const StringName &p_node, int p_input_index);
@@ -388,15 +388,15 @@ public:
ConnectionError can_connect_node(const StringName &p_input_node, int p_input_index, const StringName &p_output_node) const;
void get_node_connections(List<NodeConnection> *r_connections) const;
- virtual String get_caption() const;
- virtual float process(float p_time, bool p_seek);
+ virtual String get_caption() const override;
+ virtual float process(float p_time, bool p_seek) override;
void get_node_list(List<StringName> *r_list);
void set_graph_offset(const Vector2 &p_graph_offset);
Vector2 get_graph_offset() const;
- virtual Ref<AnimationNode> get_child_by_name(const StringName &p_name);
+ virtual Ref<AnimationNode> get_child_by_name(const StringName &p_name) override;
AnimationNodeBlendTree();
~AnimationNodeBlendTree();
diff --git a/scene/animation/animation_node_state_machine.h b/scene/animation/animation_node_state_machine.h
index 72fa6f77d0..ae8975e940 100644
--- a/scene/animation/animation_node_state_machine.h
+++ b/scene/animation/animation_node_state_machine.h
@@ -172,8 +172,8 @@ protected:
void _get_property_list(List<PropertyInfo> *p_list) const;
public:
- virtual void get_parameter_list(List<PropertyInfo> *r_list) const;
- virtual Variant get_parameter_default_value(const StringName &p_parameter) const;
+ virtual void get_parameter_list(List<PropertyInfo> *r_list) const override;
+ virtual Variant get_parameter_default_value(const StringName &p_parameter) const override;
void add_node(const StringName &p_name, Ref<AnimationNode> p_node, const Vector2 &p_position = Vector2());
void replace_node(const StringName &p_name, Ref<AnimationNode> p_node);
@@ -187,7 +187,7 @@ public:
void set_node_position(const StringName &p_name, const Vector2 &p_position);
Vector2 get_node_position(const StringName &p_name) const;
- virtual void get_child_nodes(List<ChildNode> *r_child_nodes);
+ virtual void get_child_nodes(List<ChildNode> *r_child_nodes) override;
bool has_transition(const StringName &p_from, const StringName &p_to) const;
int find_transition(const StringName &p_from, const StringName &p_to) const;
@@ -208,10 +208,10 @@ public:
void set_graph_offset(const Vector2 &p_offset);
Vector2 get_graph_offset() const;
- virtual float process(float p_time, bool p_seek);
- virtual String get_caption() const;
+ virtual float process(float p_time, bool p_seek) override;
+ virtual String get_caption() const override;
- virtual Ref<AnimationNode> get_child_by_name(const StringName &p_name);
+ virtual Ref<AnimationNode> get_child_by_name(const StringName &p_name) override;
AnimationNodeStateMachine();
};
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp
index 66c587e2d4..30757d2d80 100644
--- a/scene/animation/animation_player.cpp
+++ b/scene/animation/animation_player.cpp
@@ -1294,12 +1294,12 @@ bool AnimationPlayer::is_valid() const {
}
float AnimationPlayer::get_current_animation_position() const {
- ERR_FAIL_COND_V(!playback.current.from, 0);
+ ERR_FAIL_COND_V_MSG(!playback.current.from, 0, "AnimationPlayer has no current animation");
return playback.current.pos;
}
float AnimationPlayer::get_current_animation_length() const {
- ERR_FAIL_COND_V(!playback.current.from, 0);
+ ERR_FAIL_COND_V_MSG(!playback.current.from, 0, "AnimationPlayer has no current animation");
return playback.current.from->animation->get_length();
}
diff --git a/scene/animation/animation_player.h b/scene/animation/animation_player.h
index 1a66665803..e1b9dffb1f 100644
--- a/scene/animation/animation_player.h
+++ b/scene/animation/animation_player.h
@@ -257,7 +257,7 @@ private:
protected:
bool _set(const StringName &p_name, const Variant &p_value);
bool _get(const StringName &p_name, Variant &r_ret) const;
- virtual void _validate_property(PropertyInfo &property) const;
+ virtual void _validate_property(PropertyInfo &property) const override;
void _get_property_list(List<PropertyInfo> *p_list) const;
void _notification(int p_what);
@@ -323,7 +323,7 @@ public:
void clear_caches(); ///< must be called by hand if an animation was modified after added
- void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const;
+ void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;
#ifdef TOOLS_ENABLED
// These may be interesting for games, but are too dangerous for general use
diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp
index 466536db10..d7d55b468e 100644
--- a/scene/animation/animation_tree.cpp
+++ b/scene/animation/animation_tree.cpp
@@ -1288,39 +1288,31 @@ String AnimationTree::get_configuration_warning() const {
String warning = Node::get_configuration_warning();
if (!root.is_valid()) {
- if (warning != String()) {
+ if (!warning.empty()) {
warning += "\n\n";
}
warning += TTR("No root AnimationNode for the graph is set.");
}
if (!has_node(animation_player)) {
- if (warning != String()) {
+ if (!warning.empty()) {
warning += "\n\n";
}
-
warning += TTR("Path to an AnimationPlayer node containing animations is not set.");
- return warning;
- }
-
- AnimationPlayer *player = Object::cast_to<AnimationPlayer>(get_node(animation_player));
-
- if (!player) {
- if (warning != String()) {
- warning += "\n\n";
- }
-
- warning += TTR("Path set for AnimationPlayer does not lead to an AnimationPlayer node.");
- return warning;
- }
+ } else {
+ AnimationPlayer *player = Object::cast_to<AnimationPlayer>(get_node(animation_player));
- if (!player->has_node(player->get_root())) {
- if (warning != String()) {
- warning += "\n\n";
+ if (!player) {
+ if (!warning.empty()) {
+ warning += "\n\n";
+ }
+ warning += TTR("Path set for AnimationPlayer does not lead to an AnimationPlayer node.");
+ } else if (!player->has_node(player->get_root())) {
+ if (!warning.empty()) {
+ warning += "\n\n";
+ }
+ warning += TTR("The AnimationPlayer root node is not a valid node.");
}
-
- warning += TTR("The AnimationPlayer root node is not a valid node.");
- return warning;
}
return warning;
diff --git a/scene/animation/animation_tree.h b/scene/animation/animation_tree.h
index 8fe01fac8f..166ca04f40 100644
--- a/scene/animation/animation_tree.h
+++ b/scene/animation/animation_tree.h
@@ -108,7 +108,7 @@ protected:
static void _bind_methods();
- void _validate_property(PropertyInfo &property) const;
+ void _validate_property(PropertyInfo &property) const override;
void _set_parent(Object *p_parent);
@@ -312,7 +312,7 @@ public:
void set_animation_player(const NodePath &p_player);
NodePath get_animation_player() const;
- virtual String get_configuration_warning() const;
+ virtual String get_configuration_warning() const override;
bool is_state_invalid() const;
String get_invalid_state_reason() const;
diff --git a/scene/animation/root_motion_view.h b/scene/animation/root_motion_view.h
index c8a755a854..77c51fe47a 100644
--- a/scene/animation/root_motion_view.h
+++ b/scene/animation/root_motion_view.h
@@ -68,8 +68,8 @@ public:
void set_zero_y(bool p_zero_y);
bool get_zero_y() const;
- virtual AABB get_aabb() const;
- virtual Vector<Face3> get_faces(uint32_t p_usage_flags) const;
+ virtual AABB get_aabb() const override;
+ virtual Vector<Face3> get_faces(uint32_t p_usage_flags) const override;
RootMotionView();
~RootMotionView();
diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp
index 854db5fee2..bd4396d680 100644
--- a/scene/animation/tween.cpp
+++ b/scene/animation/tween.cpp
@@ -701,21 +701,21 @@ void Tween::_tween_process(float p_delta) {
}
// Are all of the tweens complete?
- bool all_finished = true;
+ int any_unfinished = 0;
// For each tween we wish to interpolate...
for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
// Get the data from it
InterpolateData &data = E->get();
- // Track if we hit one that isn't finished yet
- all_finished = all_finished && data.finish;
-
// Is the data not active or already finished? No need to go any further
if (!data.active || data.finish) {
continue;
}
+ // Track if we hit one that isn't finished yet
+ any_unfinished++;
+
// Get the target object for this interpolation
Object *object = ObjectDB::get_instance(data.id);
if (object == nullptr) {
@@ -802,17 +802,15 @@ void Tween::_tween_process(float p_delta) {
// If we are not repeating the tween, remove it
if (!repeat) {
call_deferred("_remove_by_uid", data.uid);
+ any_unfinished--;
}
- } else if (!repeat) {
- // Check whether all tweens are finished
- all_finished = all_finished && data.finish;
}
}
// One less update left to go
pending_update--;
// If all tweens are completed, we no longer need to be active
- if (all_finished) {
+ if (any_unfinished == 0) {
set_active(false);
emit_signal("tween_all_completed");
}