diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-05-23 19:21:35 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-05-23 19:59:26 +0300 |
commit | b642b510e110abfe15d37344e67b07f98d73a273 (patch) | |
tree | c3e84dc21219cd8152402e990671d989ec1a59da | |
parent | b6725d3cbf947ad60e701fa34aca35f5f5dc3125 (diff) |
Fix T55168: missing updates when switching particle system type.
-rw-r--r-- | source/blender/blenkernel/intern/object_update.c | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/particle_system.c | 3 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_particle.c | 28 |
3 files changed, 22 insertions, 14 deletions
diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c index bf01c20a8b7..91571e8bf62 100644 --- a/source/blender/blenkernel/intern/object_update.c +++ b/source/blender/blenkernel/intern/object_update.c @@ -238,11 +238,6 @@ void BKE_object_handle_data_update( ob->transflag &= ~OB_DUPLIPARTS; psys = ob->particlesystem.first; while (psys) { - /* ensure this update always happens even if psys is disabled */ - if (psys->recalc & PSYS_RECALC_TYPE) { - psys_changed_type(ob, psys); - } - if (psys_check_enabled(ob, psys, use_render_params)) { /* check use of dupli objects here */ if (psys->part && (psys->part->draw_as == PART_DRAW_REND || use_render_params) && diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index a7261e0e6ee..6c454cfa0b1 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -4254,9 +4254,6 @@ void particle_system_update(struct Depsgraph *depsgraph, Scene *scene, Object *o /* to verify if we need to restore object afterwards */ psys->flag &= ~PSYS_OB_ANIM_RESTORE; - if (psys->recalc & PSYS_RECALC_TYPE) - psys_changed_type(sim.ob, sim.psys); - if (psys->recalc & PSYS_RECALC_RESET) psys->totunexist = 0; diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index cbd87fb0666..17e9a6604fd 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -585,11 +585,12 @@ static void rna_ParticleSystem_mcol_on_emitter(ParticleSystem *particlesystem, R static void particle_recalc(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr, short flag) { if (ptr->type == &RNA_ParticleSystem) { + Object *ob = ptr->id.data; ParticleSystem *psys = (ParticleSystem *)ptr->data; - + psys->recalc = flag; - DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); } else DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA | flag); @@ -618,9 +619,22 @@ static void rna_Particle_reset_dependency(Main *bmain, Scene *scene, PointerRNA rna_Particle_reset(bmain, scene, ptr); } -static void rna_Particle_change_type(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_Particle_change_type(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { - particle_recalc(bmain, scene, ptr, PSYS_RECALC_RESET | PSYS_RECALC_TYPE); + ParticleSettings *part = ptr->id.data; + + /* Iterating over all object is slow, but no better solution exists at the moment. */ + for (Object *ob = bmain->object.first; ob; ob = ob->id.next) { + for (ParticleSystem *psys = ob->particlesystem.first; psys; psys = psys->next) { + if (psys->part == part) { + psys_changed_type(ob, psys); + psys->recalc |= PSYS_RECALC_RESET; + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); + } + } + } + + WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, NULL); DEG_relations_tag_update(bmain); } @@ -734,6 +748,7 @@ static PointerRNA rna_particle_settings_get(PointerRNA *ptr) static void rna_particle_settings_set(PointerRNA *ptr, PointerRNA value) { + Object *ob = ptr->id.data; ParticleSystem *psys = (ParticleSystem *)ptr->data; int old_type = 0; @@ -748,8 +763,9 @@ static void rna_particle_settings_set(PointerRNA *ptr, PointerRNA value) if (psys->part) { id_us_plus(&psys->part->id); psys_check_boid_data(psys); - if (old_type != psys->part->type) - psys->recalc |= PSYS_RECALC_TYPE; + if (old_type != psys->part->type) { + psys_changed_type(ob, psys); + } } } static void rna_Particle_abspathtime_update(Main *bmain, Scene *scene, PointerRNA *ptr) |