[Bf-blender-cvs] [25d072436d8] lineart-shadow: LineArt: Intersection priority

YimingWu noreply at git.blender.org
Mon May 23 14:29:30 CEST 2022


Commit: 25d072436d84b7e8e4b022d1730ad485b59ba2d2
Author: YimingWu
Date:   Mon May 23 20:28:55 2022 +0800
Branches: lineart-shadow
https://developer.blender.org/rB25d072436d84b7e8e4b022d1730ad485b59ba2d2

LineArt: Intersection priority

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

M	release/scripts/startup/bl_ui/properties_collection.py
M	release/scripts/startup/bl_ui/properties_material.py
M	release/scripts/startup/bl_ui/properties_object.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/makesdna/DNA_collection_types.h
M	source/blender/makesdna/DNA_material_types.h
M	source/blender/makesdna/DNA_object_types.h
M	source/blender/makesrna/intern/rna_collection.c
M	source/blender/makesrna/intern/rna_material.c
M	source/blender/makesrna/intern/rna_object.c

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

diff --git a/release/scripts/startup/bl_ui/properties_collection.py b/release/scripts/startup/bl_ui/properties_collection.py
index f2a8f1a2f7d..fd38c07536d 100644
--- a/release/scripts/startup/bl_ui/properties_collection.py
+++ b/release/scripts/startup/bl_ui/properties_collection.py
@@ -80,12 +80,17 @@ class COLLECTION_PT_lineart_collection(CollectionButtonsPanel, Panel):
             if i == 3:
                 row = col.row(align=True)
                 
-            
         row = layout.row(heading="Silouette Group")
         row.prop(collection, "use_lineart_silhouette_group", text="")
         subrow = row.row()
         subrow.active = collection.use_lineart_silhouette_group
         subrow.prop(collection, "lineart_silhouette_group", text="")
+        
+        row = layout.row(heading="Intersection Priority")
+        row.prop(collection, "use_lineart_intersection_priority", text="")
+        subrow = row.row()
+        subrow.active = collection.use_lineart_intersection_priority
+        subrow.prop(collection, "lineart_intersection_priority", text="")
 
 
 classes = (
diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py
index d168e576165..da411184900 100644
--- a/release/scripts/startup/bl_ui/properties_material.py
+++ b/release/scripts/startup/bl_ui/properties_material.py
@@ -294,6 +294,12 @@ class MATERIAL_PT_lineart(MaterialButtonsPanel, Panel):
         subrow = row.row()
         subrow.active = lineart.use_silhouette_group_override
         subrow.prop(lineart, "mat_silhouette_group", text="")
+            
+        row = layout.row(heading="Intersection Priority")
+        row.prop(lineart, "use_intersection_priority_override", text="")
+        subrow = row.row()
+        subrow.active = lineart.use_intersection_priority_override
+        subrow.prop(lineart, "intersection_priority", text="")
 
 
 classes = (
diff --git a/release/scripts/startup/bl_ui/properties_object.py b/release/scripts/startup/bl_ui/properties_object.py
index 93e237a78d3..dc4115763e5 100644
--- a/release/scripts/startup/bl_ui/properties_object.py
+++ b/release/scripts/startup/bl_ui/properties_object.py
@@ -324,6 +324,12 @@ class OBJECT_PT_lineart(ObjectButtonsPanel, Panel):
         subrow = row.row()
         subrow.active = lineart.use_silhouette_group_override
         subrow.prop(lineart, "silhouette_group", text="")
+        
+        row = layout.row(heading="Intersection Priority")
+        row.prop(lineart, "use_intersection_priority_override", text="")
+        subrow = row.row()
+        subrow.active = lineart.use_intersection_priority_override
+        subrow.prop(lineart, "intersection_priority", text="")
 
 
 class OBJECT_PT_motion_paths(MotionPathButtonsPanel, Panel):
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
index c4ea68a9591..21e5ad83f6e 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
@@ -351,8 +351,6 @@ static void edge_types_panel_draw(const bContext *UNUSED(C), Panel *panel)
 
   uiLayout *col = uiLayoutColumn(layout, true);
 
-  uiItemR(col, ptr, "use_contour", 0, IFACE_("Contour"), ICON_NONE);
-
   uiLayout *sub = uiLayoutRowWithHeading(col, false, IFACE_("Outline"));
   uiItemR(sub, ptr, "use_contour", 0, "", ICON_NONE);
   uiLayout *entry = uiLayoutRow(sub, false);
diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
index c656eba4d45..5e17839e262 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
+++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
@@ -46,6 +46,7 @@ typedef struct LineartTriangle {
   int target_reference;
 
   unsigned char silhouette_group;
+  unsigned char intersection_priority;
 
   /**
    * Only use single link list, because we don't need to go back in order.
@@ -480,7 +481,8 @@ typedef struct LineartRenderTaskInfo {
 } LineartRenderTaskInfo;
 
 #define LRT_OBINDEX_SHIFT 20
-#define LRT_OBINDEX_LOWER 0x0fffff /* Lower 20 bits. */
+#define LRT_OBINDEX_LOWER 0x0fffff    /* Lower 20 bits. */
+#define LRT_OBINDEX_HIGHER 0xFFF00000 /* Higher 12 bits. */
 #define LRT_EDGE_IDENTIFIER(obi, e) \
   (((uint64_t)((obi->obindex << 0) | (e->v1->index & LRT_OBINDEX_LOWER)) << 32) | \
    ((obi->obindex << 0) | (e->v2->index & LRT_OBINDEX_LOWER)))
@@ -496,6 +498,7 @@ typedef struct LineartObjectInfo {
   int usage;
   uint8_t override_intersection_mask;
   uint8_t silhouette_group;
+  uint8_t intersection_priority;
   int global_i_offset;
 
   /* Shifted LRT_OBINDEX_SHIFT bits to be combined with object triangle index. */
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
index 351dfc1ac2e..89101ed4e59 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
@@ -17,13 +17,16 @@
 
 #define LRT_OTHER_VERT(e, vt) ((vt) == (e)->v1 ? (e)->v2 : ((vt) == (e)->v2 ? (e)->v1 : NULL))
 
+struct Object;
+
 /* Get a connected line, only for lines who has the exact given vert, or (in the case of
  * intersection lines) who has a vert that has the exact same position. */
 static LineartEdge *lineart_line_get_connected(LineartBoundingArea *ba,
                                                LineartVert *vt,
                                                LineartVert **new_vt,
                                                int match_flag,
-                                               unsigned char match_isec_mask)
+                                               unsigned char match_isec_mask,
+                                               struct Object *match_isec_object)
 {
   for (int i = 0; i < ba->line_count; i++) {
     LineartEdge *n_e = ba->linked_lines[i];
@@ -46,6 +49,9 @@ static LineartEdge *lineart_line_get_connected(LineartBoundingArea *ba,
     }
 
     if (n_e->flags & LRT_EDGE_FLAG_INTERSECTION) {
+      if (n_e->object_ref != match_isec_object) {
+        continue;
+      }
       if (vt->fbcoord[0] == n_e->v1->fbcoord[0] && vt->fbcoord[1] == n_e->v1->fbcoord[1]) {
         *new_vt = LRT_OTHER_VERT(n_e, n_e->v1);
         return n_e;
@@ -235,7 +241,7 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb)
                                 es->silhouette_group,
                                 e->v1->index);
     while (ba && (new_e = lineart_line_get_connected(
-                      ba, new_vt, &new_vt, e->flags, ec->intersection_mask))) {
+                      ba, new_vt, &new_vt, e->flags, ec->intersection_mask, ec->object_ref))) {
       new_e->flags |= LRT_EDGE_FLAG_CHAIN_PICKED;
 
       if (new_e->t1 || new_e->t2) {
@@ -389,7 +395,7 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb)
     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, ec->intersection_mask))) {
+                      ba, new_vt, &new_vt, e->flags, ec->intersection_mask, ec->object_ref))) {
       new_e->flags |= LRT_EDGE_FLAG_CHAIN_PICKED;
 
       if (new_e->t1 || new_e->t2) {
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
index d364975dc46..d0a834ee2dd 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
@@ -765,6 +765,8 @@ static void lineart_triangle_post(LineartTriangle *tri, LineartTriangle *orig)
   tri->intersection_mask = orig->intersection_mask;
   tri->material_mask_bits = orig->material_mask_bits;
   tri->mat_occlusion = orig->mat_occlusion;
+  tri->silhouette_group = orig->silhouette_group;
+  tri->intersection_priority = orig->intersection_priority;
 }
 
 static void lineart_triangle_set_cull_flag(LineartTriangle *tri, uchar flag)
@@ -1906,6 +1908,10 @@ static void lineart_load_tri_task(void *__restrict userdata,
   tri->silhouette_group = ((mat && (mat->lineart.flags & LRT_MATERIAL_CUSTOM_SILHOUETTE_GROUP)) ?
                                mat->lineart.mat_silhouette_group :
                                ob_info->silhouette_group);
+  tri->intersection_priority = ((mat && (mat->lineart.flags &
+                                         LRT_MATERIAL_CUSTOM_INTERSECTION_PRIORITY)) ?
+                                    mat->lineart.intersection_priority :
+                                    ob_info->intersection_priority);
   tri->flags |= (mat && (mat->blend_flag & MA_BL_CULL_BACKFACE)) ?
                     LRT_TRIANGLE_MAT_BACK_FACE_CULLING :
                     0;
@@ -2430,7 +2436,7 @@ static uchar lineart_silhouette_group_check(Collection *c, Object *ob)
   }
 
   LISTBASE_FOREACH (CollectionChild *, cc, &c->children) {
-    uchar result = lineart_intersection_mask_check(cc->collection, ob);
+    uchar result = lineart_silhouette_group_check(cc->collection, ob);
     if (result) {
       return result;
     }
@@ -2443,6 +2449,26 @@ static uchar lineart_silhouette_group_check(Collection *c, Object *ob)
   return 0;
 }
 
+static uchar lineart_intersection_priority_check(Collection *c, Object *ob)
+{
+  if (ob->lineart.flags & OBJECT_LRT_OWN_INTERSECTION_PRIORITY) {
+    return ob->lineart.intersection_priority;
+  }
+
+  LISTBASE_FOREACH (CollectionChild *, cc, &c->children) {
+    uchar result = lineart_intersection_priority_check(cc->collection, ob);
+    if (result) {
+      return result;
+    }
+  }
+  if (BKE_collection_has_object(c, (Object *)(ob->id.orig_id))) {
+    if (c->lineart_flags & COLLECTION_LRT_USE_INTERSECTION_PRIORITY) {
+      return c->lineart_silhouette_group;
+    }
+  }
+  return 0;
+}
+
 /**
  * See if this object in such collection is used for generating line art,
  * Disabling a collection for line art will doable all objects inside.
@@ -2570,6 +2596,7 @@ static void lineart_object_load_s

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list