Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective
Split up from #12017, rename Bevy's direction types.
Currently, Bevy has the
Direction2d
,Direction3d
, andDirection3dA
types, which provide a type-level guarantee that their contained vectors remain normalized. They can be very useful for a lot of APIs for safety, explicitness, and in some cases performance, as they can sometimes avoid unnecessary normalizations.However, many consider them to be inconvenient to use, and opt for standard vector types like
Vec3
because of this. One reason is that the direction type names are a bit long and can be annoying to write (of course you can use autocomplete, but just typingVec3
is still nicer), and in some intances, the extra characters can make formatting worse. The naming is also inconsistent with Glam's shorter type names, and results in names likeDirection3dA
, which (in my opinion) are difficult to read and even a bit ugly.This PR proposes renaming the types to
Dir2
,Dir3
, andDir3A
. These names are nice and easy to write, consistent with Glam, and work well for variants like the SIMD alignedDir3A
. As a bonus, it can also result in nicer formatting in a lot of cases, which can be seen from the diff of this PR.Some examples of what it looks like: (copied from #12017)
Solution
Rename
Direction2d
,Direction3d
, andDirection3dA
toDir2
,Dir3
, andDir3A
.Migration Guide
The
Direction2d
andDirection3d
types have been renamed toDir2
andDir3
.Additional Context
This has been brought up on the Discord a few times, and we had a small poll on this.
Dir2
/Dir3
/Dir3A
was quite unanimously chosen as the best option, but of course it was a very small poll and inconclusive, so other opinions are certainly welcome too.