diff options
author | Sebastián Barschkis <sebbas@sebbas.org> | 2020-07-13 17:09:24 +0300 |
---|---|---|
committer | Sebastián Barschkis <sebbas@sebbas.org> | 2020-07-13 17:15:43 +0300 |
commit | 952279a366783bf471c900e368ee2fc3055cb64b (patch) | |
tree | cd3c759671524cb427f4578b51766c8fa46c4a71 | |
parent | 5ecefc6a07a44f2617396bd5aec92714d8d760e2 (diff) |
Fix T76687: [Mantaflow] low domain transformation performance
Implemented G.moving suggestion from comments.
-rw-r--r-- | source/blender/blenkernel/intern/fluid.c | 64 |
1 files changed, 34 insertions, 30 deletions
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; + } + } } } |