diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-05-15 15:38:02 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-05-15 18:20:02 +0300 |
commit | a104c41759613899e314c328e48d6b16cd634d1a (patch) | |
tree | 7c5eb42b5d51cb417264a8a4ae841cf99f202037 /source/blender | |
parent | ed0901b47e1c8bdee2461643f779bffbff121894 (diff) |
Particle edit: Support children particles display with copy on write
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/particle.c | 17 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_cache_impl_particles.c | 17 |
2 files changed, 23 insertions, 11 deletions
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 0f23fc1deea..75d4d5cf736 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -297,6 +297,14 @@ ParticleSystem *psys_original_get(ParticleSystem *psys) return psys->orig_psys; } +static PTCacheEdit *psys_original_edit_get(ParticleSystem *psys) +{ + if (psys->orig_psys == NULL) { + return psys->edit; + } + return psys->orig_psys->edit; +} + bool psys_in_edit_mode(Depsgraph *depsgraph, ParticleSystem *psys) { const ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph); @@ -1899,7 +1907,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->edit == NULL || pset->flag & PE_DRAW_PART) == 0) + if ((use_render_params == 0) && (psys_original_edit_get(psys) == NULL || pset->flag & PE_DRAW_PART) == 0) totchild = 0; segments = 1 << pset->draw_step; @@ -1993,7 +2001,8 @@ static void psys_thread_create_path(ParticleTask *task, struct ChildParticle *cp ParticleSystem *psys = ctx->sim.psys; ParticleSettings *part = psys->part; ParticleCacheKey **cache = psys->childcache; - ParticleCacheKey **pcache = psys_in_edit_mode(ctx->sim.depsgraph, psys) && psys->edit ? psys->edit->pathcache : psys->pathcache; + PTCacheEdit *edit = psys_original_edit_get(psys); + ParticleCacheKey **pcache = psys_in_edit_mode(ctx->sim.depsgraph, psys) && edit ? edit->pathcache : psys->pathcache; ParticleCacheKey *child, *key[4]; ParticleTexture ptex; float *cpa_fuv = 0, *par_rot = 0, rot[4]; @@ -2019,7 +2028,7 @@ static void psys_thread_create_path(ParticleTask *task, struct ChildParticle *cp needupdate = 0; w = 0; while (w < 4 && cpa->pa[w] >= 0) { - if (psys->edit->points[cpa->pa[w]].flag & PEP_EDIT_RECALC) { + if (edit->points[cpa->pa[w]].flag & PEP_EDIT_RECALC) { needupdate = 1; break; } @@ -2106,7 +2115,7 @@ static void psys_thread_create_path(ParticleTask *task, struct ChildParticle *cp ParticleData *pa = psys->particles + cpa->parent; float co[3]; if (ctx->editupdate) { - if (!(psys->edit->points[cpa->parent].flag & PEP_EDIT_RECALC)) + if (!(edit->points[cpa->parent].flag & PEP_EDIT_RECALC)) return; memset(child_keys, 0, sizeof(*child_keys) * (ctx->segments + 1)); diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c index f9b3735eb42..a1eb98a85e2 100644 --- a/source/blender/draw/intern/draw_cache_impl_particles.c +++ b/source/blender/draw/intern/draw_cache_impl_particles.c @@ -616,6 +616,7 @@ static void particle_batch_cache_ensure_pos(Object *object, } static void drw_particle_update_ptcache_edit(Object *object_eval, + ParticleSystem *psys, PTCacheEdit *edit) { if (edit->psys == NULL) { @@ -627,8 +628,9 @@ static void drw_particle_update_ptcache_edit(Object *object_eval, const DRWContextState *draw_ctx = DRW_context_state_get(); Scene *scene_orig = (Scene *)DEG_get_original_id(&draw_ctx->scene->id); Object *object_orig = DEG_get_original_object(object_eval); - if (edit->psys->flag & PSYS_HAIR_UPDATED) { + if (psys->flag & PSYS_HAIR_UPDATED) { PE_update_object(draw_ctx->depsgraph, scene_orig, object_orig, 0); + psys->flag &= ~PSYS_HAIR_UPDATED; } if (edit->pathcache == NULL) { Depsgraph *depsgraph = draw_ctx->depsgraph; @@ -640,7 +642,8 @@ static void drw_particle_update_ptcache_edit(Object *object_eval, } } -static void drw_particle_update_ptcache(Object *object_eval) +static void drw_particle_update_ptcache(Object *object_eval, + ParticleSystem *psys) { if ((object_eval->mode & OB_MODE_PARTICLE_EDIT) == 0) { return; @@ -651,7 +654,7 @@ static void drw_particle_update_ptcache(Object *object_eval) PTCacheEdit *edit = PE_create_current( draw_ctx->depsgraph, scene_orig, object_orig); if (edit != NULL) { - drw_particle_update_ptcache_edit(object_eval, edit); + drw_particle_update_ptcache_edit(object_eval, psys, edit); } } @@ -663,7 +666,7 @@ Gwn_Batch *DRW_particles_batch_cache_get_hair( ParticleBatchCache *cache = particle_batch_cache_get(psys); if (cache->hair.hairs == NULL) { - drw_particle_update_ptcache(object); + drw_particle_update_ptcache(object, psys); ensure_seg_pt_count(NULL, psys, &cache->hair); particle_batch_cache_ensure_pos_and_seg(NULL, psys, md, &cache->hair); cache->hair.hairs = GWN_batch_create(GWN_PRIM_LINE_STRIP, @@ -695,7 +698,7 @@ Gwn_Batch *DRW_particles_batch_cache_get_edit_strands( if (cache->edit_hair.hairs != NULL) { return cache->edit_hair.hairs; } - drw_particle_update_ptcache_edit(object, edit); + drw_particle_update_ptcache_edit(object, psys, edit); ensure_seg_pt_count(edit, psys, &cache->edit_hair); particle_batch_cache_ensure_pos_and_seg(edit, psys, NULL, &cache->edit_hair); cache->edit_hair.hairs = GWN_batch_create(GWN_PRIM_LINE_STRIP, @@ -779,7 +782,7 @@ Gwn_Batch *DRW_particles_batch_cache_get_edit_inner_points( if (cache->edit_inner_points != NULL) { return cache->edit_inner_points; } - drw_particle_update_ptcache_edit(object, edit); + drw_particle_update_ptcache_edit(object, psys, edit); ensure_edit_inner_points_count(edit, cache); particle_batch_cache_ensure_edit_inner_pos(edit, cache); cache->edit_inner_points = GWN_batch_create(GWN_PRIM_POINTS, @@ -844,7 +847,7 @@ Gwn_Batch *DRW_particles_batch_cache_get_edit_tip_points( if (cache->edit_tip_points != NULL) { return cache->edit_tip_points; } - drw_particle_update_ptcache_edit(object, edit); + drw_particle_update_ptcache_edit(object, psys, edit); ensure_edit_tip_points_count(edit, cache); particle_batch_cache_ensure_edit_tip_pos(edit, cache); cache->edit_tip_points = GWN_batch_create(GWN_PRIM_POINTS, |