1
0
Fork 0

Properly clear scene tiles

This commit is contained in:
kobewi 2023-07-27 01:31:20 +02:00
parent 41a7f6b380
commit 055b9892d2
1 changed files with 3 additions and 12 deletions

View File

@ -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) {
@ -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());
}
@ -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();