Skip to content

Commit

Permalink
Merge pull request #79941 from KoBeWi/scene_tile_devastation
Browse files Browse the repository at this point in the history
Properly clear scene tiles
  • Loading branch information
YuriSizov authored Jul 27, 2023
2 parents a0f5724 + 055b989 commit 1e314d5
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions scene/2d/tile_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -773,18 +773,7 @@ void TileMapLayer::_scenes_update_dirty_quadrants(SelfList<TileMapQuadrant>::Lis
SelfList<TileMapQuadrant> *q_list_element = r_dirty_quadrant_list.first();
while (q_list_element) {
TileMapQuadrant &q = *q_list_element->self();

// Clear the scenes if instance cache was cleared.
if (instantiated_scenes.is_empty()) {
for (const KeyValue<Vector2i, String> &E : q.scenes) {
Node *node = tile_map_node->get_node_or_null(E.value);
if (node) {
node->queue_free();
}
}
}

q.scenes.clear();
_scenes_cleanup_quadrant(&q);

// Recreate the scenes.
for (const Vector2i &E_cell : q.cells) {
Expand Down Expand Up @@ -1562,6 +1551,7 @@ void TileMapLayer::clear_instantiated_scenes() {

void TileMapLayer::clear_internals() {
// Clear quadrants.
clear_instantiated_scenes();
while (quadrant_map.size()) {
_erase_quadrant(quadrant_map.begin());
}
Expand Down Expand Up @@ -1962,6 +1952,7 @@ TileData *TileMapLayer::get_cell_tile_data(const Vector2i &p_coords, bool p_use_

void TileMapLayer::clear() {
// Remove all tiles.
clear_instantiated_scenes();
clear_internals();
tile_map.clear();
recreate_internals();
Expand Down

0 comments on commit 1e314d5

Please sign in to comment.