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

Calculate the mouse focus inverse transform only when needed #69598

Merged
merged 1 commit into from
Jan 16, 2023

Conversation

Sauermann
Copy link
Contributor

@Sauermann Sauermann commented Dec 5, 2022

Revival of #49158
Supersedes #49158
fix #69593
Co-authored-by: Marcel Admiraal madmiraal@users.noreply.github.com

madmiraal did the heavy lifting, I just fixed merge conflicts.

Orignal description:

Currently, gui.focus_inv_xform is used to determine the location of an event within a Control. Viewport::_gui_find_control() has the side-effect of updating gui.focus_inv_xform. This would be fine if _gui_find_control() was just used to assign gui.mouse_focus, but it's not. The result is, when a mouse button release event happens, sometimes gui.focus_inv_xform does not provide the location of the event inside the Control where the mouse button press event happened.

Instead of calculating the mouse_focus's Control's inverse transform every time _gui_find_control() is called and storing the result for later use, this PR calculates the required inverse transform only when it is needed. This will not only prevent the wrong inverse transform sometimes being used, but should result in better performance too.

Edited 2023-01-09: Fix merge conflict

@Sauermann Sauermann requested a review from a team as a code owner December 5, 2022 10:16
@Calinou Calinou added this to the 4.0 milestone Dec 5, 2022
Revival of godotengine#49158

Co-authored-by: Marcel Admiraal <madmiraal@users.noreply.github.com>
Copy link
Member

@groud groud left a comment

Choose a reason for hiding this comment

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

This seems to solve the problem correctly, as my own investigations lead to the same conclusion that focus_inv_xform had sometimes wrong values.

As the matrix multiplication to compute the transform should not be a very heavy processing, I don't think it a problem to remove this "optimization" and compute the value on demand.

@akien-mga akien-mga merged commit ae3ca04 into godotengine:master Jan 16, 2023
@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
Development

Successfully merging this pull request may close these issues.

Unexpected behavior when use ColorRect
4 participants