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 screen center position returned for rotated Camera2D #83427

Conversation

kleonc
Copy link
Member

@kleonc kleonc commented Oct 16, 2023

Fixes #44358 (needs a cherry-pick for 3.x) and #83372 which was is a duplicate.

MRP from #83372 (a little tweaked):

v4.2.beta1.official [b137180] This PR This PR
with added camera animation + drag enabled
(aka target_position != screen_center)
XNdH2YWkSD citRceaTDX K2KxTERgo6
ZHc3sFZF44 utZBsnAlUG VhQwH1Fwzs

Basically within the Camera2D calculations the position ("top right" corner) of the screen rect is calculated taking the rotation into account but the screen rect itself is considered in an unrotated space. Simpler to visualize, the red rect (the green rect is what camera would actually show):
DcjCCeMo2o

Note this PR fixes only the returned screen center position. The incorrectly calculated screen rect (red bounds) is still what is taken into account e.g. when limiting position with limit_smoothed == false and position_smoothing_enabled == false (orange lines = camera limits):

v4.2.beta1.official [b137180] This PR
wS3H39lKsK N9YiCM6A25

Wanted to keep this PR super simple as there are many other strange/suspicious things in the Camera2D logic (see #63773). It's kinda domino-like. 🙃

@kleonc kleonc added this to the 4.2 milestone Oct 16, 2023
@kleonc kleonc requested a review from a team as a code owner October 16, 2023 08:37
@akien-mga akien-mga requested review from KoBeWi and groud October 16, 2023 08:45
@akien-mga akien-mga merged commit 2ba83f2 into godotengine:master Oct 16, 2023
15 checks passed
@akien-mga
Copy link
Member

Thanks!

@kleonc kleonc deleted the camera2d-screen-center-position-when-rotated branch October 16, 2023 12:41
@awardell
Copy link
Contributor

You're a hero kleonc, that was fast. Thanks!

@kleonc kleonc added the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Oct 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug cherrypick:3.x Considered for cherry-picking into a future 3.x release topic:core topic:2d
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Camera2D get_camera_screen_center() reports bad position with rotating camera
4 participants