Skip to content
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

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

Merged
merged 1 commit into from
Feb 24, 2024

Conversation

Sauermann
Copy link
Contributor

@Sauermann Sauermann commented Jun 17, 2023

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

This brings several benefits:

  • Correctly handle cases, where the 3D-GUI is located behind other collision objects. (currently one can interact with it, even when there is a collision object (e.g. wall) between camera and the 3D-GUI)
  • Proper passive hovering support

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 godotengine/godot#58334 did for 2D-SubViewportContainer.

Needs to work correctly godotengine/godot#78383 (included in V4.2)

Updated 2023-08-31: Make sure to include Velocity in InputEventMouseMotion when sending event to SubViewport. (Necessary for solving #925 (comment))
Updated 2023-11-10: Ordering of lines in config files has changed.
Updated 2024-02-21: Rebase after #1013

@akien-mga
Copy link
Member

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
Copy link
Contributor Author

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

@Calinou
Copy link
Member

Calinou commented Aug 23, 2023

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:

simplescreenrecorder-2023-08-24_01.00.21.mp4

@Sauermann
Copy link
Contributor Author

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
Copy link
Member

Calinou commented Aug 24, 2023

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
Copy link
Contributor Author

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: godotengine/godot#81243

viewport/gui_in_3d/gui_3d.gd Outdated Show resolved Hide resolved
viewport/gui_in_3d/gui_3d.gd Outdated Show resolved Hide resolved
viewport/gui_in_3d/gui_3d.gd Outdated Show resolved Hide resolved
viewport/gui_in_3d/gui_3d.gd Outdated Show resolved Hide resolved
viewport/gui_in_3d/gui_3d.gd Outdated Show resolved Hide resolved
@Sauermann Sauermann marked this pull request as ready for review November 30, 2023 21:40
Rework Gui in 3D Demo to handle mouse events via
Physics Picking instead of in _unhandled_input.

This brings several benefits:
- Correctly handle cases, where the 3D-GUI is located behind other
collision objects.
- Proper passive hovering support

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

fire commented Feb 24, 2024

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

Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally on 4.2.1, it works as expected.

@Calinou Calinou merged commit a69b2f7 into godotengine:master Feb 24, 2024
1 check passed
@Sauermann Sauermann deleted the fix-update-gui-3d branch February 27, 2024 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants