[Bf-blender-cvs] [bf9c4af9bb7] master: Fix T74762: Mantaflow: Non emmiting flow source affects simulation

Sebastián Barschkis noreply at git.blender.org
Tue Mar 17 18:22:08 CET 2020


Commit: bf9c4af9bb7436468eaa4fc954ab06c7369738d2
Author: Sebastián Barschkis
Date:   Tue Mar 17 18:20:08 2020 +0100
Branches: master
https://developer.blender.org/rBbf9c4af9bb7436468eaa4fc954ab06c7369738d2

Fix T74762: Mantaflow: Non emmiting flow source affects simulation

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

M	source/blender/blenkernel/intern/fluid.c

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

diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c
index 797e03e015a..dc872b933eb 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -1894,40 +1894,6 @@ static void sample_mesh(FluidFlowSettings *mfs,
     v3 = mloop[mlooptri[f_index].tri[2]].v;
     interp_weights_tri_v3(weights, mvert[v1].co, mvert[v2].co, mvert[v3].co, nearest.co);
 
-    /* Initial velocity of flow object. */
-    if (mfs->flags & FLUID_FLOW_INITVELOCITY && velocity_map) {
-      /* Apply normal directional velocity. */
-      if (mfs->vel_normal) {
-        /* Interpolate vertex normal vectors to get nearest point normal. */
-        normal_short_to_float_v3(n1, mvert[v1].no);
-        normal_short_to_float_v3(n2, mvert[v2].no);
-        normal_short_to_float_v3(n3, mvert[v3].no);
-        interp_v3_v3v3v3(hit_normal, n1, n2, n3, weights);
-        normalize_v3(hit_normal);
-
-        /* Apply normal directional velocity. */
-        velocity_map[index * 3] += hit_normal[0] * mfs->vel_normal * 0.25f;
-        velocity_map[index * 3 + 1] += hit_normal[1] * mfs->vel_normal * 0.25f;
-        velocity_map[index * 3 + 2] += hit_normal[2] * mfs->vel_normal * 0.25f;
-      }
-      /* Apply object velocity. */
-      if (has_velocity && mfs->vel_multi) {
-        float hit_vel[3];
-        interp_v3_v3v3v3(
-            hit_vel, &vert_vel[v1 * 3], &vert_vel[v2 * 3], &vert_vel[v3 * 3], weights);
-        velocity_map[index * 3] += hit_vel[0] * mfs->vel_multi;
-        velocity_map[index * 3 + 1] += hit_vel[1] * mfs->vel_multi;
-        velocity_map[index * 3 + 2] += hit_vel[2] * mfs->vel_multi;
-#  ifdef DEBUG_PRINT
-        /* Debugging: Print flow object velocities. */
-        printf("adding flow object vel: [%f, %f, %f]\n", hit_vel[0], hit_vel[1], hit_vel[2]);
-#  endif
-      }
-      velocity_map[index * 3] += mfs->vel_coord[0];
-      velocity_map[index * 3 + 1] += mfs->vel_coord[1];
-      velocity_map[index * 3 + 2] += mfs->vel_coord[2];
-    }
-
     /* Compute emission strength for smoke flow. */
     if (is_gas_flow) {
       /* Emission from surface is based on UI configurable distance value. */
@@ -1977,6 +1943,40 @@ static void sample_mesh(FluidFlowSettings *mfs,
         emission_strength *= texres.tin;
       }
     }
+
+    /* Initial velocity of flow object. Only compute velocity if emission is present. */
+    if (mfs->flags & FLUID_FLOW_INITVELOCITY && velocity_map && emission_strength != 0.0) {
+      /* Apply normal directional velocity. */
+      if (mfs->vel_normal) {
+        /* Interpolate vertex normal vectors to get nearest point normal. */
+        normal_short_to_float_v3(n1, mvert[v1].no);
+        normal_short_to_float_v3(n2, mvert[v2].no);
+        normal_short_to_float_v3(n3, mvert[v3].no);
+        interp_v3_v3v3v3(hit_normal, n1, n2, n3, weights);
+        normalize_v3(hit_normal);
+
+        /* Apply normal directional velocity. */
+        velocity_map[index * 3] += hit_normal[0] * mfs->vel_normal * 0.25f;
+        velocity_map[index * 3 + 1] += hit_normal[1] * mfs->vel_normal * 0.25f;
+        velocity_map[index * 3 + 2] += hit_normal[2] * mfs->vel_normal * 0.25f;
+      }
+      /* Apply object velocity. */
+      if (has_velocity && mfs->vel_multi) {
+        float hit_vel[3];
+        interp_v3_v3v3v3(
+            hit_vel, &vert_vel[v1 * 3], &vert_vel[v2 * 3], &vert_vel[v3 * 3], weights);
+        velocity_map[index * 3] += hit_vel[0] * mfs->vel_multi;
+        velocity_map[index * 3 + 1] += hit_vel[1] * mfs->vel_multi;
+        velocity_map[index * 3 + 2] += hit_vel[2] * mfs->vel_multi;
+#  ifdef DEBUG_PRINT
+        /* Debugging: Print flow object velocities. */
+        printf("adding flow object vel: [%f, %f, %f]\n", hit_vel[0], hit_vel[1], hit_vel[2]);
+#  endif
+      }
+      velocity_map[index * 3] += mfs->vel_coord[0];
+      velocity_map[index * 3 + 1] += mfs->vel_coord[1];
+      velocity_map[index * 3 + 2] += mfs->vel_coord[2];
+    }
   }
 
   /* Apply final influence value but also consider volume initialization factor. */



More information about the Bf-blender-cvs mailing list