[Bf-blender-cvs] [f5adb96d5ca] temp-lineart-contained: LineArt: Use Smooth/AutoSmooth for crease.

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


Commit: f5adb96d5ca7769683bf26c83b3f80578524c6d9
Author: YimingWu
Date:   Wed Jun 23 15:28:23 2021 +0800
Branches: temp-lineart-contained
https://developer.blender.org/rBf5adb96d5ca7769683bf26c83b3f80578524c6d9

LineArt: Use Smooth/AutoSmooth for 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_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 6ddcf2e0327..34fe3ad6b5a 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
@@ -418,6 +418,7 @@ static void options_panel_draw(const bContext *UNUSED(C), Panel *panel)
   uiItemR(layout, ptr, "use_clip_plane_boundaries", 0, NULL, ICON_NONE);
   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);
 }
 
 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 271d16e04c0..b788b33e94a 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
+++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
@@ -308,6 +308,8 @@ typedef struct LineartRenderBuffer {
   bool filter_face_mark_invert;
   bool filter_face_mark_boundaries;
 
+  bool force_crease;
+
   /* Keep an copy of these data so when line art is running it's self-contained. */
   bool cam_is_persp;
   float cam_obmat[4][4];
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
index e0d6e975a09..2332f6cb6cf 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
@@ -1455,7 +1455,8 @@ static uint16_t lineart_identify_feature_line(LineartRenderBuffer *rb,
                                               LineartTriangle *rt_array,
                                               LineartVert *rv_array,
                                               float crease_threshold,
-                                              bool no_crease,
+                                              bool force_crease,
+                                              bool use_auto_smooth,
                                               bool use_freestyle_edge,
                                               bool use_freestyle_face,
                                               BMesh *bm_if_freestyle)
@@ -1563,11 +1564,16 @@ static uint16_t lineart_identify_feature_line(LineartRenderBuffer *rb,
     }
   }
 
-  if (rb->use_crease && (dot_v3v3_db(tri1->gn, tri2->gn) < crease_threshold)) {
-    if (!no_crease) {
-      edge_flag_result |= LRT_EDGE_FLAG_CREASE;
+  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 (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)) {
     edge_flag_result |= LRT_EDGE_FLAG_MATERIAL;
   }
@@ -1707,6 +1713,8 @@ static void lineart_geometry_object_load(LineartObjectInfo *obi, LineartRenderBu
   Object *orig_ob;
   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;
 
@@ -1789,6 +1797,9 @@ static void lineart_geometry_object_load(LineartObjectInfo *obi, LineartRenderBu
   }
   else {
     use_crease = rb->crease_threshold;
+    if (use_auto_smooth) {
+      use_crease = cos(obi->original_me->smoothresh);
+    }
   }
 
   /* FIXME(Yiming): Hack for getting clean 3D text, the seam that extruded text object creates
@@ -1879,7 +1890,8 @@ static void lineart_geometry_object_load(LineartObjectInfo *obi, LineartRenderBu
                                                    ort,
                                                    orv,
                                                    use_crease,
-                                                   orig_ob->type == OB_FONT,
+                                                   force_crease,
+                                                   use_auto_smooth,
                                                    can_find_freestyle_edge,
                                                    can_find_freestyle_face,
                                                    bm);
@@ -3127,6 +3139,8 @@ 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;
+
   int16_t edge_types = lmd->edge_types_override;
 
   /* lmd->edge_types_override contains all used flags in the modifier stack. */
diff --git a/source/blender/makesdna/DNA_lineart_types.h b/source/blender/makesdna/DNA_lineart_types.h
index 3aa61c3c775..4bf1ce50979 100644
--- a/source/blender/makesdna/DNA_lineart_types.h
+++ b/source/blender/makesdna/DNA_lineart_types.h
@@ -57,6 +57,7 @@ typedef enum eLineartMainFlags {
   LRT_CHAIN_GEOMETRY_SPACE = (1 << 12),
   LRT_ALLOW_MULTIPLE_EDGE_TYPES = (1 << 13),
   LRT_USE_CUSTOM_CAMERA = (1 << 14),
+  LRT_USE_CREASE_ON_SMOOTH_SURFACES = (1 << 15),
 } 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 1eaa13fc4dc..45ea2335d09 100644
--- a/source/blender/makesrna/intern/rna_gpencil_modifier.c
+++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c
@@ -3092,6 +3092,13 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna)
   RNA_def_property_ui_text(prop, "Masks", "");
   RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
 
+  prop = RNA_def_property(srna, "use_crease_on_smooth", PROP_BOOLEAN, PROP_NONE);
+  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");
+  RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
   RNA_define_lib_overridable(false);
 }



More information about the Bf-blender-cvs mailing list