Ensure non-emitting particles not processed on entering tree

Also removed non-active CPUParticles(3d) from render list
Fixes #27066
This commit is contained in:
Daeil Kim 2019-03-20 18:50:56 +09:00
parent a53645e726
commit 24b7f08892
2 changed files with 10 additions and 7 deletions

View File

@ -37,7 +37,8 @@
void CPUParticles2D::set_emitting(bool p_emitting) { void CPUParticles2D::set_emitting(bool p_emitting) {
emitting = p_emitting; emitting = p_emitting;
set_process_internal(true); if (emitting)
set_process_internal(true);
} }
void CPUParticles2D::set_amount(int p_amount) { void CPUParticles2D::set_amount(int p_amount) {
@ -965,7 +966,7 @@ void CPUParticles2D::_update_render_thread() {
void CPUParticles2D::_notification(int p_what) { void CPUParticles2D::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) { if (p_what == NOTIFICATION_ENTER_TREE) {
_set_redraw(true); set_process_internal(emitting);
} }
if (p_what == NOTIFICATION_EXIT_TREE) { if (p_what == NOTIFICATION_EXIT_TREE) {
@ -1001,7 +1002,6 @@ void CPUParticles2D::_notification(int p_what) {
float delta = get_process_delta_time(); float delta = get_process_delta_time();
if (emitting) { if (emitting) {
_set_redraw(true);
inactive_time = 0; inactive_time = 0;
} else { } else {
inactive_time += delta; inactive_time += delta;
@ -1017,6 +1017,7 @@ void CPUParticles2D::_notification(int p_what) {
return; return;
} }
} }
_set_redraw(true);
if (time == 0 && pre_process_time > 0.0) { if (time == 0 && pre_process_time > 0.0) {

View File

@ -47,7 +47,8 @@ PoolVector<Face3> CPUParticles::get_faces(uint32_t p_usage_flags) const {
void CPUParticles::set_emitting(bool p_emitting) { void CPUParticles::set_emitting(bool p_emitting) {
emitting = p_emitting; emitting = p_emitting;
set_process_internal(true); if (emitting)
set_process_internal(true);
} }
void CPUParticles::set_amount(int p_amount) { void CPUParticles::set_amount(int p_amount) {
@ -1002,9 +1003,11 @@ void CPUParticles::_set_redraw(bool p_redraw) {
if (redraw) { if (redraw) {
VS::get_singleton()->connect("frame_pre_draw", this, "_update_render_thread"); VS::get_singleton()->connect("frame_pre_draw", this, "_update_render_thread");
VS::get_singleton()->instance_geometry_set_flag(get_instance(), VS::INSTANCE_FLAG_DRAW_NEXT_FRAME_IF_VISIBLE, true); VS::get_singleton()->instance_geometry_set_flag(get_instance(), VS::INSTANCE_FLAG_DRAW_NEXT_FRAME_IF_VISIBLE, true);
VS::get_singleton()->multimesh_set_visible_instances(multimesh, -1);
} else { } else {
VS::get_singleton()->disconnect("frame_pre_draw", this, "_update_render_thread"); VS::get_singleton()->disconnect("frame_pre_draw", this, "_update_render_thread");
VS::get_singleton()->instance_geometry_set_flag(get_instance(), VS::INSTANCE_FLAG_DRAW_NEXT_FRAME_IF_VISIBLE, false); VS::get_singleton()->instance_geometry_set_flag(get_instance(), VS::INSTANCE_FLAG_DRAW_NEXT_FRAME_IF_VISIBLE, false);
VS::get_singleton()->multimesh_set_visible_instances(multimesh, 0);
} }
#ifndef NO_THREADS #ifndef NO_THREADS
update_mutex->unlock(); update_mutex->unlock();
@ -1029,7 +1032,7 @@ void CPUParticles::_update_render_thread() {
void CPUParticles::_notification(int p_what) { void CPUParticles::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) { if (p_what == NOTIFICATION_ENTER_TREE) {
_set_redraw(true); set_process_internal(emitting);
} }
if (p_what == NOTIFICATION_EXIT_TREE) { if (p_what == NOTIFICATION_EXIT_TREE) {
@ -1048,8 +1051,6 @@ void CPUParticles::_notification(int p_what) {
float delta = get_process_delta_time(); float delta = get_process_delta_time();
if (emitting) { if (emitting) {
_set_redraw(true);
inactive_time = 0; inactive_time = 0;
} else { } else {
inactive_time += delta; inactive_time += delta;
@ -1065,6 +1066,7 @@ void CPUParticles::_notification(int p_what) {
return; return;
} }
} }
_set_redraw(true);
bool processed = false; bool processed = false;