Merge pull request #19764 from malbach/godot_malbach

Fix #19507 Not emitted particles affects performance
This commit is contained in:
Max Hilbrunner 2018-07-17 16:47:41 +02:00 committed by GitHub
commit 4b626dc114
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 28 additions and 4 deletions

View File

@ -682,6 +682,7 @@ public:
void particles_set_emission_transform(RID p_particles, const Transform &p_transform) {}
bool particles_get_emitting(RID p_particles) { return false; }
bool particles_get_inactive(RID p_particles) { return false; }
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(); }

View File

@ -1637,6 +1637,10 @@ bool RasterizerStorageGLES2::particles_get_emitting(RID p_particles) {
return false;
}
bool RasterizerStorageGLES2::particles_get_inactive(RID p_particles) {
return false;
}
void RasterizerStorageGLES2::particles_set_amount(RID p_particles, int p_amount) {
}

View File

@ -693,6 +693,7 @@ public:
virtual void particles_set_emitting(RID p_particles, bool p_emitting);
virtual bool particles_get_emitting(RID p_particles);
virtual bool particles_get_inactive(RID p_particles);
virtual void particles_set_amount(RID p_particles, int p_amount);
virtual void particles_set_lifetime(RID p_particles, float p_lifetime);

View File

@ -1679,6 +1679,9 @@ void RasterizerSceneGLES3::_render_geometry(RenderList::Element *e) {
RasterizerStorageGLES3::Particles *particles = static_cast<RasterizerStorageGLES3::Particles *>(e->owner);
RasterizerStorageGLES3::Surface *s = static_cast<RasterizerStorageGLES3::Surface *>(e->geometry);
if (!particles->emitting && particles->inactive)
break;
if (!particles->use_local_coords) //not using local coordinates? then clear transform..
state.scene_shader.set_uniform(SceneShaderGLES3::WORLD_TRANSFORM, Transform());

View File

@ -5574,6 +5574,13 @@ bool RasterizerStorageGLES3::particles_get_emitting(RID p_particles) {
return particles->emitting;
}
bool RasterizerStorageGLES3::particles_get_inactive(RID p_particles) {
Particles *particles = particles_owner.getornull(p_particles);
ERR_FAIL_COND_V(!particles, false);
return particles->inactive;
}
void RasterizerStorageGLES3::particles_set_amount(RID p_particles, int p_amount) {
Particles *particles = particles_owner.getornull(p_particles);

View File

@ -1224,6 +1224,7 @@ public:
virtual void particles_set_emitting(RID p_particles, bool p_emitting);
virtual bool particles_get_emitting(RID p_particles);
virtual bool particles_get_inactive(RID p_particles);
virtual void particles_set_amount(RID p_particles, int p_amount);
virtual void particles_set_lifetime(RID p_particles, float p_lifetime);
virtual void particles_set_one_shot(RID p_particles, bool p_one_shot);

View File

@ -482,6 +482,7 @@ public:
virtual void particles_set_emitting(RID p_particles, bool p_emitting) = 0;
virtual bool particles_get_emitting(RID p_particles) = 0;
virtual bool particles_get_inactive(RID p_particles) = 0;
virtual void particles_set_amount(RID p_particles, int p_amount) = 0;
virtual void particles_set_lifetime(RID p_particles, float p_lifetime) = 0;

View File

@ -396,6 +396,7 @@ public:
BIND2(particles_set_emitting, RID, bool)
BIND1R(bool, particles_get_emitting, RID)
BIND1R(bool, particles_get_inactive, RID)
BIND2(particles_set_amount, RID, int)
BIND2(particles_set_lifetime, RID, float)
BIND2(particles_set_one_shot, RID, bool)

View File

@ -1872,10 +1872,12 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(ins->base_data);
if (ins->base_type == VS::INSTANCE_PARTICLES) {
//particles visible? process them
VSG::storage->particles_request_process(ins->base);
//particles visible? request redraw
VisualServerRaster::redraw_request();
if (VSG::storage->particles_get_emitting(ins->base) || !VSG::storage->particles_get_inactive(ins->base)) {
//particles visible? process them
VSG::storage->particles_request_process(ins->base);
//particles visible? request redraw
VisualServerRaster::redraw_request();
}
}
if (geom->lighting_dirty) {

View File

@ -328,6 +328,7 @@ public:
FUNC2(particles_set_emitting, RID, bool)
FUNC1R(bool, particles_get_emitting, RID)
FUNC1R(bool, particles_get_inactive, RID)
FUNC2(particles_set_amount, RID, int)
FUNC2(particles_set_lifetime, RID, float)
FUNC2(particles_set_one_shot, RID, bool)

View File

@ -1699,6 +1699,7 @@ void VisualServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("particles_create"), &VisualServer::particles_create);
ClassDB::bind_method(D_METHOD("particles_set_emitting", "particles", "emitting"), &VisualServer::particles_set_emitting);
ClassDB::bind_method(D_METHOD("particles_get_emitting", "particles"), &VisualServer::particles_get_emitting);
ClassDB::bind_method(D_METHOD("particles_get_inactive", "particles"), &VisualServer::particles_get_inactive);
ClassDB::bind_method(D_METHOD("particles_set_amount", "particles", "amount"), &VisualServer::particles_set_amount);
ClassDB::bind_method(D_METHOD("particles_set_lifetime", "particles", "lifetime"), &VisualServer::particles_set_lifetime);
ClassDB::bind_method(D_METHOD("particles_set_one_shot", "particles", "one_shot"), &VisualServer::particles_set_one_shot);

View File

@ -519,6 +519,7 @@ public:
virtual void particles_set_emitting(RID p_particles, bool p_emitting) = 0;
virtual bool particles_get_emitting(RID p_particles) = 0;
virtual bool particles_get_inactive(RID p_particles) = 0;
virtual void particles_set_amount(RID p_particles, int p_amount) = 0;
virtual void particles_set_lifetime(RID p_particles, float p_lifetime) = 0;
virtual void particles_set_one_shot(RID p_particles, bool p_one_shot) = 0;