[Bf-blender-cvs] [86e24ea10cb] blender-v2.82-release: Fluid: Fixes for fluid guiding
Sebastián Barschkis
noreply at git.blender.org
Sun Feb 9 17:28:25 CET 2020
Commit: 86e24ea10cba05dcb48eccc026530edab14dfe01
Author: Sebastián Barschkis
Date: Sun Feb 9 17:15:41 2020 +0100
Branches: blender-v2.82-release
https://developer.blender.org/rB86e24ea10cba05dcb48eccc026530edab14dfe01
Fluid: Fixes for fluid guiding
Fluid guiding functionality was broken in the bake / read cache loop in fluid.c. Committing this to the release branch as otherwise fluid guiding would not have worked as expected (i.e. not at all).
===================================================================
M intern/mantaflow/intern/MANTA_main.cpp
M intern/mantaflow/intern/strings/fluid_script.h
M release/scripts/startup/bl_ui/properties_physics_fluid.py
M source/blender/blenkernel/intern/fluid.c
M source/blender/editors/physics/physics_fluid.c
===================================================================
diff --git a/intern/mantaflow/intern/MANTA_main.cpp b/intern/mantaflow/intern/MANTA_main.cpp
index cd496ac0c01..f13dc4e5f52 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -2001,6 +2001,9 @@ int MANTA::bakeGuiding(FluidModifierData *mmd, int framenr)
std::string gformat = getCacheFileEnding(mmd->domain->cache_data_format);
+ bool final_cache = (mmd->domain->cache_type == FLUID_DOMAIN_CACHE_FINAL);
+ std::string resumable_cache = (final_cache) ? "False" : "True";
+
BLI_path_join(cacheDirGuiding,
sizeof(cacheDirGuiding),
mmd->domain->cache_directory,
@@ -2010,7 +2013,7 @@ int MANTA::bakeGuiding(FluidModifierData *mmd, int framenr)
ss.str("");
ss << "bake_guiding_" << mCurrentID << "('" << escapeSlashes(cacheDirGuiding) << "', " << framenr
- << ", '" << gformat << "')";
+ << ", '" << gformat << "', " << resumable_cache << ")";
pythonCommands.push_back(ss.str());
runPythonString(pythonCommands);
diff --git a/intern/mantaflow/intern/strings/fluid_script.h b/intern/mantaflow/intern/strings/fluid_script.h
index f66f2fadcb1..babcdd7551e 100644
--- a/intern/mantaflow/intern/strings/fluid_script.h
+++ b/intern/mantaflow/intern/strings/fluid_script.h
@@ -559,12 +559,9 @@ def bake_particles_$ID$(path_data, path_particles, framenr, format_data, format_
const std::string fluid_bake_guiding =
"\n\
-def bake_guiding_process_$ID$(framenr, format_guiding, path_guiding):\n\
+def bake_guiding_process_$ID$(framenr, format_guiding, path_guiding, resumable):\n\
mantaMsg('Bake fluid guiding')\n\
\n\
- if framenr>1:\n\
- fluid_load_guiding_$ID$(path_guiding, framenr-1, format_guiding)\n\
- \n\
# Average out velocities from multiple guiding objects at one cell\n\
x_guidevel_s$ID$.safeDivide(numGuides_s$ID$)\n\
y_guidevel_s$ID$.safeDivide(numGuides_s$ID$)\n\
@@ -582,13 +579,13 @@ def bake_guiding_process_$ID$(framenr, format_guiding, path_guiding):\n\
extrapolateVec3Simple(vel=guidevelC_s$ID$, phi=phiGuideIn_s$ID$, distance=4, inside=False)\n\
resampleVec3ToMac(source=guidevelC_s$ID$, target=guidevel_sg$ID$)\n\
\n\
- fluid_save_guiding_$ID$(path_guiding, framenr, format_guiding)\n\
+ fluid_save_guiding_$ID$(path_guiding, framenr, format_guiding, resumable)\n\
\n\
-def bake_guiding_$ID$(path_guiding, framenr, format_guiding):\n\
+def bake_guiding_$ID$(path_guiding, framenr, format_guiding, resumable):\n\
if not withMPBake or isWindows:\n\
- bake_guiding_process_$ID$(framenr, format_guiding, path_guiding)\n\
+ bake_guiding_process_$ID$(framenr, format_guiding, path_guiding, resumable)\n\
else:\n\
- fluid_cache_multiprocessing_start_$ID$(function=bake_guiding_process_$ID$, framenr=framenr, format_guiding=format_guiding, path_guiding=path_guiding)\n";
+ fluid_cache_multiprocessing_start_$ID$(function=bake_guiding_process_$ID$, framenr=framenr, format_guiding=format_guiding, path_guiding=path_guiding, resumable=resumable)\n";
//////////////////////////////////////////////////////////////////////
// IMPORT
diff --git a/release/scripts/startup/bl_ui/properties_physics_fluid.py b/release/scripts/startup/bl_ui/properties_physics_fluid.py
index 2a918f0c58b..807ce5a81b8 100644
--- a/release/scripts/startup/bl_ui/properties_physics_fluid.py
+++ b/release/scripts/startup/bl_ui/properties_physics_fluid.py
@@ -162,9 +162,6 @@ class PHYSICS_PT_settings(PhysicButtonsPanel, Panel):
if md.fluid_type == 'DOMAIN':
domain = md.domain_settings
- # Deactivate UI if guides are enabled but not baked yet.
- layout.active = not self.check_domain_has_unbaked_guide(domain)
-
is_baking_any = domain.is_cache_baking_any
has_baked_data = domain.has_cache_baked_data
@@ -176,7 +173,9 @@ class PHYSICS_PT_settings(PhysicButtonsPanel, Panel):
flow.enabled = not is_baking_any and not has_baked_data
col = flow.column()
+ col.enabled = not domain.has_cache_baked_guide
col.prop(domain, "resolution_max", text="Resolution Divisions")
+ col = flow.column()
col.prop(domain, "time_scale", text="Time Scale")
col.prop(domain, "cfl_condition", text="CFL Number")
@@ -201,7 +200,17 @@ class PHYSICS_PT_settings(PhysicButtonsPanel, Panel):
if domain.cache_type == 'MODULAR':
col.separator()
+
+ # Deactivate bake operator if guides are enabled but not baked yet.
+ note_flag = True
+ if self.check_domain_has_unbaked_guide(domain) and domain.cache_type == 'MODULAR':
+ note = layout.split()
+ note_flag = False
+ note.enabled = note_flag
+ note.label(icon='INFO', text="Unbaked Guides: Bake Guides or disable them.")
+
split = layout.split()
+ split.enabled = note_flag
bake_incomplete = (domain.cache_frame_pause_data < domain.cache_frame_end)
if domain.has_cache_baked_data and not domain.is_cache_baking_data and bake_incomplete:
@@ -354,10 +363,13 @@ class PHYSICS_PT_smoke_dissolve(PhysicButtonsPanel, Panel):
return (context.engine in cls.COMPAT_ENGINES)
def draw_header(self, context):
- md = context.fluid
- domain = md.domain_settings
+ md = context.fluid.domain_settings
+ domain = context.fluid.domain_settings
+
+ is_baking_any = domain.is_cache_baking_any
- self.layout.prop(domain, "use_dissolve_smoke", text="")
+ self.layout.enabled = not is_baking_any
+ self.layout.prop(md, "use_dissolve_smoke", text="")
def draw(self, context):
layout = self.layout
@@ -433,6 +445,11 @@ class PHYSICS_PT_liquid(PhysicButtonsPanel, Panel):
def draw_header(self, context):
md = context.fluid.domain_settings
+ domain = context.fluid.domain_settings
+
+ is_baking_any = domain.is_cache_baking_any
+
+ self.layout.enabled = not is_baking_any
self.layout.prop(md, "use_flip_particles", text="")
def draw(self, context):
@@ -618,6 +635,12 @@ class PHYSICS_PT_adaptive_domain(PhysicButtonsPanel, Panel):
if not PhysicButtonsPanel.poll_gas_domain(context):
return False
+ md = context.fluid
+ domain = md.domain_settings
+ # Effector guides require a fixed domain size
+ if domain.use_guide and domain.guide_source == 'EFFECTOR':
+ return False
+
return (context.engine in cls.COMPAT_ENGINES)
def draw_header(self, context):
@@ -678,9 +701,7 @@ class PHYSICS_PT_noise(PhysicButtonsPanel, Panel):
layout.use_property_split = True
domain = context.fluid.domain_settings
-
- # Deactivate UI if guides are enabled but not baked yet.
- layout.enabled = domain.use_noise and not self.check_domain_has_unbaked_guide(domain)
+ layout.enabled = domain.use_noise
is_baking_any = domain.is_cache_baking_any
has_baked_noise = domain.has_cache_baked_noise
@@ -701,8 +722,16 @@ class PHYSICS_PT_noise(PhysicButtonsPanel, Panel):
if domain.cache_type == 'MODULAR':
col.separator()
+ # Deactivate bake operator if data has not been baked yet.
+ note_flag = True
+ if domain.use_noise and not domain.has_cache_baked_data and domain.cache_type == 'MODULAR':
+ note = layout.split()
+ note_flag = False
+ note.enabled = note_flag
+ note.label(icon='INFO', text="Unbaked Data: Bake Data first.")
+
split = layout.split()
- split.enabled = domain.has_cache_baked_data
+ split.enabled = domain.has_cache_baked_data and note_flag
bake_incomplete = (domain.cache_frame_pause_noise < domain.cache_frame_end)
if domain.has_cache_baked_noise and not domain.is_cache_baking_noise and bake_incomplete:
@@ -744,9 +773,7 @@ class PHYSICS_PT_mesh(PhysicButtonsPanel, Panel):
layout.use_property_split = True
domain = context.fluid.domain_settings
-
- # Deactivate UI if guides are enabled but not baked yet.
- layout.enabled = domain.use_mesh and not self.check_domain_has_unbaked_guide(domain)
+ layout.enabled = domain.use_mesh
is_baking_any = domain.is_cache_baking_any
has_baked_mesh = domain.has_cache_baked_mesh
@@ -780,8 +807,16 @@ class PHYSICS_PT_mesh(PhysicButtonsPanel, Panel):
if domain.cache_type == 'MODULAR':
col.separator()
+ # Deactivate bake operator if data has not been baked yet.
+ note_flag = True
+ if domain.use_mesh and not domain.has_cache_baked_data and domain.cache_type == 'MODULAR':
+ note = layout.split()
+ note_flag = False
+ note.enabled = note_flag
+ note.label(icon='INFO', text="Unbaked Data: Bake Data first.")
+
split = layout.split()
- split.enabled = domain.has_cache_baked_data
+ split.enabled = domain.has_cache_baked_data and note_flag
bake_incomplete = (domain.cache_frame_pause_mesh < domain.cache_frame_end)
if domain.has_cache_baked_mesh and not domain.is_cache_baking_mesh and bake_incomplete:
@@ -817,9 +852,6 @@ class PHYSICS_PT_particles(PhysicButtonsPanel, Panel):
domain = context.fluid.domain_settings
- # Deactivate UI if guides are enabled but not baked yet.
- layout.enabled = not self.check_domain_has_unbaked_guide(domain)
-
is_baking_any = domain.is_cache_baking_any
has_baked_particles = domain.has_cache_baked_particles
using_particles = domain.use_spray_particles or domain.use_foam_particles or domain.use_bubble_particles
@@ -887,8 +919,17 @@ class PHYSICS_PT_particles(PhysicButtonsPanel, Panel):
if domain.cache_type == 'MODULAR':
col.separator()
+ # Deactivate bake operator if data has not been baked y
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list