diff options
author | Germano Cavalcante <mano-wii> | 2022-06-27 22:50:13 +0300 |
---|---|---|
committer | Germano Cavalcante <germano.costa@ig.com.br> | 2022-06-27 22:54:23 +0300 |
commit | 67e23b4b29676e7cbc039eba96e3edd78a632997 (patch) | |
tree | 2470da1ee0a27b261e7bf86c6b3f909544e9653b | |
parent | a571c74e106bc864b84372d60a7504b730c801bd (diff) |
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
-rw-r--r-- | source/blender/blenkernel/intern/fluid.c | 18 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/pointcache.c | 9 |
2 files changed, 18 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c index 5cd5a699dec..8e95bf18c6b 100644 --- a/source/blender/blenkernel/intern/fluid.c +++ b/source/blender/blenkernel/intern/fluid.c @@ -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)) { diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index d7bdfe08ab9..21217a7f9bf 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -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)) { |