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 offset in CanvasItem drag movement #55333

Merged
merged 1 commit into from
Nov 27, 2021

Conversation

pablodp606
Copy link
Contributor

The initial offset was using the mouse position when the threshold
was reached instead of the initial click position. This was adding
the drag threshold distance as an extra offset to the final
transformation.

Now the offset is calculated from the initial click position.

Before (notice the initial and the final mouse position over the sprite):

2021-11-26.01-00-41.mp4

After

2021-11-26.00-58-25.mp4

@Calinou
Copy link
Member

Calinou commented Nov 26, 2021

For reference, the drag distance threshold was originally implemented in #49310.

The same change should most likely be performed in the 3D editor (editor/plugins/node_3d_editor_plugin.cpp), since the bug is probably present there too.

@JFonS
Copy link
Contributor

JFonS commented Nov 26, 2021

The 3D equivalent would be to set

_compute_edit(_edit.mouse_pos);

to _compute_edit(_edit.original_mouse_pos);.

It's barely noticeable by default because the perspective changes and there's no reference point, but it does make a difference in orthogonal mode.

The initial offset was using the mouse position when the threshold
was reached instead of the initial click position. This was adding
the drag threshold distance as an extra offset to the final
transformation.

Now the offset is calculated from the initial click position.
@pablodp606 pablodp606 requested a review from a team as a code owner November 27, 2021 00:33
@pablodp606
Copy link
Contributor Author

Ok, updated to include the fix for the 3D editor.

@akien-mga akien-mga merged commit 52b7d5f into godotengine:master Nov 27, 2021
@akien-mga
Copy link
Member

Thanks! And congrats for your first merged Godot contribution 🎉

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.

4 participants