summaryrefslogtreecommitdiff
path: root/scene/animation
diff options
context:
space:
mode:
Diffstat (limited to 'scene/animation')
-rw-r--r--scene/animation/animation_blend_space_1d.cpp2
-rw-r--r--scene/animation/animation_blend_space_2d.cpp2
-rw-r--r--scene/animation/animation_cache.cpp21
-rw-r--r--scene/animation/animation_node_state_machine.cpp4
-rw-r--r--scene/animation/animation_player.cpp17
-rw-r--r--scene/animation/animation_player.h3
-rw-r--r--scene/animation/animation_tree.cpp1
-rw-r--r--scene/animation/animation_tree_player.cpp20
-rw-r--r--scene/animation/tween.cpp44
9 files changed, 41 insertions, 73 deletions
diff --git a/scene/animation/animation_blend_space_1d.cpp b/scene/animation/animation_blend_space_1d.cpp
index dded44b990..416a291da1 100644
--- a/scene/animation/animation_blend_space_1d.cpp
+++ b/scene/animation/animation_blend_space_1d.cpp
@@ -266,7 +266,7 @@ float AnimationNodeBlendSpace1D::process(float p_time, bool p_seek) {
// fill in weights
- if (point_lower == -1) {
+ if (point_lower == -1 && point_higher != -1) {
// we are on the left side, no other point to the left
// we just play the next point.
diff --git a/scene/animation/animation_blend_space_2d.cpp b/scene/animation/animation_blend_space_2d.cpp
index 95d4644004..75031f0149 100644
--- a/scene/animation/animation_blend_space_2d.cpp
+++ b/scene/animation/animation_blend_space_2d.cpp
@@ -527,7 +527,7 @@ float AnimationNodeBlendSpace2D::process(float p_time, bool p_seek) {
}
}
- if (new_closest != closest) {
+ if (new_closest != closest && new_closest != -1) {
float from = 0;
if (blend_mode == BLEND_MODE_DISCRETE_CARRY && closest != -1) {
diff --git a/scene/animation/animation_cache.cpp b/scene/animation/animation_cache.cpp
index 84b3f103c5..e26bd5b5a1 100644
--- a/scene/animation/animation_cache.cpp
+++ b/scene/animation/animation_cache.cpp
@@ -80,8 +80,7 @@ void AnimationCache::_update_cache() {
if (!node) {
path_cache.push_back(Path());
- ERR_EXPLAIN("Invalid Track Path in Animation: " + np);
- ERR_CONTINUE(!node);
+ ERR_CONTINUE_MSG(!node, "Invalid track path in animation: " + np + ".");
}
Path path;
@@ -92,8 +91,7 @@ void AnimationCache::_update_cache() {
if (np.get_subname_count() > 1) {
path_cache.push_back(Path());
- ERR_EXPLAIN("Transform tracks can't have a subpath: " + np);
- ERR_CONTINUE(animation->track_get_type(i) == Animation::TYPE_TRANSFORM);
+ ERR_CONTINUE_MSG(animation->track_get_type(i) == Animation::TYPE_TRANSFORM, "Transform tracks can't have a subpath: " + np + ".");
}
Spatial *sp = Object::cast_to<Spatial>(node);
@@ -101,8 +99,7 @@ void AnimationCache::_update_cache() {
if (!sp) {
path_cache.push_back(Path());
- ERR_EXPLAIN("Transform track not of type Spatial: " + np);
- ERR_CONTINUE(!sp);
+ ERR_CONTINUE_MSG(!sp, "Transform track not of type Spatial: " + np + ".");
}
if (np.get_subname_count() == 1) {
@@ -113,15 +110,13 @@ void AnimationCache::_update_cache() {
if (!sk) {
path_cache.push_back(Path());
- ERR_EXPLAIN("Property defined in Transform track, but not a Skeleton!: " + np);
- ERR_CONTINUE(!sk);
+ ERR_CONTINUE_MSG(!sk, "Property defined in Transform track, but not a Skeleton!: " + np + ".");
}
int idx = sk->find_bone(ps);
if (idx == -1) {
path_cache.push_back(Path());
- ERR_EXPLAIN("Property defined in Transform track, but not a Skeleton Bone!: " + np);
- ERR_CONTINUE(idx == -1);
+ ERR_CONTINUE_MSG(idx == -1, "Property defined in Transform track, but not a Skeleton Bone!: " + np + ".");
}
path.bone_idx = idx;
@@ -161,8 +156,7 @@ void AnimationCache::_update_cache() {
if (np.get_subname_count() == 0) {
path_cache.push_back(Path());
- ERR_EXPLAIN("Value Track lacks property: " + np);
- ERR_CONTINUE(np.get_subname_count() == 0);
+ ERR_CONTINUE_MSG(np.get_subname_count() == 0, "Value Track lacks property: " + np + ".");
}
} else if (animation->track_get_type(i) == Animation::TYPE_METHOD) {
@@ -170,8 +164,7 @@ void AnimationCache::_update_cache() {
if (path.subpath.size() != 0) { // Trying to call a method of a non-resource
path_cache.push_back(Path());
- ERR_EXPLAIN("Method Track has property: " + np);
- ERR_CONTINUE(path.subpath.size() != 0);
+ ERR_CONTINUE_MSG(path.subpath.size() != 0, "Method Track has property: " + np + ".");
}
}
diff --git a/scene/animation/animation_node_state_machine.cpp b/scene/animation/animation_node_state_machine.cpp
index f1ce948c43..65bf1e0134 100644
--- a/scene/animation/animation_node_state_machine.cpp
+++ b/scene/animation/animation_node_state_machine.cpp
@@ -235,6 +235,7 @@ bool AnimationNodeStateMachinePlayback::_travel(AnimationNodeStateMachine *p_sta
if (cost < least_cost) {
least_cost_transition = E;
+ least_cost = cost;
}
}
@@ -316,8 +317,7 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_st
if (!playing) {
String node_name = start_request;
start_request = StringName();
- ERR_EXPLAIN("Can't travel to '" + node_name + "' if state machine is not playing.");
- ERR_FAIL_V(0);
+ ERR_FAIL_V_MSG(0, "Can't travel to '" + node_name + "' if state machine is not playing.");
}
if (!_travel(p_state_machine, start_request)) {
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp
index 54df346374..051f832882 100644
--- a/scene/animation/animation_player.cpp
+++ b/scene/animation/animation_player.cpp
@@ -248,10 +248,7 @@ void AnimationPlayer::_ensure_node_caches(AnimationData *p_anim) {
RES resource;
Vector<StringName> leftover_path;
Node *child = parent->get_node_and_resource(a->track_get_path(i), resource, leftover_path);
- if (!child) {
- ERR_EXPLAIN("On Animation: '" + p_anim->name + "', couldn't resolve track: '" + String(a->track_get_path(i)) + "'");
- }
- ERR_CONTINUE(!child); // couldn't find the child node
+ ERR_CONTINUE_MSG(!child, "On Animation: '" + p_anim->name + "', couldn't resolve track: '" + String(a->track_get_path(i)) + "'."); // couldn't find the child node
uint32_t id = resource.is_valid() ? resource->get_instance_id() : child->get_instance_id();
int bone_idx = -1;
@@ -973,8 +970,7 @@ void AnimationPlayer::_animation_process(float p_delta) {
Error AnimationPlayer::add_animation(const StringName &p_name, const Ref<Animation> &p_animation) {
#ifdef DEBUG_ENABLED
- ERR_EXPLAIN("Invalid animation name: " + String(p_name));
- ERR_FAIL_COND_V(String(p_name).find("/") != -1 || String(p_name).find(":") != -1 || String(p_name).find(",") != -1 || String(p_name).find("[") != -1, ERR_INVALID_PARAMETER);
+ 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) + ".");
#endif
ERR_FAIL_COND_V(p_animation.is_null(), ERR_INVALID_PARAMETER);
@@ -1158,10 +1154,7 @@ void AnimationPlayer::play(const StringName &p_name, float p_custom_blend, float
if (String(name) == "")
name = playback.assigned;
- if (!animation_set.has(name)) {
- ERR_EXPLAIN("Animation not found: " + name);
- ERR_FAIL();
- }
+ ERR_FAIL_COND_MSG(!animation_set.has(name), "Animation not found: " + name + ".");
Playback &c = playback;
@@ -1207,7 +1200,9 @@ void AnimationPlayer::play(const StringName &p_name, float p_custom_blend, float
}
}
- _stop_playing_caches();
+ if (get_current_animation() != p_name) {
+ _stop_playing_caches();
+ }
c.current.from = &animation_set[name];
diff --git a/scene/animation/animation_player.h b/scene/animation/animation_player.h
index f3d38110c6..320fd2084c 100644
--- a/scene/animation/animation_player.h
+++ b/scene/animation/animation_player.h
@@ -35,9 +35,6 @@
#include "scene/3d/skeleton.h"
#include "scene/3d/spatial.h"
#include "scene/resources/animation.h"
-/**
- @author Juan Linietsky <reduzio@gmail.com>
-*/
#ifdef TOOLS_ENABLED
// To save/restore animated values
diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp
index 6745b57cff..bb7c400cfe 100644
--- a/scene/animation/animation_tree.cpp
+++ b/scene/animation/animation_tree.cpp
@@ -1412,6 +1412,7 @@ void AnimationTree::_update_properties_for_node(const String &p_base_path, Ref<A
Vector<Activity> activity;
for (int i = 0; i < node->get_input_count(); i++) {
Activity a;
+ a.activity = 0;
a.last_pass = 0;
activity.push_back(a);
}
diff --git a/scene/animation/animation_tree_player.cpp b/scene/animation/animation_tree_player.cpp
index 5c3e123ac3..8f6d53c21c 100644
--- a/scene/animation/animation_tree_player.cpp
+++ b/scene/animation/animation_tree_player.cpp
@@ -403,8 +403,7 @@ void AnimationTreePlayer::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
- ERR_EXPLAIN("AnimationTreePlayer has been deprecated. Use AnimationTree instead.");
- WARN_DEPRECATED;
+ WARN_DEPRECATED_MSG("AnimationTreePlayer has been deprecated. Use AnimationTree instead.");
if (!processing) {
//make sure that a previous process state was not saved
@@ -993,10 +992,9 @@ int AnimationTreePlayer::node_get_input_count(const StringName &p_node) const {
ERR_FAIL_COND_V(!node_map.has(p_node), -1);
return node_map[p_node]->inputs.size();
}
-#define GET_NODE(m_type, m_cast) \
- ERR_FAIL_COND(!node_map.has(p_node)); \
- ERR_EXPLAIN("Invalid parameter for node type."); \
- ERR_FAIL_COND(node_map[p_node]->type != m_type); \
+#define GET_NODE(m_type, m_cast) \
+ ERR_FAIL_COND(!node_map.has(p_node)); \
+ ERR_FAIL_COND_MSG(node_map[p_node]->type != m_type, "Invalid parameter for node type."); \
m_cast *n = static_cast<m_cast *>(node_map[p_node]);
void AnimationTreePlayer::animation_node_set_animation(const StringName &p_node, const Ref<Animation> &p_animation) {
@@ -1209,10 +1207,9 @@ Point2 AnimationTreePlayer::node_get_position(const StringName &p_node) const {
return node_map[p_node]->pos;
}
-#define GET_NODE_V(m_type, m_cast, m_ret) \
- ERR_FAIL_COND_V(!node_map.has(p_node), m_ret); \
- ERR_EXPLAIN("Invalid parameter for node type."); \
- ERR_FAIL_COND_V(node_map[p_node]->type != m_type, m_ret); \
+#define GET_NODE_V(m_type, m_cast, m_ret) \
+ ERR_FAIL_COND_V(!node_map.has(p_node), m_ret); \
+ ERR_FAIL_COND_V_MSG(node_map[p_node]->type != m_type, m_ret, "Invalid parameter for node type."); \
m_cast *n = static_cast<m_cast *>(node_map[p_node]);
Ref<Animation> AnimationTreePlayer::animation_node_get_animation(const StringName &p_node) const {
@@ -1367,8 +1364,7 @@ void AnimationTreePlayer::get_node_list(List<StringName> *p_node_list) const {
void AnimationTreePlayer::remove_node(const StringName &p_node) {
ERR_FAIL_COND(!node_map.has(p_node));
- ERR_EXPLAIN("Node 0 (output) can't be removed.");
- ERR_FAIL_COND(p_node == out_name);
+ ERR_FAIL_COND_MSG(p_node == out_name, "Node 0 (output) can't be removed.");
for (Map<StringName, NodeBase *>::Element *E = node_map.front(); E; E = E->next()) {
diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp
index 4dee4e1d12..2609924f33 100644
--- a/scene/animation/tween.cpp
+++ b/scene/animation/tween.cpp
@@ -1185,35 +1185,29 @@ bool Tween::_build_interpolation(InterpolateType p_interpolation_type, Object *p
// Validate and apply interpolation data
// Give it the object
- ERR_EXPLAIN("Invalid object provided to Tween!");
- ERR_FAIL_COND_V(p_object == NULL, false); // Is the object real
- ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_object), false); // Is the object a valid instance?
+ ERR_FAIL_COND_V_MSG(p_object == NULL, false, "Invalid object provided to Tween.");
+ ERR_FAIL_COND_V_MSG(!ObjectDB::instance_validate(p_object), false, "Invalid object provided to Tween.");
data.id = p_object->get_instance_id();
// Validate the initial and final values
- ERR_EXPLAIN("Initial value type does not match final value type!"); // TODO: Print both types to make debugging easier
- ERR_FAIL_COND_V(p_initial_val.get_type() != p_final_val.get_type(), false); // Do the initial and final value types match?
+ ERR_FAIL_COND_V_MSG(p_initial_val.get_type() != p_final_val.get_type(), false, "Initial value type '" + Variant::get_type_name(p_initial_val.get_type()) + "' does not match final value type '" + Variant::get_type_name(p_final_val.get_type()) + "'.");
data.initial_val = p_initial_val;
data.final_val = p_final_val;
// Check the Duration
- ERR_EXPLAIN("Only non-negative duration values allowed in Tweens!");
- ERR_FAIL_COND_V(p_duration < 0, false); // Is the tween duration non-negative
+ ERR_FAIL_COND_V_MSG(p_duration < 0, false, "Only non-negative duration values allowed in Tweens.");
data.duration = p_duration;
// Tween Delay
- ERR_EXPLAIN("Only non-negative delay values allowed in Tweens!");
- ERR_FAIL_COND_V(p_delay < 0, false); // Is the delay non-negative?
+ ERR_FAIL_COND_V_MSG(p_delay < 0, false, "Only non-negative delay values allowed in Tweens.");
data.delay = p_delay;
// Transition type
- ERR_EXPLAIN("Invalid transition type provided to Tween");
- ERR_FAIL_COND_V(p_trans_type < 0 || p_trans_type >= TRANS_COUNT, false); // Is the transition type valid
+ ERR_FAIL_COND_V_MSG(p_trans_type < 0 || p_trans_type >= TRANS_COUNT, false, "Invalid transition type provided to Tween.");
data.trans_type = p_trans_type;
// Easing type
- ERR_EXPLAIN("Invalid easing type provided to Tween");
- ERR_FAIL_COND_V(p_ease_type < 0 || p_ease_type >= EASE_COUNT, false); // Is the easing type valid
+ ERR_FAIL_COND_V_MSG(p_ease_type < 0 || p_ease_type >= EASE_COUNT, false, "Invalid easing type provided to Tween.");
data.ease_type = p_ease_type;
// Is the property defined?
@@ -1221,8 +1215,7 @@ bool Tween::_build_interpolation(InterpolateType p_interpolation_type, Object *p
// Check that the object actually contains the given property
bool prop_valid = false;
p_object->get_indexed(p_property->get_subnames(), &prop_valid);
- ERR_EXPLAIN("Tween target object has no property named: " + p_property->get_concatenated_subnames());
- ERR_FAIL_COND_V(!prop_valid, false);
+ ERR_FAIL_COND_V_MSG(!prop_valid, false, "Tween target object has no property named: " + p_property->get_concatenated_subnames() + ".");
data.key = p_property->get_subnames();
data.concatenated_key = p_property->get_concatenated_subnames();
@@ -1231,8 +1224,7 @@ bool Tween::_build_interpolation(InterpolateType p_interpolation_type, Object *p
// Is the method defined?
if (p_method) {
// Does the object even have the requested method?
- ERR_EXPLAIN("Tween target object has no method named: " + *p_method); // TODO: Fix this error message
- ERR_FAIL_COND_V(!p_object->has_method(*p_method), false);
+ ERR_FAIL_COND_V_MSG(!p_object->has_method(*p_method), false, "Tween target object has no method named: " + *p_method + ".");
data.key.push_back(*p_method);
data.concatenated_key = *p_method;
@@ -1301,8 +1293,7 @@ bool Tween::interpolate_callback(Object *p_object, real_t p_duration, String p_c
ERR_FAIL_COND_V(p_duration < 0, false);
// Check whether the object even has the callback
- ERR_EXPLAIN("Object has no callback named: %s" + p_callback);
- ERR_FAIL_COND_V(!p_object->has_method(p_callback), false);
+ ERR_FAIL_COND_V_MSG(!p_object->has_method(p_callback), false, "Object has no callback named: " + p_callback + ".");
// Build a new InterpolationData
InterpolateData data;
@@ -1361,8 +1352,7 @@ bool Tween::interpolate_deferred_callback(Object *p_object, real_t p_duration, S
ERR_FAIL_COND_V(p_duration < 0, false);
// Confirm the callback exists on the object
- ERR_EXPLAIN("Object has no callback named: %s" + p_callback);
- ERR_FAIL_COND_V(!p_object->has_method(p_callback), false);
+ ERR_FAIL_COND_V_MSG(!p_object->has_method(p_callback), false, "Object has no callback named: " + p_callback + ".");
// Create a new InterpolateData for the callback
InterpolateData data;
@@ -1505,10 +1495,8 @@ bool Tween::follow_method(Object *p_object, StringName p_method, Variant p_initi
ERR_FAIL_COND_V(p_delay < 0, false);
// Confirm both objects have the target methods
- ERR_EXPLAIN("Object has no method named: %s" + p_method);
- ERR_FAIL_COND_V(!p_object->has_method(p_method), false);
- ERR_EXPLAIN("Target has no method named: %s" + p_target_method);
- ERR_FAIL_COND_V(!p_target->has_method(p_target_method), false);
+ ERR_FAIL_COND_V_MSG(!p_object->has_method(p_method), false, "Object has no method named: " + p_method + ".");
+ ERR_FAIL_COND_V_MSG(!p_target->has_method(p_target_method), false, "Target has no method named: " + p_target_method + ".");
// Call the method to get the target value
Variant::CallError error;
@@ -1641,10 +1629,8 @@ bool Tween::targeting_method(Object *p_object, StringName p_method, Object *p_in
ERR_FAIL_COND_V(p_delay < 0, false);
// Make sure both objects have the given method
- ERR_EXPLAIN("Object has no method named: %s" + p_method);
- ERR_FAIL_COND_V(!p_object->has_method(p_method), false);
- ERR_EXPLAIN("Initial Object has no method named: %s" + p_initial_method);
- ERR_FAIL_COND_V(!p_initial->has_method(p_initial_method), false);
+ ERR_FAIL_COND_V_MSG(!p_object->has_method(p_method), false, "Object has no method named: " + p_method + ".");
+ ERR_FAIL_COND_V_MSG(!p_initial->has_method(p_initial_method), false, "Initial Object has no method named: " + p_initial_method + ".");
// Call the method to get the initial value
Variant::CallError error;