@@ -861,7 +861,7 @@ void TileMap::set_cell(int p_x, int p_y, int p_tile, bool p_flip_x, bool p_flip_
861
861
if (!E && p_tile == INVALID_CELL)
862
862
return ; // nothing to do
863
863
864
- PosKey qk (p_x / _get_quadrant_size (), p_y / _get_quadrant_size ());
864
+ PosKey qk = pk. to_quadrant ( _get_quadrant_size ());
865
865
if (p_tile == INVALID_CELL) {
866
866
// erase existing
867
867
tile_map.erase (pk);
@@ -1020,7 +1020,7 @@ void TileMap::update_cell_bitmask(int p_x, int p_y) {
1020
1020
E->get ().autotile_coord_x = (int )coord.x ;
1021
1021
E->get ().autotile_coord_y = (int )coord.y ;
1022
1022
1023
- PosKey qk (p_x / _get_quadrant_size (), p_y / _get_quadrant_size ());
1023
+ PosKey qk = p. to_quadrant ( _get_quadrant_size ());
1024
1024
Map<PosKey, Quadrant>::Element *Q = quadrant_map.find (qk);
1025
1025
_make_quadrant_dirty (Q);
1026
1026
@@ -1117,7 +1117,7 @@ void TileMap::set_cell_autotile_coord(int p_x, int p_y, const Vector2 &p_coord)
1117
1117
c.autotile_coord_y = p_coord.y ;
1118
1118
tile_map[pk] = c;
1119
1119
1120
- PosKey qk (p_x / _get_quadrant_size (), p_y / _get_quadrant_size ());
1120
+ PosKey qk = pk. to_quadrant ( _get_quadrant_size ());
1121
1121
Map<PosKey, Quadrant>::Element *Q = quadrant_map.find (qk);
1122
1122
1123
1123
if (!Q)
@@ -1144,7 +1144,7 @@ void TileMap::_recreate_quadrants() {
1144
1144
1145
1145
for (Map<PosKey, Cell>::Element *E = tile_map.front (); E; E = E->next ()) {
1146
1146
1147
- PosKey qk (E->key ().x / _get_quadrant_size () , E->key ().y / _get_quadrant_size ());
1147
+ PosKey qk = PosKey (E->key ().x , E->key ().y ). to_quadrant ( _get_quadrant_size ());
1148
1148
1149
1149
Map<PosKey, Quadrant>::Element *Q = quadrant_map.find (qk);
1150
1150
if (!Q) {
@@ -1281,7 +1281,11 @@ PoolVector<int> TileMap::_get_tile_data() const {
1281
1281
}
1282
1282
1283
1283
Rect2 TileMap::_edit_get_rect () const {
1284
- const_cast <TileMap *>(this )->update_dirty_quadrants ();
1284
+ if (pending_update) {
1285
+ const_cast <TileMap *>(this )->update_dirty_quadrants ();
1286
+ } else {
1287
+ const_cast <TileMap *>(this )->_recompute_rect_cache ();
1288
+ }
1285
1289
return rect_cache;
1286
1290
}
1287
1291
0 commit comments