[Bf-blender-cvs] [79ea5f6324f] fluid-mantaflow: added guiding parameters to UI

Sebastián Barschkis noreply at git.blender.org
Fri Aug 25 12:40:26 CEST 2017


Commit: 79ea5f6324f054faad6b57b07a9e8904ef39b0a1
Author: Sebastián Barschkis
Date:   Fri Aug 25 12:32:45 2017 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rB79ea5f6324f054faad6b57b07a9e8904ef39b0a1

added guiding parameters to UI

alpha and beta parameters are used to control lag and size of fluid guiding

===================================================================

M	intern/mantaflow/intern/FLUID.cpp
M	intern/mantaflow/intern/FLUID.h
M	intern/mantaflow/intern/strings/liquid_script.h
M	intern/mantaflow/intern/strings/shared_script.h
M	intern/mantaflow/intern/strings/smoke_script.h
M	release/scripts/startup/bl_ui/properties_physics_smoke.py
M	source/blender/blenkernel/intern/smoke.c
M	source/blender/makesdna/DNA_smoke_types.h
M	source/blender/makesrna/intern/rna_smoke.c

===================================================================

diff --git a/intern/mantaflow/intern/FLUID.cpp b/intern/mantaflow/intern/FLUID.cpp
index 18fec6791cc..d1294a4b649 100644
--- a/intern/mantaflow/intern/FLUID.cpp
+++ b/intern/mantaflow/intern/FLUID.cpp
@@ -127,7 +127,8 @@ FLUID::FLUID(int *res, SmokeModifierData *smd) : mCurrentID(++solverID)
 	mPhiOutIn       = NULL;
 	mPhi            = NULL;
 
-	mNumGuide = NULL;
+	// Fluid guiding
+	mNumGuide    = NULL;
 
 	mNumVertices  = 0;
 	mNumNormals   = 0;
@@ -213,6 +214,7 @@ void FLUID::initDomain(SmokeModifierData *smd)
 		+ manta_debuglevel
 		+ fluid_variables_low
 		+ fluid_solver_low
+		+ fluid_export_low
 		+ fluid_adaptive_time_stepping_low;
 	std::string finalString = parseScript(tmpString, smd);
 	mCommands.clear();
@@ -448,6 +450,7 @@ FLUID::~FLUID()
 
 	// Cleanup multigrid
 	tmpString += fluid_multigrid_cleanup_low;
+	tmpString += fluid_guiding_cleanup_low;
 	if (mUsingHighRes) tmpString += fluid_multigrid_cleanup_high;
 
 	// Make sure that everything is garbage collected
@@ -506,7 +509,8 @@ FLUID::~FLUID()
 	mTextureV2      = NULL;
 	mTextureW2      = NULL;
 
-	mNumGuide = NULL;
+	// Fluid guiding
+	mNumGuide    = NULL;
 
 	// Liquid
 	mPhiIn      = NULL;
@@ -712,8 +716,10 @@ std::string FLUID::getRealValue(const std::string& varName,  SmokeModifierData *
 		ss << (smd->domain->particle_type & MOD_SMOKE_PARTICLE_FLOAT ? "True" : "False");
 	else if (varName == "USING_TRACER_PARTS")
 		ss << (smd->domain->particle_type & MOD_SMOKE_PARTICLE_TRACER ? "True" : "False");
-	else if (varName == "GUIDING_STRENGTH")
-		ss << smd->domain->guiding_strength;
+	else if (varName == "GUIDING_ALPHA")
+		ss << smd->domain->guiding_alpha;
+	else if (varName == "GUIDING_BETA")
+		ss << smd->domain->guiding_beta;
 	else if (varName == "GRAVITY_X")
 		ss << smd->domain->gravity[0];
 	else if (varName == "GRAVITY_Y")
@@ -855,8 +861,9 @@ void FLUID::exportSmokeData(SmokeModifierData *smd)
 
 	char parent_dir[1024];
 	BLI_split_dir_part(smd->domain->manta_filepath, parent_dir, sizeof(parent_dir));
-	
+
 	FLUID::saveSmokeData(parent_dir);
+	FLUID::saveFluidData(parent_dir);
 	if (highres)
 		FLUID::saveSmokeDataHigh(parent_dir);
 }
@@ -1353,6 +1360,18 @@ void FLUID::saveParticleVelocities(char* filename)
 	runPythonString(mCommands);
 }
 
+void FLUID::saveFluidData(char *pathname)
+{
+	std::string path(pathname);
+
+	mCommands.clear();
+	std::ostringstream save_fluid_data_low_;
+	save_fluid_data_low_ <<  "save_fluid_data_low_" << mCurrentID << "(r'" << path << "')";
+	mCommands.push_back(save_fluid_data_low_.str());
+
+	runPythonString(mCommands);
+}
+
 void FLUID::saveSmokeData(char *pathname)
 {
 	std::string path(pathname);
diff --git a/intern/mantaflow/intern/FLUID.h b/intern/mantaflow/intern/FLUID.h
index d01572eafba..9251cf52b33 100644
--- a/intern/mantaflow/intern/FLUID.h
+++ b/intern/mantaflow/intern/FLUID.h
@@ -74,6 +74,7 @@ public:
 	void saveLiquidDataHigh(char *pathname);
 	void saveSmokeData(char *pathname);
 	void saveSmokeDataHigh(char *pathname);
+	void saveFluidData(char *pathname);
 
 	// Write files for particles
 	void saveParticles(char* filename);
@@ -254,13 +255,13 @@ private:
 	int* mObstacle;
 	int* mNumObstacle;
 	int* mNumGuide;
-	float *mFlame;
-	float *mFuel;
-	float *mReact;
-	float *mColorR;
-	float *mColorG;
-	float *mColorB;
-	float *mInflow;
+	float* mFlame;
+	float* mFuel;
+	float* mReact;
+	float* mColorR;
+	float* mColorG;
+	float* mColorB;
+	float* mInflow;
 	float* mDensityHigh;
 	float* mFlameHigh;
 	float* mFuelHigh;
diff --git a/intern/mantaflow/intern/strings/liquid_script.h b/intern/mantaflow/intern/strings/liquid_script.h
index 240125e3c0a..bac7b0fdcfc 100644
--- a/intern/mantaflow/intern/strings/liquid_script.h
+++ b/intern/mantaflow/intern/strings/liquid_script.h
@@ -211,6 +211,8 @@ def liquid_step_$ID$():\n\
     \n\
     # TODO (sebbas): liquid inflow\n\
     # add initial velocity\n\
+    #setForceIn(region=phiIn_s$ID$, vel=vel_s$ID$, force=vec3(0.01,0.01,-5))\n\
+    #mapGridToPartsVec3(source=vel_s$ID$, parts=pp_s$ID$, target=pVel_pp$ID$)\n\
     #mapWeights_s$ID$.clear() # mis-use mapWeights\n\
     #setInitialVelocity(flags=flags_s$ID$, vel=vel_s$ID$, invel=invel_s$ID$)\n\
     #resampleVec3ToMac(source=invel_s$ID$, target=mapWeights_s$ID$)\n\
diff --git a/intern/mantaflow/intern/strings/shared_script.h b/intern/mantaflow/intern/strings/shared_script.h
index 2c03427d400..9d27e10bb0a 100644
--- a/intern/mantaflow/intern/strings/shared_script.h
+++ b/intern/mantaflow/intern/strings/shared_script.h
@@ -81,10 +81,11 @@ using_guiding_s$ID$   = $USING_GUIDING$\n\
 \n\
 \n\
 # fluid guiding params\n\
-beta_s$ID$     = 2\n\
-tau_s$ID$      = 1.0\n\
-sigma_s$ID$    = 0.99/tau_s$ID$\n\
-theta_s$ID$    = 1.0\n";
+alpha_s$ID$ = $GUIDING_ALPHA$\n\
+beta_s$ID$  = $GUIDING_BETA$\n\
+tau_s$ID$   = 1.0\n\
+sigma_s$ID$ = 0.99/tau_s$ID$\n\
+theta_s$ID$ = 1.0\n";
 
 const std::string fluid_variables_high= "\n\
 upres_xl$ID$  = $UPRES$\n\
@@ -151,6 +152,7 @@ if 'dt_default_s$ID$'       in globals() : del dt_default_s$ID$\n\
 if 'dt_factor_s$ID$'        in globals() : del dt_factor_s$ID$\n\
 if 'fps_s$ID$'              in globals() : del fps_s$ID$\n\
 if 'dt0_s$ID$'              in globals() : del dt0_s$ID$\n\
+if 'alpha_s$ID$'             in globals() : del alpha_s$ID$\n\
 if 'beta_s$ID$'             in globals() : del beta_s$ID$\n\
 if 'tau_s$ID$'              in globals() : del tau_s$ID$\n\
 if 'sigma_s$ID$'            in globals() : del sigma_s$ID$\n\
@@ -188,6 +190,10 @@ const std::string fluid_multigrid_cleanup_high = "\n\
 mantaMsg('Cleanup multigrid high')\n\
 releaseMG(xl$ID$)\n";
 
+const std::string fluid_guiding_cleanup_low = "\n\
+mantaMsg('Cleanup guiding low')\n\
+releaseBlurPrecomp()\n";
+
 const std::string gc_collect = "\n\
 gc.collect()\n";
 
diff --git a/intern/mantaflow/intern/strings/smoke_script.h b/intern/mantaflow/intern/strings/smoke_script.h
index 7759be35073..bcd9bea9405 100644
--- a/intern/mantaflow/intern/strings/smoke_script.h
+++ b/intern/mantaflow/intern/strings/smoke_script.h
@@ -335,7 +335,6 @@ def step_low_$ID$():\n\
         extrapolateVec3Simple(vel=guidevelC_s$ID$, phi=phiGuideIn_s$ID$, distance=int(res_s$ID$/2), inside=True)\n\
         extrapolateVec3Simple(vel=guidevelC_s$ID$, phi=phiGuideIn_s$ID$, distance=1, inside=False)\n\
         resampleVec3ToMac(source=guidevelC_s$ID$, target=guidevel_s$ID$)\n\
-        guidevel_s$ID$.multConst(vec3(factorGuiding_s$ID$))\n\
     \n\
     mantaMsg('Walls')\n\
     setWallBcs(flags=flags_s$ID$, vel=vel_s$ID$, obvel=obvel_s$ID$)\n\
@@ -343,7 +342,7 @@ def step_low_$ID$():\n\
     if using_guiding_s$ID$:\n\
         mantaMsg('Guiding and pressure')\n\
         weightGuide_s$ID$.multConst(0)\n\
-        weightGuide_s$ID$.addConst(2)\n\
+        weightGuide_s$ID$.addConst(alpha_s$ID$)\n\
         PD_fluid_guiding(vel=vel_s$ID$, velT=guidevel_s$ID$, flags=flags_s$ID$, weight=weightGuide_s$ID$, blurRadius=beta_s$ID$, pressure=pressure_s$ID$, tau=tau_s$ID$, sigma=sigma_s$ID$, theta=theta_s$ID$, preconditioner=$PRECONDITIONER$, zeroPressureFixing=not doOpen_s$ID$)\n\
     else:\n\
         mantaMsg('Pressure')\n\
@@ -693,5 +692,6 @@ const std::string smoke_standalone_load = "\n\
 # import *.uni files\n\
 path_prefix = '$MANTA_EXPORT_PATH$'\n\
 load_smoke_data_low_$ID$(path_prefix)\n\
+load_fluid_data_low_$ID$(path_prefix)\n\
 if using_highres_s$ID$:\n\
     load_smoke_data_high_$ID$(path_prefix)\n";
diff --git a/release/scripts/startup/bl_ui/properties_physics_smoke.py b/release/scripts/startup/bl_ui/properties_physics_smoke.py
index 0f4de9e0a29..8adafe04eff 100644
--- a/release/scripts/startup/bl_ui/properties_physics_smoke.py
+++ b/release/scripts/startup/bl_ui/properties_physics_smoke.py
@@ -386,6 +386,30 @@ class PHYSICS_PT_smoke_particles(PhysicButtonsPanel, Panel):
         sub4.active = domain.use_tracer_particles
         sub4.prop(domain, "particle_tracer_amount", text="Amount")
 
+class PHYSICS_PT_smoke_guiding(PhysicButtonsPanel, Panel):
+    bl_label = "Fluid Guiding"
+    COMPAT_ENGINES = {'BLENDER_RENDER'}
+
+    @classmethod
+    def poll(cls, context):
+        md = context.smoke
+        rd = context.scene.render
+        return md and (md.smoke_type == 'DOMAIN') and (rd.engine in cls.COMPAT_ENGINES)
+
+    def draw(self, context):
+        layout = self.layout
+        domain = context.smoke.domain_settings
+
+        split = layout.split()
+
+        col = split.column()
+        col.enabled = not domain.point_cache.is_baked
+        col.prop(domain, "guiding_alpha", text="Strength")
+
+        col = split.column()
+        col.enabled = not domain.point_cache.is_baked
+        col.prop(domain, "guiding_beta", text="Size")
+
 class PHYSICS_PT_smoke_groups(PhysicButtonsPanel, Panel):
     bl_label = "Fluid Groups"
     bl_options = {'DEFAULT_CLOSED'}
@@ -571,6 +595,7 @@ classes = (
     PHYSICS_PT_smoke_adaptive_domain,
     PHYSICS_PT_smoke_quality,
     PHYSICS_PT_smoke_particles,
+    PHYSICS_PT_smoke_guiding,
     PHYSICS_PT_smoke_groups,
     PHYSICS_PT_smoke_cache,
     PHYSICS_PT_smoke_field_weights,
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index 68875a6bffb..f6a6474042e 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -549,7 +549,8 @@ void smokeModifier_createType(struct SmokeModifierData *smd)
 			smd->domain->particle_type = 0;
 
 			/* guiding */
-			smd->domain->guiding_strength = 6.0f;
+			smd->domain->guiding_alpha = 2.0f;
+			smd->domain->guiding_beta = 5;
 
 			/*mantaflow settings*/
 			smd->domain->manta_solver_res = 3;
@@ -678,7 +679,8 @@ void smokeModifier_copy(struct SmokeModifierData *smd, struct SmokeModifierData
 		tsmd->domain->particle_velocity_threshold = smd->domain->particle_velocity_threshold;
 		tsmd->domain->particle_bubble_rise = smd->domain->particle_bubble_rise;
 
-		tsmd->domain->guiding_strength = smd->domain->guiding_strength;
+		tsmd->domain->guiding_alpha = smd->domain->guiding_alpha;
+		tsmd->domain->guiding_beta = smd->domain->guiding_beta;
 
 		tsmd->domain->manta_solver_res = smd->domain->manta_solver_res;
 		tsmd->domain->noise_pos_scale = smd->domain->noise_pos_scale;
@@ -826,16 +828,13

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list