[Bf-blender-cvs] [ae7280d1239] temp-lineart-contained: LineArt: Preserving countour for face mark filtering.

YimingWu noreply at git.blender.org
Mon Jun 28 11:24:48 CEST 2021


Commit: ae7280d1239ca6dbf9015a2d822a655e242e68b7
Author: YimingWu
Date:   Mon Jun 28 17:24:22 2021 +0800
Branches: temp-lineart-contained
https://developer.blender.org/rBae7280d1239ca6dbf9015a2d822a655e242e68b7

LineArt: Preserving countour for face mark filtering.

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

M	source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
M	source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
M	source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
M	source/blender/makesdna/DNA_gpencil_modifier_defaults.h
M	source/blender/makesdna/DNA_lineart_types.h
M	source/blender/makesrna/intern/rna_gpencil_modifier.c

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

diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
index 097acd4f816..6bbab4faed9 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
@@ -593,6 +593,7 @@ static void face_mark_panel_draw(const bContext *UNUSED(C), Panel *panel)
   if (!use_cache || is_first) {
     uiItemR(layout, ptr, "use_face_mark_invert", 0, NULL, ICON_NONE);
     uiItemR(layout, ptr, "use_face_mark_boundaries", 0, NULL, ICON_NONE);
+    uiItemR(layout, ptr, "use_face_mark_keep_contour", 0, NULL, ICON_NONE);
   }
   else {
     uiItemL(layout, "Cached with the first line art modifier.", ICON_INFO);
diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
index c04bcde9a94..a0ac7bba31c 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
+++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
@@ -308,6 +308,7 @@ typedef struct LineartRenderBuffer {
   bool filter_face_mark;
   bool filter_face_mark_invert;
   bool filter_face_mark_boundaries;
+  bool filter_face_mark_keep_contour;
 
   bool force_crease;
   bool sharp_as_crease;
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
index ca9c959d485..e1e395cca62 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
@@ -1485,6 +1485,7 @@ static uint16_t lineart_identify_feature_line(LineartRenderBuffer *rb,
 
   FreestyleEdge *fel, *fer;
   bool face_mark_filtered = false;
+  bool only_contour = false;
 
   if (use_freestyle_face && rb->filter_face_mark) {
     fel = CustomData_bmesh_get(&bm_if_freestyle->pdata, ll->f->head.data, CD_FREESTYLE_FACE);
@@ -1509,13 +1510,18 @@ static uint16_t lineart_identify_feature_line(LineartRenderBuffer *rb,
       face_mark_filtered = !face_mark_filtered;
     }
     if (!face_mark_filtered) {
-      return 0;
+      if (rb->filter_face_mark_keep_contour) {
+        only_contour = true;
+      }
+      else {
+        return 0;
+      }
     }
   }
 
   uint16_t edge_flag_result = 0;
 
-  if (use_freestyle_edge && rb->use_edge_marks) {
+  if ((!only_contour) && use_freestyle_edge && rb->use_edge_marks) {
     FreestyleEdge *fe;
     fe = CustomData_bmesh_get(&bm_if_freestyle->edata, e->head.data, CD_FREESTYLE_EDGE);
     if (fe->flag & FREESTYLE_EDGE_MARK) {
@@ -1559,6 +1565,12 @@ static uint16_t lineart_identify_feature_line(LineartRenderBuffer *rb,
     }
   }
 
+  /* For when face mark filtering decided that we discard the face but keep_contour option is on.
+   * so we still have correct full contour around the object. */
+  if (only_contour) {
+    return edge_flag_result;
+  }
+
   if (rb->use_light_contour) {
     if (rb->light_is_sun) {
       view_vector = rb->light_vector;
@@ -3156,6 +3168,8 @@ static LineartRenderBuffer *lineart_create_render_buffer(Scene *scene,
   rb->filter_face_mark = (lmd->calculation_flags & LRT_FILTER_FACE_MARK) != 0;
   rb->filter_face_mark_boundaries = (lmd->calculation_flags & LRT_FILTER_FACE_MARK_BOUNDARIES) !=
                                     0;
+  rb->filter_face_mark_keep_contour = (lmd->calculation_flags &
+                                       LRT_FILTER_FACE_MARK_KEEP_CONTOUR) != 0;
 
   rb->chain_data_pool = &lc->chain_data_pool;
 
diff --git a/source/blender/makesdna/DNA_gpencil_modifier_defaults.h b/source/blender/makesdna/DNA_gpencil_modifier_defaults.h
index 517999eeb32..284ff59b134 100644
--- a/source/blender/makesdna/DNA_gpencil_modifier_defaults.h
+++ b/source/blender/makesdna/DNA_gpencil_modifier_defaults.h
@@ -294,7 +294,8 @@
     .opacity = 1.0f, \
     .flags = LRT_GPENCIL_MATCH_OUTPUT_VGROUP, \
     .crease_threshold = DEG2RAD(140.0f), \
-    .calculation_flags = LRT_ALLOW_DUPLI_OBJECTS | LRT_ALLOW_CLIPPING_BOUNDARIES | LRT_USE_CREASE_ON_SHARP_EDGES, \
+    .calculation_flags = LRT_ALLOW_DUPLI_OBJECTS | LRT_ALLOW_CLIPPING_BOUNDARIES | \
+                         LRT_USE_CREASE_ON_SHARP_EDGES | LRT_FILTER_FACE_MARK_KEEP_CONTOUR, \
     .angle_splitting_threshold = DEG2RAD(60.0f), \
     .chaining_image_threshold = 0.001f, \
     .stroke_offset = 0.05,\
diff --git a/source/blender/makesdna/DNA_lineart_types.h b/source/blender/makesdna/DNA_lineart_types.h
index ce0c813fd50..125d6979deb 100644
--- a/source/blender/makesdna/DNA_lineart_types.h
+++ b/source/blender/makesdna/DNA_lineart_types.h
@@ -59,6 +59,7 @@ typedef enum eLineartMainFlags {
   LRT_USE_CUSTOM_CAMERA = (1 << 15),
   LRT_USE_CREASE_ON_SMOOTH_SURFACES = (1 << 16),
   LRT_USE_CREASE_ON_SHARP_EDGES = (1 << 17),
+  LRT_FILTER_FACE_MARK_KEEP_CONTOUR = (1 << 18),
 } eLineartMainFlags;
 
 typedef enum eLineartEdgeFlag {
diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c
index 68101ba2f38..44f90e01a19 100644
--- a/source/blender/makesrna/intern/rna_gpencil_modifier.c
+++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c
@@ -2857,6 +2857,12 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna)
       prop, "Boundaries", "Filter feature lines based on face mark boundaries");
   RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
 
+  prop = RNA_def_property(srna, "use_face_mark_keep_contour", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_sdna(
+      prop, NULL, "calculation_flags", LRT_FILTER_FACE_MARK_KEEP_CONTOUR);
+  RNA_def_property_ui_text(prop, "Keep Contour", "Preserve contour lines while filtering");
+  RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
   prop = RNA_def_property(srna, "chaining_image_threshold", PROP_FLOAT, PROP_DISTANCE);
   RNA_def_property_ui_text(
       prop,



More information about the Bf-blender-cvs mailing list