소스 검색

Merge pull request #78165 from timothyqiu/invalid-tile

Fix crash when opening a TileSet with invalid tiles
Rémi Verschelde 2 년 전
부모
커밋
52493767fc
1개의 변경된 파일5개의 추가작업 그리고 3개의 파일을 삭제
  1. 5 3
      editor/plugins/tiles/tiles_editor_plugin.cpp

+ 5 - 3
editor/plugins/tiles/tiles_editor_plugin.cpp

@@ -108,9 +108,11 @@ void TilesEditorPlugin::_thread() {
 						Vector2i coords = tile_map->get_cell_atlas_coords(0, cell);
 						int alternative = tile_map->get_cell_alternative_tile(0, cell);
 
-						Vector2 center = world_pos - atlas_source->get_tile_data(coords, alternative)->get_texture_origin();
-						encompassing_rect.expand_to(center - atlas_source->get_tile_texture_region(coords).size / 2);
-						encompassing_rect.expand_to(center + atlas_source->get_tile_texture_region(coords).size / 2);
+						if (atlas_source->has_tile(coords) && atlas_source->has_alternative_tile(coords, alternative)) {
+							Vector2 center = world_pos - atlas_source->get_tile_data(coords, alternative)->get_texture_origin();
+							encompassing_rect.expand_to(center - atlas_source->get_tile_texture_region(coords).size / 2);
+							encompassing_rect.expand_to(center + atlas_source->get_tile_texture_region(coords).size / 2);
+						}
 					}
 				}