@@ -760,7 +760,7 @@ void TileMap::set_cell(int p_x, int p_y, int p_tile, bool p_flip_x, bool p_flip_
760
760
if (!E && p_tile == INVALID_CELL)
761
761
return ; // nothing to do
762
762
763
- PosKey qk (p_x / _get_quadrant_size (), p_y / _get_quadrant_size ());
763
+ PosKey qk = pk. to_quadrant ( _get_quadrant_size ());
764
764
if (p_tile == INVALID_CELL) {
765
765
// erase existing
766
766
tile_map.erase (pk);
@@ -919,7 +919,7 @@ void TileMap::update_cell_bitmask(int p_x, int p_y) {
919
919
E->get ().autotile_coord_x = (int )coord.x ;
920
920
E->get ().autotile_coord_y = (int )coord.y ;
921
921
922
- PosKey qk (p_x / _get_quadrant_size (), p_y / _get_quadrant_size ());
922
+ PosKey qk = p. to_quadrant ( _get_quadrant_size ());
923
923
Map<PosKey, Quadrant>::Element *Q = quadrant_map.find (qk);
924
924
_make_quadrant_dirty (Q);
925
925
@@ -1007,7 +1007,7 @@ void TileMap::set_cell_autotile_coord(int p_x, int p_y, const Vector2 &p_coord)
1007
1007
c.autotile_coord_y = p_coord.y ;
1008
1008
tile_map[pk] = c;
1009
1009
1010
- PosKey qk (p_x / _get_quadrant_size (), p_y / _get_quadrant_size ());
1010
+ PosKey qk = pk. to_quadrant ( _get_quadrant_size ());
1011
1011
Map<PosKey, Quadrant>::Element *Q = quadrant_map.find (qk);
1012
1012
1013
1013
if (!Q)
@@ -1034,7 +1034,7 @@ void TileMap::_recreate_quadrants() {
1034
1034
1035
1035
for (Map<PosKey, Cell>::Element *E = tile_map.front (); E; E = E->next ()) {
1036
1036
1037
- PosKey qk (E->key ().x / _get_quadrant_size () , E->key ().y / _get_quadrant_size ());
1037
+ PosKey qk = PosKey (E->key ().x , E->key ().y ). to_quadrant ( _get_quadrant_size ());
1038
1038
1039
1039
Map<PosKey, Quadrant>::Element *Q = quadrant_map.find (qk);
1040
1040
if (!Q) {
@@ -1174,7 +1174,11 @@ PoolVector<int> TileMap::_get_tile_data() const {
1174
1174
}
1175
1175
1176
1176
Rect2 TileMap::_edit_get_rect () const {
1177
- const_cast <TileMap *>(this )->update_dirty_quadrants ();
1177
+ if (pending_update) {
1178
+ const_cast <TileMap *>(this )->update_dirty_quadrants ();
1179
+ } else {
1180
+ const_cast <TileMap *>(this )->_recompute_rect_cache ();
1181
+ }
1178
1182
return rect_cache;
1179
1183
}
1180
1184
0 commit comments