-
-
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 more transform relative vectors #1300
Merged
cart
merged 2 commits into
bevyengine:master
from
RedlineTriad:transform-relative-vectors
Jan 25, 2021
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
If Bevy is right-handed y-up, and we're calling +z forward, then doesn't that make +x left, not right?
(Sorry about my previous deleted comment; got momentarily confused about the whole "-handed" naming convention.)
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.e. I expect the direction called "left" to be to my left if I'm looking down the direction called "forward".
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.
Ah! Unity (referenced above) is left-handed — maybe that's where the oddness came from. I was beginning to worry that there were two different conventions for what's called "left", i.e. because -x is left on screen in Bevy when doing 2D rendering. 😅
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.
haha yeah fortunately left still means left 😄
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 I communicated that poorly. I was actually trying to say that I think the code in this PR is actually "wrong" as it stands, at least in that by one obvious interpretation it appears internally inconsistent.
Let me try again. 😊
Unity, which appears to have inspired this code, is left-handed. In that left-handed context, all of the function names in this PR would actually match up to their implementations.
But Bevy is right-handed, and so they appear to be inconsistent. If
forward
means "along the positive z-axis", as it is defined in this PR, thenright
should be whatever direction you end up facing by turning 90 degrees clockwise from forward. Which in Bevy would mean you are now pointing along the negative x-axis, whereas this PR definesright
as pointing down the positive x-axis.I suspect the confusion exists because of mixing the idea of absolute directions in screen space with relative orientation in 3D space — and in particular the fact that you can actually do that without consequence in Unity, but not in Bevy. Or of course it could be as simple as just having copied the definitions from Unity without correcting for the differing handedness.
Or... there could be a third explanation that I haven't thought of, which makes the code in this PR "as intended". But if that's so, then I feel this whole API as it stands — at least in the context of a right-handed coordinate system like Bevy's — is likely to provide more confusion than utility, because there are so many obvious interpretations of it that make it look wrong.
I hope I'm making sense... 😅
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.
Ahh yeah I see your point now. And I do think you were clear enough in your initial description, I just didn't think enough about it / fixated too much on your last message. In 2d this "works" because +x is "the viewer's right". However from the perspective of the transform, +x is left (which is also true for 3d).
This should definitely be fixed. I think the functionality is still useful, but we need new names for it. Maybe just something like "local_positive_x" and "local_negative_x"?
We could also consider just flipping the signs on the x-axis, but that also makes things a little weird in 2d, as "left" would be the viewer's "right".
If anyone has better ideas, let me know :)
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 needed these functions when making a 2d game, and I tested it in that context, so I didn't choose the +x direction because of Unity but because it seemed to do the right thing.