diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-05-15 15:50:24 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-05-15 18:20:02 +0300 |
commit | 2d0efe2e7863c5ebc5e88b2ae17cd20cb3c7e8e6 (patch) | |
tree | 0b67d1166a52b5857bbe07fc6fc2bf7d0502d8a8 /source | |
parent | a104c41759613899e314c328e48d6b16cd634d1a (diff) |
Particle edit: Need to check DONE flag from evaluated psys
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_particle.h | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/particle.c | 25 | ||||
-rw-r--r-- | source/blender/editors/physics/particle_edit.c | 8 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_particle_types.h | 2 |
4 files changed, 31 insertions, 9 deletions
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h index c2217969c98..097532ff2c3 100644 --- a/source/blender/blenkernel/BKE_particle.h +++ b/source/blender/blenkernel/BKE_particle.h @@ -302,7 +302,10 @@ void psys_set_current_num(Object *ob, int index); struct LatticeDeformData *psys_create_lattice_deform_data(struct ParticleSimulationData *sim); -struct ParticleSystem *psys_original_get(struct ParticleSystem *psys); +struct ParticleSystem *psys_orig_get(struct ParticleSystem *psys); +struct ParticleSystem *psys_eval_get(struct Depsgraph *depsgraph, + struct Object *object, + struct ParticleSystem *psys); bool psys_in_edit_mode(struct Depsgraph *depsgraph, struct ParticleSystem *psys); bool psys_check_enabled(struct Object *ob, struct ParticleSystem *psys, const bool use_render_params); bool psys_check_edited(struct ParticleSystem *psys); diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 75d4d5cf736..940263ded09 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -289,7 +289,7 @@ void psys_enable_all(Object *ob) psys->flag &= ~PSYS_DISABLED; } -ParticleSystem *psys_original_get(ParticleSystem *psys) +ParticleSystem *psys_orig_get(ParticleSystem *psys) { if (psys->orig_psys == NULL) { return psys; @@ -297,7 +297,22 @@ ParticleSystem *psys_original_get(ParticleSystem *psys) return psys->orig_psys; } -static PTCacheEdit *psys_original_edit_get(ParticleSystem *psys) +struct ParticleSystem *psys_eval_get(Depsgraph *depsgraph, + Object *object, + ParticleSystem *psys) +{ + Object *object_eval = DEG_get_evaluated_object(depsgraph, object); + ParticleSystem *psys_eval = object_eval->particlesystem.first; + while (psys_eval != NULL) { + if (psys_eval->orig_psys == psys) { + return psys_eval; + } + psys_eval = psys_eval->next; + } + return psys_eval; +} + +static PTCacheEdit *psys_orig_edit_get(ParticleSystem *psys) { if (psys->orig_psys == NULL) { return psys->edit; @@ -317,7 +332,7 @@ bool psys_in_edit_mode(Depsgraph *depsgraph, ParticleSystem *psys) if (object->mode != OB_MODE_PARTICLE_EDIT) { return false; } - ParticleSystem *psys_orig = psys_original_get(psys); + ParticleSystem *psys_orig = psys_orig_get(psys); return (psys_orig->edit || psys->pointcache->edit) && (use_render_params == false); } @@ -1907,7 +1922,7 @@ static bool psys_thread_context_init_path( if (psys_in_edit_mode(sim->depsgraph, psys)) { ParticleEditSettings *pset = &scene->toolsettings->particle; - if ((use_render_params == 0) && (psys_original_edit_get(psys) == NULL || pset->flag & PE_DRAW_PART) == 0) + if ((use_render_params == 0) && (psys_orig_edit_get(psys) == NULL || pset->flag & PE_DRAW_PART) == 0) totchild = 0; segments = 1 << pset->draw_step; @@ -2001,7 +2016,7 @@ static void psys_thread_create_path(ParticleTask *task, struct ChildParticle *cp ParticleSystem *psys = ctx->sim.psys; ParticleSettings *part = psys->part; ParticleCacheKey **cache = psys->childcache; - PTCacheEdit *edit = psys_original_edit_get(psys); + PTCacheEdit *edit = psys_orig_edit_get(psys); ParticleCacheKey **pcache = psys_in_edit_mode(ctx->sim.depsgraph, psys) && edit ? edit->pathcache : psys->pathcache; ParticleCacheKey *child, *key[4]; ParticleTexture ptex; diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 79afba38d08..7f8f08beaac 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -257,8 +257,12 @@ static PTCacheEdit *pe_get_current( edit = pid->cache->edit; } else { - if (create && !psys->edit && psys->flag & PSYS_HAIR_DONE) - PE_create_particle_edit(depsgraph, scene, ob, NULL, psys); + if (create && !psys->edit) { + ParticleSystem *psys_eval = psys_eval_get(depsgraph, ob, psys); + if (psys_eval->flag & PSYS_HAIR_DONE) { + PE_create_particle_edit(depsgraph, scene, ob, NULL, psys); + } + } edit = psys->edit; } } diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h index 123fa8e171e..3e1e301accc 100644 --- a/source/blender/makesdna/DNA_particle_types.h +++ b/source/blender/makesdna/DNA_particle_types.h @@ -332,7 +332,7 @@ typedef struct ParticleSystem { * * Original system will have this set to NULL. * - * Use psys_original_get() function to access, + * Use psys_orig_get() function to access, */ struct ParticleSystem *orig_psys; } ParticleSystem; |