Fix T84369: Fluid: Missing cache invalidation when properties on non-domain objects change

The `DEG_OB_COMP_TRANSFORM` and `DEG_OB_COMP_GEOMETRY` relations between
the **Domain** object and the **Flow**, **Effector** and **Force Field** objects
are added in the `updateDepsgraph` callback of the Fluid modifier, more
specifically in `DEG_add_collision_relations`.

The node linked to these components is the `POINT_CACHE` whose assigned
function is `BKE_ptcache_object_reset`.

So include the `eModifierType_Fluid` modifier in outdated cache checks.

Reviewed By: sergey, zeddb

Maniphest Tasks: T84369

Differential Revision: https://developer.blender.org/D15210
This commit is contained in:
Germano Cavalcante 2022-06-27 16:50:13 -03:00 committed by Germano Cavalcante
parent a571c74e10
commit 67e23b4b29
Notes: blender-bot 2024-01-15 12:33:09 +01:00
Referenced by commit 77bc95bbd5, Fix T102257: Crash when making an Object as Effector set to Guide and trying to scrub the timeline
Referenced by commit edc00429e8, Fix T102257: Crash when making an Object as Effector set to Guide and trying to scrub the timeline
Referenced by commit 715c86d9e5, Fix T101231: Console flooded with warnings when fluid type is Domain
Referenced by issue #102257, Regression: Crash when making an Object as Effector set to Guide and trying to scrub the timeline.
Referenced by issue #101231, Regression: Console flooded with warnings when fluid type is Domain
Referenced by issue #84369, Fluid: Missing cache invalidation when properties on non-domain objects change.
Referenced by issue #106425, Regression: Guiding in manta is broken
Referenced by pull request #117067, Fix #106425: Mantaflow guiding with domains is broken
Referenced by commit 4da32e9334, Fix #106425: Mantaflow guiding with domains is broken
2 changed files with 18 additions and 9 deletions

View File

@ -3761,16 +3761,16 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *fmd,
MEM_freeN(objs);
}
/* TODO(sebbas): Cache reset for when flow / effector object need update flag is set. */
# if 0
/* If the just updated flags now carry the 'outdated' flag, reset the cache here!
* Plus sanity check: Do not clear cache on file load. */
if (fds->cache_flag & FLUID_DOMAIN_OUTDATED_DATA &&
((fds->flags & FLUID_DOMAIN_FILE_LOAD) == 0)) {
BKE_fluid_cache_free_all(fds, ob);
BKE_fluid_modifier_reset_ex(fmd, false);
/* If 'outdated', reset the cache here. */
if (is_startframe && mode == FLUID_DOMAIN_CACHE_REPLAY) {
PTCacheID pid;
BKE_ptcache_id_from_smoke(&pid, ob, fmd);
if (pid.cache->flag & PTCACHE_OUTDATED) {
BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
BKE_fluid_cache_free_all(fds, ob);
BKE_fluid_modifier_reset_ex(fmd, false);
}
}
# endif
/* Fluid domain init must not fail in order to continue modifier evaluation. */
if (!fds->fluid && !BKE_fluid_modifier_init(fmd, depsgraph, ob, scene, me)) {

View File

@ -2980,6 +2980,15 @@ int BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode)
}
}
}
if (md->type == eModifierType_Fluid) {
FluidModifierData *fmd = (FluidModifierData *)md;
FluidDomainSettings *fds = fmd->domain;
if ((fmd->type & MOD_FLUID_TYPE_DOMAIN) && fds &&
fds->cache_type == FLUID_DOMAIN_CACHE_REPLAY) {
BKE_ptcache_id_from_smoke(&pid, ob, fmd);
reset |= BKE_ptcache_id_reset(scene, &pid, mode);
}
}
}
if (scene->rigidbody_world && (ob->rigidbody_object || ob->rigidbody_constraint)) {