[Bf-blender-cvs] [be91ecbca31] temp-lineart-contained: LineArt: Toggle duplicated edge for types.

YimingWu noreply at git.blender.org
Thu May 13 08:23:38 CEST 2021


Commit: be91ecbca313073bbd27f7ada75cd5efcce8f22f
Author: YimingWu
Date:   Thu May 13 14:22:25 2021 +0800
Branches: temp-lineart-contained
https://developer.blender.org/rBbe91ecbca313073bbd27f7ada75cd5efcce8f22f

LineArt: Toggle duplicated edge for types.

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

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 d821472942b..b9ef610bb0a 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
@@ -349,6 +349,7 @@ static void options_panel_draw(const bContext *UNUSED(C), Panel *panel)
   uiItemR(layout, ptr, "use_object_instances", 0, NULL, ICON_NONE);
   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);
 }
 
 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 e59f245de6c..d3e3aa5ce92 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
+++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
@@ -302,6 +302,7 @@ typedef struct LineartRenderBuffer {
   bool fuzzy_everything;
   bool allow_boundaries;
   bool allow_overlapping_edges;
+  bool allow_duplicated_types;
   bool remove_doubles;
   bool floating_as_contour;
   bool chain_floating_edges;
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
index 26ff1abc342..3abf5b0bb20 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
@@ -1818,8 +1818,9 @@ static void lineart_geometry_object_load(LineartObjectInfo *obi, LineartRenderBu
                                                can_find_freestyle_face,
                                                bm);
     if (eflag) {
-      /* Only allocate for feature lines (instead of all lines) to save memory. */
-      allocate_la_e += lineart_edge_type_duplication_count(eflag);
+      /* Only allocate for feature lines (instead of all lines) to save memory.
+       * If allow duplicated edges, one edge gets added multiple times if it has multiple types. */
+      allocate_la_e += rb->allow_duplicated_types ? lineart_edge_type_duplication_count(eflag) : 1;
     }
     /* Here we just use bm's flag for when loading actual lines, then we don't need to call
      * lineart_identify_feature_line() again, e->head.hflag deleted after loading anyway. Always
@@ -1886,6 +1887,10 @@ static void lineart_geometry_object_load(LineartObjectInfo *obi, LineartRenderBu
 
       la_e++;
       la_s++;
+
+      if (!rb->allow_duplicated_types) {
+        break;
+      }
     }
   }
 
@@ -3017,6 +3022,9 @@ static LineartRenderBuffer *lineart_create_render_buffer(Scene *scene,
   /* See lineart_edge_from_triangle() for how this option may impact performance. */
   rb->allow_overlapping_edges = (lmd->calculation_flags & LRT_ALLOW_OVERLAPPING_EDGES) != 0;
 
+  rb->allow_duplicated_types = (lmd->calculation_flags & LRT_ALLOW_MULTIPLE_EDGE_TYPES) != 0;
+
+  /* lmd->edge_types_override contains all used flags in the modifier stack. */
   rb->use_contour = (lmd->edge_types_override & LRT_EDGE_FLAG_CONTOUR) != 0;
   rb->use_crease = (lmd->edge_types_override & LRT_EDGE_FLAG_CREASE) != 0;
   rb->use_material = (lmd->edge_types_override & LRT_EDGE_FLAG_MATERIAL) != 0;
diff --git a/source/blender/makesdna/DNA_lineart_types.h b/source/blender/makesdna/DNA_lineart_types.h
index 16a7d386fa5..d9dd069a32d 100644
--- a/source/blender/makesdna/DNA_lineart_types.h
+++ b/source/blender/makesdna/DNA_lineart_types.h
@@ -55,6 +55,7 @@ typedef enum eLineartMainFlags {
   LRT_FILTER_FACE_MARK_BOUNDARIES = (1 << 11),
   LRT_CHAIN_FLOATING_EDGES = (1 << 11),
   LRT_CHAIN_GEOMETRY_SPACE = (1 << 12),
+  LRT_ALLOW_MULTIPLE_EDGE_TYPES = (1 << 13),
 } 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 dbae7c90c5f..86b673573b0 100644
--- a/source/blender/makesrna/intern/rna_gpencil_modifier.c
+++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c
@@ -2810,6 +2810,12 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna)
       prop, "Use Geometry Space", "Use geometry distance for chaining instead of image space.");
   RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
 
+  prop = RNA_def_property(srna, "use_multiple_edge_types", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_sdna(prop, NULL, "calculation_flags", LRT_ALLOW_MULTIPLE_EDGE_TYPES);
+  RNA_def_property_ui_text(
+      prop, "Multiple Edge Types", "Allow edges with muliple types be added for every type");
+  RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
   prop = RNA_def_property(srna, "stroke_offset", PROP_FLOAT, PROP_DISTANCE);
   RNA_def_property_ui_text(prop,
                            "Stroke Offset",



More information about the Bf-blender-cvs mailing list