feat(animation): implement Animatable for Rot2#23621
Open
YurikoDX wants to merge 1 commit intobevyengine:mainfrom
Open
feat(animation): implement Animatable for Rot2#23621YurikoDX wants to merge 1 commit intobevyengine:mainfrom
Animatable for Rot2#23621YurikoDX wants to merge 1 commit intobevyengine:mainfrom
Conversation
Member
|
Clippy is failing :) |
alice-i-cecile
approved these changes
Apr 2, 2026
Member
alice-i-cecile
left a comment
There was a problem hiding this comment.
LGTM other than clippy now. Thanks for cleaning this up :)
This adds animation support for 2D rotations by implementing the `Animatable` trait for `Rot2`. - Uses spherical linear interpolation (slerp) to ensure shortest-path consistency. - Implements correct cumulative and additive blending logic matching existing mathematical types like `Quat`. - Adds unit tests verifying shortest-path behavior and cumulative weighting. - Updates the `animated_ui` example to showcase `Rot2` rotation animation.
8eb8ed9 to
ea53e5f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
This PR adds animation support for 2D rotations by implementing the
Animatabletrait forRot2. This enables developers to smoothly animate 2D entities and UI elements.(Note: This is a clean, cherry-picked recreation of #23618 targeting the
mainbranch, as suggested by @alice-i-cecile .)Solution
To ensure mathematical correctness and consistency with existing Bevy math types (like
Quat), this implementation includes:slerp) so that rotations naturally take the shortest route (e.g., passing through 0° rather than 180° when moving from 89° to -89°).Quat.animated_uiexample to showcase the newRot2animation capabilities.Testing
cargo test -p bevy_animation --lib animatable).cargo fmtandcargo clippy.animated_uiexample locally to ensure the 2D rotation curve behaves as expected.