From bf9c4af9bb7436468eaa4fc954ab06c7369738d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Barschkis?= Date: Tue, 17 Mar 2020 18:20:08 +0100 Subject: Fix T74762: Mantaflow: Non emmiting flow source affects simulation --- source/blender/blenkernel/intern/fluid.c | 68 ++++++++++++++++---------------- 1 file changed, 34 insertions(+), 34 deletions(-) (limited to 'source/blender') 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. */ -- cgit v1.2.3