[Bf-blender-cvs] [da7964ea493] lanpr-under-gp: LANPR: Modifier apply now works for all line types.

YimingWu noreply at git.blender.org
Sun Jun 28 15:45:51 CEST 2020


Commit: da7964ea4939cdd0c0100b00e54d9fb3dc586d11
Author: YimingWu
Date:   Sun Jun 28 21:45:45 2020 +0800
Branches: lanpr-under-gp
https://developer.blender.org/rBda7964ea4939cdd0c0100b00e54d9fb3dc586d11

LANPR: Modifier apply now works for all line types.

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

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

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

diff --git a/source/blender/editors/lineart/lineart_cpu.c b/source/blender/editors/lineart/lineart_cpu.c
index 1371fd80796..76bb1dc8bac 100644
--- a/source/blender/editors/lineart/lineart_cpu.c
+++ b/source/blender/editors/lineart/lineart_cpu.c
@@ -4043,7 +4043,11 @@ void ED_lineart_generate_gpencil_from_chain(Depsgraph *depsgraph,
       continue;
     }
     if (col && rlc->object_ref) {
-      if (!BKE_collection_has_object_recursive(col, (Object *)rlc->object_ref)) {
+      if (col->id.orig_id) {
+        col = col->id.orig_id;
+        /* Need this for using the same code for modifier preview and applying. */
+      }
+      if (!BKE_collection_has_object_recursive(col, (Object *)rlc->object_ref->id.orig_id)) {
         continue;
       }
     }
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
index 9d51f79812d..c3735d55210 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
@@ -82,20 +82,6 @@ static void generate_strokes_actual(
     return;
   }
 
-  if (ED_lineart_modifier_sync_flag_check(LRT_SYNC_IDLE)) {
-    /* Update triggered when nothing's happening, means DG update, so we request a refresh on line
-     * art cache, meanwhile waiting for result. Update will trigger agian */
-    ED_lineart_modifier_sync_set_flag(LRT_SYNC_WAITING, true);
-    return;
-  }
-  else if (ED_lineart_modifier_sync_flag_check(LRT_SYNC_WAITING)) {
-    /* Calculation in process */
-    return;
-  }
-
-  /* If we reach here, means calculation is finished (LRT_SYNC_FRESH), we grab cache. flag reset is
-   * done by calculation function.*/
-
   if (lmd->source_type == LRT_SOURCE_OBJECT) {
     Object *source_object = lmd->source_object;
     if (!source_object) {
@@ -143,6 +129,21 @@ static void generateStrokes(GpencilModifierData *md, Depsgraph *depsgraph, Objec
 {
   LineartGpencilModifierData *lmd = (LineartGpencilModifierData *)md;
   bGPdata *gpd = ob->data;
+
+  if (ED_lineart_modifier_sync_flag_check(LRT_SYNC_IDLE)) {
+    /* Update triggered when nothing's happening, means DG update, so we request a refresh on line
+     * art cache, meanwhile waiting for result. Update will trigger agian */
+    ED_lineart_modifier_sync_set_flag(LRT_SYNC_WAITING, true);
+    return;
+  }
+  else if (ED_lineart_modifier_sync_flag_check(LRT_SYNC_WAITING)) {
+    /* Calculation in process */
+    return;
+  }
+
+  /* If we reach here, means calculation is finished (LRT_SYNC_FRESH), we grab cache. flag reset is
+   * done by calculation function.*/
+
   Scene *scene = DEG_get_evaluated_scene(depsgraph);
 
   bGPDlayer *gpl = BKE_gpencil_layer_get_by_name(gpd, lmd->target_gp_layer, 1);
@@ -156,13 +157,19 @@ static void bakeModifier(Main *UNUSED(bmain),
                          GpencilModifierData *md,
                          Object *ob)
 {
+
   bGPdata *gpd = ob->data;
+  Scene *scene = DEG_get_evaluated_scene(depsgraph);
+  LineartGpencilModifierData *lmd = (LineartGpencilModifierData *)md;
 
-  LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
-    LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
-      generate_strokes_actual(md, depsgraph, ob, gpl, gpf);
-    }
+  bGPDlayer *gpl = BKE_gpencil_layer_get_by_name(gpd, lmd->target_gp_layer, 1);
+  bGPDframe *gpf = BKE_gpencil_layer_frame_get(gpl, scene->r.cfra, GP_GETFRAME_ADD_NEW);
+
+  while (ED_lineart_modifier_sync_flag_check(LRT_SYNC_WAITING)) {
+    ; /* TODO: Should use a "poll" callback to stop it from applying.
+       *For now just wait for it's done. */
   }
+  generate_strokes_actual(md, depsgraph, ob, gpl, gpf);
 }
 
 static void updateDepsgraph(GpencilModifierData *md, const ModifierUpdateDepsgraphContext *ctx)



More information about the Bf-blender-cvs mailing list