Do not draw particles if they are not processing at all, fixes #19507

This commit is contained in:
Juan Linietsky 2018-11-19 20:34:29 -03:00
parent 55ded6b2de
commit d304228003
7 changed files with 27 additions and 3 deletions

View File

@ -681,6 +681,8 @@ public:
int particles_get_draw_passes(RID p_particles) const { return 0; } int particles_get_draw_passes(RID p_particles) const { return 0; }
RID particles_get_draw_pass_mesh(RID p_particles, int p_pass) const { return RID(); } RID particles_get_draw_pass_mesh(RID p_particles, int p_pass) const { return RID(); }
virtual bool particles_is_inactive(RID p_particles) const { return false; }
/* RENDER TARGET */ /* RENDER TARGET */
RID render_target_create() { return RID(); } RID render_target_create() { return RID(); }

View File

@ -3842,6 +3842,10 @@ RID RasterizerStorageGLES2::particles_get_draw_pass_mesh(RID p_particles, int p_
void RasterizerStorageGLES2::update_particles() { void RasterizerStorageGLES2::update_particles() {
} }
bool RasterizerStorageGLES2::particles_is_inactive(RID p_particles) const {
return true;
}
//////// ////////
void RasterizerStorageGLES2::instance_add_skeleton(RID p_skeleton, RasterizerScene::InstanceBase *p_instance) { void RasterizerStorageGLES2::instance_add_skeleton(RID p_skeleton, RasterizerScene::InstanceBase *p_instance) {

View File

@ -1090,6 +1090,8 @@ public:
virtual int particles_get_draw_passes(RID p_particles) const; virtual int particles_get_draw_passes(RID p_particles) const;
virtual RID particles_get_draw_pass_mesh(RID p_particles, int p_pass) const; virtual RID particles_get_draw_pass_mesh(RID p_particles, int p_pass) const;
virtual bool particles_is_inactive(RID p_particles) const;
/* INSTANCE */ /* INSTANCE */
virtual void instance_add_skeleton(RID p_skeleton, RasterizerScene::InstanceBase *p_instance); virtual void instance_add_skeleton(RID p_skeleton, RasterizerScene::InstanceBase *p_instance);

View File

@ -6455,6 +6455,13 @@ void RasterizerStorageGLES3::update_particles() {
glDisable(GL_RASTERIZER_DISCARD); glDisable(GL_RASTERIZER_DISCARD);
} }
bool RasterizerStorageGLES3::particles_is_inactive(RID p_particles) const {
const Particles *particles = particles_owner.getornull(p_particles);
ERR_FAIL_COND_V(!particles, false);
return !particles->emitting && particles->inactive;
}
//////// ////////
void RasterizerStorageGLES3::instance_add_skeleton(RID p_skeleton, RasterizerScene::InstanceBase *p_instance) { void RasterizerStorageGLES3::instance_add_skeleton(RID p_skeleton, RasterizerScene::InstanceBase *p_instance) {

View File

@ -1261,6 +1261,8 @@ public:
virtual int particles_get_draw_passes(RID p_particles) const; virtual int particles_get_draw_passes(RID p_particles) const;
virtual RID particles_get_draw_pass_mesh(RID p_particles, int p_pass) const; virtual RID particles_get_draw_pass_mesh(RID p_particles, int p_pass) const;
virtual bool particles_is_inactive(RID p_particles) const;
/* INSTANCE */ /* INSTANCE */
virtual void instance_add_skeleton(RID p_skeleton, RasterizerScene::InstanceBase *p_instance); virtual void instance_add_skeleton(RID p_skeleton, RasterizerScene::InstanceBase *p_instance);

View File

@ -518,6 +518,8 @@ public:
virtual void particles_set_fractional_delta(RID p_particles, bool p_enable) = 0; virtual void particles_set_fractional_delta(RID p_particles, bool p_enable) = 0;
virtual void particles_restart(RID p_particles) = 0; virtual void particles_restart(RID p_particles) = 0;
virtual bool particles_is_inactive(RID p_particles) const = 0;
virtual void particles_set_draw_order(RID p_particles, VS::ParticlesDrawOrder p_order) = 0; virtual void particles_set_draw_order(RID p_particles, VS::ParticlesDrawOrder p_order) = 0;
virtual void particles_set_draw_passes(RID p_particles, int p_count) = 0; virtual void particles_set_draw_passes(RID p_particles, int p_count) = 0;

View File

@ -1912,9 +1912,14 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca
if (ins->base_type == VS::INSTANCE_PARTICLES) { if (ins->base_type == VS::INSTANCE_PARTICLES) {
//particles visible? process them //particles visible? process them
VSG::storage->particles_request_process(ins->base); if (VSG::storage->particles_is_inactive(ins->base)) {
//particles visible? request redraw //but if nothing is going on, don't do it.
VisualServerRaster::redraw_request(); keep = false;
} else {
VSG::storage->particles_request_process(ins->base);
//particles visible? request redraw
VisualServerRaster::redraw_request();
}
} }
if (geom->lighting_dirty) { if (geom->lighting_dirty) {