-
-
Notifications
You must be signed in to change notification settings - Fork 22k
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
Prevent PhysicsDirectSpaceState3D::instersect_ray
when mouse is over non-ignorable gui
#87362
base: master
Are you sure you want to change the base?
Conversation
PhysicsDirectSpaceState3D::instersect_ray
when mouse is over non-ignorable gui
60e1194
to
2c6ba09
Compare
@Sauermann I am moving this out of draft mode. My latest commit fixes the bug I reported, and the issue you found. Please let me know what you think. Latest Fix2c6ba092265c9a1b0f5d7adac9dcaa575e33aed7 Fixes the issues by blocking This commit also prevents an unneeded Latest MRPminimal_mouse_hover_example_02.zip (no .godot folder) Screen Recording1-19-2023-7_21.mp4The screen recording shows that there are no extra calls to the 3D collision object's mouse enter/exit, and the PASS-Control does not prevent print statements from being executed when mouse is moved over it. QuestionI noticed that the print statement for mouse movement still get printed even over the section of the PASS-Control that overlaps the STOP-Control (~9s into the screen recording). That might be another bug, but if it is, I think it is separate from this PR, and might be less of a big deal than the current bug since devs can make easier workarounds for it. My question is: does the engine keep track of every Control hierarchy that it is over, or does it only keep track of the top-most Control hierarchy? I couldn't find anything like "gui.mouse_over_all_hierarchies" so I am assuming it only keeps track of the top-most. |
related: There is an issue when there are multiple Controls in the mouse over hierarchy and the top one is STOP.
Yes, it only keeps track of the the top most since it is intended that the mouse can only be over one chain of Control nodes at a time. The mouse filter MOUSE_FILTER_PASS actually sends events up to its parent with event bubbling, it is not intended to let events behind it.
Since PASS sends events up and not behind, I feel that PASS and STOP should work the same in this case and not let mouse events through to the physics picking at all, but others have different opinions about it (#54529). |
@kitbdev I'm not sure I completely understand your comment. I see the issue, but are you suggesting that this PR is the cause of the issue you linked? Is there something I should change in my PR or are you just pointing out that there is a separate, but possibly related, issue? |
The linked issues are only related. The issue in the Gif is a result of this PR, since you changed the behavior ( |
@kitbdev can you share the MRP of the gif you shared? I see the issue in your gif, but I'd like to be sure I test against the same setup. I think I know the issue -- my changes don't take into account the gui.mouse_over_hierarchy. I will take another look. |
Sure, here's the MRP: |
2c6ba09
to
d6efa63
Compare
@kitbdev d6efa63 fixes the issue exposed by your MRP, and fixes the issue exposed in my MRP. I did not expect it, but on |
scene/main/viewport.cpp
Outdated
@@ -3172,6 +3172,7 @@ void Viewport::_update_mouse_over(Vector2 p_pos) { | |||
// Find the common ancestor of `gui.mouse_over` and `over`. | |||
Control *common_ancestor = nullptr; | |||
LocalVector<Control *> over_ancestors; | |||
bool ancenstor_is_stop_filter = false; |
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.
bool ancenstor_is_stop_filter = false; | |
bool ancestor_is_stop_filter = false; |
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.
nice catch, fixed: 3fc735f
d6efa63
to
3fc735f
Compare
Hi @Sauermann, this is my first PR for Godot and just want to know if I need to do anything on my end to make sure this gets reviewed in time for the the milestone deadline. Is there anything else I need to do in particular to get the reviewed? |
A large part of the reviews are done by volunteers in their spare time. So it depends on their availability. This PR is not a trivial change and will require some effort to review and test it in depth, because PRs that touch a core-class can easily introduces unintended consequences. |
Overview
This PR is intended to fix #87322, where a non-ignorable gui element was not blocking a
CollisionShape3D
's_mouse_enter
from being emitted.Issue
The cause of this bug is that
_drop_physics_mouseover
(in viewport.cpp) would get called when the mouse would move over gui, and that would cause a_mouse_exit
to occur, and it would also result in the following if statement condition to be true:new_collider != physics_object_over
because thephysics_object_over
would be null. That shouldn't be an issue, except that it is possible for_process_picking
to be invoked on the same exact frame as the previous_drop_physics_mouseover
.I'm not 100% certain about the last sentence above, but that was my best understanding based on my debugging. I look forward to hearing from others that understand the engine better than I do.
Fix
I think the fix is to only check for 3D objects in
process_picking
if!gui.mouse_over
. This does not break the Stop, Ignore, and Pass settings (as far as I can tell), but I have only tested on the minimum example project attached to this PR, and in the MRPs created based on comments from others.Minimum Fix Project
minimal_mouse_hove_example.zip
Screen Recording of Fix
FIX_Prevent.on.enter.over.gui.mp4
When the mouse hovers over the 3D shape (it looks 2D because there is no lighting), the shape scales up use _mouse_enter. When the mouse hovers off the 3D shape it scales down to its original scale. I can explain the logs further if people have questions, but I want to keep this description short so I will hold off on that.