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

Allow const function calls of various methods #173

Closed
alice-i-cecile opened this issue May 4, 2021 · 2 comments
Closed

Allow const function calls of various methods #173

alice-i-cecile opened this issue May 4, 2021 · 2 comments

Comments

@alice-i-cecile
Copy link

This is very useful for specifying configuration. For example, in Bevy I'm trying to write:

    pub const PADDLE_STARTING_LOCATION: Transform = Transform::from_xyz(0.0, -215.0, 0.0);
    pub const PADDLE_SIZE: Vec2 = Vec2::new(120.0, 30.0);

but neither of these are const fn's :(

alice-i-cecile added a commit to alice-i-cecile/bevy that referenced this issue May 4, 2021
@bitshifter
Copy link
Owner

Closing as duplicate of #76. There's discussion in there as to why this is the case and what needs to happen to resolve it.

@bitshifter
Copy link
Owner

bitshifter commented May 4, 2021

There are macros to create const glam types, Transform is a bevy type so that's a bit trickier. It contains a Quat and Quat::new cannot be made const fn because it uses SSE __m128 for storage and there is no const fn to initialise one of those. That is the problem, this needs to be addressed in Rust's std::arch. Bevy could create a const_transform! macro using the glam ones in the interim. You can make a const Vec2 using glam::const_vec2!.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants