diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 61f45114de7..3ae7a0b34d0 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -358,7 +358,7 @@ TileMap::TerrainConstraint::TerrainConstraint(const TileMap *p_tile_map, const V terrain = p_terrain; } -Vector2i TileMap::transform_coords_layout(Vector2i p_coords, TileSet::TileOffsetAxis p_offset_axis, TileSet::TileLayout p_from_layout, TileSet::TileLayout p_to_layout) { +Vector2i TileMap::transform_coords_layout(const Vector2i &p_coords, TileSet::TileOffsetAxis p_offset_axis, TileSet::TileLayout p_from_layout, TileSet::TileLayout p_to_layout) { // Transform to stacked layout. Vector2i output = p_coords; if (p_offset_axis == TileSet::TILE_OFFSET_AXIS_VERTICAL) { @@ -1343,7 +1343,7 @@ void TileMap::_rendering_draw_quadrant_debug(TileMapQuadrant *p_quadrant) { } } -void TileMap::draw_tile(RID p_canvas_item, Vector2i p_position, const Ref p_tile_set, int p_atlas_source_id, Vector2i p_atlas_coords, int p_alternative_tile, int p_frame, Color p_modulation, const TileData *p_tile_data_override) { +void TileMap::draw_tile(RID p_canvas_item, const Vector2i &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) { 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)); @@ -2187,7 +2187,7 @@ Ref TileMap::get_pattern(int p_layer, TypedArray p_coo return output; } -Vector2i TileMap::map_pattern(Vector2i p_position_in_tilemap, Vector2i p_coords_in_pattern, Ref p_pattern) { +Vector2i TileMap::map_pattern(const Vector2i &p_position_in_tilemap, const Vector2i &p_coords_in_pattern, Ref p_pattern) { ERR_FAIL_COND_V(p_pattern.is_null(), Vector2i()); ERR_FAIL_COND_V(!p_pattern->has_cell(p_coords_in_pattern), Vector2i()); @@ -2211,7 +2211,7 @@ Vector2i TileMap::map_pattern(Vector2i p_position_in_tilemap, Vector2i p_coords_ return output; } -void TileMap::set_pattern(int p_layer, Vector2i p_position, const Ref p_pattern) { +void TileMap::set_pattern(int p_layer, const Vector2i &p_position, const Ref p_pattern) { ERR_FAIL_INDEX(p_layer, (int)layers.size()); ERR_FAIL_COND(!tile_set.is_valid()); @@ -2222,7 +2222,7 @@ void TileMap::set_pattern(int p_layer, Vector2i p_position, const Ref p_constraints, TileSet::TerrainsPattern p_current_pattern) { +TileSet::TerrainsPattern TileMap::_get_best_terrain_pattern_for_constraints(int p_terrain_set, const Vector2i &p_position, const RBSet &p_constraints, TileSet::TerrainsPattern p_current_pattern) { if (!tile_set.is_valid()) { return TileSet::TerrainsPattern(); } @@ -2235,7 +2235,7 @@ TileSet::TerrainsPattern TileMap::_get_best_terrain_pattern_for_constraints(int // Check the center bit constraint TerrainConstraint terrain_constraint = TerrainConstraint(this, p_position, terrain_pattern.get_terrain()); - RBSet::Element *in_set_constraint_element = p_constraints.find(terrain_constraint); + const RBSet::Element *in_set_constraint_element = p_constraints.find(terrain_constraint); if (in_set_constraint_element) { if (in_set_constraint_element->get().get_terrain() != terrain_constraint.get_terrain()) { score += in_set_constraint_element->get().get_priority(); @@ -2282,7 +2282,7 @@ TileSet::TerrainsPattern TileMap::_get_best_terrain_pattern_for_constraints(int return min_score_pattern; } -RBSet TileMap::_get_terrain_constraints_from_added_pattern(Vector2i p_position, int p_terrain_set, TileSet::TerrainsPattern p_terrains_pattern) const { +RBSet TileMap::_get_terrain_constraints_from_added_pattern(const Vector2i &p_position, int p_terrain_set, TileSet::TerrainsPattern p_terrains_pattern) const { if (!tile_set.is_valid()) { return RBSet(); } @@ -2390,7 +2390,7 @@ RBSet TileMap::_get_terrain_constraints_from_painted return constraints; } -HashMap TileMap::terrain_fill_constraints(int p_layer, const Vector &p_to_replace, int p_terrain_set, const RBSet p_constraints) { +HashMap TileMap::terrain_fill_constraints(int p_layer, const Vector &p_to_replace, int p_terrain_set, const RBSet &p_constraints) { if (!tile_set.is_valid()) { return HashMap(); } @@ -3842,7 +3842,7 @@ void TileMap::set_texture_repeat(CanvasItem::TextureRepeat p_texture_repeat) { } } -TypedArray TileMap::get_surrounding_cells(Vector2i coords) { +TypedArray TileMap::get_surrounding_cells(const Vector2i &coords) { if (!tile_set.is_valid()) { return TypedArray(); } @@ -3880,7 +3880,7 @@ TypedArray TileMap::get_surrounding_cells(Vector2i coords) { return around; } -void TileMap::draw_cells_outline(Control *p_control, RBSet p_cells, Color p_color, Transform2D p_transform) { +void TileMap::draw_cells_outline(Control *p_control, const RBSet &p_cells, Color p_color, Transform2D p_transform) { if (!tile_set.is_valid()) { return; } diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h index 19f0e5a553c..6f71636e470 100644 --- a/scene/2d/tile_map.h +++ b/scene/2d/tile_map.h @@ -155,7 +155,7 @@ public: priority = p_priority; } - int get_priority() { + int get_priority() const { return priority; } @@ -268,8 +268,8 @@ private: void _scenes_draw_quadrant_debug(TileMapQuadrant *p_quadrant); // Terrains. - TileSet::TerrainsPattern _get_best_terrain_pattern_for_constraints(int p_terrain_set, const Vector2i &p_position, RBSet p_constraints, TileSet::TerrainsPattern p_current_pattern); - RBSet _get_terrain_constraints_from_added_pattern(Vector2i p_position, int p_terrain_set, TileSet::TerrainsPattern p_terrains_pattern) const; + TileSet::TerrainsPattern _get_best_terrain_pattern_for_constraints(int p_terrain_set, const Vector2i &p_position, const RBSet &p_constraints, TileSet::TerrainsPattern p_current_pattern); + RBSet _get_terrain_constraints_from_added_pattern(const Vector2i &p_position, int p_terrain_set, TileSet::TerrainsPattern p_terrains_pattern) const; RBSet _get_terrain_constraints_from_painted_cells_list(int p_layer, const RBSet &p_painted, int p_terrain_set, bool p_ignore_empty_terrains) const; // Set and get tiles from data arrays. @@ -291,7 +291,7 @@ protected: static void _bind_methods(); public: - static Vector2i transform_coords_layout(Vector2i p_coords, TileSet::TileOffsetAxis p_offset_axis, TileSet::TileLayout p_from_layout, TileSet::TileLayout p_to_layout); + static Vector2i transform_coords_layout(const Vector2i &p_coords, TileSet::TileOffsetAxis p_offset_axis, TileSet::TileLayout p_from_layout, TileSet::TileLayout p_to_layout); enum { INVALID_CELL = -1 @@ -307,7 +307,7 @@ public: void set_quadrant_size(int p_size); int get_quadrant_size() const; - static void draw_tile(RID p_canvas_item, Vector2i p_position, const Ref p_tile_set, int p_atlas_source_id, 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); + static void draw_tile(RID p_canvas_item, const Vector2i &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); // Layers management. int get_layers_count() const; @@ -350,11 +350,11 @@ public: // Patterns. Ref get_pattern(int p_layer, TypedArray p_coords_array); - Vector2i map_pattern(Vector2i p_position_in_tilemap, Vector2i p_coords_in_pattern, Ref p_pattern); - void set_pattern(int p_layer, Vector2i p_position, const Ref p_pattern); + Vector2i map_pattern(const Vector2i &p_position_in_tilemap, const Vector2i &p_coords_in_pattern, Ref p_pattern); + void set_pattern(int p_layer, const Vector2i &p_position, const Ref p_pattern); // Terrains. - HashMap terrain_fill_constraints(int p_layer, const Vector &p_to_replace, int p_terrain_set, const RBSet p_constraints); // Not exposed. + HashMap terrain_fill_constraints(int p_layer, const Vector &p_to_replace, int p_terrain_set, const RBSet &p_constraints); // Not exposed. HashMap terrain_fill_connect(int p_layer, const Vector &p_coords_array, int p_terrain_set, int p_terrain, bool p_ignore_empty_terrains = true); // Not exposed. HashMap terrain_fill_path(int p_layer, const Vector &p_coords_array, int p_terrain_set, int p_terrain, bool p_ignore_empty_terrains = true); // Not exposed. HashMap terrain_fill_pattern(int p_layer, const Vector &p_coords_array, int p_terrain_set, TileSet::TerrainsPattern p_terrains_pattern, bool p_ignore_empty_terrains = true); // Not exposed. @@ -400,8 +400,8 @@ public: void force_update(int p_layer = -1); // Helpers? - TypedArray get_surrounding_cells(Vector2i coords); - void draw_cells_outline(Control *p_control, RBSet p_cells, Color p_color, Transform2D p_transform = Transform2D()); + TypedArray get_surrounding_cells(const Vector2i &coords); + void draw_cells_outline(Control *p_control, const RBSet &p_cells, Color p_color, Transform2D p_transform = Transform2D()); // Virtual function to modify the TileData at runtime GDVIRTUAL2R(bool, _use_tile_data_runtime_update, int, Vector2i);