Fix rounding in steps easing function - #17743
Conversation
|
cc @RobWalt |
JasmineLowen
left a comment
There was a problem hiding this comment.
LGTM, thanks!
I think it would be good to support all of the CSS modi of steps via configuration options somewhere. Can you open an issue and link to this PR please? I'll tackle it later on when I'm back home (on mobile atm)
Carter0
left a comment
There was a problem hiding this comment.
Can you take a screenshot of what it looks like with your changes?
It does look odd on close inspection. It starts like halfway through a step I think. And then I swear the vertical lines are slightly bent. Maybe I’m seeing things tho
That's the appearance, but I would say "it advances half-way through the step."
That's to be expected based on the sampling that's happening in the example.
Sure |
|
Looking into the failing test. It succeeds locally. edit: Oh, oops. Just failed to push the new test code. |
|
It looks like your PR is a breaking change, but you didn't provide a migration guide. Could you add some context on what users should update when this change get released in a new version of Bevy? |
…17752) # Objective - In #17743, attention was raised to the fact that we supported an unusual kind of step easing function. The author of the fix kindly provided some links to standards used in CSS. It would be desirable to support generally agreed upon standards so this PR here tries to implement an extra configuration option of the step easing function - Resolve #17744 ## Solution - Introduce `StepConfig` - `StepConfig` can configure both the number of steps and the jumping behavior of the function - `StepConfig` replaces the raw `usize` parameter of the `EasingFunction::Steps(usize)` construct. - `StepConfig`s default jumping behavior is `end`, so in that way it follows #17743 ## Testing - I added a new test per `JumpAt` jumping behavior. These tests replicate the visuals that can be found at https://developer.mozilla.org/en-US/docs/Web/CSS/easing-function/steps#description ## Migration Guide - `EasingFunction::Steps` now uses a `StepConfig` instead of a raw `usize`. You can replicate the previous behavior by replaceing `EasingFunction::Steps(10)` with `EasingFunction::Steps(StepConfig::new(10))`. --------- Co-authored-by: François Mockers <francois.mockers@vleue.com> Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
# Objective While working on bevyengine#17742, I noticed that the `Steps` easing function looked a bit suspicious.  Comparing to the options available in [css](https://developer.mozilla.org/en-US/docs/Web/CSS/easing-function/steps#description):  It is "off the charts," so probably not what users are expecting. ## Solution Use `floor` when rounding to match the default behavior (jump-end, top right) in css. <img width="100" alt="image" src="https://github.com/user-attachments/assets/1ec46270-72f2-4227-87e4-03de881548ab" /> ## Testing I had to modify an existing test that was testing against the old behavior. This function and test were introduced in bevyengine#14788 and I didn't see any discussion about the rounding there. `cargo run --example easing_functions` ## Migration Guide <!-- Note to editors: this should be adjusted if 17744 is addressed, and possibly combined with the notes from the PR that fixes it. --> `EaseFunction::Steps` now behaves like css's default, "jump-end." If you were relying on the old behavior, we plan on providing it. See bevyengine#17744.
Objective
While working on #17742, I noticed that the
Stepseasing function looked a bit suspicious.Comparing to the options available in css:
It is "off the charts," so probably not what users are expecting.
Solution
Use
floorwhen rounding to match the default behavior (jump-end, top right) in css.Testing
I had to modify an existing test that was testing against the old behavior. This function and test were introduced in #14788 and I didn't see any discussion about the rounding there.
cargo run --example easing_functionsMigration Guide
EaseFunction::Stepsnow behaves like css's default, "jump-end." If you were relying on the old behavior, we plan on providing it. See #17744.