From 6743ac34d334f6067b80456dbf0b2e1a4d99d57b Mon Sep 17 00:00:00 2001 From: Markus Sauermann <6299227+Sauermann@users.noreply.github.com> Date: Thu, 2 Feb 2023 19:00:07 +0100 Subject: Simplify Viewport::_set_size `Viewport.to_screen_rect` is used only in a single location to compare it to `Rect2i()`. When called from `SubViewport`, `to_screen_rect` is always equal to `Rect2i()`. When called from `Window`, `to_screen_rect` is always different from `Rect2i()`. So the comparison `to_screen_rect != Rect2i()` can be replaced by `Object::cast_to(this)`. This allows the removal of `Viewport.to_screen_rect` and the simplification of `Viewport::_set_size`. --- scene/main/window.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scene/main/window.cpp') diff --git a/scene/main/window.cpp b/scene/main/window.cpp index b6f1d3f54b..be2a0dca13 100644 --- a/scene/main/window.cpp +++ b/scene/main/window.cpp @@ -1004,7 +1004,7 @@ void Window::_update_viewport_size() { } bool allocate = is_inside_tree() && visible && (window_id != DisplayServer::INVALID_WINDOW_ID || embedder != nullptr); - _set_size(final_size, final_size_override, attach_to_screen_rect, allocate); + _set_size(final_size, final_size_override, allocate); if (window_id != DisplayServer::INVALID_WINDOW_ID) { RenderingServer::get_singleton()->viewport_attach_to_screen(get_viewport_rid(), attach_to_screen_rect, window_id); -- cgit v1.2.3