From d50821f145550b60078ce1106edd21348476d960 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 11 May 2018 12:44:43 +0200 Subject: Particle edit: Initial support of edit with copy-on-write The idea is that edit mode structure is owned by original object, and used for drawing. This is a bit confusing, especially since path cache is also in that structure and needs evaluated object to calculate cache. In the future we should split edit data from visualization data, but that's bigger refactor. --- .../draw/intern/draw_cache_impl_particles.c | 31 +++++++++++++++------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'source/blender/draw/intern/draw_cache_impl_particles.c') diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c index 4102b72175f..f1ae9d6ef8c 100644 --- a/source/blender/draw/intern/draw_cache_impl_particles.c +++ b/source/blender/draw/intern/draw_cache_impl_particles.c @@ -597,10 +597,25 @@ Gwn_Batch *DRW_particles_batch_cache_get_dots(Object *object, ParticleSystem *ps return cache->hairs; } -Gwn_Batch *DRW_particles_batch_cache_get_edit_strands(PTCacheEdit *edit) +/* TODO(sergey): Avoid linear lookup. */ +static ParticleBatchCache *particle_batch_cache_get_edit(Object *object, PTCacheEdit *edit) +{ + ParticleSystem *psys_orig = edit->psys; + for (ParticleSystem *psys_eval = object->particlesystem.first; + psys_eval != NULL; + psys_eval = psys_eval->next) + { + if (STREQ(psys_orig->name, psys_eval->name)) { + return particle_batch_cache_get(psys_eval); + } + } + return NULL; +} + +Gwn_Batch *DRW_particles_batch_cache_get_edit_strands(Object *object, PTCacheEdit *edit) { ParticleSystem *psys = edit->psys; - ParticleBatchCache *cache = particle_batch_cache_get(psys); + ParticleBatchCache *cache = particle_batch_cache_get_edit(object, edit); if (cache->hairs != NULL) { return cache->hairs; } @@ -676,10 +691,9 @@ static void particle_batch_cache_ensure_edit_inner_pos( } } -Gwn_Batch *DRW_particles_batch_cache_get_edit_inner_points(PTCacheEdit *edit) +Gwn_Batch *DRW_particles_batch_cache_get_edit_inner_points(Object *object, PTCacheEdit *edit) { - ParticleSystem *psys = edit->psys; - ParticleBatchCache *cache = particle_batch_cache_get(psys); + ParticleBatchCache *cache = particle_batch_cache_get_edit(object, edit); if (cache->edit_inner_points != NULL) { return cache->edit_inner_points; } @@ -692,7 +706,7 @@ Gwn_Batch *DRW_particles_batch_cache_get_edit_inner_points(PTCacheEdit *edit) } static void ensure_edit_tip_points_count(const PTCacheEdit *edit, - ParticleBatchCache *cache) + ParticleBatchCache *cache) { if (cache->edit_tip_pos != NULL) { return; @@ -738,10 +752,9 @@ static void particle_batch_cache_ensure_edit_tip_pos( } } -Gwn_Batch *DRW_particles_batch_cache_get_edit_tip_points(PTCacheEdit *edit) +Gwn_Batch *DRW_particles_batch_cache_get_edit_tip_points(Object *object, PTCacheEdit *edit) { - ParticleSystem *psys = edit->psys; - ParticleBatchCache *cache = particle_batch_cache_get(psys); + ParticleBatchCache *cache = particle_batch_cache_get_edit(object, edit); if (cache->edit_tip_points != NULL) { return cache->edit_tip_points; } -- cgit v1.2.3