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

Add Direction2d::from_xy and Direction3d::from_xyz #10882

Merged
merged 3 commits into from
Dec 14, 2023

Conversation

Jondolf
Copy link
Contributor

@Jondolf Jondolf commented Dec 5, 2023

Objective

Make direction construction a bit more ergonomic.

Solution

Add Direction2d::from_xy and Direction3d::from_xyz, similar to Transform::from_xyz:

let dir2 = Direction2d::from_xy(0.5, 0.5).unwrap();
let dir3 = Direction3d::from_xyz(0.5, 0.5, 0.5).unwrap();

This can be a bit cleaner than using new:

let dir2 = Direction2d::new(Vec2::new(0.5, 0.5)).unwrap();
let dir3 = Direction3d::new(Vec3::new(0.5, 0.5, 0.5)).unwrap();

@Jondolf Jondolf added C-Usability A targeted quality-of-life change that makes Bevy easier to use A-Math Fundamental domain-agnostic mathematical operations labels Dec 5, 2023
@alice-i-cecile
Copy link
Member

@NiseVoid can I get your review here?

Copy link
Contributor

@NiseVoid NiseVoid left a comment

Choose a reason for hiding this comment

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

Looks good to me, having to wrap things in VecX::new(...) can get quite ugly if your code happens to not work with them already.

@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Dec 14, 2023
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Dec 14, 2023
Merged via the queue into bevyengine:main with commit 029dd06 Dec 14, 2023
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Math Fundamental domain-agnostic mathematical operations 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