mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Fix debug rendering in TileMapLayer
This commit is contained in:
parent
967e2d499a
commit
8637922926
2 changed files with 29 additions and 2 deletions
|
|
@ -113,8 +113,7 @@ void TileMapLayer::_debug_update(bool p_force_cleanup) {
|
|||
}
|
||||
}
|
||||
|
||||
// Update those quadrants.
|
||||
bool needs_set_not_interpolated = is_inside_tree() && get_tree()->is_physics_interpolation_enabled() && !is_physics_interpolated();
|
||||
// Create new quadrants if needed.
|
||||
for (const Vector2i &quadrant_coords : quadrants_to_updates) {
|
||||
if (!debug_quadrant_map.has(quadrant_coords)) {
|
||||
// Create a new quadrant and add it to the quadrant map.
|
||||
|
|
@ -123,7 +122,30 @@ void TileMapLayer::_debug_update(bool p_force_cleanup) {
|
|||
new_quadrant->quadrant_coords = quadrant_coords;
|
||||
debug_quadrant_map[quadrant_coords] = new_quadrant;
|
||||
}
|
||||
}
|
||||
|
||||
// Second pass on modified cells to update the list of cells per quandrant.
|
||||
if (_debug_was_cleaned_up || anything_changed) {
|
||||
for (KeyValue<Vector2i, CellData> &kv : tile_map_layer_data) {
|
||||
CellData &cell_data = kv.value;
|
||||
Ref<DebugQuadrant> debug_quadrant = debug_quadrant_map[_coords_to_quadrant_coords(cell_data.coords, TILE_MAP_DEBUG_QUADRANT_SIZE)];
|
||||
if (!cell_data.debug_quadrant_list_element.in_list()) {
|
||||
debug_quadrant->cells.add(&cell_data.debug_quadrant_list_element);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (SelfList<CellData> *cell_data_list_element = dirty.cell_list.first(); cell_data_list_element; cell_data_list_element = cell_data_list_element->next()) {
|
||||
CellData &cell_data = *cell_data_list_element->self();
|
||||
Ref<DebugQuadrant> debug_quadrant = debug_quadrant_map[_coords_to_quadrant_coords(cell_data.coords, TILE_MAP_DEBUG_QUADRANT_SIZE)];
|
||||
if (!cell_data.debug_quadrant_list_element.in_list()) {
|
||||
debug_quadrant->cells.add(&cell_data.debug_quadrant_list_element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update those quadrants.
|
||||
bool needs_set_not_interpolated = is_inside_tree() && get_tree()->is_physics_interpolation_enabled() && !is_physics_interpolated();
|
||||
for (const Vector2i &quadrant_coords : quadrants_to_updates) {
|
||||
Ref<DebugQuadrant> debug_quadrant = debug_quadrant_map[quadrant_coords];
|
||||
|
||||
// Update the quadrant's canvas item.
|
||||
|
|
|
|||
|
|
@ -105,6 +105,9 @@ struct CellData {
|
|||
Vector2i coords;
|
||||
TileMapCell cell;
|
||||
|
||||
// Debug
|
||||
SelfList<CellData> debug_quadrant_list_element;
|
||||
|
||||
// Rendering.
|
||||
Ref<RenderingQuadrant> rendering_quadrant;
|
||||
SelfList<CellData> rendering_quadrant_list_element;
|
||||
|
|
@ -143,6 +146,7 @@ struct CellData {
|
|||
}
|
||||
|
||||
CellData(const CellData &p_other) :
|
||||
debug_quadrant_list_element(this),
|
||||
rendering_quadrant_list_element(this),
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
physics_quadrant_list_element(this),
|
||||
|
|
@ -157,6 +161,7 @@ struct CellData {
|
|||
}
|
||||
|
||||
CellData() :
|
||||
debug_quadrant_list_element(this),
|
||||
rendering_quadrant_list_element(this),
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
physics_quadrant_list_element(this),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue