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

Const all the floating point arithmetic #16124

Open
3 tasks
alice-i-cecile opened this issue Oct 28, 2024 · 2 comments
Open
3 tasks

Const all the floating point arithmetic #16124

alice-i-cecile opened this issue Oct 28, 2024 · 2 comments
Labels
A-Color Color spaces and color math A-Math Fundamental domain-agnostic mathematical operations A-UI Graphical user interfaces, styles, layouts, and widgets C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Trivial Nice and easy! A great choice to get started with Bevy S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it! X-Contentious There are nontrivial implications that should be thought through
Milestone

Comments

@alice-i-cecile
Copy link
Member

What problem does this solve or what need does it fill?

As seen in #16091, floating point arithmetic can now be used in constant functions! This is a valuable API improvement, as it allows users to define their own derived constants using our handy math operations.

What solution would you like?

We should constify our APIs, one crate at a time. The critical ones are:

  • bevy_math
  • bevy_color
  • bevy_ui

This should be kept to relatively simple functions and methods: only things that we can commit to being const indefinitely.

What alternative(s) have you considered?

Do let me know if I've missed a crate that needs this treatment!

Additional context

glam is open to making much of their API const which will unblock a ton of improvements in Bevy itself, although it's harder than one might expect there, due to SIMD support.

@alice-i-cecile alice-i-cecile added A-Color Color spaces and color math A-Math Fundamental domain-agnostic mathematical operations A-UI Graphical user interfaces, styles, layouts, and widgets C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Trivial Nice and easy! A great choice to get started with Bevy S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it! X-Contentious There are nontrivial implications that should be thought through labels Oct 28, 2024
@alice-i-cecile alice-i-cecile added this to the 0.16 milestone Oct 28, 2024
@ickshonpe
Copy link
Contributor

Does it matter that much that the functions should be const indefinitely? All the Val helper functions are begging to be made const but we really want to be able to implement some sort of Val::Calc support in support in the future. But Val::Calc can't be implemented in Bevy without support being implemented in Taffy first, so I can't see it being introduced until Bevy 18 at the earliest.

Otherwise all the ComputedNode methods use resolved values after layout and that shouldn't ever be changed, so they can be safely made const. Same should be true of the functions that use resolved values for text and texture slice layouts.

@alice-i-cecile
Copy link
Member Author

Does it matter that much that the functions should be const indefinitely

Probably not, but we should split those changes off for easier review. Ideally we'd have a path forward for users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Color Color spaces and color math A-Math Fundamental domain-agnostic mathematical operations A-UI Graphical user interfaces, styles, layouts, and widgets C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Trivial Nice and easy! A great choice to get started with Bevy S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it! X-Contentious There are nontrivial implications that should be thought through
Projects
None yet
Development

No branches or pull requests

2 participants