Fix #68436: External Particle Disk Cache Playback Is Broken

This has been broken since 2.8.

The highlevel reason for this is that the "info file" (saved as frame
zero) was not written anymore.
Reason for that in turn is that when calling BKE_ptcache_write outside
the bake job, the PTCacheID calldata (a psys in our case) is not the
evaluated particle system, causing a check for totpoint to fail (these
were always zero).

Deeper reasoning is unclear, no further investigations were done as to
why/when this happened.

The solution proposed here is using the evaluated psys when writing the
info frame (and this is isolated to just this spot and only to particle
systems). File then gets
written and can/will be read when using this as an external disk cache
in another file.

Pull Request: https://projects.blender.org/blender/blender/pulls/117401
This commit is contained in:
Philipp Oeser
2024-01-23 09:37:41 +01:00
committed by Philipp Oeser
parent 062a9f9540
commit c16b0216fe

View File

@@ -62,6 +62,8 @@
#include "BLO_read_write.hh"
#include "DEG_depsgraph_query.hh"
#include "BIK_api.h"
#ifdef WITH_BULLET
@@ -3356,7 +3358,20 @@ void BKE_ptcache_bake(PTCacheBaker *baker)
cache->flag |= PTCACHE_BAKED;
/* write info file */
if (cache->flag & PTCACHE_DISK_CACHE) {
BKE_ptcache_write(pid, 0);
if (pid->type == PTCACHE_TYPE_PARTICLES) {
/* Since writing this from outside the bake job, make sure the ParticleSystem and
* PTCacheID is in a fully evaluated state. */
PTCacheID pid_eval;
Object *ob = reinterpret_cast<Object *>(pid->owner_id);
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
ParticleSystem *psys = static_cast<ParticleSystem *>(pid->calldata);
ParticleSystem *psys_eval = psys_eval_get(depsgraph, ob, psys);
BKE_ptcache_id_from_particles(&pid_eval, ob_eval, psys_eval);
BKE_ptcache_write(&pid_eval, 0);
}
else {
BKE_ptcache_write(pid, 0);
}
}
}
}
@@ -3386,7 +3401,20 @@ void BKE_ptcache_bake(PTCacheBaker *baker)
if (bake) {
cache->flag |= PTCACHE_BAKED;
if (cache->flag & PTCACHE_DISK_CACHE) {
BKE_ptcache_write(pid, 0);
if (pid->type == PTCACHE_TYPE_PARTICLES) {
/* Since writing this from outside the bake job, make sure the ParticleSystem and
* PTCacheID is in a fully evaluated state. */
PTCacheID pid_eval;
Object *ob = reinterpret_cast<Object *>(pid->owner_id);
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
ParticleSystem *psys = static_cast<ParticleSystem *>(pid->calldata);
ParticleSystem *psys_eval = psys_eval_get(depsgraph, ob, psys);
BKE_ptcache_id_from_particles(&pid_eval, ob_eval, psys_eval);
BKE_ptcache_write(&pid_eval, 0);
}
else {
BKE_ptcache_write(pid, 0);
}
}
}
}