[Bf-blender-cvs] [c1f2cd4871c] blender-v3.3-release: LineArt: Force intersection option.

YimingWu noreply at git.blender.org
Wed Sep 21 14:27:11 CEST 2022


Commit: c1f2cd4871c73b0419806c124f5b78f9c3fa10cf
Author: YimingWu
Date:   Thu Sep 15 22:02:14 2022 +0800
Branches: blender-v3.3-release
https://developer.blender.org/rBc1f2cd4871c73b0419806c124f5b78f9c3fa10cf

LineArt: Force intersection option.

This option allows easier setup of intersection overrides on more
complex scene structures. Setting force intersection would allow objects
to always produce intersection lines even against no-intersection ones.

Reviewed By: Aleš Jelovčan (frogstomp) Antonio Vazquez (antoniov)

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

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

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_collection_types.h
M	source/blender/makesdna/DNA_object_types.h
M	source/blender/makesrna/intern/rna_collection.c
M	source/blender/makesrna/intern/rna_object.c

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

diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
index 895ffcc7818..f27efd978ad 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
+++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
@@ -441,6 +441,7 @@ typedef enum eLineartTriangleFlags {
   LRT_TRIANGLE_INTERSECTION_ONLY = (1 << 3),
   LRT_TRIANGLE_NO_INTERSECTION = (1 << 4),
   LRT_TRIANGLE_MAT_BACK_FACE_CULLING = (1 << 5),
+  LRT_TRIANGLE_FORCE_INTERSECTION = (1 << 6),
 } eLineartTriangleFlags;
 
 #define LRT_SHADOW_MASK_UNDEFINED 0
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
index d0b1efa183d..5893df2ba56 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
@@ -1897,6 +1897,9 @@ static void lineart_load_tri_task(void *__restrict userdata,
   if (ob_info->usage == OBJECT_LRT_INTERSECTION_ONLY) {
     tri->flags |= LRT_TRIANGLE_INTERSECTION_ONLY;
   }
+  else if (ob_info->usage == OBJECT_LRT_FORCE_INTERSECTION) {
+    tri->flags |= LRT_TRIANGLE_FORCE_INTERSECTION;
+  }
   else if (ob_info->usage == OBJECT_LRT_NO_INTERSECTION ||
            ob_info->usage == OBJECT_LRT_OCCLUSION_ONLY) {
     tri->flags |= LRT_TRIANGLE_NO_INTERSECTION;
@@ -2238,7 +2241,7 @@ static void lineart_geometry_object_load(LineartObjectInfo *ob_info,
       }
 
       if (usage == OBJECT_LRT_INHERIT || usage == OBJECT_LRT_INCLUDE ||
-          usage == OBJECT_LRT_NO_INTERSECTION) {
+          usage == OBJECT_LRT_NO_INTERSECTION || usage == OBJECT_LRT_FORCE_INTERSECTION) {
         lineart_add_edge_to_array_thread(ob_info, la_edge);
       }
 
@@ -2266,7 +2269,7 @@ static void lineart_geometry_object_load(LineartObjectInfo *ob_info,
       la_edge->edge_identifier = LRT_EDGE_IDENTIFIER(ob_info, la_edge);
       BLI_addtail(&la_edge->segments, la_seg);
       if (usage == OBJECT_LRT_INHERIT || usage == OBJECT_LRT_INCLUDE ||
-          usage == OBJECT_LRT_NO_INTERSECTION) {
+          usage == OBJECT_LRT_NO_INTERSECTION || usage == OBJECT_LRT_FORCE_INTERSECTION) {
         lineart_add_edge_to_array_thread(ob_info, la_edge);
         if (shadow_eln) {
           LineartEdge *shadow_e = lineart_find_matching_edge(shadow_eln, la_edge->edge_identifier);
@@ -2367,6 +2370,8 @@ static int lineart_usage_check(Collection *c, Object *ob, bool is_render)
             return OBJECT_LRT_INTERSECTION_ONLY;
           case COLLECTION_LRT_NO_INTERSECTION:
             return OBJECT_LRT_NO_INTERSECTION;
+          case COLLECTION_LRT_FORCE_INTERSECTION:
+            return OBJECT_LRT_FORCE_INTERSECTION;
         }
         return OBJECT_LRT_INHERIT;
       }
@@ -3395,10 +3400,11 @@ static void lineart_triangle_intersect_in_bounding_area(LineartTriangle *tri,
     }
     tt->testing_e[th->thread_id] = (LineartEdge *)tri;
 
-    if ((testing_triangle->flags & LRT_TRIANGLE_NO_INTERSECTION) ||
-        ((testing_triangle->flags & LRT_TRIANGLE_INTERSECTION_ONLY) &&
-         (tri->flags & LRT_TRIANGLE_INTERSECTION_ONLY))) {
-      continue;
+    if(!((testing_triangle->flags | tri->flags) & LRT_TRIANGLE_FORCE_INTERSECTION)){
+      if ((testing_triangle->flags & LRT_TRIANGLE_NO_INTERSECTION) ||
+          (testing_triangle->flags & tri->flags & LRT_TRIANGLE_INTERSECTION_ONLY)) {
+        continue;
+      }
     }
 
     double *RG0 = testing_triangle->v[0]->gloc, *RG1 = testing_triangle->v[1]->gloc,
@@ -4521,14 +4527,8 @@ static void lineart_add_triangles_worker(TaskPool *__restrict UNUSED(pool), Line
           _dir_control++;
           for (co = x1; co <= x2; co++) {
             for (r = y1; r <= y2; r++) {
-              lineart_bounding_area_link_triangle(ld,
-                                                  &ld->qtree.initials[r * ld->qtree.count_x + co],
-                                                  tri,
-                                                  0,
-                                                  1,
-                                                  0,
-                                                  (!(tri->flags & LRT_TRIANGLE_NO_INTERSECTION)),
-                                                  th);
+              lineart_bounding_area_link_triangle(
+                  ld, &ld->qtree.initials[r * ld->qtree.count_x + co], tri, 0, 1, 0, 1, th);
             }
           }
         } /* Else throw away. */
diff --git a/source/blender/makesdna/DNA_collection_types.h b/source/blender/makesdna/DNA_collection_types.h
index 26011c990d4..b4e04513d8d 100644
--- a/source/blender/makesdna/DNA_collection_types.h
+++ b/source/blender/makesdna/DNA_collection_types.h
@@ -36,6 +36,7 @@ enum eCollectionLineArt_Usage {
   COLLECTION_LRT_EXCLUDE = (1 << 1),
   COLLECTION_LRT_INTERSECTION_ONLY = (1 << 2),
   COLLECTION_LRT_NO_INTERSECTION = (1 << 3),
+  COLLECTION_LRT_FORCE_INTERSECTION = (1 << 4),
 };
 
 enum eCollectionLineArt_Flags {
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index ac9e61e03e8..66a684527e3 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -231,6 +231,7 @@ enum eObjectLineArt_Usage {
   OBJECT_LRT_EXCLUDE = (1 << 2),
   OBJECT_LRT_INTERSECTION_ONLY = (1 << 3),
   OBJECT_LRT_NO_INTERSECTION = (1 << 4),
+  OBJECT_LRT_FORCE_INTERSECTION = (1 << 5),
 };
 
 enum eObjectLineArt_Flags {
diff --git a/source/blender/makesrna/intern/rna_collection.c b/source/blender/makesrna/intern/rna_collection.c
index 84ddea368e7..833495dce7a 100644
--- a/source/blender/makesrna/intern/rna_collection.c
+++ b/source/blender/makesrna/intern/rna_collection.c
@@ -599,6 +599,11 @@ void RNA_def_collections(BlenderRNA *brna)
        0,
        "No Intersection",
        "Include this collection but do not generate intersection lines"},
+      {COLLECTION_LRT_FORCE_INTERSECTION,
+       "FORCE_INTERSECTION",
+       0,
+       "Force Intersection",
+       "Generate intersection lines even with objects that disabled intersection"},
       {0, NULL, 0, NULL, NULL}};
 
   prop = RNA_def_property(srna, "lineart_usage", PROP_ENUM, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index f15ca63268b..36288916923 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -2928,6 +2928,11 @@ static void rna_def_object_lineart(BlenderRNA *brna)
        0,
        "No Intersection",
        "Include this object but do not generate intersection lines"},
+      {OBJECT_LRT_FORCE_INTERSECTION,
+       "FORCE_INTERSECTION",
+       0,
+       "Force Intersection",
+       "Generate intersection lines even with objects that disabled intersection"},
       {0, NULL, 0, NULL, NULL},
   };



More information about the Bf-blender-cvs mailing list