-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Public easing #17711
Public easing #17711
Conversation
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.
Is this useful if the functions within are pub(crate)?
I'm ambivalent about this change. These functions can already be used from the public EasingCurve API, although it's a little verbose: let x = EasingCurve::new(0.0, 1.0, EaseFunction::SmoothStep).sample_clamped(t); Also these low-level functions do not clamp their inputs, which might surprise people. Unity/Unreal/Godot and shader language smoothsteps all clamp. On the other hand, having access to these low-level functions might be useful for optimisation. Maybe it's fine if |
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 don't think those should be public, they're more of an implementation detail
# Objective - Expand the documentation for `EasingCurve`. - I suspect this might have avoided the confusion in #17711. - Also add a shortcut for simple cases. ## Solution - Added various examples and extra context. - Implemented `Curve<T>` for `EaseFunction`. - This means `EasingCurve::new(0.0, 1.0, EaseFunction::X)` can be shortened to `EaseFunction::X`. - In some cases this will be a minor performance improvement. - Added test to confirm they're the same. - ~~Added some benchmarks for bonus points.~~ ## Side Notes - I would have liked to rename `EaseFunction` to `EaseFn` for brevity, but that would be a breaking change and maybe controversial. - Also suspect `EasingCurve` should be `EaseCurve`, but say la vee. - Benchmarks show that calling `EaseFunction::Smoothstep` is still slower than calling `smoothstep` directly. - I think this is because the compiler refuses to inline `EaseFunction::eval`. - I don't see any good solution - might need a whole different interface. ## Testing ```sh cargo test --package bevy_math cargo doc --package bevy_math ./target/doc/bevy_math/curve/easing/struct.EasingCurve.html cargo bench --package benches --bench math -- easing ```
Objective
Make easing functions publicly accessible
Fixes #17665
Solution
add
pub
to modTesting
local build and run