mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
Fix #106425: Mantaflow guiding with domains is broken
Caused bye968b4197b/67e23b4b29Since culprit commits, we are not running `MANTA::initGuiding` / `fluid_alloc_guiding` if guiding is meant to be pulled from other domains (it does work with effectors though). This is because atm. only the `FLUID_DOMAIN_ACTIVE_GUIDE` flag sets `mUsingGuiding` to true (activated in `update_obstacleflags`, so only for effectors). So to fix this, we have to ensure that `MANTA::initGuiding` runs (also if guiding is pulled from domains), but also make sure we dont run into the crashes from T102257. It seems that the real reason we were getting crashes in T102257 is that67e23b4b29made it so that resetting the cache (including a call to `fluid_modifier_reset_ex`) in `fluid_modifier_processDomain` happens **after** `FluidDomainSettings.active_fields` have been updated (this happens in `update_flowsflags` & `update_obstacleflags`). But `fluid_modifier_reset_ex` also resets `FluidDomainSettings.active_fields`. If we then update pointers later in `fluid_modifier_processDomain`, we never get anything in the guiding related pointers for the new `mCurrentID` (specifically `mPhiGuideIn` will be a nullptr). This is the real reason `initGuiding()` runs a second time (it does once for `fluid_modifier_init` then again as a consequence of the call to `manta_guiding`). This patch proposes to move the resetting process from67e23b4b29**above** the refreshing of the `FluidDomainSettings.active_fields`, this way these field stay intact, we do get the first run of `initGuiding()` from `fluid_modifier_init`, manta pointers get updated with intact fields afterwards (so we then get a valid `mPhiGuideIn`), which then prevents the second run from `manta_guiding` to actually call the python script again. The fix frome968b4197bis then not needed and reverted in this patch. This should be good for LTS I think. Pull Request: https://projects.blender.org/blender/blender/pulls/117067
This commit is contained in:
parent
94b359d1f2
commit
1925c62d5f
2 changed files with 12 additions and 12 deletions
|
|
@ -58,6 +58,7 @@ MANTA::MANTA(int *res, FluidModifierData *fmd)
|
|||
mUsingDiffusion = (fds->flags & FLUID_DOMAIN_USE_DIFFUSION) && mUsingLiquid;
|
||||
mUsingViscosity = (fds->flags & FLUID_DOMAIN_USE_VISCOSITY) && mUsingLiquid;
|
||||
mUsingMVel = (fds->flags & FLUID_DOMAIN_USE_SPEED_VECTORS) && mUsingLiquid;
|
||||
mUsingGuiding = (fds->flags & FLUID_DOMAIN_USE_GUIDE);
|
||||
mUsingDrops = (fds->particle_type & FLUID_DOMAIN_PARTICLE_SPRAY) && mUsingLiquid;
|
||||
mUsingBubbles = (fds->particle_type & FLUID_DOMAIN_PARTICLE_BUBBLE) && mUsingLiquid;
|
||||
mUsingFloats = (fds->particle_type & FLUID_DOMAIN_PARTICLE_FOAM) && mUsingLiquid;
|
||||
|
|
@ -67,7 +68,6 @@ MANTA::MANTA(int *res, FluidModifierData *fmd)
|
|||
mUsingFire = (fds->active_fields & FLUID_DOMAIN_ACTIVE_FIRE) && mUsingSmoke;
|
||||
mUsingColors = (fds->active_fields & FLUID_DOMAIN_ACTIVE_COLORS) && mUsingSmoke;
|
||||
mUsingObstacle = (fds->active_fields & FLUID_DOMAIN_ACTIVE_OBSTACLE);
|
||||
mUsingGuiding = (fds->active_fields & FLUID_DOMAIN_ACTIVE_GUIDE);
|
||||
mUsingInvel = (fds->active_fields & FLUID_DOMAIN_ACTIVE_INVEL);
|
||||
mUsingOutflow = (fds->active_fields & FLUID_DOMAIN_ACTIVE_OUTFLOW);
|
||||
|
||||
|
|
|
|||
|
|
@ -3732,6 +3732,17 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *fmd,
|
|||
const char *relbase = BKE_modifier_path_relbase_from_global(ob);
|
||||
BLI_path_abs(fds->cache_directory, relbase);
|
||||
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
|
||||
/* Ensure that all flags are up to date before doing any baking and/or cache reading. */
|
||||
objs = BKE_collision_objects_create(
|
||||
depsgraph, ob, fds->fluid_group, &numobj, eModifierType_Fluid);
|
||||
|
|
@ -3746,17 +3757,6 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *fmd,
|
|||
MEM_freeN(objs);
|
||||
}
|
||||
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
|
||||
/* Fluid domain init must not fail in order to continue modifier evaluation. */
|
||||
if (!fds->fluid && !BKE_fluid_modifier_init(fmd, depsgraph, ob, scene, me)) {
|
||||
CLOG_ERROR(&LOG, "Fluid initialization failed. Should not happen!");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue