summaryrefslogtreecommitdiff
path: root/scene/animation
diff options
context:
space:
mode:
Diffstat (limited to 'scene/animation')
-rw-r--r--scene/animation/animation_blend_tree.cpp2
-rw-r--r--scene/animation/animation_node_state_machine.cpp6
-rw-r--r--scene/animation/animation_player.cpp4
-rw-r--r--scene/animation/animation_tree.cpp36
-rw-r--r--scene/animation/animation_tree.h16
-rw-r--r--scene/animation/tween.cpp10
6 files changed, 42 insertions, 32 deletions
diff --git a/scene/animation/animation_blend_tree.cpp b/scene/animation/animation_blend_tree.cpp
index 3b55dd4a42..3d0ac291b8 100644
--- a/scene/animation/animation_blend_tree.cpp
+++ b/scene/animation/animation_blend_tree.cpp
@@ -857,7 +857,7 @@ 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_name == SceneStringNames::get_singleton()->output);
- ERR_FAIL_COND(String(p_name).find("/") != -1);
+ ERR_FAIL_COND(String(p_name).contains("/"));
Node n;
n.node = p_node;
diff --git a/scene/animation/animation_node_state_machine.cpp b/scene/animation/animation_node_state_machine.cpp
index a23e1b689c..a68f7e037d 100644
--- a/scene/animation/animation_node_state_machine.cpp
+++ b/scene/animation/animation_node_state_machine.cpp
@@ -50,7 +50,7 @@ bool AnimationNodeStateMachineTransition::has_auto_advance() const {
void AnimationNodeStateMachineTransition::set_advance_condition(const StringName &p_condition) {
String cs = p_condition;
- ERR_FAIL_COND(cs.find("/") != -1 || cs.find(":") != -1);
+ ERR_FAIL_COND(cs.contains("/") || cs.contains(":"));
advance_condition = p_condition;
if (!cs.is_empty()) {
advance_condition_name = "conditions/" + cs;
@@ -536,7 +536,7 @@ Variant AnimationNodeStateMachine::get_parameter_default_value(const StringName
void AnimationNodeStateMachine::add_node(const StringName &p_name, Ref<AnimationNode> p_node, const Vector2 &p_position) {
ERR_FAIL_COND(states.has(p_name));
ERR_FAIL_COND(p_node.is_null());
- ERR_FAIL_COND(String(p_name).find("/") != -1);
+ ERR_FAIL_COND(String(p_name).contains("/"));
State state;
state.node = p_node;
@@ -553,7 +553,7 @@ void AnimationNodeStateMachine::add_node(const StringName &p_name, Ref<Animation
void AnimationNodeStateMachine::replace_node(const StringName &p_name, Ref<AnimationNode> p_node) {
ERR_FAIL_COND(states.has(p_name) == false);
ERR_FAIL_COND(p_node.is_null());
- ERR_FAIL_COND(String(p_name).find("/") != -1);
+ ERR_FAIL_COND(String(p_name).contains("/"));
{
Ref<AnimationNode> node = states[p_name].node;
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp
index 128c6cae8b..4a3fd72080 100644
--- a/scene/animation/animation_player.cpp
+++ b/scene/animation/animation_player.cpp
@@ -1171,7 +1171,7 @@ void AnimationPlayer::_animation_process(double p_delta) {
Error AnimationPlayer::add_animation(const StringName &p_name, const Ref<Animation> &p_animation) {
#ifdef DEBUG_ENABLED
- ERR_FAIL_COND_V_MSG(String(p_name).find("/") != -1 || String(p_name).find(":") != -1 || String(p_name).find(",") != -1 || String(p_name).find("[") != -1, ERR_INVALID_PARAMETER, "Invalid animation name: " + String(p_name) + ".");
+ ERR_FAIL_COND_V_MSG(String(p_name).contains("/") || String(p_name).contains(":") || String(p_name).contains(",") || String(p_name).contains("["), ERR_INVALID_PARAMETER, "Invalid animation name: " + String(p_name) + ".");
#endif
ERR_FAIL_COND_V(p_animation.is_null(), ERR_INVALID_PARAMETER);
@@ -1213,7 +1213,7 @@ void AnimationPlayer::_unref_anim(const Ref<Animation> &p_anim) {
void AnimationPlayer::rename_animation(const StringName &p_name, const StringName &p_new_name) {
ERR_FAIL_COND(!animation_set.has(p_name));
- ERR_FAIL_COND(String(p_new_name).find("/") != -1 || String(p_new_name).find(":") != -1);
+ ERR_FAIL_COND(String(p_new_name).contains("/") || String(p_new_name).contains(":"));
ERR_FAIL_COND(animation_set.has(p_new_name));
stop();
diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp
index a551417778..f2f69fc439 100644
--- a/scene/animation/animation_tree.cpp
+++ b/scene/animation/animation_tree.cpp
@@ -88,7 +88,7 @@ void AnimationNode::get_child_nodes(List<ChildNode> *r_child_nodes) {
}
}
-void AnimationNode::blend_animation(const StringName &p_animation, real_t p_time, real_t p_delta, bool p_seeked, real_t p_blend, int p_pingponged) {
+void AnimationNode::blend_animation(const StringName &p_animation, double p_time, double p_delta, bool p_seeked, real_t p_blend, int p_pingponged) {
ERR_FAIL_COND(!state);
ERR_FAIL_COND(!state->player->has_animation(p_animation));
@@ -119,13 +119,13 @@ void AnimationNode::blend_animation(const StringName &p_animation, real_t p_time
state->animation_states.push_back(anim_state);
}
-real_t AnimationNode::_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) {
+double AnimationNode::_pre_process(const StringName &p_base_path, AnimationNode *p_parent, State *p_state, double p_time, bool p_seek, const Vector<StringName> &p_connections) {
base_path = p_base_path;
parent = p_parent;
connections = p_connections;
state = p_state;
- real_t t = process(p_time, p_seek);
+ double t = process(p_time, p_seek);
state = nullptr;
parent = nullptr;
@@ -144,7 +144,7 @@ void AnimationNode::make_invalid(const String &p_reason) {
state->invalid_reasons += String::utf8("• ") + p_reason;
}
-real_t AnimationNode::blend_input(int p_input, real_t p_time, bool p_seek, real_t p_blend, FilterAction p_filter, bool p_optimize) {
+double AnimationNode::blend_input(int p_input, double p_time, bool p_seek, real_t p_blend, FilterAction p_filter, bool p_optimize) {
ERR_FAIL_INDEX_V(p_input, inputs.size(), 0);
ERR_FAIL_COND_V(!state, 0);
@@ -163,7 +163,7 @@ real_t AnimationNode::blend_input(int p_input, real_t p_time, bool p_seek, real_
//inputs.write[p_input].last_pass = state->last_pass;
real_t activity = 0.0;
- real_t ret = _blend_node(node_name, blend_tree->get_node_connection_array(node_name), nullptr, node, p_time, p_seek, p_blend, p_filter, p_optimize, &activity);
+ double ret = _blend_node(node_name, blend_tree->get_node_connection_array(node_name), nullptr, node, p_time, p_seek, p_blend, p_filter, p_optimize, &activity);
Vector<AnimationTree::Activity> *activity_ptr = state->tree->input_activity_map.getptr(base_path);
@@ -174,11 +174,11 @@ real_t AnimationNode::blend_input(int p_input, real_t p_time, bool p_seek, real_
return ret;
}
-real_t AnimationNode::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, bool p_optimize) {
+double AnimationNode::blend_node(const StringName &p_sub_path, Ref<AnimationNode> p_node, double p_time, bool p_seek, real_t p_blend, FilterAction p_filter, bool p_optimize) {
return _blend_node(p_sub_path, Vector<StringName>(), this, p_node, p_time, p_seek, p_blend, p_filter, p_optimize);
}
-real_t AnimationNode::_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, bool p_optimize, real_t *r_max) {
+double AnimationNode::_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, real_t p_blend, FilterAction p_filter, bool p_optimize, real_t *r_max) {
ERR_FAIL_COND_V(!p_node.is_valid(), 0);
ERR_FAIL_COND_V(!state, 0);
@@ -314,7 +314,7 @@ void AnimationNode::add_input(const String &p_name) {
//root nodes can't add inputs
ERR_FAIL_COND(Object::cast_to<AnimationRootNode>(this) != nullptr);
Input input;
- ERR_FAIL_COND(p_name.find(".") != -1 || p_name.find("/") != -1);
+ ERR_FAIL_COND(p_name.contains(".") || p_name.contains("/"));
input.name = p_name;
inputs.push_back(input);
emit_changed();
@@ -322,7 +322,7 @@ void AnimationNode::add_input(const String &p_name) {
void AnimationNode::set_input_name(int p_input, const String &p_name) {
ERR_FAIL_INDEX(p_input, inputs.size());
- ERR_FAIL_COND(p_name.find(".") != -1 || p_name.find("/") != -1);
+ ERR_FAIL_COND(p_name.contains(".") || p_name.contains("/"));
inputs.write[p_input].name = p_name;
emit_changed();
}
@@ -796,7 +796,7 @@ void AnimationTree::_clear_caches() {
cache_valid = false;
}
-void AnimationTree::_process_graph(real_t p_delta) {
+void AnimationTree::_process_graph(double p_delta) {
_update_properties(); //if properties need updating, update them
//check all tracks, see if they need modification
@@ -1335,10 +1335,10 @@ void AnimationTree::_process_graph(real_t p_delta) {
t->playing = false;
playing_caches.erase(t);
} else {
- real_t start_ofs = a->audio_track_get_key_start_offset(i, idx);
+ double start_ofs = a->audio_track_get_key_start_offset(i, idx);
start_ofs += time - a->track_get_key_time(i, idx);
- real_t end_ofs = a->audio_track_get_key_end_offset(i, idx);
- real_t len = stream->get_length();
+ double end_ofs = a->audio_track_get_key_end_offset(i, idx);
+ double len = stream->get_length();
if (start_ofs > len - end_ofs) {
t->object->call("stop");
@@ -1374,9 +1374,9 @@ void AnimationTree::_process_graph(real_t p_delta) {
t->playing = false;
playing_caches.erase(t);
} else {
- real_t start_ofs = a->audio_track_get_key_start_offset(i, idx);
- real_t end_ofs = a->audio_track_get_key_end_offset(i, idx);
- real_t len = stream->get_length();
+ double start_ofs = a->audio_track_get_key_start_offset(i, idx);
+ double end_ofs = a->audio_track_get_key_end_offset(i, idx);
+ double len = stream->get_length();
t->object->call("set_stream", stream);
t->object->call("play", start_ofs);
@@ -1407,7 +1407,7 @@ void AnimationTree::_process_graph(real_t p_delta) {
}
}
} else if (t->len > 0) {
- real_t len = t->start > time ? (a->get_length() - t->start) + time : time - t->start;
+ double len = t->start > time ? (a->get_length() - t->start) + time : time - t->start;
if (len > t->len) {
stop = true;
@@ -1455,7 +1455,7 @@ void AnimationTree::_process_graph(real_t p_delta) {
Ref<Animation> anim = player2->get_animation(anim_name);
- real_t at_anim_pos = 0.0;
+ double at_anim_pos = 0.0;
switch (anim->get_loop_mode()) {
case Animation::LoopMode::LOOP_NONE: {
diff --git a/scene/animation/animation_tree.h b/scene/animation/animation_tree.h
index 11c9bcd4ef..705ee91c76 100644
--- a/scene/animation/animation_tree.h
+++ b/scene/animation/animation_tree.h
@@ -83,7 +83,7 @@ public:
Vector<real_t> blends;
State *state = nullptr;
- 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);
+ double _pre_process(const StringName &p_base_path, AnimationNode *p_parent, State *p_state, double p_time, bool p_seek, const Vector<StringName> &p_connections);
//all this is temporary
StringName base_path;
@@ -96,12 +96,12 @@ public:
Array _get_filters() const;
void _set_filters(const Array &p_filters);
friend class AnimationNodeBlendTree;
- 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);
+ 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, 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, real_t p_time, real_t p_delta, bool p_seeked, real_t p_blend, int p_pingponged = 0);
- 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 blend_animation(const StringName &p_animation, double p_time, double p_delta, bool p_seeked, real_t p_blend, int p_pingponged = 0);
+ double blend_node(const StringName &p_sub_path, Ref<AnimationNode> p_node, double p_time, bool p_seek, real_t p_blend, FilterAction p_filter = FILTER_IGNORE, bool p_optimize = true);
+ double blend_input(int p_input, double 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);
@@ -234,8 +234,8 @@ private:
struct TrackCacheAudio : public TrackCache {
bool playing = false;
- real_t start = 0.0;
- real_t len = 0.0;
+ double start = 0.0;
+ double len = 0.0;
TrackCacheAudio() {
type = Animation::TYPE_AUDIO;
@@ -265,7 +265,7 @@ private:
void _clear_caches();
bool _update_caches(AnimationPlayer *player);
- void _process_graph(real_t p_delta);
+ void _process_graph(double p_delta);
uint64_t setup_pass = 1;
uint64_t process_pass = 1;
diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp
index 53ff3eeeae..a2fed718be 100644
--- a/scene/animation/tween.cpp
+++ b/scene/animation/tween.cpp
@@ -283,6 +283,10 @@ bool Tween::step(float p_delta) {
float step_delta = rem_delta;
step_active = false;
+#ifdef DEBUG_ENABLED
+ float prev_delta = rem_delta;
+#endif
+
for (Ref<Tweener> &tweener : tweeners.write[current_step]) {
// Modified inside Tweener.step().
float temp_delta = rem_delta;
@@ -312,6 +316,12 @@ bool Tween::step(float p_delta) {
start_tweeners();
}
}
+
+#ifdef DEBUG_ENABLED
+ if (Math::is_equal_approx(rem_delta, prev_delta) && running && loops <= 0) {
+ ERR_FAIL_V_MSG(false, "Infinite loop detected. Check set_loops() description for more info.");
+ }
+#endif
}
return true;