From a9df89703cb746a80ed6304a36b1cbadd44e0709 Mon Sep 17 00:00:00 2001 From: Relintai Date: Wed, 27 Jul 2022 13:54:29 +0200 Subject: [PATCH] Ported: TileMap: Use const ref for all Vector2 parameters - akien-mga https://github.com/godotengine/godot/commit/2834332591ef5a8490ef6a1a87b06e6cdaf16ff8 --- modules/rtile_map/tile_map.cpp | 4 ++-- modules/rtile_map/tile_map.h | 4 ++-- modules/rtile_map/tile_set.cpp | 8 ++++---- modules/rtile_map/tile_set.h | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/rtile_map/tile_map.cpp b/modules/rtile_map/tile_map.cpp index a14ac3a0e..7e2b1bf38 100644 --- a/modules/rtile_map/tile_map.cpp +++ b/modules/rtile_map/tile_map.cpp @@ -207,7 +207,7 @@ Ref RTileMap::get_tileset() const { return tile_set; } -void RTileMap::set_cell_size(Size2 p_size) { +void RTileMap::set_cell_size(const Size2 &p_size) { ERR_FAIL_COND(p_size.x < 1 || p_size.y < 1); _clear_quadrants(); @@ -885,7 +885,7 @@ void RTileMap::_set_celld(const Vector2 &p_pos, const Dictionary &p_data) { call("set_cell", args, 7, ce); } -void RTileMap::set_cell(int p_x, int p_y, int p_tile, bool p_flip_x, bool p_flip_y, bool p_transpose, Vector2 p_autotile_coord) { +void RTileMap::set_cell(int p_x, int p_y, int p_tile, bool p_flip_x, bool p_flip_y, bool p_transpose, const Vector2 &p_autotile_coord) { PosKey pk(p_x, p_y); Map::Element *E = tile_map.find(pk); diff --git a/modules/rtile_map/tile_map.h b/modules/rtile_map/tile_map.h index 674f7247d..80a90bbc6 100644 --- a/modules/rtile_map/tile_map.h +++ b/modules/rtile_map/tile_map.h @@ -259,7 +259,7 @@ public: void set_tileset(const Ref &p_tileset); Ref get_tileset() const; - void set_cell_size(Size2 p_size); + void set_cell_size(const Size2 &p_size); Size2 get_cell_size() const; void set_quadrant_size(int p_size); @@ -268,7 +268,7 @@ public: void set_use_rao(bool p_rao); bool get_use_rao() const; - void set_cell(int p_x, int p_y, int p_tile, bool p_flip_x = false, bool p_flip_y = false, bool p_transpose = false, Vector2 p_autotile_coord = Vector2()); + void set_cell(int p_x, int p_y, int p_tile, bool p_flip_x = false, bool p_flip_y = false, bool p_transpose = false, const Vector2 &p_autotile_coord = Vector2()); int get_cell(int p_x, int p_y) const; bool is_cell_x_flipped(int p_x, int p_y) const; bool is_cell_y_flipped(int p_x, int p_y) const; diff --git a/modules/rtile_map/tile_set.cpp b/modules/rtile_map/tile_set.cpp index ff40050d7..302de7a29 100644 --- a/modules/rtile_map/tile_set.cpp +++ b/modules/rtile_map/tile_set.cpp @@ -469,7 +469,7 @@ RTileSet::TileMode RTileSet::tile_get_tile_mode(int p_id) const { return tile_map[p_id].tile_mode; } -void RTileSet::autotile_set_icon_coordinate(int p_id, Vector2 coord) { +void RTileSet::autotile_set_icon_coordinate(int p_id, const Vector2 &coord) { ERR_FAIL_COND_MSG(!tile_map.has(p_id), vformat("The RTileSet doesn't have a tile with ID '%d'.", p_id)); tile_map[p_id].autotile_data.icon_coord = coord; emit_changed(); @@ -492,7 +492,7 @@ int RTileSet::autotile_get_spacing(int p_id) const { return tile_map[p_id].autotile_data.spacing; } -void RTileSet::autotile_set_size(int p_id, Size2 p_size) { +void RTileSet::autotile_set_size(int p_id, const Size2 &p_size) { ERR_FAIL_COND_MSG(!tile_map.has(p_id), vformat("The RTileSet doesn't have a tile with ID '%d'.", p_id)); ERR_FAIL_COND(p_size.x <= 0 || p_size.y <= 0); tile_map[p_id].autotile_data.size = p_size; @@ -550,7 +550,7 @@ const Map &RTileSet::autotile_get_z_index_map(int p_id) const { return tile_map[p_id].autotile_data.z_index_map; } -void RTileSet::autotile_set_bitmask(int p_id, Vector2 p_coord, uint32_t p_flag) { +void RTileSet::autotile_set_bitmask(int p_id, const Vector2 &p_coord, uint32_t p_flag) { ERR_FAIL_COND_MSG(!tile_map.has(p_id), vformat("The RTileSet doesn't have a tile with ID '%d'.", p_id)); if (p_flag == 0) { if (tile_map[p_id].autotile_data.flags.has(p_coord)) { @@ -561,7 +561,7 @@ void RTileSet::autotile_set_bitmask(int p_id, Vector2 p_coord, uint32_t p_flag) } } -uint32_t RTileSet::autotile_get_bitmask(int p_id, Vector2 p_coord) { +uint32_t RTileSet::autotile_get_bitmask(int p_id, const Vector2 &p_coord) { ERR_FAIL_COND_V_MSG(!tile_map.has(p_id), 0, vformat("The RTileSet doesn't have a tile with ID '%d'.", p_id)); if (!tile_map[p_id].autotile_data.flags.has(p_coord)) { return 0; diff --git a/modules/rtile_map/tile_set.h b/modules/rtile_map/tile_set.h index 91c0b72ea..193e67c46 100644 --- a/modules/rtile_map/tile_set.h +++ b/modules/rtile_map/tile_set.h @@ -174,13 +174,13 @@ public: void tile_set_tile_mode(int p_id, TileMode p_tile_mode); TileMode tile_get_tile_mode(int p_id) const; - void autotile_set_icon_coordinate(int p_id, Vector2 coord); + void autotile_set_icon_coordinate(int p_id, const Vector2 &coord); Vector2 autotile_get_icon_coordinate(int p_id) const; void autotile_set_spacing(int p_id, int p_spacing); int autotile_get_spacing(int p_id) const; - void autotile_set_size(int p_id, Size2 p_size); + void autotile_set_size(int p_id, const Size2 &p_size); Size2 autotile_get_size(int p_id) const; void autotile_clear_bitmask_map(int p_id); @@ -192,8 +192,8 @@ public: int autotile_get_z_index(int p_id, const Vector2 &p_coord); const Map &autotile_get_z_index_map(int p_id) const; - void autotile_set_bitmask(int p_id, Vector2 p_coord, uint32_t p_flag); - uint32_t autotile_get_bitmask(int p_id, Vector2 p_coord); + void autotile_set_bitmask(int p_id, const Vector2 &p_coord, uint32_t p_flag); + uint32_t autotile_get_bitmask(int p_id, const Vector2 &p_coord); const Map &autotile_get_bitmask_map(int p_id); Vector2 autotile_get_subtile_for_bitmask(int p_id, uint16_t p_bitmask, const Node *p_tilemap_node = nullptr, const Vector2 &p_tile_location = Vector2()); Vector2 atlastile_get_subtile_by_priority(int p_id, const Node *p_tilemap_node = nullptr, const Vector2 &p_tile_location = Vector2());