mirror of https://github.com/godotengine/godot
Properly clear scene tiles
This commit is contained in:
parent
41a7f6b380
commit
055b9892d2
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in New Issue