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

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions scene/2d/camera_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,16 +209,16 @@ Transform2D Camera2D::get_camera_transform() {
screen_rect.position += offset;
}

camera_screen_center = screen_rect.get_center();

Transform2D xform;
xform.scale_basis(zoom_scale);
if (!ignore_rotation) {
xform.set_rotation(camera_angle);
}
xform.set_origin(screen_rect.position);

return (xform).affine_inverse();
camera_screen_center = xform.xform(0.5 * screen_size);

return xform.affine_inverse();
}

void Camera2D::_notification(int p_what) {
Expand Down
Loading