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<Window>(this)`. This allows the removal of `Viewport.to_screen_rect` and the simplification of `Viewport::_set_size`.
This commit is contained in:
parent
db8c85a75f
commit
6743ac34d3
3 changed files with 8 additions and 10 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue