diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-11-12 18:24:53 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-11-13 13:39:02 +0300 |
commit | 34058c4ff1684b4d2e4d8619e2a7b690d9286140 (patch) | |
tree | 9fbfd91cbc8a8f9719b4a677e7b36df75e01ead2 /source/blender/blenkernel/intern/particle.c | |
parent | 647a79807600f8ad3159935d1f985fe7a1ede5fc (diff) |
Fix T57105: Baked Particles could not be rendered as expected
Same fix as for smoke (and is what caching proposal is AFAIK):
share cache between copied and original objects.
One thing which is still missing to be fixed is to make auto-cache
more reliable. It was already kind of broken, so don't think it
should be a stopping factor for this fix.
Diffstat (limited to 'source/blender/blenkernel/intern/particle.c')
-rw-r--r-- | source/blender/blenkernel/intern/particle.c | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index cec27b8f187..360dcd7b26a 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -453,7 +453,7 @@ void BKE_particlesettings_free(ParticleSettings *part) fluid_free_settings(part->fluid); } -void free_hair(Object *UNUSED(ob), ParticleSystem *psys, int dynamics) +void free_hair(Object *object, ParticleSystem *psys, int dynamics) { PARTICLE_P; @@ -468,13 +468,10 @@ void free_hair(Object *UNUSED(ob), ParticleSystem *psys, int dynamics) if (psys->clmd) { if (dynamics) { - BKE_ptcache_free_list(&psys->ptcaches); - psys->pointcache = NULL; - modifier_free((ModifierData *)psys->clmd); - - psys->clmd = NULL; - psys->pointcache = BKE_ptcache_add(&psys->ptcaches); + PTCacheID pid; + BKE_ptcache_id_from_particles(&pid, object, psys); + BKE_ptcache_id_clear(&pid, PTCACHE_CLEAR_ALL, 0); } else { cloth_free_modifier(psys->clmd); @@ -596,7 +593,21 @@ void psys_free(Object *ob, ParticleSystem *psys) psys_free_path_cache(psys, NULL); - free_hair(ob, psys, 1); + /* NOTE: We pass dynamics=0 to free_hair() to prevent it from doing an + * unneeded clear of the cache. But for historical reason that code path + * was only clearing cloth part of modifier data. + * + * Part of the story there is that particle evaluation is trying to not + * re-allocate thew ModifierData itself, and limits all allocations to + * the cloth part of it. + * + * Why evaluation is relying on hair_free() and in some specific code + * paths there is beyond me. + */ + free_hair(ob, psys, 0); + if (psys->clmd != NULL) { + modifier_free((ModifierData *)psys->clmd); + } psys_free_particles(psys); @@ -624,7 +635,9 @@ void psys_free(Object *ob, ParticleSystem *psys) psys->part = NULL; - BKE_ptcache_free_list(&psys->ptcaches); + if ((psys->flag & PSYS_SHARED_CACHES) == 0) { + BKE_ptcache_free_list(&psys->ptcaches); + } psys->pointcache = NULL; BLI_freelistN(&psys->targets); |