-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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 Direction3dA
and move direction types out of primitives
#12018
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.
Can you add the changed path to a Migration Guide section please?
It looks like your PR is a breaking change, but you didn't provide a migration guide. Could you add some context on what users should update when this change get released in a new version of Bevy? |
Co-authored-by: Alice Cecile <[email protected]>
Done 👍 |
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.
Haven't noticed any mistakes, I think this is ready to merge.
|
||
// Make sure the result is normalized. | ||
// This can fail for non-unit quaternions. | ||
debug_assert!(rotated.is_normalized()); |
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.
Maybe it would be good to provide an assertion message?
Probably not a blocker, I think it's already pretty clear.
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.
Yeah, it'd be good to have a message since I've seen this confuse some people already. Probably in a follow-up though; I didn't want to make any changes to the direction types in this PR since that's not the focus here
} | ||
} | ||
|
||
impl std::ops::Neg for Direction2d { |
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.
Direction2d should also implement Mul<f32>
-> Vec2
.
Although we can do that in another PR (I think we should do a PR that adds Add<DirectionNd>
-> VecN
as well, but that's beyond this PR.)
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 that add implementation makes much sense honestly.
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 think it does as an escape hatch from APIs that return a Direction even when the user wants to do vector arithmetic (like Transforms). The current solution is usually a bunch of Derefs, but I've heard feedback that they make the syntax uglier. (But I understand the controversy on this API.)
…engine#12018) # Objective Split up from bevyengine#12017, add an aligned version of `Direction3d` for SIMD, and move direction types out of `primitives`. ## Solution Add `Direction3dA` and move direction types into a new `direction` module. --- ## Migration Guide The `Direction2d`, `Direction3d`, and `InvalidDirectionError` types have been moved out of `bevy::math::primitives`. Before: ```rust use bevy::math::primitives::Direction3d; ``` After: ```rust use bevy::math::Direction3d; ``` --------- Co-authored-by: Alice Cecile <[email protected]>
…engine#12018) # Objective Split up from bevyengine#12017, add an aligned version of `Direction3d` for SIMD, and move direction types out of `primitives`. ## Solution Add `Direction3dA` and move direction types into a new `direction` module. --- ## Migration Guide The `Direction2d`, `Direction3d`, and `InvalidDirectionError` types have been moved out of `bevy::math::primitives`. Before: ```rust use bevy::math::primitives::Direction3d; ``` After: ```rust use bevy::math::Direction3d; ``` --------- Co-authored-by: Alice Cecile <[email protected]>
Objective
Split up from #12017, add an aligned version of
Direction3d
for SIMD, and move direction types out ofprimitives
.Solution
Add
Direction3dA
and move direction types into a newdirection
module.Migration Guide
The
Direction2d
,Direction3d
, andInvalidDirectionError
types have been moved out ofbevy::math::primitives
.Before:
After: