[Bf-blender-cvs] [d1e0059eac9] master: LineArt: Filtering intersection lines using mask numbers

YimingWu noreply at git.blender.org
Tue Jun 29 14:50:32 CEST 2021


Commit: d1e0059eac99654624edee2a2390a3e2fdc4c7cb
Author: YimingWu
Date:   Tue Jun 29 20:47:55 2021 +0800
Branches: master
https://developer.blender.org/rBd1e0059eac99654624edee2a2390a3e2fdc4c7cb

LineArt: Filtering intersection lines using mask numbers

Mask value works just like transparency mask.

You are able to select intersection lines inside a
collection or, between collections.

Reviewed By: Sebastian Parborg (zeddb)

Differential Revision: https://developer.blender.org/D11309

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

M	release/scripts/startup/bl_ui/properties_collection.py
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_chain.c
M	source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
M	source/blender/gpencil_modifiers/intern/lineart/lineart_ops.c
M	source/blender/makesdna/DNA_collection_types.h
M	source/blender/makesdna/DNA_gpencil_modifier_types.h
M	source/blender/makesdna/intern/dna_rename_defs.h
M	source/blender/makesrna/intern/rna_collection.c
M	source/blender/makesrna/intern/rna_gpencil_modifier.c

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

diff --git a/release/scripts/startup/bl_ui/properties_collection.py b/release/scripts/startup/bl_ui/properties_collection.py
index 5a98e638992..27de80bb88d 100644
--- a/release/scripts/startup/bl_ui/properties_collection.py
+++ b/release/scripts/startup/bl_ui/properties_collection.py
@@ -86,6 +86,13 @@ class COLLECTION_PT_lineart_collection(CollectionButtonsPanel, Panel):
         row = layout.row()
         row.prop(collection, "lineart_usage")
 
+        layout.prop(collection, "lineart_use_intersection_mask")
+
+        row = layout.row(align=True, heading="Masks")
+        row.active = collection.lineart_use_intersection_mask
+        for i in range(0,8):
+            row.prop(collection, "lineart_intersection_mask", index=i, text=str(i), toggle=True)
+
 
 classes = (
     COLLECTION_PT_collection_flags,
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
index f205559b941..9593a1364e7 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
@@ -101,8 +101,9 @@ static void generate_strokes_actual(
       lmd->use_multiple_levels ? lmd->level_end : lmd->level_start,
       lmd->target_material ? BKE_gpencil_object_material_index_get(ob, lmd->target_material) : 0,
       lmd->edge_types,
-      lmd->material_mask_flags,
+      lmd->mask_switches,
       lmd->material_mask_bits,
+      lmd->intersection_mask,
       lmd->thickness,
       lmd->opacity,
       lmd->source_vertex_group,
@@ -462,6 +463,32 @@ static void material_mask_panel_draw(const bContext *UNUSED(C), Panel *panel)
   uiItemR(col, ptr, "use_material_mask_match", 0, IFACE_("Match All Masks"), ICON_NONE);
 }
 
+static void intersection_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");
+  uiLayoutSetEnabled(layout, !is_baked);
+
+  uiLayoutSetPropSep(layout, true);
+
+  uiLayoutSetActive(layout, RNA_boolean_get(ptr, "use_intersection"));
+
+  uiLayout *row = uiLayoutRow(layout, true);
+  uiLayoutSetPropDecorate(row, false);
+  uiLayout *sub = uiLayoutRowWithHeading(row, true, IFACE_("Masks"));
+  char text[2] = "0";
+
+  PropertyRNA *prop = RNA_struct_find_property(ptr, "use_intersection_mask");
+  for (int i = 0; i < 8; i++, text[0]++) {
+    uiItemFullR(sub, ptr, prop, i, 0, UI_ITEM_R_TOGGLE, text, ICON_NONE);
+  }
+  uiItemL(row, "", ICON_BLANK1); /* Space for decorator. */
+
+  uiLayout *col = uiLayoutColumn(layout, true);
+  uiItemR(col, ptr, "use_intersection_match", 0, IFACE_("Match All Masks"), ICON_NONE);
+}
 static void face_mark_panel_draw_header(const bContext *UNUSED(C), Panel *panel)
 {
   uiLayout *layout = panel->layout;
@@ -626,6 +653,8 @@ static void panelRegister(ARegionType *region_type)
                                      material_mask_panel_draw_header,
                                      material_mask_panel_draw,
                                      occlusion_panel);
+  gpencil_modifier_subpanel_register(
+      region_type, "intersection", "Intersection", NULL, intersection_panel_draw, panel_type);
   gpencil_modifier_subpanel_register(
       region_type, "face_mark", "", face_mark_panel_draw_header, face_mark_panel_draw, panel_type);
   gpencil_modifier_subpanel_register(
diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
index debfabae869..247b0b3f57b 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
+++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
@@ -52,8 +52,8 @@ typedef struct LineartTriangle {
   /* first culled in line list to use adjacent triangle info, then go through triangle list. */
   double gn[3];
 
-  /* Material flag is removed to save space. */
   unsigned char material_mask_bits;
+  unsigned char intersection_mask;
   unsigned char mat_occlusion;
   unsigned char flags; /* #eLineartTriangleFlags */
 
@@ -149,6 +149,7 @@ typedef struct LineartEdge {
 
   /** Also for line type determination on chaining. */
   unsigned char flags;
+  unsigned char intersection_mask;
 
   /**
    * Still need this entry because culled lines will not add to object
@@ -174,6 +175,7 @@ typedef struct LineartEdgeChain {
   /** Chain now only contains one type of segments */
   int type;
   unsigned char material_mask_bits;
+  unsigned char intersection_mask;
 
   struct Object *object_ref;
 } LineartEdgeChain;
@@ -188,6 +190,7 @@ typedef struct LineartEdgeChainItem {
   unsigned char line_type;
   char occlusion;
   unsigned char material_mask_bits;
+  unsigned char intersection_mask;
   size_t index;
 } LineartEdgeChainItem;
 
@@ -377,6 +380,7 @@ typedef struct LineartObjectInfo {
   double normal[4][4];
   LineartElementLinkNode *v_eln;
   int usage;
+  uint8_t override_intersection_mask;
   int global_i_offset;
 
   bool free_use_mesh;
@@ -612,8 +616,9 @@ void MOD_lineart_gpencil_generate(LineartCache *cache,
                                   int level_end,
                                   int mat_nr,
                                   short edge_types,
-                                  unsigned char material_mask_flags,
+                                  unsigned char mask_switches,
                                   unsigned char material_mask_bits,
+                                  unsigned char intersection_mask,
                                   short thickness,
                                   float opacity,
                                   const char *source_vgname,
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
index a9f290eb6fa..52485648ee0 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
@@ -38,7 +38,8 @@
 static LineartEdge *lineart_line_get_connected(LineartBoundingArea *ba,
                                                LineartVert *vt,
                                                LineartVert **new_vt,
-                                               int match_flag)
+                                               int match_flag,
+                                               unsigned char match_isec_mask)
 {
   for (int i = 0; i < ba->line_count; i++) {
     LineartEdge *n_e = ba->linked_lines[i];
@@ -51,6 +52,10 @@ static LineartEdge *lineart_line_get_connected(LineartBoundingArea *ba,
       continue;
     }
 
+    if (n_e->intersection_mask != match_isec_mask) {
+      continue;
+    }
+
     *new_vt = LRT_OTHER_VERT(n_e, vt);
     if (*new_vt) {
       return n_e;
@@ -112,11 +117,11 @@ static LineartEdgeChainItem *lineart_chain_append_point(LineartRenderBuffer *rb,
     /* Because the new chain point is overlapping, just replace the type and occlusion level of the
      * current point. This makes it so that the line to the point after this one has the correct
      * type and level. */
-    LineartEdgeChainItem *old_rlci = ec->chain.last;
-    old_rlci->line_type = type;
-    old_rlci->occlusion = level;
-    old_rlci->material_mask_bits = material_mask_bits;
-    return old_rlci;
+    LineartEdgeChainItem *old_eci = ec->chain.last;
+    old_eci->line_type = type;
+    old_eci->occlusion = level;
+    old_eci->material_mask_bits = material_mask_bits;
+    return old_eci;
   }
 
   eci = lineart_mem_acquire(rb->chain_data_pool, sizeof(LineartEdgeChainItem));
@@ -194,9 +199,10 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb)
 
     ec = lineart_chain_create(rb);
 
-    /* One chain can only have one object_ref,
-     * so we assign it based on the first segment we found. */
+    /* One chain can only have one object_ref and intersection_mask,
+     * so we assign them based on the first segment we found. */
     ec->object_ref = e->object_ref;
+    ec->intersection_mask = e->intersection_mask;
 
     LineartEdge *new_e;
     LineartVert *new_vt;
@@ -230,7 +236,8 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb)
                                 es->occlusion,
                                 es->material_mask_bits,
                                 e->v1_obindex);
-    while (ba && (new_e = lineart_line_get_connected(ba, new_vt, &new_vt, e->flags))) {
+    while (ba && (new_e = lineart_line_get_connected(
+                      ba, new_vt, &new_vt, e->flags, e->intersection_mask))) {
       new_e->flags |= LRT_EDGE_FLAG_CHAIN_PICKED;
 
       if (new_e->t1 || new_e->t2) {
@@ -360,7 +367,8 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb)
     /*  Step 3: grow right. */
     ba = MOD_lineart_get_bounding_area(rb, e->v2->fbcoord[0], e->v2->fbcoord[1]);
     new_vt = e->v2;
-    while (ba && (new_e = lineart_line_get_connected(ba, new_vt, &new_vt, e->flags))) {
+    while (ba && (new_e = lineart_line_get_connected(
+                      ba, new_vt, &new_vt, e->flags, e->intersection_mask))) {
       new_e->flags |= LRT_EDGE_FLAG_CHAIN_PICKED;
 
       if (new_e->t1 || new_e->t2) {
@@ -560,8 +568,8 @@ static void lineart_bounding_area_link_chain(LineartRenderBuffer *rb, LineartEdg
 
 void MOD_lineart_chain_split_for_fixed_occlusion(LineartRenderBuffer *rb)
 {
-  LineartEdgeChain *ec, *new_rlc;
-  LineartEdgeChainItem *eci, *next_rlci;
+  LineartEdgeChain *ec, *new_ec;
+  LineartEdgeChainItem *eci, *next_eci;
   ListBase swap = {0};
 
   swap.first = rb->chains.first;
@@ -572,16 +580,16 @@ void MOD_lineart_chain_split_for_fixed_occlusion(LineartRenderBuffer *rb)
   while ((ec = BLI_pophead(&swap)) != NULL) {
     ec->next = ec->prev = NULL;
     BLI_addtail(&rb->chains, ec);
-    LineartEdgeChainItem *first_rlci = (LineartEdgeChainItem *)ec->chain.first;
-    int fixed_occ = first_rlci->occlusion;
-    unsigned char fixed_mask = first_rlci->material_mask_bits;
+    LineartEdgeChainItem *first_eci = (LineartEdgeChainItem *)ec->chain.first;
+    int fixed_occ = first_eci->occlusion;
+    unsigned char fixed_mask = first_

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list