summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-09-25 23:12:12 +0200
committerGitHub <noreply@github.com>2017-09-25 23:12:12 +0200
commit1aabf4c1668bd989db6667a2dcc76d5699d84833 (patch)
tree2c726a9dc1ad112dc93294177d98fa656e97ee49 /editor
parent5567cbe6aeb857b98694acad6fce6b66e9d7be73 (diff)
parent6f1ac101b8fd600855f52a5b77a7278cb31ad1aa (diff)
Merge pull request #11542 from marcelofg55/bucket_limit
Bucket fill will now incrementally process the queue on preview mode
Diffstat (limited to 'editor')
-rw-r--r--editor/plugins/tile_map_editor_plugin.cpp42
-rw-r--r--editor/plugins/tile_map_editor_plugin.h1
2 files changed, 32 insertions, 11 deletions
diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp
index 328d07d7a8..2f2ed7bdf0 100644
--- a/editor/plugins/tile_map_editor_plugin.cpp
+++ b/editor/plugins/tile_map_editor_plugin.cpp
@@ -39,6 +39,14 @@ void TileMapEditor::_notification(int p_what) {
switch (p_what) {
+ case NOTIFICATION_PROCESS: {
+
+ if (bucket_queue.size() && canvas_item_editor) {
+ canvas_item_editor->update();
+ }
+
+ } break;
+
case NOTIFICATION_ENTER_TREE: {
transp->set_icon(get_icon("Transpose", "EditorIcons"));
@@ -382,20 +390,26 @@ PoolVector<Vector2> TileMapEditor::_bucket_fill(const Point2i &p_start, bool era
bucket_cache = PoolVector<Vector2>();
bucket_cache_tile = prev_id;
bucket_cache_rect = r;
- } else {
- return bucket_cache;
+ bucket_queue.clear();
}
}
PoolVector<Vector2> points;
+ int count = 0;
+ int limit = 0;
- List<Point2i> queue;
- queue.push_back(p_start);
+ if (preview) {
+ limit = 1024;
+ } else {
+ bucket_queue.clear();
+ }
- while (queue.size()) {
+ bucket_queue.push_back(p_start);
- Point2i n = queue.front()->get();
- queue.pop_front();
+ while (bucket_queue.size()) {
+
+ Point2i n = bucket_queue.front()->get();
+ bucket_queue.pop_front();
if (!r.has_point(n))
continue;
@@ -413,10 +427,15 @@ PoolVector<Vector2> TileMapEditor::_bucket_fill(const Point2i &p_start, bool era
points.push_back(n);
}
- queue.push_back(n + Point2i(0, 1));
- queue.push_back(n + Point2i(0, -1));
- queue.push_back(n + Point2i(1, 0));
- queue.push_back(n + Point2i(-1, 0));
+ bucket_queue.push_back(Point2i(n.x, n.y + 1));
+ bucket_queue.push_back(Point2i(n.x, n.y - 1));
+ bucket_queue.push_back(Point2i(n.x + 1, n.y));
+ bucket_queue.push_back(Point2i(n.x - 1, n.y));
+ count++;
+ }
+
+ if (limit > 0 && count >= limit) {
+ break;
}
}
@@ -1648,6 +1667,7 @@ TileMapEditorPlugin::TileMapEditorPlugin(EditorNode *p_node) {
tile_map_editor = memnew(TileMapEditor(p_node));
add_control_to_container(CONTAINER_CANVAS_EDITOR_SIDE, tile_map_editor);
tile_map_editor->hide();
+ tile_map_editor->set_process(true);
}
TileMapEditorPlugin::~TileMapEditorPlugin() {
diff --git a/editor/plugins/tile_map_editor_plugin.h b/editor/plugins/tile_map_editor_plugin.h
index de9b9e8e0d..c8f29dfb7b 100644
--- a/editor/plugins/tile_map_editor_plugin.h
+++ b/editor/plugins/tile_map_editor_plugin.h
@@ -113,6 +113,7 @@ class TileMapEditor : public VBoxContainer {
Rect2i bucket_cache_rect;
int bucket_cache_tile;
PoolVector<Vector2> bucket_cache;
+ List<Point2i> bucket_queue;
struct CellOp {
int idx;