diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-05-11 15:54:50 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-05-11 15:55:58 +0300 |
commit | aefd181b0b19403eaa6643e63901ff1cd740f881 (patch) | |
tree | 28317d013fe44a1911fc3a6b2cc9111f69646d95 /source/blender/draw/intern/draw_cache_impl_particles.c | |
parent | af5428aa2b4d4c6255c98cc0c22e618ec0d43ff8 (diff) |
Fix crash going to edit mode of particles with copy on write
We can not rely on edit->psys, it is not set for particle edit,
and there is some logic deeper inside which does different things
dependent on that.
We need to replace those checks with some some HAIR vs. PARTICLES
flag and always set psys pointer.
Diffstat (limited to 'source/blender/draw/intern/draw_cache_impl_particles.c')
-rw-r--r-- | source/blender/draw/intern/draw_cache_impl_particles.c | 37 |
1 files changed, 15 insertions, 22 deletions
diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c index f1ae9d6ef8c..1c39cbc16cd 100644 --- a/source/blender/draw/intern/draw_cache_impl_particles.c +++ b/source/blender/draw/intern/draw_cache_impl_particles.c @@ -597,25 +597,12 @@ Gwn_Batch *DRW_particles_batch_cache_get_dots(Object *object, ParticleSystem *ps return cache->hairs; } -/* 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) +Gwn_Batch *DRW_particles_batch_cache_get_edit_strands( + Object *UNUSED(object), + ParticleSystem *psys, + PTCacheEdit *edit) { - ParticleSystem *psys = edit->psys; - ParticleBatchCache *cache = particle_batch_cache_get_edit(object, edit); + ParticleBatchCache *cache = particle_batch_cache_get(psys); if (cache->hairs != NULL) { return cache->hairs; } @@ -691,9 +678,12 @@ static void particle_batch_cache_ensure_edit_inner_pos( } } -Gwn_Batch *DRW_particles_batch_cache_get_edit_inner_points(Object *object, PTCacheEdit *edit) +Gwn_Batch *DRW_particles_batch_cache_get_edit_inner_points( + Object *UNUSED(object), + ParticleSystem *psys, + PTCacheEdit *edit) { - ParticleBatchCache *cache = particle_batch_cache_get_edit(object, edit); + ParticleBatchCache *cache = particle_batch_cache_get(psys); if (cache->edit_inner_points != NULL) { return cache->edit_inner_points; } @@ -752,9 +742,12 @@ static void particle_batch_cache_ensure_edit_tip_pos( } } -Gwn_Batch *DRW_particles_batch_cache_get_edit_tip_points(Object *object, PTCacheEdit *edit) +Gwn_Batch *DRW_particles_batch_cache_get_edit_tip_points( + Object *UNUSED(object), + ParticleSystem *psys, + PTCacheEdit *edit) { - ParticleBatchCache *cache = particle_batch_cache_get_edit(object, edit); + ParticleBatchCache *cache = particle_batch_cache_get(psys); if (cache->edit_tip_points != NULL) { return cache->edit_tip_points; } |