summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2022-12-05 00:06:23 +0100
committerRémi Verschelde <rverschelde@gmail.com>2022-12-05 00:06:23 +0100
commita738f508866e955d124c3b6c5bd1ecff44a0077a (patch)
treea3f9b470f3467c47abde3f88a75f33db9d5f3c93 /scene
parentf4bccf90a3e7cd6132c8b96f1e8d8ab52ad3b3a7 (diff)
parent83135aa122dcd1a260830767b119b33984364838 (diff)
Merge pull request #69357 from TokageItLab/byebye-trigger
Remove `UPDATE_TRIGGER` mode from `ValueTrack::UpdateMode` & Match behaviors between `AnimationTree` and `AnimationPlayer`
Diffstat (limited to 'scene')
-rw-r--r--scene/animation/animation_player.cpp52
-rw-r--r--scene/animation/animation_tree.cpp8
-rw-r--r--scene/resources/animation.cpp3
-rw-r--r--scene/resources/animation.h1
4 files changed, 36 insertions, 28 deletions
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp
index ee6fb58583..ca1befc135 100644
--- a/scene/animation/animation_player.cpp
+++ b/scene/animation/animation_player.cpp
@@ -664,7 +664,7 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, double
}
}
- if (update_mode == Animation::UPDATE_CONTINUOUS || update_mode == Animation::UPDATE_CAPTURE || (p_delta == 0 && update_mode == Animation::UPDATE_DISCRETE)) { //delta == 0 means seek
+ if (update_mode == Animation::UPDATE_CONTINUOUS || update_mode == Animation::UPDATE_CAPTURE) {
Variant value = a->value_track_interpolate(i, p_time);
if (value == Variant()) {
@@ -681,15 +681,23 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, double
pa->value_accum = Animation::interpolate_variant(pa->value_accum, value, p_interp);
}
- } else if (p_is_current && p_delta != 0) {
+ } else {
List<int> indices;
- if (p_started) {
- int first_key = a->track_find_key(i, p_prev_time, true);
- if (first_key >= 0) {
- indices.push_back(first_key);
+
+ if (p_seeked) {
+ int found_key = a->track_find_key(i, p_time);
+ if (found_key >= 0) {
+ indices.push_back(found_key);
}
+ } else {
+ if (p_started) {
+ int first_key = a->track_find_key(i, p_prev_time, true);
+ if (first_key >= 0) {
+ indices.push_back(first_key);
+ }
+ }
+ a->track_get_key_indices_in_range(i, p_time, p_delta, &indices, p_looped_flag);
}
- a->track_get_key_indices_in_range(i, p_time, p_delta, &indices, p_looped_flag);
for (int &F : indices) {
Variant value = a->track_get_key_value(i, F);
@@ -740,21 +748,26 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, double
if (!nc->node) {
continue;
}
- if (p_delta == 0) {
- continue;
- }
if (!p_is_current) {
break;
}
List<int> indices;
- if (p_started) {
- int first_key = a->track_find_key(i, p_prev_time, true);
- if (first_key >= 0) {
- indices.push_back(first_key);
+
+ if (p_seeked) {
+ int found_key = a->track_find_key(i, p_time);
+ if (found_key >= 0) {
+ indices.push_back(found_key);
+ }
+ } else {
+ if (p_started) {
+ int first_key = a->track_find_key(i, p_prev_time, true);
+ if (first_key >= 0) {
+ indices.push_back(first_key);
+ }
}
+ a->track_get_key_indices_in_range(i, p_time, p_delta, &indices, p_looped_flag);
}
- a->track_get_key_indices_in_range(i, p_time, p_delta, &indices, p_looped_flag);
for (int &E : indices) {
StringName method = a->method_track_get_name(i, E);
@@ -798,9 +811,6 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, double
if (!nc->node) {
continue;
}
- if (p_delta == 0) {
- continue;
- }
if (p_seeked) {
//find whatever should be playing
@@ -910,7 +920,7 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, double
continue;
}
- if (p_delta == 0 || p_seeked) {
+ if (p_seeked) {
//seek
int idx = a->track_find_key(i, p_time);
if (idx < 0) {
@@ -1056,7 +1066,7 @@ void AnimationPlayer::_animation_process2(double p_delta, bool p_started) {
accum_pass++;
- _animation_process_data(c.current, p_delta, 1.0f, c.seeked && p_delta != 0, p_started);
+ _animation_process_data(c.current, p_delta, 1.0f, c.seeked, p_started);
if (p_delta != 0) {
c.seeked = false;
}
@@ -2135,7 +2145,7 @@ void AnimationPlayer::_bind_methods() {
ClassDB::bind_method(D_METHOD("advance", "delta"), &AnimationPlayer::advance);
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "root_node"), "set_root", "get_root");
- ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "current_animation", PROPERTY_HINT_ENUM, "", PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_ANIMATE_AS_TRIGGER), "set_current_animation", "get_current_animation");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "current_animation", PROPERTY_HINT_ENUM, "", PROPERTY_USAGE_EDITOR), "set_current_animation", "get_current_animation");
ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "assigned_animation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_assigned_animation", "get_assigned_animation");
ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "autoplay", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_autoplay", "get_autoplay");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "reset_on_save", PROPERTY_HINT_NONE, ""), "set_reset_on_save_enabled", "is_reset_on_save_enabled");
diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp
index 16621faa33..bd9b918900 100644
--- a/scene/animation/animation_tree.cpp
+++ b/scene/animation/animation_tree.cpp
@@ -586,7 +586,7 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) {
track_value->object = child;
}
- track_value->is_discrete = anim->value_track_get_update_mode(i) == Animation::UPDATE_DISCRETE || anim->value_track_get_update_mode(i) == Animation::UPDATE_TRIGGER;
+ track_value->is_discrete = anim->value_track_get_update_mode(i) == Animation::UPDATE_DISCRETE;
track_value->is_using_angle = anim->track_get_interpolation_type(i) == Animation::INTERPOLATION_LINEAR_ANGLE || anim->track_get_interpolation_type(i) == Animation::INTERPOLATION_CUBIC_ANGLE;
track_value->subpath = leftover_path;
@@ -803,11 +803,11 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) {
TrackCacheValue *track_value = static_cast<TrackCacheValue *>(track);
bool was_discrete = track_value->is_discrete;
bool was_using_angle = track_value->is_using_angle;
- track_value->is_discrete |= anim->value_track_get_update_mode(i) == Animation::UPDATE_DISCRETE || anim->value_track_get_update_mode(i) == Animation::UPDATE_TRIGGER;
+ track_value->is_discrete |= anim->value_track_get_update_mode(i) == Animation::UPDATE_DISCRETE;
track_value->is_using_angle |= anim->track_get_interpolation_type(i) == Animation::INTERPOLATION_LINEAR_ANGLE || anim->track_get_interpolation_type(i) == Animation::INTERPOLATION_CUBIC_ANGLE;
if (was_discrete != track_value->is_discrete) {
- ERR_PRINT_ED("Value track: " + String(path) + " with different update modes are blended. Blending prioritizes Discrete/Trigger mode, so other update mode tracks will not be blended.");
+ ERR_PRINT_ED("Value track: " + String(path) + " with different update modes are blended. Blending prioritizes Discrete mode, so other update mode tracks will not be blended.");
}
if (was_using_angle != track_value->is_using_angle) {
WARN_PRINT_ED("Value track: " + String(path) + " with different interpolation types for rotation are blended. Blending prioritizes angle interpolation, so the blending result uses the shortest path referenced to the initial (RESET animation) value.");
@@ -1670,7 +1670,7 @@ void AnimationTree::_process_graph(double p_delta) {
TrackCacheValue *t = static_cast<TrackCacheValue *>(track);
if (t->is_discrete) {
- break; // Don't overwrite the value set by UPDATE_DISCRETE or UPDATE_TRIGGER.
+ break; // Don't overwrite the value set by UPDATE_DISCRETE.
}
if (t->init_value.get_type() == Variant::BOOL) {
diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp
index 3967858d47..077a53464e 100644
--- a/scene/resources/animation.cpp
+++ b/scene/resources/animation.cpp
@@ -2709,7 +2709,7 @@ void Animation::value_track_set_update_mode(int p_track, UpdateMode p_mode) {
ERR_FAIL_INDEX(p_track, tracks.size());
Track *t = tracks[p_track];
ERR_FAIL_COND(t->type != TYPE_VALUE);
- ERR_FAIL_INDEX((int)p_mode, 4);
+ ERR_FAIL_INDEX((int)p_mode, 3);
ValueTrack *vt = static_cast<ValueTrack *>(t);
vt->update_mode = p_mode;
@@ -3896,7 +3896,6 @@ void Animation::_bind_methods() {
BIND_ENUM_CONSTANT(UPDATE_CONTINUOUS);
BIND_ENUM_CONSTANT(UPDATE_DISCRETE);
- BIND_ENUM_CONSTANT(UPDATE_TRIGGER);
BIND_ENUM_CONSTANT(UPDATE_CAPTURE);
BIND_ENUM_CONSTANT(LOOP_NONE);
diff --git a/scene/resources/animation.h b/scene/resources/animation.h
index e66af77018..0ac1279063 100644
--- a/scene/resources/animation.h
+++ b/scene/resources/animation.h
@@ -64,7 +64,6 @@ public:
enum UpdateMode {
UPDATE_CONTINUOUS,
UPDATE_DISCRETE,
- UPDATE_TRIGGER,
UPDATE_CAPTURE,
};