[Bf-blender-cvs] [730c829b25c] fluid-mantaflow: Mantaflow: Cleaned up smoke noise code

Sebastián Barschkis noreply at git.blender.org
Tue Nov 26 22:02:26 CET 2019


Commit: 730c829b25cf378c12ec9a787c542a906195e67c
Author: Sebastián Barschkis
Date:   Mon Nov 25 21:36:06 2019 +0100
Branches: fluid-mantaflow
https://developer.blender.org/rB730c829b25cf378c12ec9a787c542a906195e67c

Mantaflow: Cleaned up smoke noise code

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

M	intern/mantaflow/intern/MANTA_main.cpp
M	intern/mantaflow/intern/MANTA_main.h
M	intern/mantaflow/intern/strings/fluid_script.h
M	intern/mantaflow/intern/strings/smoke_script.h
M	source/blender/blenkernel/intern/manta.c

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

diff --git a/intern/mantaflow/intern/MANTA_main.cpp b/intern/mantaflow/intern/MANTA_main.cpp
index cf66dd438f0..9d60fb900f4 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -284,7 +284,7 @@ void MANTA::initDomain(MantaModifierData *mmd)
 void MANTA::initNoise(MantaModifierData *mmd)
 {
   std::vector<std::string> pythonCommands;
-  std::string tmpString = fluid_variables_noise + fluid_solver_noise + fluid_time_stepping_noise;
+  std::string tmpString = fluid_variables_noise + fluid_solver_noise;
   std::string finalString = parseScript(tmpString, mmd);
   pythonCommands.push_back(finalString);
 
@@ -1868,9 +1868,6 @@ void MANTA::exportSmokeScript(MantaModifierData *mmd)
 
   // Time
   manta_script += header_time + fluid_time_stepping + fluid_adapt_time_step;
-  if (noise) {
-    manta_script += fluid_time_stepping_noise;
-  }
 
   // Import
   manta_script += header_import + fluid_file_import + fluid_cache_helper + fluid_load_data +
diff --git a/intern/mantaflow/intern/MANTA_main.h b/intern/mantaflow/intern/MANTA_main.h
index dfc30d1fd99..08c39a5e0e4 100644
--- a/intern/mantaflow/intern/MANTA_main.h
+++ b/intern/mantaflow/intern/MANTA_main.h
@@ -80,7 +80,6 @@ struct MANTA {
 
   // Pointer transfer: Mantaflow -> Blender
   void updatePointers();
-  void updatePointersNoise();
 
   // Write cache
   int writeConfiguration(MantaModifierData *mmd, int framenr);
diff --git a/intern/mantaflow/intern/strings/fluid_script.h b/intern/mantaflow/intern/strings/fluid_script.h
index 86ad3777eac..36468353ec8 100644
--- a/intern/mantaflow/intern/strings/fluid_script.h
+++ b/intern/mantaflow/intern/strings/fluid_script.h
@@ -204,17 +204,6 @@ s$ID$.timestep     = dt0_s$ID$\n\
 s$ID$.timeTotal    = timeTotal_s$ID$\n\
 #mantaMsg('timestep: ' + str(s$ID$.timestep) + ' // timPerFrame: ' + str(s$ID$.timePerFrame) + ' // frameLength: ' + str(s$ID$.frameLength) + ' // timeTotal: ' + str(s$ID$.timeTotal) )\n";
 
-const std::string fluid_time_stepping_noise =
-    "\n\
-mantaMsg('Fluid adaptive time stepping noise')\n\
-sn$ID$.frameLength = frameLength_s$ID$\n\
-sn$ID$.timestepMin = s$ID$.timestepMin\n\
-sn$ID$.timestepMax = s$ID$.timestepMax\n\
-sn$ID$.cfl         = cflCond_s$ID$\n\
-sn$ID$.timestep    = dt0_s$ID$\n\
-sn$ID$.timeTotal   = timeTotal_s$ID$\n\
-#mantaMsg('noise timestep: ' + str(sn$ID$.timestep) + ' // timPerFrame: ' + str(sn$ID$.timePerFrame) + ' // frameLength: ' + str(sn$ID$.frameLength) + ' // timeTotal: ' + str(sn$ID$.timeTotal) )\n";
-
 const std::string fluid_adapt_time_step =
     "\n\
 def fluid_adapt_time_step_$ID$():\n\
@@ -407,11 +396,13 @@ if 'liquid_data_dict_s$ID$' in globals(): liquid_data_dict_s$ID$.clear()\n\
 if 'liquid_flip_dict_s$ID$' in globals(): liquid_flip_dict_s$ID$.clear()\n\
 if 'liquid_mesh_dict_s$ID$' in globals(): liquid_mesh_dict_s$ID$.clear()\n\
 if 'liquid_meshvel_dict_s$ID$' in globals(): liquid_meshvel_dict_s$ID$.clear()\n\
+if 'liquid_particles_dict_s$ID$' in globals(): liquid_particles_dict_s$ID$.clear()\n\
 if 'smoke_data_dict_s$ID$' in globals(): smoke_data_dict_s$ID$.clear()\n\
 if 'smoke_noise_dict_s$ID$' in globals(): smoke_noise_dict_s$ID$.clear()\n\
 if 'fluid_particles_dict_s$ID$' in globals(): fluid_particles_dict_s$ID$.clear()\n\
 if 'fluid_guiding_dict_s$ID$' in globals(): fluid_guiding_dict_s$ID$.clear()\n\
 if 'fluid_data_dict_s$ID$' in globals(): fluid_data_dict_s$ID$.clear()\n\
+if 'fluid_vel_dict_s$ID$' in globals(): fluid_vel_dict_s$ID$.clear()\n\
 \n\
 # Delete all childs from objects (e.g. pdata for particles)\n\
 mantaMsg('Release solver childs childs')\n\
@@ -520,6 +511,7 @@ def bake_noise_process_$ID$(framenr, format_data, format_noise, path_data, path_
     \n\
     sn$ID$.frame = framenr\n\
     sn$ID$.timeTotal = (framenr-1) * frameLength_s$ID$\n\
+    sn$ID$.timestep  = dt0_s$ID$\n\
     mantaMsg('sn$ID$.timeTotal: ' + str(sn$ID$.timeTotal))\n\
     \n\
     smoke_step_noise_$ID$(framenr)\n\
@@ -538,6 +530,7 @@ def bake_mesh_process_$ID$(framenr, format_data, format_mesh, format_particles,
     \n\
     sm$ID$.frame = framenr\n\
     sm$ID$.timeTotal = (framenr-1) * frameLength_s$ID$\n\
+    sm$ID$.timestep  = dt0_s$ID$\n\
     \n\
     #if using_smoke_s$ID$:\n\
         # TODO (sebbas): Future update could include smoke mesh (vortex sheets)\n\
@@ -560,6 +553,7 @@ def bake_particles_process_$ID$(framenr, format_data, format_particles, path_dat
     \n\
     sp$ID$.frame = framenr\n\
     sp$ID$.timeTotal = (framenr-1) * frameLength_s$ID$\n\
+    sn$ID$.timestep  = dt0_s$ID$\n\
     \n\
     fluid_load_data_$ID$(path_data, framenr, format_data)\n\
     #if using_smoke_s$ID$:\n\
@@ -648,8 +642,8 @@ const std::string fluid_load_vel =
     "\n\
 def fluid_load_vel_$ID$(path, framenr, file_format):\n\
     mantaMsg('Fluid load vel, frame ' + str(framenr))\n\
-    vel_dict = dict(vel=guidevel_sg$ID$)\n\
-    fluid_file_import_s$ID$(dict=vel_dict, path=path, framenr=framenr, file_format=file_format)\n";
+    fluid_vel_dict = dict(vel=guidevel_sg$ID$)\n\
+    fluid_file_import_s$ID$(dict=fluid_vel_dict, path=path, framenr=framenr, file_format=file_format)\n";
 
 //////////////////////////////////////////////////////////////////////
 // EXPORT
diff --git a/intern/mantaflow/intern/strings/smoke_script.h b/intern/mantaflow/intern/strings/smoke_script.h
index ca60ff068ff..08952e3571a 100644
--- a/intern/mantaflow/intern/strings/smoke_script.h
+++ b/intern/mantaflow/intern/strings/smoke_script.h
@@ -136,22 +136,17 @@ color_b_sn$ID$    = 0\n\
 wltnoise_sn$ID$   = sn$ID$.create(NoiseField, fixedSeed=265, loadFromFile=True)\n\
 \n\
 mantaMsg('Initializing UV Grids')\n\
-uv_s$ID$ = [] # list for UV grids\n\
-for i in range(uvs_s$ID$):\n\
-    uvGrid_s$ID$ = s$ID$.create(VecGrid)\n\
-    uv_s$ID$.append(uvGrid_s$ID$)\n\
-    resetUvGrid(target=uv_s$ID$[i], offset=uvs_offset_s$ID$)\n\
+uvGrid0_s$ID$ = s$ID$.create(VecGrid)\n\
+uvGrid1_s$ID$ = s$ID$.create(VecGrid)\n\
+resetUvGrid(target=uvGrid0_s$ID$, offset=uvs_offset_s$ID$)\n\
+resetUvGrid(target=uvGrid1_s$ID$, offset=uvs_offset_s$ID$)\n\
 \n\
 # Sync UV and texture grids\n\
-copyVec3ToReal(source=uv_s$ID$[0], targetX=texture_u_s$ID$, targetY=texture_v_s$ID$, targetZ=texture_w_s$ID$)\n\
-copyVec3ToReal(source=uv_s$ID$[1], targetX=texture_u2_s$ID$, targetY=texture_v2_s$ID$, targetZ=texture_w2_s$ID$)\n\
+copyVec3ToReal(source=uvGrid0_s$ID$, targetX=texture_u_s$ID$, targetY=texture_v_s$ID$, targetZ=texture_w_s$ID$)\n\
+copyVec3ToReal(source=uvGrid1_s$ID$, targetX=texture_u2_s$ID$, targetY=texture_v2_s$ID$, targetZ=texture_w2_s$ID$)\n\
 \n\
 # Keep track of important objects in dict to load them later on\n\
-smoke_noise_dict_s$ID$ = dict(density_noise=density_sn$ID$)\n\
-for i in range(uvs_s$ID$):\n\
-    k_s$ID$ = 'uvGrid' + str(i)\n\
-    v_s$ID$ = uv_s$ID$[i]\n\
-    smoke_noise_dict_s$ID$[k_s$ID$] = v_s$ID$\n";
+smoke_noise_dict_s$ID$ = dict(density_noise=density_sn$ID$, uv0_noise=uvGrid0_s$ID$, uv1_noise=uvGrid1_s$ID$)\n";
 
 //////////////////////////////////////////////////////////////////////
 // ADDITIONAL GRIDS
@@ -168,10 +163,9 @@ color_g_in_s$ID$ = s$ID$.create(RealGrid)\n\
 color_b_in_s$ID$ = s$ID$.create(RealGrid)\n\
 \n\
 # Add objects to dict to load them later on\n\
-tmpDict_s$ID$ = dict(color_r=color_r_s$ID$, color_g=color_g_s$ID$, color_b=color_b_s$ID$)\n\
-smoke_data_dict_s$ID$.update(tmpDict_s$ID$)\n\
-tmpDict_s$ID$ = dict(color_r_in=color_r_in_s$ID$, color_g_in=color_g_in_s$ID$, color_b_in=color_b_in_s$ID$)\n\
-smoke_data_dict_s$ID$.update(tmpDict_s$ID$)\n";
+if 'smoke_data_dict_s$ID$' in globals():\n\
+    smoke_data_dict_s$ID$.update(color_r=color_r_s$ID$, color_g=color_g_s$ID$, color_b=color_b_s$ID$)\n\
+    smoke_data_dict_s$ID$.update(color_r_in=color_r_in_s$ID$, color_g_in=color_g_in_s$ID$, color_b_in=color_b_in_s$ID$)\n";
 
 const std::string smoke_alloc_colors_noise =
     "\
@@ -181,8 +175,8 @@ color_g_sn$ID$ = sn$ID$.create(RealGrid)\n\
 color_b_sn$ID$ = sn$ID$.create(RealGrid)\n\
 \n\
 # Add objects to dict to load them later on\n\
-tmpDict_s$ID$ = dict(color_r_noise=color_r_sn$ID$, color_g_noise=color_g_sn$ID$, color_b_noise=color_b_sn$ID$)\n\
-smoke_noise_dict_s$ID$.update(tmpDict_s$ID$)\n";
+if 'smoke_noise_dict_s$ID$' in globals():\n\
+    smoke_noise_dict_s$ID$.update(color_r_noise=color_r_sn$ID$, color_g_noise=color_g_sn$ID$, color_b_noise=color_b_sn$ID$)\n";
 
 const std::string smoke_init_colors =
     "\n\
@@ -211,8 +205,8 @@ heat_s$ID$   = s$ID$.create(RealGrid)\n\
 heatIn_s$ID$ = s$ID$.create(RealGrid)\n\
 \n\
 # Add objects to dict to load them later on\n\
-tmpDict_s$ID$ = dict(heat=heat_s$ID$, heatIn=heatIn_s$ID$,)\n\
-smoke_data_dict_s$ID$.update(tmpDict_s$ID$)\n";
+if 'smoke_data_dict_s$ID$' in globals():\n\
+    smoke_data_dict_s$ID$.update(heat=heat_s$ID$, heatIn=heatIn_s$ID$)\n";
 
 const std::string smoke_alloc_fire =
     "\n\
@@ -224,10 +218,9 @@ fuelIn_s$ID$  = s$ID$.create(RealGrid)\n\
 reactIn_s$ID$ = s$ID$.create(RealGrid)\n\
 \n\
 # Add objects to dict to load them later on\n\
-tmpDict_s$ID$ = dict(flame=flame_s$ID$, fuel=fuel_s$ID$, react=react_s$ID$,)\n\
-smoke_data_dict_s$ID$.update(tmpDict_s$ID$)\n\
-tmpDict_s$ID$ = dict(fuelIn=fuelIn_s$ID$, reactIn=reactIn_s$ID$,)\n\
-smoke_data_dict_s$ID$.update(tmpDict_s$ID$)\n";
+if 'smoke_data_dict_s$ID$' in globals():\n\
+    smoke_data_dict_s$ID$.update(flame=flame_s$ID$, fuel=fuel_s$ID$, react=react_s$ID$)\n\
+    smoke_data_dict_s$ID$.update(fuelIn=fuelIn_s$ID$, reactIn=reactIn_s$ID$)\n";
 
 const std::string smoke_alloc_fire_noise =
     "\n\
@@ -237,8 +230,8 @@ fuel_sn$ID$  = sn$ID$.create(RealGrid)\n\
 react_sn$ID$ = sn$ID$.create(RealGrid)\n\
 \n\
 # Add objects to dict to load them later on\n\
-tmpDict_s$ID$ = dict(flame_noise=flame_sn$ID$, fuel_noise=fuel_sn$ID$, react_noise=react_sn$ID$)\n\
-smoke_noise_dict_s$ID$.update(tmpDict_s$ID$)\n";
+if 'smoke_noise_dict_s$ID$' in globals():\n\
+    smoke_noise_dict_s$ID$.update(flame_noise=flame_sn$ID$, fuel_noise=fuel_sn$ID$, react_noise=react_sn$ID$)\n";
 
 //////////////////////////////////////////////////////////////////////
 // STEP FUNCTIONS
@@ -386,15 +379,15 @@ def smoke_step_noise_$ID$(framenr):\n\
     mantaMsg('Manta step noise, frame ' + str(frame

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list