[Bf-blender-cvs] [bd0feef52a3] temp-lineart-contained: LineArt: Mark sharp as crease.

YimingWu noreply at git.blender.org
Wed Jun 23 09:54:03 CEST 2021


Commit: bd0feef52a30afc727ea8ee51e58267e453ae91a
Author: YimingWu
Date:   Wed Jun 23 15:50:25 2021 +0800
Branches: temp-lineart-contained
https://developer.blender.org/rBbd0feef52a30afc727ea8ee51e58267e453ae91a

LineArt: Mark sharp as crease.

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

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 34fe3ad6b5a..9d47ef2ffe9 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
@@ -419,6 +419,7 @@ static void options_panel_draw(const bContext *UNUSED(C), Panel *panel)
   uiItemR(layout, ptr, "floating_as_contour", 0, NULL, ICON_NONE);
   uiItemR(layout, ptr, "use_multiple_edge_types", 0, NULL, ICON_NONE);
   uiItemR(layout, ptr, "use_crease_on_smooth", 0, IFACE_("Crease On Smooth"), ICON_NONE);
+  uiItemR(layout, ptr, "use_crease_on_sharp", 0, IFACE_("Crease On Sharp"), ICON_NONE);
 }
 
 static void style_panel_draw(const bContext *UNUSED(C), Panel *panel)
diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
index b788b33e94a..a6d6b16174f 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
+++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
@@ -309,6 +309,7 @@ typedef struct LineartRenderBuffer {
   bool filter_face_mark_boundaries;
 
   bool force_crease;
+  bool sharp_as_crease;
 
   /* Keep an copy of these data so when line art is running it's self-contained. */
   bool cam_is_persp;
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
index 2332f6cb6cf..85af630249f 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
@@ -1455,7 +1455,6 @@ static uint16_t lineart_identify_feature_line(LineartRenderBuffer *rb,
                                               LineartTriangle *rt_array,
                                               LineartVert *rv_array,
                                               float crease_threshold,
-                                              bool force_crease,
                                               bool use_auto_smooth,
                                               bool use_freestyle_edge,
                                               bool use_freestyle_face,
@@ -1564,17 +1563,24 @@ static uint16_t lineart_identify_feature_line(LineartRenderBuffer *rb,
     }
   }
 
-  bool do_crease = true;
-  if (!force_crease &&
-      (BM_elem_flag_test(ll->f, BM_ELEM_SMOOTH) && BM_elem_flag_test(lr->f, BM_ELEM_SMOOTH))) {
-    if (!use_auto_smooth) {
-      do_crease = false;
+  if (rb->use_crease) {
+    if (rb->sharp_as_crease && !BM_elem_flag_test(e, BM_ELEM_SMOOTH)) {
+      edge_flag_result |= LRT_EDGE_FLAG_CREASE;
+    }
+    else {
+      bool do_crease = true;
+      if (!rb->force_crease &&
+          (BM_elem_flag_test(ll->f, BM_ELEM_SMOOTH) && BM_elem_flag_test(lr->f, BM_ELEM_SMOOTH))) {
+        if (!use_auto_smooth) {
+          do_crease = false;
+        }
+      }
+      if (do_crease && (dot_v3v3_db(tri1->gn, tri2->gn) < crease_threshold)) {
+        edge_flag_result |= LRT_EDGE_FLAG_CREASE;
+      }
     }
   }
-  if (do_crease && rb->use_crease && (dot_v3v3_db(tri1->gn, tri2->gn) < crease_threshold)) {
-    edge_flag_result |= LRT_EDGE_FLAG_CREASE;
-  }
-  else if (rb->use_material && (ll->f->mat_nr != lr->f->mat_nr)) {
+  if (rb->use_material && (ll->f->mat_nr != lr->f->mat_nr)) {
     edge_flag_result |= LRT_EDGE_FLAG_MATERIAL;
   }
   else if (use_freestyle_edge && rb->use_edge_marks) {
@@ -1714,7 +1720,6 @@ static void lineart_geometry_object_load(LineartObjectInfo *obi, LineartRenderBu
   bool can_find_freestyle_edge = false;
   bool can_find_freestyle_face = false;
   bool use_auto_smooth = obi->original_me->flag & ME_AUTOSMOOTH;
-  bool force_crease = rb->force_crease;
   int i;
   float use_crease = 0;
 
@@ -1890,7 +1895,6 @@ static void lineart_geometry_object_load(LineartObjectInfo *obi, LineartRenderBu
                                                    ort,
                                                    orv,
                                                    use_crease,
-                                                   force_crease,
                                                    use_auto_smooth,
                                                    can_find_freestyle_edge,
                                                    can_find_freestyle_face,
@@ -3140,6 +3144,7 @@ static LineartRenderBuffer *lineart_create_render_buffer(Scene *scene,
   rb->allow_duplicated_types = (lmd->calculation_flags & LRT_ALLOW_MULTIPLE_EDGE_TYPES) != 0;
 
   rb->force_crease = (lmd->calculation_flags & LRT_USE_CREASE_ON_SMOOTH_SURFACES) != 0;
+  rb->sharp_as_crease = (lmd->calculation_flags & LRT_USE_CREASE_ON_SHARP_EDGES) != 0;
 
   int16_t edge_types = lmd->edge_types_override;
 
diff --git a/source/blender/makesdna/DNA_gpencil_modifier_defaults.h b/source/blender/makesdna/DNA_gpencil_modifier_defaults.h
index 05f37da56fe..517999eeb32 100644
--- a/source/blender/makesdna/DNA_gpencil_modifier_defaults.h
+++ b/source/blender/makesdna/DNA_gpencil_modifier_defaults.h
@@ -294,7 +294,7 @@
     .opacity = 1.0f, \
     .flags = LRT_GPENCIL_MATCH_OUTPUT_VGROUP, \
     .crease_threshold = DEG2RAD(140.0f), \
-    .calculation_flags = LRT_ALLOW_DUPLI_OBJECTS | LRT_ALLOW_CLIPPING_BOUNDARIES, \
+    .calculation_flags = LRT_ALLOW_DUPLI_OBJECTS | LRT_ALLOW_CLIPPING_BOUNDARIES | LRT_USE_CREASE_ON_SHARP_EDGES, \
     .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 4bf1ce50979..39654ce7555 100644
--- a/source/blender/makesdna/DNA_lineart_types.h
+++ b/source/blender/makesdna/DNA_lineart_types.h
@@ -58,6 +58,7 @@ typedef enum eLineartMainFlags {
   LRT_ALLOW_MULTIPLE_EDGE_TYPES = (1 << 13),
   LRT_USE_CUSTOM_CAMERA = (1 << 14),
   LRT_USE_CREASE_ON_SMOOTH_SURFACES = (1 << 15),
+  LRT_USE_CREASE_ON_SHARP_EDGES = (1 << 16),
 } 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 df7b0d3eeaa..cc99eb74196 100644
--- a/source/blender/makesrna/intern/rna_gpencil_modifier.c
+++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c
@@ -3096,7 +3096,12 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna)
   RNA_def_property_boolean_sdna(
       prop, NULL, "calculation_flags", LRT_USE_CREASE_ON_SMOOTH_SURFACES);
   RNA_def_property_ui_text(
-      prop, "Crease On Smooth Surfaces", "Allow crease edges to show on smooth surfaces");
+      prop, "Crease On Smooth Surfaces", "Allow crease edges to show inside smooth surfaces");
+  RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+  prop = RNA_def_property(srna, "use_crease_on_sharp", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_sdna(prop, NULL, "calculation_flags", LRT_USE_CREASE_ON_SHARP_EDGES);
+  RNA_def_property_ui_text(prop, "Crease On Sharp Edges", "Allow crease to show on sharp edges");
   RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
 
   RNA_define_lib_overridable(false);



More information about the Bf-blender-cvs mailing list