feat(animation): impl Animatable for Rot2#23618
feat(animation): impl Animatable for Rot2#23618YurikoDX wants to merge 2 commits intobevyengine:release-0.18.1from
Animatable for Rot2#23618Conversation
Enable animation support for 2D rotations. Since `UiTransform` and other 2D components now use `Rot2` for rotation, implementing `Animatable` is required to drive these fields via the `AnimationGraph`. - Implemented `Animatable` for `Rot2` in `bevy_animation`. - Used `slerp` for shortest-path interpolation, mirroring `Quat` behavior. - Implemented `blend` using cumulative SLERP to support multi-track blending and additive layers. - Added documentation comments consistent with existing `Quat` implementation. - Verified `interpolate` correctly handles shortest-path rotation.
|
Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke! If it's expected, please add the M-Deliberate-Rendering-Change label. If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it. |
alice-i-cecile
left a comment
There was a problem hiding this comment.
Would not mind a test or two, especially for the shortest path behavior, but this LGTM. Thanks!
You need to format this code (see CI), and we'll need a second approval before we can merge though.
|
This needs to target
This was also not done in this PR. |
- Added comprehensive unit tests verifying shortest-path interpolation and Bevy's cumulative blending behavior for `Rot2`. - Updated the `animated_ui` example to showcase 2D rotation curves using `Rot2`. - Fixed minor formatting issues in `animatable.rs` to satisfy CI checks.
|
Swapping this to target the |
|
Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke! If it's expected, please add the M-Deliberate-Rendering-Change label. If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it. |
|
I've cherry-picked these changes into a clean branch targeting main as suggested! Closing this in favor of the new PR: #23621 Thanks again for the guidance, @alice-i-cecile ! |
Objective
Rot2does not implement theAnimatabletrait, which preventsUiTransform::rotationand other 2D components from being animated viaAnimationGraph.Solution
AnimatableforRot2inbevy_animation.Quatimplementation to ensure consistency across the engine's math types:slerpforinterpolateto ensure shortest-path 2D rotation.blendwith cumulative SLERP to support multi-track and additive blending.Quat.Testing
animated-uiexample.Showcase
Modified the
animated-uiexample to includeUiTransform::rotationanimation:Click to view code snippet