diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-06-19 16:25:48 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-06-19 16:28:33 +0300 |
commit | d8f9ec1547387bf363e9c7100322a7d94f08f12a (patch) | |
tree | ebb07e56bb90954eedd97e6a8d03ef28be381853 /source/blender/blenkernel/intern/particle_system.c | |
parent | 95306a4d1982e569616211d901bb81b0467d0b8b (diff) |
Particles: Support changing modifiers during particle edit mode
The idea is to only use pointers to particles in original object when
creating an edit structure. The derived mesh we get from evaluated
object.
The rest of the commit is just keeping pointers in sync.
Diffstat (limited to 'source/blender/blenkernel/intern/particle_system.c')
-rw-r--r-- | source/blender/blenkernel/intern/particle_system.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 9c6c30143cc..314a58647a9 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -4211,7 +4211,9 @@ void particle_system_update(struct Depsgraph *depsgraph, Scene *scene, Object *o { ParticleSimulationData sim= {0}; ParticleSettings *part = psys->part; + ParticleSystem *psys_orig = psys_orig_get(psys); float cfra; + ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys); /* drawdata is outdated after ANY change */ if (psys->pdd) psys->pdd->flag &= ~PARTICLE_DRAW_DATA_UPDATED; @@ -4219,13 +4221,23 @@ void particle_system_update(struct Depsgraph *depsgraph, Scene *scene, Object *o if (!psys_check_enabled(ob, psys, use_render_params)) return; + if (DEG_is_active(depsgraph)) { + if (psys->orig_psys != NULL && + psys->orig_psys->edit != NULL && + psys->orig_psys->edit->psys == psys_orig_get(psys)) + { + psys->orig_psys->edit->psys_eval = psys; + psys->orig_psys->edit->psmd_eval = psmd; + } + } + cfra = DEG_get_ctime(depsgraph); sim.depsgraph = depsgraph; sim.scene = scene; sim.ob = ob; sim.psys = psys; - sim.psmd = psys_get_modifier(ob, psys); + sim.psmd = psmd; /* system was already updated from modifier stack */ if (sim.psmd->flag & eParticleSystemFlag_psys_updated) { @@ -4270,10 +4282,10 @@ void particle_system_update(struct Depsgraph *depsgraph, Scene *scene, Object *o free_hair(ob, psys, 0); - if (psys->edit && psys->free_edit) { - psys->free_edit(psys->edit); - psys->edit = NULL; - psys->free_edit = NULL; + if (psys_orig->edit && psys_orig->free_edit) { + psys_orig->free_edit(psys_orig->edit); + psys_orig->edit = NULL; + psys_orig->free_edit = NULL; } /* first step is negative so particles get killed and reset */ @@ -4369,6 +4381,10 @@ void particle_system_update(struct Depsgraph *depsgraph, Scene *scene, Object *o psys->flag &= ~PSYS_OB_ANIM_RESTORE; } + if (psys_orig->edit) { + psys_orig->edit->flags |= PT_CACHE_EDIT_UPDATE_PARTICLE_FROM_EVAL; + } + psys->cfra = cfra; psys->recalc = 0; |