-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
Refactor process of animation to retrive keys more exactly #69336
Refactor process of animation to retrive keys more exactly #69336
Conversation
396f945
to
cafb211
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some explanations for some changes to make the review easier.
@@ -75,9 +75,10 @@ | |||
<param index="3" name="seeked" type="bool" /> | |||
<param index="4" name="is_external_seeking" type="bool" /> | |||
<param index="5" name="blend" type="float" /> | |||
<param index="6" name="pingponged" type="int" default="0" /> | |||
<param index="6" name="looped_flag" type="int" enum="Animation.LoopedFlag" default="0" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I renamed it because this is available in linear loop as well as pingpong. In addition, the enum is now properly defined.
if (!p_is_backward) { | ||
for (int i = from; i <= to; i++) { | ||
p_indices->push_back(i); | ||
} | ||
} else { | ||
for (int i = to; i >= to; i--) { | ||
p_indices->push_back(i); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reworked _track_get_key_indices_in_range()
. Also, for reverse playback, the order in which keys are stored should be reversed.
@@ -2879,207 +2964,209 @@ void Animation::track_get_key_indices_in_range(int p_track, double p_time, doubl | |||
to_time = Math::pingpong(to_time, length); | |||
} | |||
|
|||
if ((int)Math::floor(abs(p_delta) / length) % 2 == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As noted in the overview, this check for extreme corner case should not be a concern.
if (!is_backward) { | ||
_track_get_key_indices_in_range(tt->positions, from_time, anim_end, p_indices, is_backward); | ||
_track_get_key_indices_in_range(tt->positions, anim_start, to_time, p_indices, is_backward); | ||
} else { | ||
_track_get_key_indices_in_range(tt->positions, anim_start, to_time, p_indices, is_backward); | ||
_track_get_key_indices_in_range(tt->positions, from_time, anim_end, p_indices, is_backward); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just like what it do in _track_get_key_indices_in_range()
, we need to care about the order in which the keys are stored outside of it.
cafb211
to
e8a6221
Compare
ca54c34
to
cd957d7
Compare
cd957d7
to
7f1f9f2
Compare
7f1f9f2
to
1fc3833
Compare
Thanks! |
Follow up #68992.
Fixes #61853 (completely!)
Fixes #69415
Fundamentally change the process of retrieving keys in animations.
Here is the current key retrieving process:
Due to reason 2, there was a problem as #64644. This has been fixed by #68992 for now.
However, there is a problem with getting duplicate keys by 1. So it conflicts with the elimination of the seek and playback delays that was the problem in #52518.
This fix changes it so that it does not always get the value of the frame where it is currently located. Whenever an animation is played from a stopped state, there is always some method. So it will be no problem by getting the key of the first frame there.
This also eliminates the need to hack to get the key of the end frame. Compared to before, it should now be possible to retrieve keys in a much more stable.
Includes removal of some unnecessary code and clarify of arguments. For example, check
(int)Math::floor(abs(p_delta) / length) % 2 == 0
is to correctly calculate the pingpong if the delta length is longer than the animation length. However, this is an extreme corner case and affects performance, so it has been removed.