summaryrefslogtreecommitdiff
path: root/scene/2d
diff options
context:
space:
mode:
authorMarcelo Fernandez <marcelofg55@gmail.com>2018-06-25 22:24:12 -0300
committerMarcelo Fernandez <marcelofg55@gmail.com>2018-06-26 00:07:48 -0300
commit67a78e020a1254bf9f37a1aee3bcbc31806cf13e (patch)
tree155b8628144a80c0b76833e7e47774deffe4bd4f /scene/2d
parent8c7da84e1eae25302a0c88594cce88b84f2dc21e (diff)
Optimize _recreate_quadrants
Diffstat (limited to 'scene/2d')
-rw-r--r--scene/2d/tile_map.cpp10
-rw-r--r--scene/2d/tile_map.h2
2 files changed, 8 insertions, 4 deletions
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index 98275510d6..7fb4e36b63 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -708,7 +708,7 @@ void TileMap::_erase_quadrant(Map<PosKey, Quadrant>::Element *Q) {
rect_cache_dirty = true;
}
-void TileMap::_make_quadrant_dirty(Map<PosKey, Quadrant>::Element *Q) {
+void TileMap::_make_quadrant_dirty(Map<PosKey, Quadrant>::Element *Q, bool update) {
Quadrant &q = Q->get();
if (!q.dirty_list.in_list())
@@ -719,7 +719,10 @@ void TileMap::_make_quadrant_dirty(Map<PosKey, Quadrant>::Element *Q) {
pending_update = true;
if (!is_inside_tree())
return;
- _update_dirty_quadrants();
+
+ if (update) {
+ _update_dirty_quadrants();
+ }
}
void TileMap::set_cellv(const Vector2 &p_pos, int p_tile, bool p_flip_x, bool p_flip_y, bool p_transpose) {
@@ -1016,8 +1019,9 @@ void TileMap::_recreate_quadrants() {
}
Q->get().cells.insert(E->key());
- _make_quadrant_dirty(Q);
+ _make_quadrant_dirty(Q, false);
}
+ _update_dirty_quadrants();
}
void TileMap::_clear_quadrants() {
diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h
index 07947004b3..d6774d42bb 100644
--- a/scene/2d/tile_map.h
+++ b/scene/2d/tile_map.h
@@ -188,7 +188,7 @@ private:
Map<PosKey, Quadrant>::Element *_create_quadrant(const PosKey &p_qk);
void _erase_quadrant(Map<PosKey, Quadrant>::Element *Q);
- void _make_quadrant_dirty(Map<PosKey, Quadrant>::Element *Q);
+ void _make_quadrant_dirty(Map<PosKey, Quadrant>::Element *Q, bool update = true);
void _recreate_quadrants();
void _clear_quadrants();
void _update_dirty_quadrants();