[Bf-blender-cvs] [0bcf788c615] lanpr-under-gp: LineArt: Baking keyframes only.

YimingWu noreply at git.blender.org
Wed Sep 23 05:31:07 CEST 2020


Commit: 0bcf788c615069c94097ac2b55405ca4cd3c3b95
Author: YimingWu
Date:   Wed Sep 23 11:30:45 2020 +0800
Branches: lanpr-under-gp
https://developer.blender.org/rB0bcf788c615069c94097ac2b55405ca4cd3c3b95

LineArt: Baking keyframes only.

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

M	release/scripts/startup/bl_ui/properties_render.py
M	source/blender/editors/lineart/lineart_cpu.c
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/intern/rna_scene.c

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

diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py
index 0797adc2d9f..8702d3e0557 100644
--- a/release/scripts/startup/bl_ui/properties_render.py
+++ b/release/scripts/startup/bl_ui/properties_render.py
@@ -780,7 +780,10 @@ class RENDER_PT_lineart_baking(RenderButtonsPanel, Panel):
             col.prop(lineart, "baking_preview_start", text='Start')
             col.prop(lineart, "baking_preview_end", text='End')
 
-        layout.prop(lineart, "baking_skip")
+        layout.prop(lineart, "baking_keyframes_only")
+
+        if not lineart.baking_keyframes_only:
+            layout.prop(lineart, "baking_skip")
 
         layout.operator('scene.lineart_bake_strokes')
 
diff --git a/source/blender/editors/lineart/lineart_cpu.c b/source/blender/editors/lineart/lineart_cpu.c
index dc7b3ea1b98..671573bc3ee 100644
--- a/source/blender/editors/lineart/lineart_cpu.c
+++ b/source/blender/editors/lineart/lineart_cpu.c
@@ -4121,10 +4121,13 @@ static int lineart_gpencil_bake_strokes_invoke(bContext *C,
                                                                lineart->baking_preview_end);
   int frame_total = frame_end - frame_begin;
   int frame_orig = scene->r.cfra;
-  int frame_increment = lineart->baking_skip + 1;
+  int frame_increment = ((lineart->flags & LRT_BAKING_KEYFRAMES_ONLY) ?
+                             1 :
+                             (lineart->baking_skip + 1));
   LineartGpencilModifierData *lmd;
   LineartRenderBuffer *rb;
   int use_types;
+  bool frame_updated;
 
   /* Needed for progress report. */
   lineart_share.wm = CTX_wm_manager(C);
@@ -4132,30 +4135,7 @@ static int lineart_gpencil_bake_strokes_invoke(bContext *C,
 
   for (frame = frame_begin; frame <= frame_end; frame += frame_increment) {
 
-    /* Reset flags. LRT_SYNC_IGNORE prevent any line art modifiers run calculation function when
-     * depsgraph calls for modifier evalurates. */
-    ED_lineart_modifier_sync_flag_set(LRT_SYNC_IGNORE, false);
-    ED_lineart_calculation_flag_set(LRT_RENDER_IDLE);
-
-    BKE_scene_frame_set(scene, frame);
-    BKE_scene_graph_update_for_newframe(dg);
-
-    ED_lineart_update_render_progress((int)((float)(frame - frame_begin) / frame_total * 100),
-                                      NULL);
-
-    BLI_spin_lock(&lineart_share.lock_loader);
-    ED_lineart_compute_feature_lines_background(dg, 0);
-
-    /* Wait for loading finish */
-    BLI_spin_lock(&lineart_share.lock_loader);
-    BLI_spin_unlock(&lineart_share.lock_loader);
-
-    while (!ED_lineart_modifier_sync_flag_check(LRT_SYNC_FRESH) ||
-           !ED_lineart_calculation_flag_check(LRT_RENDER_FINISHED)) {
-      /* Wait till it's done. */
-    }
-
-    ED_lineart_chain_clear_picked_flag(lineart_share.render_buffer_shared);
+    frame_updated = false;
 
     FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN (
         scene->master_collection, ob, DAG_EVAL_RENDER) {
@@ -4167,7 +4147,42 @@ static int lineart_gpencil_bake_strokes_invoke(bContext *C,
             lmd = (LineartGpencilModifierData *)md;
             bGPdata *gpd = ob->data;
             bGPDlayer *gpl = BKE_gpencil_layer_get_by_name(gpd, lmd->target_layer, 1);
-            bGPDframe *gpf = BKE_gpencil_layer_frame_get(gpl, frame, GP_GETFRAME_ADD_NEW);
+            bGPDframe *gpf = ((lineart->flags & LRT_BAKING_KEYFRAMES_ONLY) ?
+                                  BKE_gpencil_layer_frame_find(gpl, frame) :
+                                  BKE_gpencil_layer_frame_get(gpl, frame, GP_GETFRAME_ADD_NEW));
+
+            if (!gpf) {
+              continue; /* happens when it's keyframe only. */
+            }
+
+            if (!frame_updated) {
+              /* Reset flags. LRT_SYNC_IGNORE prevent any line art modifiers run calculation
+               * function when depsgraph calls for modifier evalurates. */
+              ED_lineart_modifier_sync_flag_set(LRT_SYNC_IGNORE, false);
+              ED_lineart_calculation_flag_set(LRT_RENDER_IDLE);
+
+              BKE_scene_frame_set(scene, frame);
+              BKE_scene_graph_update_for_newframe(dg);
+
+              ED_lineart_update_render_progress(
+                  (int)((float)(frame - frame_begin) / frame_total * 100), NULL);
+
+              BLI_spin_lock(&lineart_share.lock_loader);
+              ED_lineart_compute_feature_lines_background(dg, 0);
+
+              /* Wait for loading finish */
+              BLI_spin_lock(&lineart_share.lock_loader);
+              BLI_spin_unlock(&lineart_share.lock_loader);
+
+              while (!ED_lineart_modifier_sync_flag_check(LRT_SYNC_FRESH) ||
+                     !ED_lineart_calculation_flag_check(LRT_RENDER_FINISHED)) {
+                /* Wait till it's done. */
+              }
+
+              ED_lineart_chain_clear_picked_flag(lineart_share.render_buffer_shared);
+
+              frame_updated = true;
+            }
 
             /* Clear original frame */
             if ((scene->lineart.flags & LRT_GPENCIL_OVERWRITE) && (!cleared)) {
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index ce5072e5517..bd7de83997e 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1674,6 +1674,7 @@ typedef enum eLineartMainFlags {
   LRT_ALLOW_OVERLAPPING_EDGES = (1 << 10),
   LRT_ALLOW_CLIPPING_BOUNDARIES = (1 << 11),
   LRT_BAKING_FINAL_RANGE = (1 << 12),
+  LRT_BAKING_KEYFRAMES_ONLY = (1 << 13),
 } eLineartMainFlags;
 
 typedef struct SceneLineart {
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 0e6f478701e..6802d5f45a0 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -7459,18 +7459,23 @@ static void rna_def_scene_lineart(BlenderRNA *brna)
   RNA_def_property_boolean_sdna(prop, NULL, "flags", LRT_BAKING_FINAL_RANGE);
   RNA_def_property_boolean_default(prop, 1);
   RNA_def_property_ui_text(
-      prop, "Final Range", "Bake final frame ranges instead of preview range.");
+      prop, "Final Range", "Bake final frame ranges instead of preview range");
+
+  prop = RNA_def_property(srna, "baking_keyframes_only", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_sdna(prop, NULL, "flags", LRT_BAKING_KEYFRAMES_ONLY);
+  RNA_def_property_boolean_default(prop, 0);
+  RNA_def_property_ui_text(prop, "Keyframes Only", "Only fill in existing gpencil key frames");
 
   prop = RNA_def_property(srna, "baking_preview_start", PROP_INT, PROP_NONE);
-  RNA_def_property_ui_text(prop, "Preview start", "First frame to be baked in preview.");
+  RNA_def_property_ui_text(prop, "Preview start", "First frame to be baked in preview");
   RNA_def_property_range(prop, 0, 100000);
 
   prop = RNA_def_property(srna, "baking_preview_end", PROP_INT, PROP_NONE);
-  RNA_def_property_ui_text(prop, "Preview end", "Last frame to be baked in preview.");
+  RNA_def_property_ui_text(prop, "Preview end", "Last frame to be baked in preview");
   RNA_def_property_range(prop, 0, 100000);
 
   prop = RNA_def_property(srna, "baking_skip", PROP_INT, PROP_NONE);
-  RNA_def_property_ui_text(prop, "Skip", "Skipping frames when baking.");
+  RNA_def_property_ui_text(prop, "Skip", "Skipping frames when baking");
   RNA_def_property_range(prop, 0, 1000);
 }



More information about the Bf-blender-cvs mailing list