Skip to content

Commit

Permalink
Merge pull request #83427 from kleonc/camera2d-screen-center-position…
Browse files Browse the repository at this point in the history
…-when-rotated

Fix screen center position returned for rotated Camera2D
  • Loading branch information
akien-mga committed Oct 16, 2023
2 parents 3d9ce12 + 836d80b commit 2ba83f2
Showing 1 changed file with 3 additions and 3 deletions.
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

0 comments on commit 2ba83f2

Please sign in to comment.