Fix infinite loop when calculating zoom level if tile_size * max_zoom < default

(cherry picked from commit 42c672afd6)
This commit is contained in:
jsjtxietian 2023-12-28 10:42:37 +08:00 committed by Rémi Verschelde
parent 8f0966982d
commit 4e615b162d
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 10 additions and 2 deletions

View File

@ -719,11 +719,19 @@ void GenericTilePolygonEditor::set_tile_set(Ref<TileSet> p_tile_set) {
Vector2 zoomed_tile = editor_zoom_widget->get_zoom() * tile_set->get_tile_size();
while (zoomed_tile.y < default_control_y_size) {
editor_zoom_widget->set_zoom_by_increments(6, false);
zoomed_tile = editor_zoom_widget->get_zoom() * tile_set->get_tile_size();
float current_zoom = editor_zoom_widget->get_zoom();
zoomed_tile = current_zoom * tile_set->get_tile_size();
if (Math::is_equal_approx(current_zoom, editor_zoom_widget->get_max_zoom())) {
break;
}
}
while (zoomed_tile.y > default_control_y_size) {
editor_zoom_widget->set_zoom_by_increments(-6, false);
zoomed_tile = editor_zoom_widget->get_zoom() * tile_set->get_tile_size();
float current_zoom = editor_zoom_widget->get_zoom();
zoomed_tile = current_zoom * tile_set->get_tile_size();
if (Math::is_equal_approx(current_zoom, editor_zoom_widget->get_min_zoom())) {
break;
}
}
editor_zoom_widget->set_zoom_by_increments(-6, false);
_zoom_changed();