[Bf-blender-cvs] [71ce47a71d6] master: LineArt: Temporary fix for object loading iterator.

Yiming Wu noreply at git.blender.org
Wed Jun 1 08:37:31 CEST 2022


Commit: 71ce47a71d69b5433b22f02010c47db37a739a98
Author: Yiming Wu
Date:   Wed Jun 1 14:34:10 2022 +0800
Branches: master
https://developer.blender.org/rB71ce47a71d69b5433b22f02010c47db37a739a98

LineArt: Temporary fix for object loading iterator.

Use `DEG_OBJECT_ITER_BEGIN`for loading objects, this iterator is
technially unsafe to use *during* depsgraph evaluation,
see https://developer.blender.org/D14997 for detailed explainations.

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

M	source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c

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

diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
index 016b70cedb0..5c529a7f6b6 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
@@ -2454,31 +2454,35 @@ static void lineart_main_load_geometries(
   eEvaluationMode eval_mode = DEG_get_mode(depsgraph);
   bool is_render = eval_mode == DAG_EVAL_RENDER;
 
-  FOREACH_SCENE_OBJECT_BEGIN (scene, ob) {
+  int flags = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET |
+              DEG_ITER_OBJECT_FLAG_VISIBLE;
+
+  /* Instance duplicated & particles. */
+  if (allow_duplicates) {
+    flags |= DEG_ITER_OBJECT_FLAG_DUPLI;
+  }
+
+  /* XXX(Yiming): Temporary solution, this iterator is technially unsafe to use *during* depsgraph
+   * evaluation, see https://developer.blender.org/D14997 for detailed explainations. */
+  DEG_OBJECT_ITER_BEGIN (depsgraph, ob, flags) {
     Object *eval_ob = DEG_get_evaluated_object(depsgraph, ob);
 
     if (!eval_ob) {
       continue;
     }
 
+    /* DEG_OBJECT_ITER_BEGIN will include the instanced mesh of these curve object types, so don't
+     * load them twice. */
+    if (allow_duplicates && ELEM(ob->type, OB_CURVES_LEGACY, OB_FONT, OB_SURF)) {
+      continue;
+    }
+
     if (BKE_object_visibility(eval_ob, eval_mode) & OB_VISIBLE_SELF) {
       lineart_object_load_single_instance(
           rb, depsgraph, scene, eval_ob, eval_ob, eval_ob->obmat, is_render, olti, thread_count);
     }
-    if (allow_duplicates) {
-      ListBase *dupli = object_duplilist(depsgraph, scene, eval_ob);
-      LISTBASE_FOREACH (DupliObject *, dob, dupli) {
-        if (BKE_object_visibility(eval_ob, eval_mode) &
-            (OB_VISIBLE_PARTICLES | OB_VISIBLE_INSTANCES)) {
-          Object *ob_ref = (dob->type & OB_DUPLIPARTS) ? eval_ob : dob->ob;
-          lineart_object_load_single_instance(
-              rb, depsgraph, scene, dob->ob, ob_ref, dob->mat, is_render, olti, thread_count);
-        }
-      }
-      free_object_duplilist(dupli);
-    }
   }
-  FOREACH_SCENE_OBJECT_END;
+  DEG_OBJECT_ITER_END;
 
   TaskPool *tp = BLI_task_pool_create(NULL, TASK_PRIORITY_HIGH);



More information about the Bf-blender-cvs mailing list