Skip to content
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

Expand EasingCurve documentation #17778

Merged
merged 4 commits into from
Feb 10, 2025

Conversation

greeble-dev
Copy link
Contributor

@greeble-dev greeble-dev commented Feb 10, 2025

Objective

  • Expand the documentation for EasingCurve.
  • 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

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

@alice-i-cecile alice-i-cecile added C-Docs An addition or correction to our documentation A-Animation Make things move and change over time A-Math Fundamental domain-agnostic mathematical operations S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Feb 10, 2025
@alice-i-cecile alice-i-cecile added the C-Usability A targeted quality-of-life change that makes Bevy easier to use label Feb 10, 2025
@alice-i-cecile
Copy link
Member

@fjkorf can I get your review here?

Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the expanded usage docs. So-so on the benchmark; I think I'd prefer to have that in its own PR.

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Feb 10, 2025
@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Feb 10, 2025
Merged via the queue into bevyengine:main with commit 71b2239 Feb 10, 2025
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Animation Make things move and change over time A-Math Fundamental domain-agnostic mathematical operations C-Docs An addition or correction to our documentation C-Usability A targeted quality-of-life change that makes Bevy easier to use S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants