summaryrefslogtreecommitdiff
path: root/editor/plugins/particles_editor_plugin.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2018-08-14 20:20:28 +0200
committerGitHub <noreply@github.com>2018-08-14 20:20:28 +0200
commit78a6cd9e09fe6d2df21ec7d978e2eb85b8cca1c3 (patch)
tree6d721fbf2e077e4d4086e5258d4954222f164ff9 /editor/plugins/particles_editor_plugin.cpp
parentd7b9fcd33689673c6237d91afdb4a8dfe548784a (diff)
parent334922de8f8da023140a6a91c67c8f608ce62b08 (diff)
Merge pull request #20977 from malbach/Particles3D_AABB
Particles3D: set emitting if not set before generating AABB
Diffstat (limited to 'editor/plugins/particles_editor_plugin.cpp')
-rw-r--r--editor/plugins/particles_editor_plugin.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/editor/plugins/particles_editor_plugin.cpp b/editor/plugins/particles_editor_plugin.cpp
index 1f5a4a8a36..7732103220 100644
--- a/editor/plugins/particles_editor_plugin.cpp
+++ b/editor/plugins/particles_editor_plugin.cpp
@@ -270,6 +270,12 @@ void ParticlesEditor::_menu_option(int p_option) {
switch (p_option) {
case MENU_OPTION_GENERATE_AABB: {
+ float gen_time = node->get_lifetime();
+
+ if (gen_time < 1.0)
+ generate_seconds->set_value(1.0);
+ else
+ generate_seconds->set_value(trunc(gen_time) + 1.0);
generate_aabb->popup_centered_minsize();
} break;
case MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_MESH: {
@@ -323,7 +329,15 @@ void ParticlesEditor::_generate_aabb() {
EditorProgress ep("gen_aabb", TTR("Generating AABB"), int(time));
+ bool was_emitting = node->is_emitting();
+ if (!was_emitting) {
+ node->set_emitting(true);
+ OS::get_singleton()->delay_usec(1000);
+ }
+
+ running = 0.0;
AABB rect;
+
while (running < time) {
uint64_t ticks = OS::get_singleton()->get_ticks_usec();
@@ -339,6 +353,10 @@ void ParticlesEditor::_generate_aabb() {
running += (OS::get_singleton()->get_ticks_usec() - ticks) / 1000000.0;
}
+ if (!was_emitting) {
+ node->set_emitting(false);
+ }
+
node->set_visibility_aabb(rect);
}