diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-05-15 13:34:18 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-05-15 18:20:02 +0300 |
commit | fe01430f74f1440827c3055bd1025b33302afd7b (patch) | |
tree | 88b623d81c8ee2e0cc584d928295aba01b8713a2 /source | |
parent | e5560e8d56774bc7502f9cf3b304ef27d16298eb (diff) |
Particle edit: Make check to work within copy-on-write concept
Not fully optimal, we can probably store pointer to original psys
similar to ID's orig_id.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/particle.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 37607de9c36..d740963cde8 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -291,14 +291,31 @@ void psys_enable_all(Object *ob) bool psys_in_edit_mode(Depsgraph *depsgraph, ParticleSystem *psys) { - ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph); + const ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph); + if (view_layer->basact == NULL) { + /* TODO(sergey): Needs double-check with multi-object edit. */ + return false; + } const bool use_render_params = (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER); - - return (view_layer->basact && - (view_layer->basact->object->mode & OB_MODE_PARTICLE_EDIT) && - psys == psys_get_current((view_layer->basact)->object) && - (psys->edit || psys->pointcache->edit) && - !use_render_params); + const Object *object = view_layer->basact->object; + if (object->mode != OB_MODE_PARTICLE_EDIT) { + return false; + } + /* TODO(sergey): Find a faster way to switch to an original psys. */ + /*const*/ Object *object_orig = DEG_get_original_object(view_layer->basact->object); + ParticleSystem *psys_orig = object_orig->particlesystem.first; + while (psys_orig != NULL) { + if (STREQ(psys_orig->name, psys->name)) { + break; + } + psys = psys->next; + psys_orig = psys_orig->next; + } + if (psys_orig != psys_get_current(object_orig)) { + return false; + } + return (psys_orig->edit || psys->pointcache->edit) && + (use_render_params == false); } bool psys_check_enabled(Object *ob, ParticleSystem *psys, const bool use_render_params) |