[Bf-blender-cvs] [7c979ad568d] lineart-fn-cached: LineArt: UI grey out for cache mode.

YimingWu noreply at git.blender.org
Tue Jun 15 14:09:21 CEST 2021


Commit: 7c979ad568d275b766c5d4e25020648175ae8ef6
Author: YimingWu
Date:   Thu Apr 29 21:04:55 2021 +0800
Branches: lineart-fn-cached
https://developer.blender.org/rB7c979ad568d275b766c5d4e25020648175ae8ef6

LineArt: UI grey out for cache mode.

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

M	source/blender/blenkernel/BKE_gpencil_modifier.h
M	source/blender/blenkernel/intern/gpencil_modifier.c
M	source/blender/blenloader/intern/versioning_300.c
M	source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
M	source/blender/makesdna/DNA_gpencil_modifier_types.h
M	source/blender/makesrna/intern/rna_gpencil_modifier.c

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

diff --git a/source/blender/blenkernel/BKE_gpencil_modifier.h b/source/blender/blenkernel/BKE_gpencil_modifier.h
index 25fd3b18234..b49a6fa244c 100644
--- a/source/blender/blenkernel/BKE_gpencil_modifier.h
+++ b/source/blender/blenkernel/BKE_gpencil_modifier.h
@@ -305,6 +305,7 @@ void BKE_gpencil_get_lineart_global_limits(struct Object *ob,
 
 void BKE_gpencil_assign_lineart_global_limits(struct GpencilModifierData *md,
                                               struct GpencilLineartLimitInfo *info);
+bool BKE_gpencil_lineart_is_first_run(struct Object *ob, struct GpencilModifierData *md);
 
 void BKE_gpencil_lattice_init(struct Object *ob);
 void BKE_gpencil_lattice_clear(struct Object *ob);
diff --git a/source/blender/blenkernel/intern/gpencil_modifier.c b/source/blender/blenkernel/intern/gpencil_modifier.c
index 24d3be8e0d6..83c7938a2ad 100644
--- a/source/blender/blenkernel/intern/gpencil_modifier.c
+++ b/source/blender/blenkernel/intern/gpencil_modifier.c
@@ -225,6 +225,24 @@ void BKE_gpencil_assign_lineart_global_limits(GpencilModifierData *md,
   lmd->edge_types_override = info->edge_types;
 }
 
+bool BKE_gpencil_lineart_is_first_run(Object *ob, GpencilModifierData *md)
+{
+  if (md->type != eGpencilModifierType_Lineart) {
+    return false;
+  }
+  LISTBASE_FOREACH (GpencilModifierData *, gmd, &ob->greasepencil_modifiers) {
+    if (gmd->type == eGpencilModifierType_Lineart) {
+      if (gmd == md) {
+        return true;
+      }
+      else {
+        return false;
+      }
+    }
+  }
+  return false; /* Unlikely. */
+}
+
 /* apply time modifiers */
 static int gpencil_time_modifier(
     Depsgraph *depsgraph, Scene *scene, Object *ob, bGPDlayer *gpl, int cfra, bool is_render)
diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c
index 8c5e86eadd3..b68f65a9c39 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -26,6 +26,7 @@
 
 #include "DNA_brush_types.h"
 #include "DNA_genfile.h"
+#include "DNA_gpencil_modifier_types.h"
 #include "DNA_modifier_types.h"
 #include "DNA_text_types.h"
 
@@ -131,5 +132,18 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
         }
       }
     }
+    if (!DNA_struct_elem_find(
+            fd->filesdna, "LineartGpencilModifierData", "bool", "use_cached_result")) {
+      LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
+        if (ob->type == OB_GPENCIL) {
+          LISTBASE_FOREACH (GpencilModifierData *, md, &ob->greasepencil_modifiers) {
+            if (md->type == eGpencilModifierType_Lineart) {
+              LineartGpencilModifierData *lmd = (LineartGpencilModifierData *)md;
+              lmd->flags |= LRT_GPENCIL_USE_CACHE;
+            }
+          }
+        }
+      }
+    }
   }
 }
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
index 203f56b11e7..4019677159b 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
@@ -255,6 +255,10 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
   uiLayoutSetPropSep(layout, true);
   uiLayoutSetEnabled(layout, !is_baked);
 
+  if (!BKE_gpencil_lineart_is_first_run(ob_ptr.data, ptr->data)) {
+    uiItemR(layout, ptr, "use_cached_result", 0, NULL, ICON_NONE);
+  }
+
   uiItemR(layout, ptr, "source_type", 0, NULL, ICON_NONE);
 
   if (source_type == LRT_SOURCE_OBJECT) {
@@ -274,10 +278,11 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
   uiItemR(col, ptr, "use_edge_mark", 0, IFACE_("Edge Marks"), ICON_NONE);
   uiItemR(col, ptr, "use_intersection", 0, IFACE_("Intersections"), ICON_NONE);
   uiItemR(col, ptr, "use_crease", 0, IFACE_("Crease"), ICON_NONE);
+
   uiLayout *sub = uiLayoutRow(col, true);
-  uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_crease"));
+  uiLayoutSetActive(
+      sub, RNA_boolean_get(ptr, "use_crease") && (!RNA_boolean_get(ptr, "use_cached_result")));
   uiLayoutSetPropSep(sub, true);
-
   uiItemR(sub, ptr, "crease_threshold", UI_ITEM_R_SLIDER, " ", ICON_NONE);
 
   uiItemPointerR(layout, ptr, "target_layer", &obj_data_ptr, "layers", NULL, ICON_GREASEPENCIL);
@@ -301,12 +306,24 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
                  NULL,
                  material_valid ? ICON_SHADING_TEXTURE : ICON_ERROR);
 
+  gpencil_modifier_panel_end(layout, ptr);
+}
+
+static void options_panel_draw(const bContext *UNUSED(C), Panel *panel)
+{
+  uiLayout *layout = panel->layout;
+  PointerRNA *ptr = gpencil_modifier_panel_get_property_pointers(panel, NULL);
+
+  const bool is_baked = RNA_boolean_get(ptr, "is_baked");
+  const bool use_cache = RNA_boolean_get(ptr, "use_cached_result");
+
+  uiLayoutSetPropSep(layout, true);
+  uiLayoutSetEnabled(layout, !is_baked && !use_cache);
+
   uiItemR(layout, ptr, "use_remove_doubles", 0, NULL, ICON_NONE);
   uiItemR(layout, ptr, "use_edge_overlap", 0, IFACE_("Overlapping Edges As Contour"), ICON_NONE);
   uiItemR(layout, ptr, "use_object_instances", 0, NULL, ICON_NONE);
   uiItemR(layout, ptr, "use_clip_plane_boundaries", 0, NULL, ICON_NONE);
-
-  gpencil_modifier_panel_end(layout, ptr);
 }
 
 static void style_panel_draw(const bContext *UNUSED(C), Panel *panel)
@@ -393,9 +410,10 @@ static void chaining_panel_draw(const bContext *UNUSED(C), Panel *panel)
   uiLayout *layout = panel->layout;
 
   const bool is_baked = RNA_boolean_get(ptr, "is_baked");
+  const bool use_cache = RNA_boolean_get(ptr, "use_cached_result");
 
   uiLayoutSetPropSep(layout, true);
-  uiLayoutSetEnabled(layout, !is_baked);
+  uiLayoutSetEnabled(layout, !is_baked && !use_cache);
 
   uiLayout *col = uiLayoutColumnWithHeading(layout, true, IFACE_("Chain"));
   uiItemR(col, ptr, "use_fuzzy_intersections", 0, NULL, ICON_NONE);
@@ -414,9 +432,10 @@ static void vgroup_panel_draw(const bContext *UNUSED(C), Panel *panel)
   uiLayout *layout = panel->layout;
 
   const bool is_baked = RNA_boolean_get(ptr, "is_baked");
+  const bool use_cache = RNA_boolean_get(ptr, "use_cached_result");
 
   uiLayoutSetPropSep(layout, true);
-  uiLayoutSetEnabled(layout, !is_baked);
+  uiLayoutSetEnabled(layout, !is_baked && !use_cache);
 
   uiLayout *col = uiLayoutColumn(layout, true);
 
@@ -466,6 +485,8 @@ static void panelRegister(ARegionType *region_type)
   PanelType *panel_type = gpencil_modifier_panel_register(
       region_type, eGpencilModifierType_Lineart, panel_draw);
 
+  gpencil_modifier_subpanel_register(
+      region_type, "options", "Options", NULL, options_panel_draw, panel_type);
   gpencil_modifier_subpanel_register(
       region_type, "style", "Style", NULL, style_panel_draw, panel_type);
   PanelType *occlusion_panel = gpencil_modifier_subpanel_register(
diff --git a/source/blender/makesdna/DNA_gpencil_modifier_types.h b/source/blender/makesdna/DNA_gpencil_modifier_types.h
index f37d9257a6c..4c81a04870b 100644
--- a/source/blender/makesdna/DNA_gpencil_modifier_types.h
+++ b/source/blender/makesdna/DNA_gpencil_modifier_types.h
@@ -844,6 +844,7 @@ typedef enum eLineArtGPencilModifierFlags {
   LRT_GPENCIL_MATCH_OUTPUT_VGROUP = (1 << 1),
   LRT_GPENCIL_BINARY_WEIGHTS = (1 << 2) /* Deprecated, this is removed for lack of use case. */,
   LRT_GPENCIL_IS_BAKED = (1 << 3),
+  LRT_GPENCIL_USE_CACHE = (1 << 4),
 } eLineArtGPencilModifierFlags;
 
 typedef enum eLineartGpencilTransparencyFlags {
diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c
index 85a3bd2192c..56756e0cec7 100644
--- a/source/blender/makesrna/intern/rna_gpencil_modifier.c
+++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c
@@ -2870,6 +2870,13 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna)
   RNA_def_property_ui_text(prop, "Is Baked", "This modifier has baked data");
   RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
 
+  prop = RNA_def_property(srna, "use_cached_result", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_sdna(prop, NULL, "flags", LRT_GPENCIL_USE_CACHE);
+  RNA_def_property_ui_text(prop,
+                           "Used Cached Result",
+                           "Use cached line art result instead of run line art once again.");
+  RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
   prop = RNA_def_property(srna, "thickness", PROP_INT, PROP_NONE);
   RNA_def_property_ui_text(prop, "Thickness", "The thickness for the generated strokes");
   RNA_def_property_ui_range(prop, 1, 100, 1, 1);



More information about the Bf-blender-cvs mailing list