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 mouse position in sub-viewports #62274

Closed
wants to merge 1 commit into from
Closed

Conversation

KoBeWi
Copy link
Member

@KoBeWi KoBeWi commented Jun 21, 2022

Fixes #60390

As I was debugging the issue, I discovered that the problem lies in Viewport's method to get mouse position:

godot/scene/main/viewport.cpp

Lines 1100 to 1102 in b5f20a4

Vector2 Viewport::get_mouse_position() const {
return gui.last_mouse_pos;
}

It's returning the last recorded mouse position. The problem is that sub-viewports (or at least the 2D editor viewport) never updates this value, so it was always returning (0, 0).

This was originally changed in:
c7b4dca
Not sure why. I copied the previous code and it fixes the issue.

@KoBeWi KoBeWi added this to the 4.0 milestone Jun 21, 2022
@KoBeWi KoBeWi requested a review from a team as a code owner June 21, 2022 11:40
@akien-mga
Copy link
Member

CC @Sauermann

@Sauermann
Copy link
Contributor

@akien-mga thanks, I have seen this PR. I will revisit this PR after #67791, which touches related behavior.

@Sauermann
Copy link
Contributor

The approach of this PR is to fix the problem for one additional layer of SubViewports.
In #71768 I aim to solve the problem even for deeply nested Viewports.

@Sauermann
Copy link
Contributor

I believe, that the reason, why this PR has failed the checks, was fixed in #71972.

scene/main/viewport.cpp Outdated Show resolved Hide resolved
@akien-mga
Copy link
Member

Superseded by #71768.

@akien-mga akien-mga closed this Feb 7, 2023
@KoBeWi KoBeWi deleted the 🐁 branch February 7, 2023 16:07
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.

Mouse position does not work in @tool scripts
3 participants