[Bf-blender-cvs] [952279a3667] master: Fix T76687: [Mantaflow] low domain transformation performance

Sebastián Barschkis noreply at git.blender.org
Mon Jul 13 16:15:54 CEST 2020


Commit: 952279a366783bf471c900e368ee2fc3055cb64b
Author: Sebastián Barschkis
Date:   Mon Jul 13 16:09:24 2020 +0200
Branches: master
https://developer.blender.org/rB952279a366783bf471c900e368ee2fc3055cb64b

Fix T76687: [Mantaflow] low domain transformation performance

Implemented G.moving suggestion from comments.

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

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

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

diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c
index bcda77e9d44..194d5074993 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -4118,43 +4118,47 @@ static void BKE_fluid_modifier_process(
 struct Mesh *BKE_fluid_modifier_do(
     FluidModifierData *fmd, Depsgraph *depsgraph, Scene *scene, Object *ob, Mesh *me)
 {
-  /* Lock so preview render does not read smoke data while it gets modified. */
-  if ((fmd->type & MOD_FLUID_TYPE_DOMAIN) && fmd->domain) {
-    BLI_rw_mutex_lock(fmd->domain->fluid_mutex, THREAD_LOCK_WRITE);
-  }
-
-  BKE_fluid_modifier_process(fmd, depsgraph, scene, ob, me);
-
-  if ((fmd->type & MOD_FLUID_TYPE_DOMAIN) && fmd->domain) {
-    BLI_rw_mutex_unlock(fmd->domain->fluid_mutex);
-  }
-
   /* Optimization: Do not update viewport during bakes (except in replay mode)
    * Reason: UI is locked and updated liquid / smoke geometry is not visible anyways. */
   bool needs_viewport_update = false;
-  if (fmd->domain) {
-    FluidDomainSettings *fds = fmd->domain;
 
-    /* Always update viewport in cache replay mode. */
-    if (fds->cache_type == FLUID_DOMAIN_CACHE_REPLAY ||
-        fds->flags & FLUID_DOMAIN_USE_ADAPTIVE_DOMAIN) {
-      needs_viewport_update = true;
+  /* Optimization: Only process modifier if object is not being altered. */
+  if (!G.moving) {
+    /* Lock so preview render does not read smoke data while it gets modified. */
+    if ((fmd->type & MOD_FLUID_TYPE_DOMAIN) && fmd->domain) {
+      BLI_rw_mutex_lock(fmd->domain->fluid_mutex, THREAD_LOCK_WRITE);
     }
-    /* In other cache modes, only update the viewport when no bake is going on. */
-    else {
-      bool with_mesh;
-      with_mesh = fds->flags & FLUID_DOMAIN_USE_MESH;
-      bool baking_data, baking_noise, baking_mesh, baking_particles, baking_guide;
-      baking_data = fds->cache_flag & FLUID_DOMAIN_BAKING_DATA;
-      baking_noise = fds->cache_flag & FLUID_DOMAIN_BAKING_NOISE;
-      baking_mesh = fds->cache_flag & FLUID_DOMAIN_BAKING_MESH;
-      baking_particles = fds->cache_flag & FLUID_DOMAIN_BAKING_PARTICLES;
-      baking_guide = fds->cache_flag & FLUID_DOMAIN_BAKING_GUIDE;
-
-      if (with_mesh && !baking_data && !baking_noise && !baking_mesh && !baking_particles &&
-          !baking_guide) {
+
+    BKE_fluid_modifier_process(fmd, depsgraph, scene, ob, me);
+
+    if ((fmd->type & MOD_FLUID_TYPE_DOMAIN) && fmd->domain) {
+      BLI_rw_mutex_unlock(fmd->domain->fluid_mutex);
+    }
+
+    if (fmd->domain) {
+      FluidDomainSettings *fds = fmd->domain;
+
+      /* Always update viewport in cache replay mode. */
+      if (fds->cache_type == FLUID_DOMAIN_CACHE_REPLAY ||
+          fds->flags & FLUID_DOMAIN_USE_ADAPTIVE_DOMAIN) {
         needs_viewport_update = true;
       }
+      /* In other cache modes, only update the viewport when no bake is going on. */
+      else {
+        bool with_mesh;
+        with_mesh = fds->flags & FLUID_DOMAIN_USE_MESH;
+        bool baking_data, baking_noise, baking_mesh, baking_particles, baking_guide;
+        baking_data = fds->cache_flag & FLUID_DOMAIN_BAKING_DATA;
+        baking_noise = fds->cache_flag & FLUID_DOMAIN_BAKING_NOISE;
+        baking_mesh = fds->cache_flag & FLUID_DOMAIN_BAKING_MESH;
+        baking_particles = fds->cache_flag & FLUID_DOMAIN_BAKING_PARTICLES;
+        baking_guide = fds->cache_flag & FLUID_DOMAIN_BAKING_GUIDE;
+
+        if (with_mesh && !baking_data && !baking_noise && !baking_mesh && !baking_particles &&
+            !baking_guide) {
+          needs_viewport_update = true;
+        }
+      }
     }
   }



More information about the Bf-blender-cvs mailing list