summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-01-07 00:58:36 +0100
committerGitHub <noreply@github.com>2022-01-07 00:58:36 +0100
commite885de050701a034355d7064d813387a66421754 (patch)
tree2f587d042b6dcc3c3da1381766e7ad5e473a65d8
parentdc7235b71c90ef45d765072f6048d8fdb2baf7ef (diff)
parent0761605435d6cd9c8e37de8bf69fcbc439aa699b (diff)
Merge pull request #56367 from Calinou/bakedlightmap-print-time-request-attention
-rw-r--r--editor/plugins/lightmap_gi_editor_plugin.cpp12
-rw-r--r--editor/plugins/lightmap_gi_editor_plugin.h2
2 files changed, 11 insertions, 3 deletions
diff --git a/editor/plugins/lightmap_gi_editor_plugin.cpp b/editor/plugins/lightmap_gi_editor_plugin.cpp
index be17fc238a..2126ca1bc9 100644
--- a/editor/plugins/lightmap_gi_editor_plugin.cpp
+++ b/editor/plugins/lightmap_gi_editor_plugin.cpp
@@ -33,13 +33,14 @@
void LightmapGIEditorPlugin::_bake_select_file(const String &p_file) {
if (lightmap) {
LightmapGI::BakeError err;
+ const uint64_t time_started = OS::get_singleton()->get_ticks_msec();
if (get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root() == lightmap) {
err = lightmap->bake(lightmap, p_file, bake_func_step);
} else {
err = lightmap->bake(lightmap->get_parent(), p_file, bake_func_step);
}
- bake_func_end();
+ bake_func_end(time_started);
switch (err) {
case LightmapGI::BAKE_ERROR_NO_SAVE_PATH: {
@@ -104,11 +105,18 @@ bool LightmapGIEditorPlugin::bake_func_step(float p_progress, const String &p_de
return tmp_progress->step(p_description, p_progress * 1000, p_refresh);
}
-void LightmapGIEditorPlugin::bake_func_end() {
+void LightmapGIEditorPlugin::bake_func_end(uint64_t p_time_started) {
if (tmp_progress != nullptr) {
memdelete(tmp_progress);
tmp_progress = nullptr;
}
+
+ const int time_taken = (OS::get_singleton()->get_ticks_msec() - p_time_started) * 0.001;
+ print_line(vformat("Done baking lightmaps in %02d:%02d:%02d.", time_taken / 3600, (time_taken % 3600) / 60, time_taken % 60));
+ // Request attention in case the user was doing something else.
+ // Baking lightmaps is likely the editor task that can take the most time,
+ // so only request the attention for baking lightmaps.
+ DisplayServer::get_singleton()->window_request_attention();
}
void LightmapGIEditorPlugin::_bind_methods() {
diff --git a/editor/plugins/lightmap_gi_editor_plugin.h b/editor/plugins/lightmap_gi_editor_plugin.h
index d0edf9f324..5eec972228 100644
--- a/editor/plugins/lightmap_gi_editor_plugin.h
+++ b/editor/plugins/lightmap_gi_editor_plugin.h
@@ -47,7 +47,7 @@ class LightmapGIEditorPlugin : public EditorPlugin {
EditorFileDialog *file_dialog;
static EditorProgress *tmp_progress;
static bool bake_func_step(float p_progress, const String &p_description, void *, bool p_refresh);
- static void bake_func_end();
+ static void bake_func_end(uint64_t p_time_started);
void _bake_select_file(const String &p_file);
void _bake();