Commit: 86e3e95de6feaa5706faddf16ee9cd468866f991
Author: Sebastián Barschkis
Date:   Sun Feb 26 15:44:23 2017 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rB86e3e95de6feaa5706faddf16ee9cd468866f991

reordered cleanup before and after smoke step

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

M       intern/mantaflow/intern/strings/smoke_script.h
M       source/blender/blenkernel/intern/smoke.c

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

diff --git a/intern/mantaflow/intern/strings/smoke_script.h 
b/intern/mantaflow/intern/strings/smoke_script.h
index d53e214579..4d9b8cdf1f 100644
--- a/intern/mantaflow/intern/strings/smoke_script.h
+++ b/intern/mantaflow/intern/strings/smoke_script.h
@@ -191,52 +191,19 @@ 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\
-    averageGrid(grid=obvel, num=numObs)\n";
+    copyRealToVec3(sourceX=x_force, sourceY=y_force, sourceZ=z_force, 
target=forces)\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";
+    copyRealToVec3(sourceX=texture_u2, sourceY=texture_v2, sourceZ=texture_w2, 
target=uv[1])\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";
 
@@ -283,9 +250,24 @@ def manta_step(start_frame):\n\
 const std::string smoke_step_low = "\n\
 def step_low():\n\
     mantaMsg('Smoke step low')\n\
+    \n\
+    mantaMsg('Setting flags')\n\
     setObstacleFlags(flags=flags, phiObs=phiObsIn, fractions=fractions, 
phiOut=phiOut)\n\
     flags.fillGrid()\n\
     \n\
+    mantaMsg('Clearing cells')\n\
+    clearInObstacle(flags=flags, grid=density)\n\
+    clearInObstacle(flags=flags, grid=vel)\n\
+    clearInObstacle(flags=flags, grid=pressure)\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\
     mantaMsg('Advecting density')\n\
     advectSemiLagrange(flags=flags, vel=vel, grid=density, 
order=$ADVECT_ORDER$)\n\
     \n\
@@ -326,6 +308,7 @@ def step_low():\n\
     \n\
     mantaMsg('Adding forces')\n\
     addForceField(flags=flags, vel=vel, force=forces)\n\
+    forces.clear()\n\
     \n\
     mantaMsg('Walls')\n\
     setWallBcs(flags=flags, vel=vel)\n\
@@ -350,6 +333,18 @@ def step_high():\n\
     setObstacleFlags(flags=xl_flags, phiObs=xl_phiObsIn, 
fractions=xl_fractions)\n\
     xl_flags.fillGrid()\n\
     \n\
+    mantaMsg('Clearing cells high')\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\
+    \n\
     interpolateMACGrid(source=vel, target=xl_vel)\n\
     for i in range(uvs):\n\
         mantaMsg('Advecting UV')\n\
diff --git a/source/blender/blenkernel/intern/smoke.c 
b/source/blender/blenkernel/intern/smoke.c
index a65186861a..b2aa2c7e81 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -977,31 +977,25 @@ static void update_obstacles(Scene *scene, Object *ob, 
SmokeDomainSettings *sds,
 //     float *b = smoke_get_color_b(sds->fluid);
        float *phiObs = liquid_get_phiobs(sds->fluid);
        int *num_obstacles = fluid_get_num_obstacle(sds->fluid);
-//     unsigned int z;
+       unsigned int z;
 
-       // TODO (sebbas): Removing for now - better do this directly in 
Mantaflow
-       // TODO: delete old obstacle flags
-//     for (z = 0; z < sds->res[0] * sds->res[1] * sds->res[2]; z++)
-//     {
-//             if (obstacles[z] & 2 && obstaclesAnim[z] == 1) // Only delete 
moving obstacles, do not delete static obstacles, mantaflow convention: 2 == 
FlagObstacle
-//             {
-//                     obstaclesAnim[z] = 0;
-//                     obstacles[z] |= (sds->type == 
MOD_SMOKE_DOMAIN_TYPE_LIQUID) ? 4 : 1; // mantaflow convention: 4 == FlagEmpty, 
1 == FlagFluid
-//             }
-//        
-        /* Make sure phi grids are "fresh" before performing any joins in 
manta script */
-//        if (phi)
-//            phi[z] = 0.5f;
-//             if (phiObs)
-//                     phiObs[z] = 0.5f;
-//
-//             if (velx && velz && velz) {
-//                     velx[z] = 0;
-//                     vely[z] = 0;
-//                     velz[z] = 0;
-//             }
-//     }
+       /* Resetting all grids related to moving obstacles */
+       for (z = 0; z < sds->res[0] * sds->res[1] * sds->res[2]; z++)
+       {
+               // TODO (sebbas): when and how reset liquid phi?
+//             if (phi)
+//                     phi[z] = 0.5f;
+               if (phiObs)
+                       phiObs[z] = 0.5f;
+               if (num_obstacles)
+                       num_obstacles[z] = 0;
 
+               if (velx && velz && velz) {
+                       velx[z] = 0.0f;
+                       vely[z] = 0.0f;
+                       velz[z] = 0.0f;
+               }
+       }
 
        collobjs = get_collisionobjects(scene, ob, sds->coll_group, 
&numcollobj, eModifierType_Smoke);

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

Reply via email to