Commit: 037662d04bdf0619c5c8888dbd992da5a1330c53
Author: Sebastián Barschkis
Date:   Tue Nov 15 12:01:31 2016 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rB037662d04bdf0619c5c8888dbd992da5a1330c53

added pre and post step functions

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

M       intern/mantaflow/intern/FLUID.cpp
M       intern/mantaflow/intern/strings/liquid_script.h
M       intern/mantaflow/intern/strings/smoke_script.h

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

diff --git a/intern/mantaflow/intern/FLUID.cpp 
b/intern/mantaflow/intern/FLUID.cpp
index 7090476..2a1cde8 100644
--- a/intern/mantaflow/intern/FLUID.cpp
+++ b/intern/mantaflow/intern/FLUID.cpp
@@ -218,7 +218,9 @@ void FLUID::initSmoke(SmokeModifierData *smd)
                + smoke_bounds_low
                + smoke_adaptive_step
                + smoke_export_low
-               + smoke_step_low;
+               + smoke_pre_step_low
+               + smoke_step_low
+               + smoke_post_step_low;
        std::string finalString = parseScript(tmpString, smd);
        mCommands.clear();
        mCommands.push_back(finalString);
@@ -234,11 +236,13 @@ void FLUID::initSmokeHigh(SmokeModifierData *smd)
                + smoke_bounds_high
                + smoke_wavelet_turbulence_noise
                + smoke_export_high
-               + smoke_step_high;
+               + smoke_pre_step_high
+               + smoke_step_high
+               + smoke_post_step_high;
        std::string finalString = parseScript(tmpString, smd);
        mCommands.clear();
        mCommands.push_back(finalString);
-               
+
        runPythonString(mCommands);
        mUsingHighRes = true;
 }
@@ -320,7 +324,9 @@ void FLUID::initLiquid(SmokeModifierData *smd)
                        + liquid_export_low
                        + liquid_import_low
                        + liquid_adaptive_step
-                       + liquid_step_low;
+                       + liquid_pre_step_low
+                       + liquid_step_low
+                       + liquid_post_step_low;
                std::string finalString = parseScript(tmpString, smd);
                mCommands.clear();
                mCommands.push_back(finalString);
@@ -338,11 +344,13 @@ void FLUID::initLiquidHigh(SmokeModifierData *smd)
                + liquid_save_mesh_high
                + liquid_export_high
                + liquid_import_high
-               + liquid_step_high;
+               + liquid_pre_step_high
+               + liquid_step_high
+               + liquid_post_step_high;
        std::string finalString = parseScript(tmpString, smd);
        mCommands.clear();
        mCommands.push_back(finalString);
-               
+
        runPythonString(mCommands);
        mUsingHighRes = true;
 }
@@ -679,6 +687,14 @@ void FLUID::exportSmokeScript(SmokeModifierData *smd)
        if (highres)
                manta_script += smoke_import_high;
        
+       manta_script += smoke_pre_step_low;
+       if (highres)
+               manta_script += smoke_pre_step_high;
+       
+       manta_script += smoke_post_step_low;
+       if (highres)
+               manta_script += smoke_post_step_high;
+
        manta_script += smoke_step_low;
        if (highres)
                manta_script += smoke_step_high;
@@ -734,7 +750,15 @@ void FLUID::exportLiquidScript(SmokeModifierData *smd)
        manta_script += liquid_import_low;
        if (highres)
                manta_script += liquid_import_high;
-
+       
+       manta_script += liquid_pre_step_low;
+       if (highres)
+               manta_script += liquid_pre_step_high;
+       
+       manta_script += liquid_post_step_low;
+       if (highres)
+               manta_script += liquid_post_step_high;
+       
        manta_script += liquid_step_low;
        if (highres)
                manta_script += liquid_step_high;
diff --git a/intern/mantaflow/intern/strings/liquid_script.h 
b/intern/mantaflow/intern/strings/liquid_script.h
index 0b223a4..6b1d3d6 100644
--- a/intern/mantaflow/intern/strings/liquid_script.h
+++ b/intern/mantaflow/intern/strings/liquid_script.h
@@ -125,6 +125,36 @@ phi.initFromFlags(flags)\n\
 phiInit.initFromFlags(flags)\n";
 
 //////////////////////////////////////////////////////////////////////
+// PRE / POST STEP
+//////////////////////////////////////////////////////////////////////
+
+const std::string liquid_pre_step_low = "\n\
+def liquid_pre_step_low():\n\
+    copyRealToVec3(sourceX=x_vel, sourceY=y_vel, sourceZ=z_vel, target=vel)\n\
+    copyRealToVec3(sourceX=x_obvel, sourceY=y_obvel, sourceZ=z_obvel, 
target=obvel)\n\
+    \n\
+    clearInObstacle(flags=flags, grid=phi)\n";
+
+const std::string liquid_pre_step_high = "\n\
+def liquid_pre_step_high():\n\
+    clearInObstacle(flags=xl_flags, grid=xl_phi)\n";
+
+const std::string liquid_post_step_low = "\n\
+def liquid_post_step_low():\n\
+    forces.clear()\n\
+    obvel.clear()\n\
+    \n\
+    phiIn.setConst(0.5)\n\
+    phiObs.setConst(0.5)\n\
+    phiObsIn.setConst(0.5)\n\
+    \n\
+    copyVec3ToReal(source=vel, targetX=x_vel, targetY=y_vel, targetZ=z_vel)\n";
+
+const std::string liquid_post_step_high = "\n\
+def liquid_post_step_high():\n\
+    clearInObstacle(flags=xl_flags, grid=xl_phi)\n";
+
+//////////////////////////////////////////////////////////////////////
 // STEP FUNCTIONS
 //////////////////////////////////////////////////////////////////////
 
diff --git a/intern/mantaflow/intern/strings/smoke_script.h 
b/intern/mantaflow/intern/strings/smoke_script.h
index cd6aac8..066be54 100644
--- a/intern/mantaflow/intern/strings/smoke_script.h
+++ b/intern/mantaflow/intern/strings/smoke_script.h
@@ -179,6 +179,63 @@ xl_fuel  = xl.create(RealGrid)\n\
 xl_react = xl.create(RealGrid)\n";
 
 //////////////////////////////////////////////////////////////////////
+// PRE / POST STEP
+//////////////////////////////////////////////////////////////////////
+
+const std::string smoke_pre_step_low = "\n\
+def smoke_pre_step_low():\n\
+    copyRealToVec3(sourceX=x_vel, sourceY=y_vel, sourceZ=z_vel, target=vel)\n\
+    copyRealToVec3(sourceX=x_obvel, sourceY=y_obvel, sourceZ=z_obvel, 
target=obvel)\n\
+    copyRealToVec3(sourceX=x_force, sourceY=y_force, sourceZ=z_force, 
target=forces)\n\
+    \n\
+    clearInObstacle(flags=flags, grid=density)\n\
+    clearInObstacle(flags=flags, grid=vel)\n\
+    if (using_fire):\n\
+        clearInObstacle(flags=flags, grid=fuel)\n\
+        clearInObstacle(flags=flags, grid=flame)\n\
+        clearInObstacle(flags=flags, grid=react)\n\
+    if (using_colors):\n\
+        clearInObstacle(flags=flags, grid=color_r)\n\
+        clearInObstacle(flags=flags, grid=color_g)\n\
+        clearInObstacle(flags=flags, grid=color_b)\n\
+    \n\
+    averagedVel(vel=obvel, numObs=numObs)\n";
+
+const std::string smoke_pre_step_high = "\n\
+def smoke_pre_step_high():\n\
+    copyRealToVec3(sourceX=texture_u, sourceY=texture_v, sourceZ=texture_w, 
target=uv[0])\n\
+    copyRealToVec3(sourceX=texture_u2, sourceY=texture_v2, sourceZ=texture_w2, 
target=uv[1])\n\
+    \n\
+    clearInObstacle(flags=xl_flags, grid=xl_density)\n\
+    clearInObstacle(flags=xl_flags, grid=xl_vel)\n\
+    if (using_fire):\n\
+        clearInObstacle(flags=xl_flags, grid=xl_fuel)\n\
+        clearInObstacle(flags=xl_flags, grid=xl_flame)\n\
+        clearInObstacle(flags=xl_flags, grid=xl_react)\n\
+    if (using_colors):\n\
+        clearInObstacle(flags=xl_flags, grid=xl_color_r)\n\
+        clearInObstacle(flags=xl_flags, grid=xl_color_g)\n\
+        clearInObstacle(flags=xl_flags, grid=xl_color_b)\n";
+
+const std::string smoke_post_step_low = "\n\
+def smoke_post_step_low():\n\
+    forces.clear()\n\
+    #obvel.clear()\n\
+    #x_obvel.clear()\n\
+    #y_obvel.clear()\n\
+    #z_obvel.clear()\n\
+    phiObsIn.setConst(0.5)\n\
+    \n\
+    copyVec3ToReal(source=vel, targetX=x_vel, targetY=y_vel, targetZ=z_vel)\n";
+
+const std::string smoke_post_step_high = "\n\
+def smoke_post_step_high():\n\
+    xl_phiObsIn.setConst(0.5)\n\
+    \n\
+    copyVec3ToReal(source=uv[0], targetX=texture_u, targetY=texture_v, 
targetZ=texture_w)\n\
+    copyVec3ToReal(source=uv[1], targetX=texture_u2, targetY=texture_v2, 
targetZ=texture_w2)\n";
+
+//////////////////////////////////////////////////////////////////////
 // STEP FUNCTIONS
 //////////////////////////////////////////////////////////////////////

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to