godotengine / godot-demo-projects

Demonstration and Template Projects
https://godotengine.org
MIT License
5.92k stars 1.65k forks source link

Rewrite Gui in 3D demo to use Physics Picking for mouse events #925

Closed Sauermann closed 8 months ago

Sauermann commented 1 year ago

Rework Gui in 3D Demo to handle mouse events via Physics Picking instead of in _unhandled_input.

This brings several benefits:

This allows also to make simplifications in the code, because 3D-mouse position no longer needs to be calculated manually.

This PR does for 3D, what https://github.com/godotengine/godot/pull/58334 did for 2D-SubViewportContainer.

Needs to work correctly https://github.com/godotengine/godot/pull/78383 (included in V4.2)

Updated 2023-08-31: Make sure to include Velocity in InputEventMouseMotion when sending event to SubViewport. (Necessary for solving https://github.com/godotengine/godot-demo-projects/pull/925#issuecomment-1690752187) Updated 2023-11-10: Ordering of lines in config files has changed. Updated 2024-02-21: Rebase after #1013

akien-mga commented 1 year ago

For the record, your commit seems not to be linked to your GitHub account. See: Why are my commits linked to the wrong user? for more info.

Sauermann commented 1 year ago

@akien-mga thanks, first commit to a repository and I missed to set it up.

Calinou commented 1 year ago

Tested locally with 4.2.dev godotengine/godot@6758a7f8c (Linux), it mostly works as expected. One issue with OptionButtons is that their popup doesn't update when you don't move the mouse but the camera moves:

https://github.com/godotengine/godot-demo-projects/assets/180032/c0946d87-0ec5-4e66-967c-824cad0104b7

Sauermann commented 1 year ago

their popup doesn't update when you don't move the mouse but the camera moves

My current understanding is, that this needs to be resolved in the main-repository, since I can't do anything from this side to fix this. It is however not a regression, because the current implementation also has this problem.

Calinou commented 1 year ago

Note: Do not merge until 4.2 is released, as the master branch should keep working with 4.1.x until 4.2.stable is released. Marking as draft accordingly to avoid accidental merge.

Sauermann commented 1 year ago

One issue with OptionButtons is that their popup doesn't update when you don't move the mouse but the camera moves

I found a solution for this problem: https://github.com/godotengine/godot/pull/81243

fire commented 8 months ago

Is everyone ok with the merge of Rewrite Gui in 3D demo to use Physics Picking for mouse events?