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

Fix passive mouse hovering for physics #78017

Merged

Conversation

Sauermann
Copy link
Contributor

Currently mouse hovering doesn't update the state, when collision objects or the camera move.
This PR fixes this problem by taking the mouse position from the viewport and not from a nonexistent previous event.

Since previous events could potentially be a long time ago, their modifier-key state might be outdated. This PR fetches the current status of modifier-keys from Input.

These changes allow the removal of some class-variables and making additional simplifications.

resolve #69708
resolve #75711

@Sauermann Sauermann requested a review from a team as a code owner June 8, 2023 19:14
@clayjohn clayjohn added this to the 4.1 milestone Jun 8, 2023
Comment on lines 704 to 707
mm->set_alt_pressed(Input::get_singleton()->is_physical_key_pressed(Key::ALT));
mm->set_shift_pressed(Input::get_singleton()->is_physical_key_pressed(Key::SHIFT));
mm->set_ctrl_pressed(Input::get_singleton()->is_physical_key_pressed(Key::CMD_OR_CTRL));
mm->set_meta_pressed(Input::get_singleton()->is_physical_key_pressed(Key::META));
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
mm->set_alt_pressed(Input::get_singleton()->is_physical_key_pressed(Key::ALT));
mm->set_shift_pressed(Input::get_singleton()->is_physical_key_pressed(Key::SHIFT));
mm->set_ctrl_pressed(Input::get_singleton()->is_physical_key_pressed(Key::CMD_OR_CTRL));
mm->set_meta_pressed(Input::get_singleton()->is_physical_key_pressed(Key::META));
mm->set_alt_pressed(Input::get_singleton()->is_key_pressed(Key::ALT));
mm->set_shift_pressed(Input::get_singleton()->is_key_pressed(Key::SHIFT));
mm->set_ctrl_pressed(Input::get_singleton()->is_key_pressed(Key::CTRL));
mm->set_meta_pressed(Input::get_singleton()->is_key_pressed(Key::META));

I'm not super sure. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not versed in these difference between is_physical_key_pressed and is_key_pressed and their implications, so I will accept your changes.
Have tested these changes with the MPRs of both linked issues.

Currently mouse hovering doesn't update the state, when collision objects
or the camera move.
This PR fixes this problem by taking the mouse position from the viewport
and not from a nonexistent previous event.

Since previous events could potentially be a long time ago, their
modifier-key state might be outdated. This PR fetches the current
status of modifier-keys from `Input`.

These changes allow the removal of some class-variables and making
additional simplifications.
@Sauermann Sauermann force-pushed the fix-physics-passive-hovering branch from 23fb1a7 to 543fdc1 Compare June 9, 2023 10:51
Copy link
Member

@RandomShaper RandomShaper left a comment

Choose a reason for hiding this comment

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

TIWAGOS, but LGTM.

@akien-mga akien-mga merged commit 2a8e83c into godotengine:master Jun 9, 2023
13 checks passed
@Sauermann Sauermann deleted the fix-physics-passive-hovering branch June 9, 2023 11:49
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants