[Bf-blender-cvs] [0bab93f1a76] temp-alembic-exporter-T73363-ms2: Alembic: even nicer subsurf disable method

Sybren A. Stüvel noreply at git.blender.org
Fri Apr 10 17:05:04 CEST 2020


Commit: 0bab93f1a7629844dc8aedacaac01371f8537308
Author: Sybren A. Stüvel
Date:   Fri Apr 10 15:49:41 2020 +0200
Branches: temp-alembic-exporter-T73363-ms2
https://developer.blender.org/rB0bab93f1a7629844dc8aedacaac01371f8537308

Alembic: even nicer subsurf disable method

This is less dependent on the exact implementation of AbstractHierarchyIterator
and also avoids an evaluation of the subsurfs before they are disabled.

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

M	source/blender/io/alembic/intern/export/abc_export_capi.cc
M	source/blender/io/alembic/intern/export/abc_subdiv_disabler.cc

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

diff --git a/source/blender/io/alembic/intern/export/abc_export_capi.cc b/source/blender/io/alembic/intern/export/abc_export_capi.cc
index 671c66ba4c9..c2ba0c8a469 100644
--- a/source/blender/io/alembic/intern/export/abc_export_capi.cc
+++ b/source/blender/io/alembic/intern/export/abc_export_capi.cc
@@ -68,7 +68,6 @@ static void build_depsgraph(Depsgraph *depsgraph, Main *bmain)
   Scene *scene = DEG_get_input_scene(depsgraph);
   ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph);
   DEG_graph_build_from_view_layer(depsgraph, bmain, scene, view_layer);
-  BKE_scene_graph_update_tagged(depsgraph, bmain);
 }
 
 static void export_startjob(void *customdata, short *stop, short *do_update, float *progress)
@@ -84,13 +83,11 @@ static void export_startjob(void *customdata, short *stop, short *do_update, flo
   *do_update = true;
 
   build_depsgraph(data->depsgraph, data->bmain);
-
-  // Disable subdivison modifiers if necessary.
   SubdivModifierDisabler subdiv_disabler(data->depsgraph);
   if (!data->params.apply_subdiv) {
     subdiv_disabler.disable_modifiers();
-    BKE_scene_graph_update_tagged(data->depsgraph, data->bmain);
   }
+  BKE_scene_graph_update_tagged(data->depsgraph, data->bmain);
 
   // For restoring the current frame after exporting animation is done.
   Scene *scene = DEG_get_input_scene(data->depsgraph);
diff --git a/source/blender/io/alembic/intern/export/abc_subdiv_disabler.cc b/source/blender/io/alembic/intern/export/abc_subdiv_disabler.cc
index 0ca6ed0e328..c0d8c69dc41 100644
--- a/source/blender/io/alembic/intern/export/abc_subdiv_disabler.cc
+++ b/source/blender/io/alembic/intern/export/abc_subdiv_disabler.cc
@@ -3,9 +3,12 @@
 extern "C" {
 #include <stdio.h>
 
+#include "BLI_listbase.h"
+
 #include "DEG_depsgraph.h"
 #include "DEG_depsgraph_query.h"
 
+#include "DNA_layer_types.h"
 #include "DNA_mesh_types.h"
 #include "DNA_modifier_types.h"
 #include "DNA_object_types.h"
@@ -29,27 +32,27 @@ SubdivModifierDisabler::~SubdivModifierDisabler()
 void SubdivModifierDisabler::disable_modifiers()
 {
   Scene *scene = DEG_get_input_scene(depsgraph_);
+  ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph_);
+
+  LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
+    Object *object = base->object;
 
-  // This is the same iteration as is used by
-  // AbstractHierarchyIterator::export_graph_construct().
-  DEG_OBJECT_ITER_BEGIN (depsgraph_,
-                         object_eval,
-                         DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
-                             DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET) {
-    if (object_eval->type != OB_MESH) {
+    if (object->type != OB_MESH) {
       continue;
     }
 
-    Object *object_orig = DEG_get_original_object(object_eval);
-    ModifierData *subdiv = get_subdiv_modifier(scene, object_orig);
+    ModifierData *subdiv = get_subdiv_modifier(scene, object);
     if (subdiv == nullptr) {
       continue;
     }
 
+    /* This disables more modifiers than necessary, as it doesn't take restrictions like
+     * "export selected objects only" into account. However, with the disabled subsurfs
+     * moving to a different frame is also going to be faster, so in the end this is probably
+     * a good thing to do. */
     subdiv->mode |= eModifierMode_DisableTemporary;
-    DEG_id_tag_update(&object_orig->id, ID_RECALC_GEOMETRY);
+    DEG_id_tag_update(&object->id, ID_RECALC_GEOMETRY);
   }
-  DEG_OBJECT_ITER_END;
 }
 
 /* Check if the mesh is a subsurf, ignoring disabled modifiers and



More information about the Bf-blender-cvs mailing list