Commit: b9d1c5cb77657d6d69afc5fabf3b41c325828c86
Author: Sebastián Barschkis
Date:   Sat Jan 2 17:36:47 2016 +0100
Branches: fluid-mantaflow
https://developer.blender.org/rBb9d1c5cb77657d6d69afc5fabf3b41c325828c86

high res fixes

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

M       intern/smoke/intern/MANTA.cpp
M       intern/smoke/intern/scenarios/smoke.h

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

diff --git a/intern/smoke/intern/MANTA.cpp b/intern/smoke/intern/MANTA.cpp
index 0e065cc..f17e0b4 100644
--- a/intern/smoke/intern/MANTA.cpp
+++ b/intern/smoke/intern/MANTA.cpp
@@ -384,9 +384,12 @@ std::string 
Manta_API::get_manta_smoke_script(SmokeModifierData *smd)
     std::string smoke_script = "";
        
        // Check if high res is enabled
+       // Need to check if wt exists and NOT just check if high res flag is 
set (smd->domain->flags & MOD_SMOKE_HIGHRES)
+       // because wt might not exist, i.e. when FLUID_3D constructor is called 
before WTURBULENCE constructor
        if (smd->domain->wt) {
                smoke_script = smoke_setup_high + smoke_import_high + 
smoke_step_high;
        } else {
+               // TODO: Need to figure out how to handle liquids when high 
resolution grids are enabled, not just for low res grids
                if (smd->domain->flags & MOD_SMOKE_MANTA_USE_LIQUID)
                        smoke_script = smoke_setup_low  + liquid_step_low;
                else
@@ -452,7 +455,7 @@ std::string Manta_API::getRealValue( const std::string& 
varName, SmokeModifierDa
                ss << smd->domain->wt->getResBig()[0];
        else if (varName == "HRESY")
                if (is2D) {     ss << smd->domain->wt->getResBig()[2];}
-               else{           ss << smd->domain->wt->getResBig()[1];}
+               else {          ss << smd->domain->wt->getResBig()[1];}
        else if (varName == "HRESZ")
                if (is2D) {     ss << 1;}
                else {          ss << smd->domain->wt->getResBig()[2];}
@@ -579,14 +582,22 @@ std::string Manta_API::parseScript(const string& 
setup_string, SmokeModifierData
 
 void Manta_API::manta_export_grids(SmokeModifierData *smd)
 {
+       // Export the scene file
        std::string smoke_script = get_manta_smoke_script(smd);
-       std::string final_script = Manta_API::parseScript(smoke_script, smd) + 
standalone;
+       
+       std::string final_script = "";
+       if (smd->domain->flags & MOD_SMOKE_HIGHRES) {
+               final_script = Manta_API::parseScript(smoke_script, smd) + 
standalone_high;
+       } else {
+               final_script = Manta_API::parseScript(smoke_script, smd) + 
standalone_low;
+       }
        
        ofstream myfile;
-       myfile.open (smd->domain->_manta_filepath);
+       myfile.open(smd->domain->_manta_filepath);
        myfile << final_script;
        myfile.close();
        
+       // Run python environment to export grids, that is, create the grid 
files
        PyGILState_STATE gilstate = PyGILState_Ensure();
        if (smd->domain->flags & MOD_SMOKE_HIGHRES) {
                PyRun_SimpleString(Manta_API::parseScript(smoke_export_high, 
smd).c_str());
@@ -702,6 +713,7 @@ void Manta_API::updatePointers(FLUID_3D *fluid)
 
 void Manta_API::updateHighResPointers(WTURBULENCE *wt)
 {
+       cout << "Updating pointers high res" << endl;
        wt->_densityBig = (float* 
)pointerFromString(getGridPointer("xl_density", "xl"));;
        if (wt->using_colors) {
                wt->_color_rBig = (float* 
)pointerFromString(getGridPointer("color_r_high", "xl"));
diff --git a/intern/smoke/intern/scenarios/smoke.h 
b/intern/smoke/intern/scenarios/smoke.h
index 5e7afc4..f8c045f 100644
--- a/intern/smoke/intern/scenarios/smoke.h
+++ b/intern/smoke/intern/scenarios/smoke.h
@@ -120,12 +120,6 @@ color_b_low.add(density) \n\
 color_b_low.multConst(manta_color_b) \n\
 using_colors = True\n";
 
-const string smoke_del_colors_low = "\n\
-del color_r_low \n\
-del color_g_low \n\
-del color_b_low \n\
-using_colors = False";
-
 const string smoke_init_colors_high = "\
 print(\"Initializing colors highres\")\n\
 color_r_high.add(xl_density) \n\
@@ -136,6 +130,18 @@ color_b_high.add(xl_density) \n\
 color_b_high.multConst(manta_color_b) \n\
 using_colors = True\n";
 
+const string smoke_del_colors_low = "\n\
+del color_r_low \n\
+del color_g_low \n\
+del color_b_low \n\
+using_colors = False";
+
+const string smoke_del_colors_high = "\n\
+del color_r_high \n\
+del color_g_high \n\
+del color_b_high \n\
+using_colors = False";
+
 const string smoke_init_heat_low = "\
 print(\"Initializing heat lowres\")\n\
 using_heat = True\n";
@@ -148,29 +154,42 @@ const string smoke_init_fire_high = "\
 print(\"Initializing fire highres\")\n\
 using_fire = True\n";
 
-const string smoke_del_colors_high = "\n\
-del color_r_high \n\
-del color_g_high \n\
-del color_b_high \n\
-using_colors = False";
-
-const string standalone = "\n\
+const string standalone_low = "\n\
 if (GUI):\n\
   gui=Gui()\n\
   gui.show()\n\
   gui.pause()\n\
 \n\
-import_grids()\n\
+import_grids_low()\n\
 \n\
 for step in range(1000):\n\
   apply_inflow()\n\
   \n\
   print('Step '+ str(step))\n\
   if using_fire:\n\
-    process_burn()\n\
+    process_burn_low()\n\
   step_low()\n\
   if using_fire:\n\
-    update_flame()\n\
+    update_flame_low()\n\
+";
+
+const string standalone_high = "\n\
+if (GUI):\n\
+  gui=Gui()\n\
+  gui.show()\n\
+  gui.pause()\n\
+\n\
+import_grids_high()\n\
+\n\
+for step in range(1000):\n\
+  apply_inflow()\n\
+  \n\
+  print('Step '+ str(step))\n\
+  if using_fire:\n\
+    process_burn_high()\n\
+  step_high()\n\
+  if using_fire:\n\
+    update_flame_high()\n\
 ";
 
 /* SMOKE */
@@ -240,16 +259,18 @@ def step_high():\n\
   for o in range(octaves):\n\
     for i in range(uvs):\n\
       uvWeight = getUvWeight(uv[i])\n\
-      applyNoiseVec3( flags=xl_flags, target=xl_vel, noise=xl_wltnoise, 
scale=sStr * uvWeight, scaleSpatial=sPos , weight=energy, uv=uv[i] )\n\
+      applyNoiseVec3(flags=xl_flags, target=xl_vel, noise=xl_wltnoise, 
scale=sStr * uvWeight, scaleSpatial=sPos , weight=energy, uv=uv[i])\n\
     sStr *= 0.06 # magic kolmogorov factor \n\
     sPos *= 2.0 \n\
   for substep in range(upres):\n\
     advectSemiLagrange(flags=xl_flags, vel=xl_vel, grid=xl_density, 
order=$ADVECT_ORDER$)\n\
     if using_colors: \n\
+      print ('Advecting colors high')\n\
       advectSemiLagrange(flags=xl_flags, vel=xl_vel, grid=color_r_high, 
order=$ADVECT_ORDER$)\n\
       advectSemiLagrange(flags=xl_flags, vel=xl_vel, grid=color_g_high, 
order=$ADVECT_ORDER$)\n\
       advectSemiLagrange(flags=xl_flags, vel=xl_vel, grid=color_b_high, 
order=$ADVECT_ORDER$)\n\
     if using_fire: \n\
+      print ('Advecting fire high')\n\
       advectSemiLagrange(flags=xl_flags, vel=xl_vel, grid=fuel_high, 
order=$ADVECT_ORDER$)\n\
       advectSemiLagrange(flags=xl_flags, vel=xl_vel, grid=react_high, 
order=$ADVECT_ORDER$)\n\
   xl.step()\n\
@@ -333,7 +354,7 @@ print('Grids exported')\n\
 ";
 
 const string smoke_import_low = "\n\
-def import_grids():\n\
+def import_grids_low():\n\
   print('Importing grids')\n\
   density.load('$MANTA_EXPORT_PATH$density_low.uni')\n\
   flags.load('$MANTA_EXPORT_PATH$flags_low.uni')\n\
@@ -356,7 +377,7 @@ def import_grids():\n\
 ";
 
 const string smoke_import_high = "\n\
-def import_grids():\n\
+def import_grids_high():\n\
   print('Importing grids')\n\
   vel.load('$MANTA_EXPORT_PATH$vel.uni')\n\
   xl_density.load('$MANTA_EXPORT_PATH$xl_density.uni')\n\

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to