bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Window y coordinate inverted on main.

Open Elabajaba opened this issue 1 year ago • 10 comments

Bevy version

main 1914a3f288a812667f735ee9e7806cf1560dacc0

What you did

windows.primary().cursor_position()

What went wrong

I expected the y coordinate at the top of the window to be high, and the bottom to be low, like how it was in bevy 0.8. Instead, the top of the window was low and the bottom of the window was high.

For systems that use the mouse coordinates, you now have to either add * Vec2::new(1.0, -1.0) or make the variable mutable and add world_pos.y *= -1.0;.

Additional information

~~Probably caused by either https://github.com/bevyengine/bevy/pull/6000 or the winit upgrade.~~ Caused by https://github.com/bevyengine/bevy/pull/6000

I haven't verified if this happens on non windows 11 systems.

Elabajaba avatar Nov 09 '22 01:11 Elabajaba

I'm unsure about reverting this part of those changes

This side effect is annoying, but it really does feel like visit coordinates should be in UI space.

alice-i-cecile avatar Nov 09 '22 01:11 alice-i-cecile

With more complex 2D cameras, this will probably be a wash.

alice-i-cecile avatar Nov 09 '22 01:11 alice-i-cecile

This breaks bevy's coordinate system consistency. Y is no longer up for everything, it's now up for everything but UI and mouse cursor position.

Elabajaba avatar Nov 09 '22 02:11 Elabajaba

That is deliberate: see #5572.

alice-i-cecile avatar Nov 09 '22 02:11 alice-i-cecile

Makes sense, want me to close the issue then?

edit: Or should the mouse coordinates still be considered an issue, while UI isn't?

Elabajaba avatar Nov 09 '22 03:11 Elabajaba

Just linking this in here for context:

Discussion about the mouse changes from #6000

rparrett avatar Nov 09 '22 04:11 rparrett

Changing mouse coordinates should not have been made as part of #6000. Changing UI Y orientation was UI-only and non controversial, changing mouse is not UI-only and controversial... In short term (for the 0.9 release) we should revert that change, which can be re-submitted in its own PR after. Or at least have a controversial discussion on wether that's what we want, but that could end up blocking the 0.9 which is not something nice...

for ecosystem review:

engine (0,0)
unity bottom left https://docs.unity3d.com/ScriptReference/Input-mousePosition.html
godot top left
unreal engine couldn't find

mockersf avatar Nov 09 '22 08:11 mockersf

I agree with @mockersf. Mouse cursor orientation should not have been changed in #6000. Much more controversial decision and one worth taking the appropriate time on. We should revert for 0.9.

cart avatar Nov 09 '22 09:11 cart

Feel free to blame me as I was the one that pushed for that change :see_no_evil:

I agree that it should have some more discussion, and that we should revert it. But I also believe that it was the right decision and I'll investigate some more and collect my thoughts so it can be reconsidered for 0.10 Somewhat awkward, but I realized the viewport_to_world method was not flipping the Y-axis as it should. If that bugfix gets merged and the cursor origin reverted it will mean the cursor positions Y-axis would need to be flipped again when passing it to viewport_to_world :' )

irate-devil avatar Nov 09 '22 11:11 irate-devil

reverted in #6533 keeping this issue to continue discussing if we want to change

mockersf avatar Nov 11 '22 00:11 mockersf

I don't think this is really relevant anymore so I'm closing it.

Elabajaba avatar Oct 18 '23 06:10 Elabajaba