From b59530099e7be1ce432a681cec4a13d561d55260 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 2 Mar 2024 14:30:29 +0100 Subject: [PATCH] Work on fixing compile when layered tile maps are enabled. --- modules/layered_tile_map/layered_tile_map.cpp | 25 +++++----- modules/layered_tile_map/layered_tile_map.h | 10 ++-- .../layered_tile_map_layer.cpp | 48 +++++++++---------- .../layered_tile_map/layered_tile_map_layer.h | 20 ++++---- .../layered_tile_map_layer_group.cpp | 2 +- .../layered_tile_map_layer_group.h | 2 +- 6 files changed, 55 insertions(+), 52 deletions(-) diff --git a/modules/layered_tile_map/layered_tile_map.cpp b/modules/layered_tile_map/layered_tile_map.cpp index 9563242ad..404235bf4 100644 --- a/modules/layered_tile_map/layered_tile_map.cpp +++ b/modules/layered_tile_map/layered_tile_map.cpp @@ -33,8 +33,8 @@ #include "layered_tile_map.compat.inc" #include "core/core_string_names.h" -#include "scene/2d/tile_map_layer.h" -#include "scene/gui/control.h" +#include "layered_tile_map_layer.h" +#include "scene/main/control.h" #define TILEMAP_CALL_FOR_LAYER(layer, function, ...) \ if (layer < 0) { \ @@ -105,7 +105,10 @@ void LayeredTileMap::set_rendering_quadrant_size(int p_size) { ERR_FAIL_COND_MSG(p_size < 1, "LayeredTileMapQuadrant size cannot be smaller than 1."); rendering_quadrant_size = p_size; - for (LayeredTileMapLayer *layer : layers) { + + for (uint32_t i = 0; i < layers.size(); ++i) { + LayeredTileMapLayer *layer = layers[i]; + layer->set_rendering_quadrant_size(p_size); } _emit_changed(); @@ -115,7 +118,7 @@ int LayeredTileMap::get_rendering_quadrant_size() const { return rendering_quadrant_size; } -void LayeredTileMap::draw_tile(RID p_canvas_item, const Vector2 &p_position, const Ref p_tile_set, int p_atlas_source_id, const Vector2i &p_atlas_coords, int p_alternative_tile, int p_frame, Color p_modulation, const TileData *p_tile_data_override, real_t p_normalized_animation_offset) { +void LayeredTileMap::draw_tile(RID p_canvas_item, const Vector2 &p_position, const Ref p_tile_set, int p_atlas_source_id, const Vector2i &p_atlas_coords, int p_alternative_tile, int p_frame, Color p_modulation, const LayeredTileData *p_tile_data_override, real_t p_normalized_animation_offset) { ERR_FAIL_COND(!p_tile_set.is_valid()); ERR_FAIL_COND(!p_tile_set->has_source(p_atlas_source_id)); ERR_FAIL_COND(!p_tile_set->get_source(p_atlas_source_id)->has_tile(p_atlas_coords)); @@ -141,7 +144,7 @@ void LayeredTileMap::draw_tile(RID p_canvas_item, const Vector2 &p_position, con } // Get tile data. - const TileData *tile_data = p_tile_data_override ? p_tile_data_override : atlas_source->get_tile_data(p_atlas_coords, p_alternative_tile); + const LayeredTileData *tile_data = p_tile_data_override ? p_tile_data_override : atlas_source->get_tile_data(p_atlas_coords, p_alternative_tile); // Get the tile modulation. Color modulate = tile_data->get_modulate() * p_modulation; @@ -173,10 +176,10 @@ void LayeredTileMap::draw_tile(RID p_canvas_item, const Vector2 &p_position, con // Draw the tile. if (p_frame >= 0) { Rect2i source_rect = atlas_source->get_runtime_tile_texture_region(p_atlas_coords, p_frame); - tex->draw_rect_region(p_canvas_item, dest_rect, source_rect, modulate, transpose, p_tile_set->is_uv_clipping()); + tex->draw_rect_region(p_canvas_item, dest_rect, source_rect, modulate, transpose, Ref(), p_tile_set->is_uv_clipping()); } else if (atlas_source->get_tile_animation_frames_count(p_atlas_coords) == 1) { Rect2i source_rect = atlas_source->get_runtime_tile_texture_region(p_atlas_coords, 0); - tex->draw_rect_region(p_canvas_item, dest_rect, source_rect, modulate, transpose, p_tile_set->is_uv_clipping()); + tex->draw_rect_region(p_canvas_item, dest_rect, source_rect, modulate, transpose, Ref(), p_tile_set->is_uv_clipping()); } else { real_t speed = atlas_source->get_tile_animation_speed(p_atlas_coords); real_t animation_duration = atlas_source->get_tile_animation_total_duration(p_atlas_coords) / speed; @@ -191,7 +194,7 @@ void LayeredTileMap::draw_tile(RID p_canvas_item, const Vector2 &p_position, con RenderingServer::get_singleton()->canvas_item_add_animation_slice(p_canvas_item, animation_duration, slice_start, slice_end, animation_offset); Rect2i source_rect = atlas_source->get_runtime_tile_texture_region(p_atlas_coords, frame); - tex->draw_rect_region(p_canvas_item, dest_rect, source_rect, modulate, transpose, p_tile_set->is_uv_clipping()); + tex->draw_rect_region(p_canvas_item, dest_rect, source_rect, modulate, transpose, Ref(), p_tile_set->is_uv_clipping()); time_unscaled += frame_duration_unscaled; } @@ -406,7 +409,7 @@ int LayeredTileMap::get_cell_alternative_tile(int p_layer, const Vector2i &p_coo TILEMAP_CALL_FOR_LAYER_V(p_layer, LayeredTileSetSource::INVALID_TILE_ALTERNATIVE, get_cell_alternative_tile, p_coords, p_use_proxies); } -TileData *LayeredTileMap::get_cell_tile_data(int p_layer, const Vector2i &p_coords, bool p_use_proxies) const { +LayeredTileData *LayeredTileMap::get_cell_tile_data(int p_layer, const Vector2i &p_coords, bool p_use_proxies) const { TILEMAP_CALL_FOR_LAYER_V(p_layer, nullptr, get_cell_tile_data, p_coords, p_use_proxies); } @@ -832,8 +835,8 @@ PoolVector2iArray LayeredTileMap::get_surrounding_cells(const Vector2i &p_coords return tile_set->get_surrounding_cells(p_coords); } -PackedStringArray LayeredTileMap::get_configuration_warnings() const { - PackedStringArray warnings = Node::get_configuration_warnings(); +PoolStringArray LayeredTileMap::get_configuration_warnings() const { + PoolStringArray warnings = Node::get_configuration_warnings(); // Retrieve the set of Z index values with a Y-sorted layer. RBSet y_sorted_z_index; diff --git a/modules/layered_tile_map/layered_tile_map.h b/modules/layered_tile_map/layered_tile_map.h index e8693745b..feb57d280 100644 --- a/modules/layered_tile_map/layered_tile_map.h +++ b/modules/layered_tile_map/layered_tile_map.h @@ -113,7 +113,7 @@ public: void set_rendering_quadrant_size(int p_size); int get_rendering_quadrant_size() const; - static void draw_tile(RID p_canvas_item, const Vector2 &p_position, const Ref p_tile_set, int p_atlas_source_id, const Vector2i &p_atlas_coords, int p_alternative_tile, int p_frame = -1, Color p_modulation = Color(1.0, 1.0, 1.0, 1.0), const TileData *p_tile_data_override = nullptr, real_t p_normalized_animation_offset = 0.0); + static void draw_tile(RID p_canvas_item, const Vector2 &p_position, const Ref p_tile_set, int p_atlas_source_id, const Vector2i &p_atlas_coords, int p_alternative_tile, int p_frame = -1, Color p_modulation = Color(1.0, 1.0, 1.0, 1.0), const LayeredTileData *p_tile_data_override = nullptr, real_t p_normalized_animation_offset = 0.0); // Layers management. int get_layers_count() const; @@ -155,7 +155,7 @@ public: Vector2i get_cell_atlas_coords(int p_layer, const Vector2i &p_coords, bool p_use_proxies = false) const; int get_cell_alternative_tile(int p_layer, const Vector2i &p_coords, bool p_use_proxies = false) const; // Helper method to make accessing the data easier. - TileData *get_cell_tile_data(int p_layer, const Vector2i &p_coords, bool p_use_proxies = false) const; + LayeredTileData *get_cell_tile_data(int p_layer, const Vector2i &p_coords, bool p_use_proxies = false) const; // Patterns. Ref get_pattern(int p_layer, PoolVector2iArray p_coords_array); @@ -212,12 +212,12 @@ public: // Helpers? PoolVector2iArray get_surrounding_cells(const Vector2i &p_coords); - // Virtual function to modify the TileData at runtime. + // Virtual function to modify the LayeredTileData at runtime. GDVIRTUAL2R(bool, _use_tile_data_runtime_update, int, Vector2i); - GDVIRTUAL3(_tile_data_runtime_update, int, Vector2i, TileData *); + GDVIRTUAL3(_tile_data_runtime_update, int, Vector2i, LayeredTileData *); // Configuration warnings. - PackedStringArray get_configuration_warnings() const; + PoolStringArray get_configuration_warnings() const; LayeredTileMap(); ~LayeredTileMap(); diff --git a/modules/layered_tile_map/layered_tile_map_layer.cpp b/modules/layered_tile_map/layered_tile_map_layer.cpp index af4031099..a09bd14cc 100644 --- a/modules/layered_tile_map/layered_tile_map_layer.cpp +++ b/modules/layered_tile_map/layered_tile_map_layer.cpp @@ -33,12 +33,12 @@ #include "core/core_string_names.h" #include "core/io/marshalls.h" -#include "scene/gui/control.h" +#include "scene/main/control.h" #include "scene/resources/world_2d.h" -#include "servers/navigation_server_2d.h" +#include "servers/navigation_2d_server.h" #ifdef DEBUG_ENABLED -#include "servers/navigation_server_3d.h" +#include "servers/navigation_server.h" #endif // DEBUG_ENABLED #ifdef DEBUG_ENABLED @@ -297,7 +297,7 @@ void LayeredTileMapLayer::_rendering_update() { LayeredTileSetAtlasSource *atlas_source = Object::cast_to(*tile_set->get_source(cell_data.cell.source_id)); // Get the tile data. - const TileData *tile_data; + const LayeredTileData *tile_data; if (cell_data.runtime_tile_data_cache) { tile_data = cell_data.runtime_tile_data_cache; } else { @@ -469,7 +469,7 @@ void LayeredTileMapLayer::_rendering_quadrants_update_cell(CellData &r_cell_data LayeredTileSetAtlasSource *atlas_source = Object::cast_to(source); if (atlas_source && atlas_source->has_tile(r_cell_data.cell.get_atlas_coords()) && atlas_source->has_alternative_tile(r_cell_data.cell.get_atlas_coords(), r_cell_data.cell.alternative_tile)) { is_valid = true; - const TileData *tile_data; + const LayeredTileData *tile_data; if (r_cell_data.runtime_tile_data_cache) { tile_data = r_cell_data.runtime_tile_data_cache; } else { @@ -577,7 +577,7 @@ void LayeredTileMapLayer::_rendering_occluders_update_cell(CellData &r_cell_data LayeredTileSetAtlasSource *atlas_source = Object::cast_to(source); if (atlas_source) { // Get the tile data. - const TileData *tile_data; + const LayeredTileData *tile_data; if (r_cell_data.runtime_tile_data_cache) { tile_data = r_cell_data.runtime_tile_data_cache; } else { @@ -773,7 +773,7 @@ void LayeredTileMapLayer::_physics_update_cell(CellData &r_cell_data) { if (source->has_tile(c.get_atlas_coords()) && source->has_alternative_tile(c.get_atlas_coords(), c.alternative_tile)) { LayeredTileSetAtlasSource *atlas_source = Object::cast_to(source); if (atlas_source) { - const TileData *tile_data; + const LayeredTileData *tile_data; if (r_cell_data.runtime_tile_data_cache) { tile_data = r_cell_data.runtime_tile_data_cache; } else { @@ -1038,7 +1038,7 @@ void LayeredTileMapLayer::_navigation_update_cell(CellData &r_cell_data) { if (source->has_tile(c.get_atlas_coords()) && source->has_alternative_tile(c.get_atlas_coords(), c.alternative_tile)) { LayeredTileSetAtlasSource *atlas_source = Object::cast_to(source); if (atlas_source) { - const TileData *tile_data; + const LayeredTileData *tile_data; if (r_cell_data.runtime_tile_data_cache) { tile_data = r_cell_data.runtime_tile_data_cache; } else { @@ -1144,7 +1144,7 @@ void LayeredTileMapLayer::_navigation_draw_cell_debug(const RID &p_canvas_item, if (source->has_tile(c.get_atlas_coords()) && source->has_alternative_tile(c.get_atlas_coords(), c.alternative_tile)) { LayeredTileSetAtlasSource *atlas_source = Object::cast_to(source); if (atlas_source) { - const TileData *tile_data; + const LayeredTileData *tile_data; if (r_cell_data.runtime_tile_data_cache) { tile_data = r_cell_data.runtime_tile_data_cache; } else { @@ -1394,10 +1394,10 @@ void LayeredTileMapLayer::_build_runtime_update_tile_data_for_cell(CellData &r_c if (p_use_tilemap_for_runtime) { // Compatibility with LayeredTileMap. if (tile_map_node->GDVIRTUAL_CALL(_use_tile_data_runtime_update, layer_index_in_tile_map_node, r_cell_data.coords, ret) && ret) { - TileData *tile_data = atlas_source->get_tile_data(c.get_atlas_coords(), c.alternative_tile); + LayeredTileData *tile_data = atlas_source->get_tile_data(c.get_atlas_coords(), c.alternative_tile); - // Create the runtime TileData. - TileData *tile_data_runtime_use = tile_data->duplicate(); + // Create the runtime LayeredTileData. + LayeredTileData *tile_data_runtime_use = tile_data->duplicate(); tile_data_runtime_use->set_allow_transform(true); r_cell_data.runtime_tile_data_cache = tile_data_runtime_use; @@ -1409,10 +1409,10 @@ void LayeredTileMapLayer::_build_runtime_update_tile_data_for_cell(CellData &r_c } } else { if (GDVIRTUAL_CALL(_use_tile_data_runtime_update, r_cell_data.coords, ret) && ret) { - TileData *tile_data = atlas_source->get_tile_data(c.get_atlas_coords(), c.alternative_tile); + LayeredTileData *tile_data = atlas_source->get_tile_data(c.get_atlas_coords(), c.alternative_tile); - // Create the runtime TileData. - TileData *tile_data_runtime_use = tile_data->duplicate(); + // Create the runtime LayeredTileData. + LayeredTileData *tile_data_runtime_use = tile_data->duplicate(); tile_data_runtime_use->set_allow_transform(true); r_cell_data.runtime_tile_data_cache = tile_data_runtime_use; @@ -1559,13 +1559,13 @@ RBSet LayeredTileMapLayer::_get_terrain_constraints_from_pain // Count the number of occurrences per terrain. HashMap overlapping_terrain_bits = E_constraint.get_overlapping_coords_and_peering_bits(); for (const KeyValue &E_overlapping : overlapping_terrain_bits) { - TileData *neighbor_tile_data = nullptr; + LayeredTileData *neighbor_tile_data = nullptr; LayeredTileMapCell neighbor_cell = get_cell(E_overlapping.key); if (neighbor_cell.source_id != LayeredTileSet::INVALID_SOURCE) { Ref source = tile_set->get_source(neighbor_cell.source_id); Ref atlas_source = source; if (atlas_source.is_valid()) { - TileData *tile_data = atlas_source->get_tile_data(neighbor_cell.get_atlas_coords(), neighbor_cell.alternative_tile); + LayeredTileData *tile_data = atlas_source->get_tile_data(neighbor_cell.get_atlas_coords(), neighbor_cell.alternative_tile); if (tile_data && tile_data->get_terrain_set() == p_terrain_set) { neighbor_tile_data = tile_data; } @@ -1601,7 +1601,7 @@ RBSet LayeredTileMapLayer::_get_terrain_constraints_from_pain // Add the centers as constraints. for (Vector2i E_coords : p_painted) { - TileData *tile_data = nullptr; + LayeredTileData *tile_data = nullptr; LayeredTileMapCell cell = get_cell(E_coords); if (cell.source_id != LayeredTileSet::INVALID_SOURCE) { Ref source = tile_set->get_source(cell.source_id); @@ -1658,7 +1658,7 @@ void LayeredTileMapLayer::_deferred_internal_update() { } void LayeredTileMapLayer::_internal_update() { - // Find TileData that need a runtime modification. + // Find LayeredTileData that need a runtime modification. // This may add cells to the dirty list if a runtime modification has been notified. _build_runtime_update_tile_data(); @@ -1818,7 +1818,7 @@ HashMap LayeredTileMapLayer::terrain_ LayeredTileSetAtlasSource *atlas_source = Object::cast_to(source); if (atlas_source) { // Get tile data. - TileData *tile_data = atlas_source->get_tile_data(cell.get_atlas_coords(), cell.alternative_tile); + LayeredTileData *tile_data = atlas_source->get_tile_data(cell.get_atlas_coords(), cell.alternative_tile); if (tile_data && tile_data->get_terrain_set() == p_terrain_set) { current_pattern = tile_data->get_terrains_pattern(); } @@ -1880,7 +1880,7 @@ HashMap LayeredTileMapLayer::terrain_ connect = true; } else { // Get the center bit of the cell. - TileData *tile_data = nullptr; + LayeredTileData *tile_data = nullptr; LayeredTileMapCell cell = get_cell(coords); if (cell.source_id != LayeredTileSet::INVALID_SOURCE) { Ref source = tile_set->get_source(cell.source_id); @@ -2318,7 +2318,7 @@ int LayeredTileMapLayer::get_cell_alternative_tile(const Vector2i &p_coords, boo return E->value.cell.alternative_tile; } -TileData *LayeredTileMapLayer::get_cell_tile_data(const Vector2i &p_coords, bool p_use_proxies) const { +LayeredTileData *LayeredTileMapLayer::get_cell_tile_data(const Vector2i &p_coords, bool p_use_proxies) const { int source_id = get_cell_source_id(p_coords, p_use_proxies); if (source_id == LayeredTileSet::INVALID_SOURCE) { return nullptr; @@ -2433,7 +2433,7 @@ void LayeredTileMapLayer::set_cells_terrain_connect(PoolVector2iArray p_cells, i LayeredTileSetAtlasSource *atlas_source = Object::cast_to(source); if (atlas_source) { // Get tile data. - TileData *tile_data = atlas_source->get_tile_data(cell.get_atlas_coords(), cell.alternative_tile); + LayeredTileData *tile_data = atlas_source->get_tile_data(cell.get_atlas_coords(), cell.alternative_tile); if (tile_data && tile_data->get_terrain_set() == p_terrain_set) { in_map_terrain_pattern = tile_data->get_terrains_pattern(); } @@ -2474,7 +2474,7 @@ void LayeredTileMapLayer::set_cells_terrain_path(PoolVector2iArray p_path, int p LayeredTileSetAtlasSource *atlas_source = Object::cast_to(source); if (atlas_source) { // Get tile data. - TileData *tile_data = atlas_source->get_tile_data(cell.get_atlas_coords(), cell.alternative_tile); + LayeredTileData *tile_data = atlas_source->get_tile_data(cell.get_atlas_coords(), cell.alternative_tile); if (tile_data && tile_data->get_terrain_set() == p_terrain_set) { in_map_terrain_pattern = tile_data->get_terrains_pattern(); } diff --git a/modules/layered_tile_map/layered_tile_map_layer.h b/modules/layered_tile_map/layered_tile_map_layer.h index 93825c0e5..b1e45d88d 100644 --- a/modules/layered_tile_map/layered_tile_map_layer.h +++ b/modules/layered_tile_map/layered_tile_map_layer.h @@ -33,7 +33,7 @@ /*************************************************************************/ #include "layered_tile_set.h" -#include "scene/2d/tile_map.h" +#include "layered_tile_map.h" class LayeredTileSetAtlasSource; @@ -115,8 +115,8 @@ struct CellData { // Scenes. String scene; - // Runtime TileData cache. - TileData *runtime_tile_data_cache = nullptr; + // Runtime LayeredTileData cache. + LayeredTileData *runtime_tile_data_cache = nullptr; // List elements. SelfList dirty_list_element; @@ -164,8 +164,8 @@ struct CellDataYSortedComparator { }; #ifdef DEBUG_ENABLED -class DebugQuadrant : public RefCounted { - GDCLASS(DebugQuadrant, RefCounted); +class DebugQuadrant : public Reference { + GDCLASS(DebugQuadrant, Reference); public: Vector2i quadrant_coords; @@ -184,8 +184,8 @@ public: }; #endif // DEBUG_ENABLED -class RenderingQuadrant : public RefCounted { - GDCLASS(RenderingQuadrant, RefCounted); +class RenderingQuadrant : public Reference { + GDCLASS(RenderingQuadrant, Reference); public: struct CoordsWorldComparator { @@ -393,7 +393,7 @@ public: int get_cell_source_id(const Vector2i &p_coords, bool p_use_proxies = false) const; Vector2i get_cell_atlas_coords(const Vector2i &p_coords, bool p_use_proxies = false) const; int get_cell_alternative_tile(const Vector2i &p_coords, bool p_use_proxies = false) const; - TileData *get_cell_tile_data(const Vector2i &p_coords, bool p_use_proxies = false) const; // Helper method to make accessing the data easier. + LayeredTileData *get_cell_tile_data(const Vector2i &p_coords, bool p_use_proxies = false) const; // Helper method to make accessing the data easier. void clear(); // Patterns. @@ -445,9 +445,9 @@ public: // Helper. Ref get_effective_tile_set() const; - // Virtual function to modify the TileData at runtime. + // Virtual function to modify the LayeredTileData at runtime. GDVIRTUAL1R(bool, _use_tile_data_runtime_update, Vector2i); - GDVIRTUAL2(_tile_data_runtime_update, Vector2i, TileData *); + GDVIRTUAL2(_tile_data_runtime_update, Vector2i, LayeredTileData *); // --- LayeredTileMapLayer(); diff --git a/modules/layered_tile_map/layered_tile_map_layer_group.cpp b/modules/layered_tile_map/layered_tile_map_layer_group.cpp index 531e2dc0e..f456872b8 100644 --- a/modules/layered_tile_map/layered_tile_map_layer_group.cpp +++ b/modules/layered_tile_map/layered_tile_map_layer_group.cpp @@ -33,7 +33,7 @@ #include "core/core_string_names.h" #include "layered_tile_map_layer.h" -#include "scene/resources/2d/tile_set.h" +#include "layered_tile_set.h" #ifdef TOOLS_ENABLED diff --git a/modules/layered_tile_map/layered_tile_map_layer_group.h b/modules/layered_tile_map/layered_tile_map_layer_group.h index ef8910cb5..6e965bc02 100644 --- a/modules/layered_tile_map/layered_tile_map_layer_group.h +++ b/modules/layered_tile_map/layered_tile_map_layer_group.h @@ -32,7 +32,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "scene/2d/node_2d.h" +#include "scene/main/node_2d.h" class LayeredTileSet;