Bläddra i källkod

Fix TileMapLayer bug where dirty cells could be marked twice

When using runtime data in a TileMapLayer, calling notify_runtime_tile_update
can cause error messages to be printed to the console if the same cell has been
set or erased in the same frame. This could be partially worked around by using
call_deferred on notify_runtime_tile_update, but the problem could re-emerge if
those updates were being made in coroutines.

This commit addresses the issue by adding an additional check to the dirty cell
marking of the TileMapLayer when notify_runtime_tile_update is called. This
check ensures that the cell has not already been added to the dirty cell list,
preventing the condition that causes the error message.
Caleb Cassady 5 månader sedan
förälder
incheckning
7404873b66
1 ändrade filer med 2 tillägg och 2 borttagningar
  1. 2 2
      scene/2d/tile_map_layer.cpp

+ 2 - 2
scene/2d/tile_map_layer.cpp

@@ -1413,7 +1413,7 @@ void TileMapLayer::_build_runtime_update_tile_data_for_cell(CellData &r_cell_dat
 
 						tile_map_node->GDVIRTUAL_CALL(_tile_data_runtime_update, layer_index_in_tile_map_node, r_cell_data.coords, tile_data_runtime_use);
 
-						if (p_auto_add_to_dirty_list) {
+						if (p_auto_add_to_dirty_list && !r_cell_data.dirty_list_element.in_list()) {
 							dirty.cell_list.add(&r_cell_data.dirty_list_element);
 						}
 					}
@@ -1428,7 +1428,7 @@ void TileMapLayer::_build_runtime_update_tile_data_for_cell(CellData &r_cell_dat
 
 						GDVIRTUAL_CALL(_tile_data_runtime_update, r_cell_data.coords, tile_data_runtime_use);
 
-						if (p_auto_add_to_dirty_list) {
+						if (p_auto_add_to_dirty_list && !r_cell_data.dirty_list_element.in_list()) {
 							dirty.cell_list.add(&r_cell_data.dirty_list_element);
 						}
 					}