-
-
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
Consistent screen-space coordinates #8306
Consistent screen-space coordinates #8306
Conversation
parent.spawn( | ||
TextBundle::from_section(label, label_text_style.clone()).with_style(Style { | ||
position_type: PositionType::Absolute, | ||
bottom: Val::Px(0.), |
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 had to rework the labels in the blend_modes example a bit to keep their position the same as before.
Not a usability regression, it's just that for the labels to display correctly they need to be 'anchored' to the bottom left which happened to align with what world_to_viewport
returned before.
Solved by adding a parent node and using bottom: Val::Px(0.),
for the text itself.
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 I'm happy with the changes here!
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 this looks good but need to recheck when I’m less tired.
The mouse origin moved from the bottom left to the top left. See [relevant PR](bevyengine/bevy#8306).
# Objective Fixes #9455 This change has probably been forgotten in bevyengine/bevy#8306. ## Solution Remove the inversion of the Y axis when propagates window change back to winit.
please provide a formula to convert, guessing is so frustrating.
|
Okay, I found it out, to restore the previous behaviour, simply do this: |
Objective
Make the coordinate systems of screen-space items (cursor position, UI, viewports, etc.) consistent.
Solution
Remove the weird double inversion of the cursor position's Y origin. Once in bevy_winit to the bottom and then again in bevy_ui back to the top.
This leaves the origin at the top left like it is in every other popular app framework.
Update the
world_to_viewport
,viewport_to_world
, andviewport_to_world_2d
methods to flip the Y origin (as they should since the viewport coordinates were always relative to the top left).Migration Guide
Window::cursor_position
now returns the position of the cursor relative to the top left instead of the bottom left.This now matches other screen-space coordinates like
RelativeCursorPosition
, UI, and viewports.The
world_to_viewport
,viewport_to_world
, andviewport_to_world_2d
methods onCamera
now return/take the viewport position relative to the top left instead of the bottom left.If you were using
world_to_viewport
to position a UI node the returnedy
value should now be passed into thetop
field onStyle
instead of thebottom
field.Note that this might shift the position of the UI node as it is now anchored at the top.
If you were passing
Window::cursor_position
toviewport_to_world
orviewport_to_world_2d
no change is necessary.