[Bf-blender-cvs] [c89742c5b1b] lanpr-under-gp: LineArt: Global line type flags.

YimingWu noreply at git.blender.org
Sun Jul 26 05:34:31 CEST 2020


Commit: c89742c5b1bb19e946a46f7ff907d9be55a9ea79
Author: YimingWu
Date:   Sun Jul 26 11:33:52 2020 +0800
Branches: lanpr-under-gp
https://developer.blender.org/rBc89742c5b1bb19e946a46f7ff907d9be55a9ea79

LineArt: Global line type flags.

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

M	release/scripts/startup/bl_ui/properties_render.py
M	source/blender/blenloader/intern/versioning_280.c
M	source/blender/editors/include/ED_lineart.h
M	source/blender/editors/lineart/lineart_cpu.c
M	source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/intern/rna_scene.c

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

diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py
index 3e600f57fcb..a216569321c 100644
--- a/release/scripts/startup/bl_ui/properties_render.py
+++ b/release/scripts/startup/bl_ui/properties_render.py
@@ -728,9 +728,10 @@ class RENDER_PT_lineart(RenderButtonsPanel, Panel):
             layout.prop(lineart, "chaining_geometry_threshold")
 
 
-class RENDER_PT_lineart(RenderButtonsPanel, Panel):
+class RENDER_PT_lineart_line_types(RenderButtonsPanel, Panel):
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
     bl_label = "Line Types"
+    bl_parent_id = "RENDER_PT_lineart"
     bl_options = {'DEFAULT_CLOSED'}
 
     def draw(self, context):
@@ -808,6 +809,7 @@ classes = (
     RENDER_PT_simplify_render,
     RENDER_PT_simplify_greasepencil,
     RENDER_PT_lineart,
+    RENDER_PT_lineart_line_types,
     RENDER_PT_lineart_baking,
 )
 
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index c2a1fc33a4d..889110b22f1 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -5114,7 +5114,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
       if (!DNA_struct_find(fd->filesdna, "SceneLineart")) {
         for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
           scene->lineart.crease_threshold = 0.7f;
-          scene->lineart.flags |= (LRT_USE_INTERSECTIONS);
+          scene->lineart.line_types |= LRT_EDGE_FLAG_ALL_TYPE;
         }
       }
     }
diff --git a/source/blender/editors/include/ED_lineart.h b/source/blender/editors/include/ED_lineart.h
index f6ec9ea6db2..d27bf2bfabf 100644
--- a/source/blender/editors/include/ED_lineart.h
+++ b/source/blender/editors/include/ED_lineart.h
@@ -232,6 +232,10 @@ typedef struct LineartRenderBuffer {
   int draw_material_preview;
   double material_transparency;
 
+  char use_contour;
+  char use_crease;
+  char use_material;
+  char use_edge_marks;
   char use_intersections;
   char fuzzy_intersections;
   char fuzzy_everything;
diff --git a/source/blender/editors/lineart/lineart_cpu.c b/source/blender/editors/lineart/lineart_cpu.c
index 720f0c59446..88246260009 100644
--- a/source/blender/editors/lineart/lineart_cpu.c
+++ b/source/blender/editors/lineart/lineart_cpu.c
@@ -2248,15 +2248,16 @@ static void lineart_compute_scene_contours(LineartRenderBuffer *rb, const float
       if ((result = dot_1 * dot_2) <= 0 && (dot_1 + dot_2)) {
         add = 1;
       }
-      else if (dot_v3v3_db(rl->tl->gn, rl->tr->gn) < threshold) {
+      else if (rb->use_crease && (dot_v3v3_db(rl->tl->gn, rl->tr->gn) < threshold)) {
         add = 2;
       }
-      else if (rl->tl && rl->tr && rl->tl->material_id != rl->tr->material_id) {
+      else if (rb->use_material &&
+               (rl->tl && rl->tr && rl->tl->material_id != rl->tr->material_id)) {
         add = 3;
       }
     }
 
-    if (add == 1) {
+    if (rb->use_contour && (add == 1)) {
       rl->flags |= LRT_EDGE_FLAG_CONTOUR;
       list_append_pointer_static(&rb->contours, &rb->render_data_pool, rl);
       contour_count++;
@@ -2266,12 +2267,12 @@ static void lineart_compute_scene_contours(LineartRenderBuffer *rb, const float
       list_append_pointer_static(&rb->crease_lines, &rb->render_data_pool, rl);
       crease_count++;
     }
-    else if (add == 3) {
+    else if (rb->use_material && (add == 3)) {
       rl->flags |= LRT_EDGE_FLAG_MATERIAL;
       list_append_pointer_static(&rb->material_lines, &rb->render_data_pool, rl);
       material_count++;
     }
-    else if (rl->flags & LRT_EDGE_FLAG_EDGE_MARK) {
+    else if (rb->use_edge_marks && (rl->flags & LRT_EDGE_FLAG_EDGE_MARK)) {
       /*  no need to mark again */
       add = 4;
       list_append_pointer_static(&rb->edge_marks, &rb->render_data_pool, rl);
@@ -2397,7 +2398,11 @@ LineartRenderBuffer *ED_lineart_create_render_buffer(Scene *scene)
   rb->fuzzy_intersections = (scene->lineart.flags & LRT_INTERSECTION_AS_CONTOUR) != 0;
   rb->fuzzy_everything = (scene->lineart.flags & LRT_EVERYTHING_AS_CONTOUR) != 0;
 
-  rb->use_intersections = (scene->lineart.flags & LRT_USE_INTERSECTIONS) != 0;
+  rb->use_contour = (scene->lineart.line_types & LRT_EDGE_FLAG_CONTOUR) != 0;
+  rb->use_crease = (scene->lineart.line_types & LRT_EDGE_FLAG_CREASE) != 0;
+  rb->use_material = (scene->lineart.line_types & LRT_EDGE_FLAG_MATERIAL) != 0;
+  rb->use_edge_marks = (scene->lineart.line_types & LRT_EDGE_FLAG_EDGE_MARK) != 0;
+  rb->use_intersections = (scene->lineart.line_types & LRT_EDGE_FLAG_INTERSECTION) != 0;
 
   BLI_spin_init(&rb->lock_task);
   BLI_spin_init(&rb->render_data_pool.lock_mem);
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
index e860612c5c6..fdadaf91077 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
@@ -314,15 +314,25 @@ static void panel_draw(const bContext *C, Panel *panel)
     uiItemL(layout, "Line types are fuzzy", ICON_NONE);
   }
   else {
-    uiItemR(layout, &ptr, "use_contour", 0, NULL, ICON_NONE);
-    uiItemR(layout, &ptr, "use_crease", 0, "Crease", ICON_NONE);
-    uiItemR(layout, &ptr, "use_material", 0, "Material", ICON_NONE);
-    uiItemR(layout, &ptr, "use_edge_mark", 0, "Edge Marks", ICON_NONE);
+    if (scene->lineart.line_types & LRT_EDGE_FLAG_CONTOUR) {
+      uiItemR(layout, &ptr, "use_contour", 0, NULL, ICON_NONE);
+    }
+    if (scene->lineart.line_types & LRT_EDGE_FLAG_CREASE) {
+      uiItemR(layout, &ptr, "use_crease", 0, "Crease", ICON_NONE);
+    }
+    if (scene->lineart.line_types & LRT_EDGE_FLAG_MATERIAL) {
+      uiItemR(layout, &ptr, "use_material", 0, "Material", ICON_NONE);
+    }
+    if (scene->lineart.line_types & LRT_EDGE_FLAG_EDGE_MARK) {
+      uiItemR(layout, &ptr, "use_edge_mark", 0, "Edge Marks", ICON_NONE);
+    }
     if (scene->lineart.flags & LRT_INTERSECTION_AS_CONTOUR) {
       uiItemL(layout, "Intersection is fuzzy", ICON_NONE);
     }
     else {
-      uiItemR(layout, &ptr, "use_intersection", 0, "Intersection", ICON_NONE);
+      if (scene->lineart.line_types & LRT_EDGE_FLAG_INTERSECTION) {
+        uiItemR(layout, &ptr, "use_intersection", 0, "Intersection", ICON_NONE);
+      }
     }
   }
 
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 877f8341133..39b822726c7 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1706,8 +1706,8 @@ typedef enum eLineartMainFlags {
   LRT_SAME_TAPER = (1 << 2),
   /* Edge split modifier will cause problems in Line Art. */
   LRT_DISABLE_EDGE_SPLITS = (1 << 3),
-  LRT_USE_CHAINING = (1 << 4), /* Deprecated */
-  LRT_USE_INTERSECTIONS = (1 << 5),
+  LRT_USE_CHAINING = (1 << 4),      /* Deprecated */
+  LRT_USE_INTERSECTIONS = (1 << 5), /* Deprecated, use flags in line_types */
   /* Overwrite existing strokes in this frame. */
   LRT_GPENCIL_OVERWRITE = (1 << 6),
   LRT_INTERSECTION_AS_CONTOUR = (1 << 7),
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index c63cd04de44..2719ffe6a83 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -7324,28 +7324,32 @@ static void rna_def_scene_lineart(BlenderRNA *brna)
   /* types */
   prop = RNA_def_property(srna, "use_contour", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_boolean_sdna(prop, NULL, "line_types", LRT_EDGE_FLAG_CONTOUR);
+  RNA_def_property_boolean_default(prop, true);
   RNA_def_property_ui_text(prop, "Use Contour", "Include contour lines in the result");
   RNA_def_property_update(prop, 0, "rna_lineart_update");
 
   prop = RNA_def_property(srna, "use_crease", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_boolean_sdna(prop, NULL, "line_types", LRT_EDGE_FLAG_CREASE);
+  RNA_def_property_boolean_default(prop, true);
   RNA_def_property_ui_text(prop, "Use Crease", "Include crease lines in the result");
   RNA_def_property_update(prop, 0, "rna_lineart_update");
 
   prop = RNA_def_property(srna, "use_material", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_boolean_sdna(prop, NULL, "line_types", LRT_EDGE_FLAG_MATERIAL);
+  RNA_def_property_boolean_default(prop, true);
   RNA_def_property_ui_text(
       prop, "Use Material", "Include material separation lines in the result");
   RNA_def_property_update(prop, 0, "rna_lineart_update");
 
   prop = RNA_def_property(srna, "use_edge_mark", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_boolean_sdna(prop, NULL, "line_types", LRT_EDGE_FLAG_EDGE_MARK);
+  RNA_def_property_boolean_default(prop, true);
   RNA_def_property_ui_text(prop, "Use Edge Mark", "Include freestyle edge marks in the result");
   RNA_def_property_update(prop, 0, "rna_lineart_update");
 
   prop = RNA_def_property(srna, "use_intersections", PROP_BOOLEAN, PROP_NONE);
-  RNA_def_property_boolean_sdna(prop, NULL, "line_types", LRT_USE_INTERSECTIONS);
-  RNA_def_property_boolean_default(prop, 1);
+  RNA_def_property_boolean_sdna(prop, NULL, "line_types", LRT_EDGE_FLAG_INTERSECTION);
+  RNA_def_property_boolean_default(prop, true);
   RNA_def_property_ui_text(prop, "Calculate Intersections", "Calculate Intersections or not");
   RNA_def_property_update(prop, NC_SCENE, "rna_lineart_update");



More information about the Bf-blender-cvs mailing list