Merge pull request #50180 from Calinou/gpu-particles-improve-visibility-generation-3.x

This commit is contained in:
Rémi Verschelde 2022-08-23 21:38:28 +02:00 committed by GitHub
commit ac9bdabe5b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 12 deletions

View file

@ -82,13 +82,16 @@ void Particles2DEditorPlugin::_selection_changed() {
void Particles2DEditorPlugin::_menu_callback(int p_idx) { void Particles2DEditorPlugin::_menu_callback(int p_idx) {
switch (p_idx) { switch (p_idx) {
case MENU_GENERATE_VISIBILITY_RECT: { case MENU_GENERATE_VISIBILITY_RECT: {
float gen_time = particles->get_lifetime(); // Add one second to the default generation lifetime, since the progress is updated every second.
if (gen_time < 1.0) { generate_seconds->set_value(MAX(1.0, trunc(particles->get_lifetime()) + 1.0));
generate_seconds->set_value(1.0);
if (generate_seconds->get_value() >= 11.0 + CMP_EPSILON) {
// Only pop up the time dialog if the particle's lifetime is long enough to warrant shortening it.
generate_visibility_rect->popup_centered_minsize();
} else { } else {
generate_seconds->set_value(trunc(gen_time) + 1.0); // Generate the visibility rect immediately.
_generate_visibility_rect();
} }
generate_visibility_rect->popup_centered_minsize();
} break; } break;
case MENU_LOAD_EMISSION_MASK: { case MENU_LOAD_EMISSION_MASK: {
file->popup_centered_ratio(); file->popup_centered_ratio();
@ -126,7 +129,7 @@ void Particles2DEditorPlugin::_generate_visibility_rect() {
float running = 0.0; float running = 0.0;
EditorProgress ep("gen_vrect", TTR("Generating Visibility Rect"), int(time)); EditorProgress ep("gen_vrect", TTR("Generating Visibility Rect (Waiting for Particle Simulation)"), int(time));
bool was_emitting = particles->is_emitting(); bool was_emitting = particles->is_emitting();
if (!was_emitting) { if (!was_emitting) {

View file

@ -255,14 +255,16 @@ void ParticlesEditor::_notification(int p_notification) {
void ParticlesEditor::_menu_option(int p_option) { void ParticlesEditor::_menu_option(int p_option) {
switch (p_option) { switch (p_option) {
case MENU_OPTION_GENERATE_AABB: { case MENU_OPTION_GENERATE_AABB: {
float gen_time = node->get_lifetime(); // Add one second to the default generation lifetime, since the progress is updated every second.
generate_seconds->set_value(MAX(1.0, trunc(node->get_lifetime()) + 1.0));
if (gen_time < 1.0) { if (generate_seconds->get_value() >= 11.0 + CMP_EPSILON) {
generate_seconds->set_value(1.0); // Only pop up the time dialog if the particle's lifetime is long enough to warrant shortening it.
generate_aabb->popup_centered_minsize();
} else { } else {
generate_seconds->set_value(trunc(gen_time) + 1.0); // Generate the visibility AABB immediately.
_generate_aabb();
} }
generate_aabb->popup_centered_minsize();
} break; } break;
case MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_MESH: { case MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_MESH: {
Ref<ParticlesMaterial> material = node->get_process_material(); Ref<ParticlesMaterial> material = node->get_process_material();
@ -313,7 +315,7 @@ void ParticlesEditor::_generate_aabb() {
float running = 0.0; float running = 0.0;
EditorProgress ep("gen_aabb", TTR("Generating AABB"), int(time)); EditorProgress ep("gen_aabb", TTR("Generating Visibility AABB (Waiting for Particle Simulation)"), int(time));
bool was_emitting = node->is_emitting(); bool was_emitting = node->is_emitting();
if (!was_emitting) { if (!was_emitting) {