-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
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
Rework blending method in Variant
animation for Int
/Array
/String
#84815
Conversation
8dd50ca
to
e37063a
Compare
Working on improving the String Tween (add/sub_varaint for Tween delta with String is currently problematic). |
e37063a
to
cf6e819
Compare
Alright, I fixed tween. I believe now it is ready for review. text_bool_tween.mp4 |
cf6e819
to
2f8ec82
Compare
c727b07
to
9da0130
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 did some tests with Tweens and it works correctly. I did not test animation blending nor any of the linked issues.
Animating emoji is interesting 🤔
godot.windows.editor.dev.x86_64_S9Sh2O1OxP.mp4
25f52ae
to
0910c78
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 read through changes and it all looks sensible to me. But I can't say if this is a correct or a complete solution to the problem.
0910c78
to
aa93a9e
Compare
case Variant::PACKED_BYTE_ARRAY: { | ||
// Skip. | ||
} break; |
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.
At last, I just added exception handling for PackedByteArray to eliminated the possibility of interpolation as PACKED_INT_ARRAY in interpolate_variant(), although I think that's a very rare case where the check would be needed.
Tested the MRPs from the linked issues.
simplescreenrecorder-2023-11-16_12.19.07.mp4I'm not sure how useful the String blending shown in this PR's demo properly really is in practice, but it warns users that it's experimental so I think we can try it out and see if users are satisfied with it. I don't know if this really solves everything properly but it seems to be an improvement and fixes a number of bug reports. |
b3c8af1
to
80c9533
Compare
This is because that MRP is using UpdateMode::Discrete. If you set UpdateMode::Continuous, the blend will work. Also If you loop the animation or connect a node with a playback function such as NodeOneShot/Transition, the key update of UpdateMode::Discrete will also work.
This was implemented at the same time as the AnimationMixer implementation. When everything is in DiscreteMode, the AnimationTree only updates the value when it crosses a key. But that MRP has Continuous so AnimationMixer enforce Continuous for that track, meaning that the value is updated even though it does not cross the key. Also, AnimationMixer does not know when a blend will occur, so it iterates through the entire animation list once and generates a track cache. Changes to blend types are made at the time of cache generation, and warnings are output at the same time, which is why warnings are generated even if the AnimationTree or AnimationPlayer does not have them assigned if that tracks exist in any animation of animation list. |
Thanks for the quick turnaround fixing these issues! |
Follow up #80813
Supersedes / Closes #66771
Closes godotengine/godot-proposals#5501
Animation::blend_variant()
can't handle Array type #73342Polygon2D
points no longer works. (Animation Player) #83841I wanted to include godotengine/godot-proposals#8085, but it would be a rather complicated implementation, so I will postpone that.
This PR allows for interpolating arrays. In most cases, this is intended for use with polygon animation, so if the arrays are of different lengths, interpolation is performed with the last element of the shorter array.
array_blending.mp4
Also, it allows different strings to be interpolated by treating the characters as numbers. This should provide a behavior similar to interpolating text keyframes in AfterEffects.
For about interpolating discrete Variables (e.g. Int, Rect2i, PackedInt64Array and etc.)
During blending, these Variants must continuous as float.
cast_to_blendwise()
/cast_from_blendwise()
, ensure that casts are performed before and after the blend calculation.Interpolations that do not blend, such as
Tween
andAnimation::seek()
, are still temporarily transformed, but are refactored to use the above functions.For about interpolating
String
s which have partially same text with different lengthinterpolate_variant()
string_anim.mp4
interpolate_variant()
(used byTween
andAnimation::seek()
) can only change the length between strings with partially same text. This is because the order is fixed and the priority string is determined.blend_variant()
srting_blend.mp4
blend_variant()
interpolates characters (same as with arrays, it will be interpolated with the last element of the shorter string) at the same time as length. This is because the order is not fixed and it is difficult to apply a priority order.If the implementation of godotengine/godot-proposals#8085 is successful in the future, the priority order may be able to determine, but for now, I submit the current version as an experimental algorithm; when string blending occur, it show warning once.
BTW, there is a bug with reset on save for arrays, but it exists before this PR, so I will look into it separately.
Demo project (array_blending_r.zip)