Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dead Code in AnimationMixer #89768

Closed
BruceLiCong opened this issue Mar 22, 2024 · 0 comments · Fixed by #89794
Closed

Dead Code in AnimationMixer #89768

BruceLiCong opened this issue Mar 22, 2024 · 0 comments · Fixed by #89794

Comments

@BruceLiCong
Copy link
Contributor

BruceLiCong commented Mar 22, 2024

Tested versions

  • Latest codes in master branch

System information

All the platforms

Issue description

Find the dead code snipet in AnimationMixer
Line1643, 1644 are dead codes due to seeked is always true.

player2->set_assigned_animation(anim_name);
player2->seek(at_anim_pos, true);

if (seeked) {
// Seek.
int idx = a->track_find_key(i, time, is_external_seeking ? Animation::FIND_MODE_NEAREST : Animation::FIND_MODE_EXACT, true);
if (idx < 0) {
continue;
}
double pos = a->track_get_key_time(i, idx);
StringName anim_name = a->animation_track_get_key_animation(i, idx);
if (String(anim_name) == "[stop]" || !player2->has_animation(anim_name)) {
continue;
}
Ref<Animation> anim = player2->get_animation(anim_name);
double at_anim_pos = 0.0;
switch (anim->get_loop_mode()) {
case Animation::LOOP_NONE: {
at_anim_pos = MAX((double)anim->get_length(), time - pos); //seek to end
} break;
case Animation::LOOP_LINEAR: {
at_anim_pos = Math::fposmod(time - pos, (double)anim->get_length()); //seek to loop
} break;
case Animation::LOOP_PINGPONG: {
at_anim_pos = Math::pingpong(time - pos, (double)a->get_length());
} break;
default:
break;
}
if (player2->is_playing() || seeked) {
player2->seek(at_anim_pos);
player2->play(anim_name);
t->playing = true;
playing_caches.insert(t);
} else {
player2->set_assigned_animation(anim_name);
player2->seek(at_anim_pos, true);
}
} else {

Steps to reproduce

N/A

Minimal reproduction project (MRP)

N/A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants