forked from bartvdbraak/blender
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.
This commit is contained in:
parent
647a798076
commit
34058c4ff1
@ -1065,7 +1065,14 @@ ParticleSystem *BKE_object_copy_particlesystem(ParticleSystem *psys, const int f
|
|||||||
BLI_listbase_clear(&psysn->pathcachebufs);
|
BLI_listbase_clear(&psysn->pathcachebufs);
|
||||||
BLI_listbase_clear(&psysn->childcachebufs);
|
BLI_listbase_clear(&psysn->childcachebufs);
|
||||||
|
|
||||||
psysn->pointcache = BKE_ptcache_copy_list(&psysn->ptcaches, &psys->ptcaches, flag);
|
if (flag & LIB_ID_CREATE_NO_MAIN) {
|
||||||
|
BLI_assert((psys->flag & PSYS_SHARED_CACHES) == 0);
|
||||||
|
psysn->flag |= PSYS_SHARED_CACHES;
|
||||||
|
BLI_assert(psysn->pointcache != NULL);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
psysn->pointcache = BKE_ptcache_copy_list(&psysn->ptcaches, &psys->ptcaches, flag);
|
||||||
|
}
|
||||||
|
|
||||||
/* XXX - from reading existing code this seems correct but intended usage of
|
/* XXX - from reading existing code this seems correct but intended usage of
|
||||||
* pointcache should /w cloth should be added in 'ParticleSystem' - campbell */
|
* pointcache should /w cloth should be added in 'ParticleSystem' - campbell */
|
||||||
|
@ -453,7 +453,7 @@ void BKE_particlesettings_free(ParticleSettings *part)
|
|||||||
fluid_free_settings(part->fluid);
|
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;
|
PARTICLE_P;
|
||||||
|
|
||||||
@ -468,13 +468,10 @@ void free_hair(Object *UNUSED(ob), ParticleSystem *psys, int dynamics)
|
|||||||
|
|
||||||
if (psys->clmd) {
|
if (psys->clmd) {
|
||||||
if (dynamics) {
|
if (dynamics) {
|
||||||
BKE_ptcache_free_list(&psys->ptcaches);
|
|
||||||
psys->pointcache = NULL;
|
|
||||||
|
|
||||||
modifier_free((ModifierData *)psys->clmd);
|
modifier_free((ModifierData *)psys->clmd);
|
||||||
|
PTCacheID pid;
|
||||||
psys->clmd = NULL;
|
BKE_ptcache_id_from_particles(&pid, object, psys);
|
||||||
psys->pointcache = BKE_ptcache_add(&psys->ptcaches);
|
BKE_ptcache_id_clear(&pid, PTCACHE_CLEAR_ALL, 0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cloth_free_modifier(psys->clmd);
|
cloth_free_modifier(psys->clmd);
|
||||||
@ -596,7 +593,21 @@ void psys_free(Object *ob, ParticleSystem *psys)
|
|||||||
|
|
||||||
psys_free_path_cache(psys, NULL);
|
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);
|
psys_free_particles(psys);
|
||||||
|
|
||||||
@ -624,7 +635,9 @@ void psys_free(Object *ob, ParticleSystem *psys)
|
|||||||
|
|
||||||
psys->part = NULL;
|
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;
|
psys->pointcache = NULL;
|
||||||
|
|
||||||
BLI_freelistN(&psys->targets);
|
BLI_freelistN(&psys->targets);
|
||||||
|
@ -4386,7 +4386,7 @@ void particle_system_update(struct Depsgraph *depsgraph, Scene *scene, Object *o
|
|||||||
psys_orig->edit->psys_eval = psys;
|
psys_orig->edit->psys_eval = psys;
|
||||||
psys_orig->edit->psmd_eval = psmd;
|
psys_orig->edit->psmd_eval = psmd;
|
||||||
}
|
}
|
||||||
psys_orig->flag = psys->flag;
|
psys_orig->flag = (psys->flag & ~PSYS_SHARED_CACHES);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -567,6 +567,7 @@ typedef enum eParticleShapeFlag {
|
|||||||
//#define PSYS_PROTECT_CACHE 4096 /* deprecated */
|
//#define PSYS_PROTECT_CACHE 4096 /* deprecated */
|
||||||
#define PSYS_DISABLED 8192
|
#define PSYS_DISABLED 8192
|
||||||
#define PSYS_OB_ANIM_RESTORE 16384 /* runtime flag */
|
#define PSYS_OB_ANIM_RESTORE 16384 /* runtime flag */
|
||||||
|
#define PSYS_SHARED_CACHES 32768
|
||||||
|
|
||||||
/* pars->flag */
|
/* pars->flag */
|
||||||
#define PARS_UNEXIST 1
|
#define PARS_UNEXIST 1
|
||||||
|
Loading…
Reference in New Issue
Block a user