[Bf-blender-cvs] [34ebd61bdf6] temp-lineart-contained: LineArt: UI optimizations.

YimingWu noreply at git.blender.org
Fri Jul 9 02:34:45 CEST 2021


Commit: 34ebd61bdf68f498d9426f7832a4759399011b8f
Author: YimingWu
Date:   Wed Jul 7 14:40:15 2021 +0800
Branches: temp-lineart-contained
https://developer.blender.org/rB34ebd61bdf68f498d9426f7832a4759399011b8f

LineArt: UI optimizations.

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

M	release/scripts/startup/bl_ui/properties_collection.py
M	release/scripts/startup/bl_ui/properties_material.py
M	source/blender/blenloader/intern/versioning_300.c
M	source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
M	source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
M	source/blender/makesdna/DNA_material_defaults.h
M	source/blender/makesdna/DNA_material_types.h
M	source/blender/makesrna/intern/rna_gpencil_modifier.c
M	source/blender/makesrna/intern/rna_material.c

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

diff --git a/release/scripts/startup/bl_ui/properties_collection.py b/release/scripts/startup/bl_ui/properties_collection.py
index b51d7157c06..3aa922bf467 100644
--- a/release/scripts/startup/bl_ui/properties_collection.py
+++ b/release/scripts/startup/bl_ui/properties_collection.py
@@ -86,12 +86,15 @@ class COLLECTION_PT_lineart_collection(CollectionButtonsPanel, Panel):
         row = layout.row()
         row.prop(collection, "lineart_usage")
 
-        layout.prop(collection, "lineart_use_intersection_mask")
+        layout.prop(collection, "lineart_use_intersection_mask", text="Collection Mask")
 
-        row = layout.row(align=True, heading="Masks")
-        row.active = collection.lineart_use_intersection_mask
+        col = layout.column(align=True)
+        col.active = collection.lineart_use_intersection_mask
+        row = col.row(align=True, heading="Masks")
         for i in range(8):
             row.prop(collection, "lineart_intersection_mask", index=i, text=str(i), toggle=True)
+            if i == 3:
+                row = col.row(align=True)
 
 
 classes = (
diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py
index b217e33de12..b84e1fb9b3a 100644
--- a/release/scripts/startup/bl_ui/properties_material.py
+++ b/release/scripts/startup/bl_ui/properties_material.py
@@ -291,18 +291,18 @@ class MATERIAL_PT_lineart(MaterialButtonsPanel, Panel):
         mat = context.material
         lineart = mat.lineart
 
-        layout.prop(lineart, "use_material_mask")
+        layout.prop(lineart, "use_material_mask", text="Material Mask")
 
-        row = layout.row(align=True, heading="Masks")
-        row.active = lineart.use_material_mask
+        col = layout.column(align=True)
+        col.active = lineart.use_material_mask
+        row = col.row(align=True, heading="Masks")
         for i in range(8):
             row.prop(lineart, "use_material_mask_bits", text=str(i), index=i, toggle=True)
+            if i == 3:
+                row = col.row(align=True)
 
         row = layout.row(align=True, heading="Custom Occlusion")
-        row.prop(lineart, "use_mat_occlusion", text="")
-        sub = row.row(align=False)
-        sub.active = lineart.use_mat_occlusion
-        sub.prop(lineart, "mat_occlusion", slider=True, text="Levels")
+        row.prop(lineart, "mat_occlusion", text="Levels")
 
 
 classes = (
diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c
index f9f175b61fa..80a983f9983 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -33,6 +33,7 @@
 #include "DNA_gpencil_modifier_types.h"
 #include "DNA_lineart_types.h"
 #include "DNA_listBase.h"
+#include "DNA_material_types.h"
 #include "DNA_modifier_types.h"
 #include "DNA_text_types.h"
 
@@ -493,6 +494,11 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
                     sizeof(scene->master_collection->id.name) - 2);
       }
     }
+    LISTBASE_FOREACH (Material *, mat, &bmain->materials) {
+      if (!(mat->lineart.flags & LRT_MATERIAL_CUSTOM_OCCLUSION_EFFECTIVENESS)) {
+        mat->lineart.mat_occlusion = 1;
+      }
+    }
   }
 
   /**
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
index cf37970b81e..de813335ef2 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
@@ -469,6 +469,19 @@ static void occlusion_panel_draw(const bContext *UNUSED(C), Panel *panel)
   }
 }
 
+static bool anything_showing_through(PointerRNA *ptr)
+{
+  const bool use_multiple_levels = RNA_boolean_get(ptr, "use_multiple_levels");
+  const int level_start = RNA_int_get(ptr, "level_start");
+  const int level_end = RNA_int_get(ptr, "level_end");
+  if (use_multiple_levels) {
+    return (MAX2(level_start, level_end) > 0);
+  }
+  else {
+    return (level_start > 0);
+  }
+}
+
 static void material_mask_panel_draw_header(const bContext *UNUSED(C), Panel *panel)
 {
   uiLayout *layout = panel->layout;
@@ -479,7 +492,7 @@ static void material_mask_panel_draw_header(const bContext *UNUSED(C), Panel *pa
   const bool show_in_front = RNA_boolean_get(&ob_ptr, "show_in_front");
 
   uiLayoutSetEnabled(layout, !is_baked);
-  uiLayoutSetActive(layout, show_in_front);
+  uiLayoutSetActive(layout, show_in_front && anything_showing_through(ptr));
 
   uiItemR(layout, ptr, "use_material_mask", 0, IFACE_("Material Mask"), ICON_NONE);
 }
@@ -491,6 +504,7 @@ static void material_mask_panel_draw(const bContext *UNUSED(C), Panel *panel)
 
   const bool is_baked = RNA_boolean_get(ptr, "is_baked");
   uiLayoutSetEnabled(layout, !is_baked);
+  uiLayoutSetActive(layout, anything_showing_through(ptr));
 
   uiLayoutSetPropSep(layout, true);
 
@@ -508,7 +522,7 @@ static void material_mask_panel_draw(const bContext *UNUSED(C), Panel *panel)
   uiItemL(row, "", ICON_BLANK1); /* Space for decorator. */
 
   uiLayout *col = uiLayoutColumn(layout, true);
-  uiItemR(col, ptr, "use_material_mask_match", 0, IFACE_("Match All Masks"), ICON_NONE);
+  uiItemR(col, ptr, "use_material_mask_match", 0, IFACE_("Exact Match"), ICON_NONE);
 }
 
 static void intersection_panel_draw_header(const bContext *UNUSED(C), Panel *panel)
@@ -541,7 +555,7 @@ static void intersection_panel_draw(const bContext *UNUSED(C), Panel *panel)
 
   uiLayout *row = uiLayoutRow(layout, true);
   uiLayoutSetPropDecorate(row, false);
-  uiLayout *sub = uiLayoutRowWithHeading(row, true, IFACE_("Masks"));
+  uiLayout *sub = uiLayoutRowWithHeading(row, true, IFACE_("Collection Masks"));
   char text[2] = "0";
 
   PropertyRNA *prop = RNA_struct_find_property(ptr, "use_intersection_mask");
@@ -551,7 +565,7 @@ static void intersection_panel_draw(const bContext *UNUSED(C), Panel *panel)
   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);
+  uiItemR(col, ptr, "use_intersection_match", 0, IFACE_("Exact Match"), ICON_NONE);
 }
 
 static void face_mark_panel_draw_header(const bContext *UNUSED(C), Panel *panel)
@@ -625,7 +639,7 @@ static void chaining_panel_draw(const bContext *UNUSED(C), Panel *panel)
   uiItemR(col, ptr, "use_fuzzy_all", 0, NULL, ICON_NONE);
 
   uiItemR(col, ptr, "use_loose_edge_chain", 0, IFACE_("Loose Edges"), ICON_NONE);
-  uiItemR(col, ptr, "use_geometry_space_chain", 0, NULL, ICON_NONE);
+  uiItemR(col, ptr, "use_geometry_space_chain", 0, IFACE_("Geometry Space"), ICON_NONE);
 
   uiItemR(layout,
           ptr,
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
index f234036541d..347b3a16e1a 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
@@ -1917,10 +1917,7 @@ static void lineart_geometry_object_load(LineartObjectInfo *obi, LineartRenderBu
     tri->material_mask_bits |= ((mat && (mat->lineart.flags & LRT_MATERIAL_MASK_ENABLED)) ?
                                     mat->lineart.material_mask_bits :
                                     0);
-    tri->mat_occlusion |= ((mat &&
-                            (mat->lineart.flags & LRT_MATERIAL_CUSTOM_OCCLUSION_EFFECTIVENESS)) ?
-                               mat->lineart.mat_occlusion :
-                               1);
+    tri->mat_occlusion |= (mat ? mat->lineart.mat_occlusion : 1);
 
     tri->intersection_mask = obi->override_intersection_mask;
 
diff --git a/source/blender/makesdna/DNA_material_defaults.h b/source/blender/makesdna/DNA_material_defaults.h
index 3f4496ce735..3fa87800b2e 100644
--- a/source/blender/makesdna/DNA_material_defaults.h
+++ b/source/blender/makesdna/DNA_material_defaults.h
@@ -45,6 +45,8 @@
     .alpha_threshold = 0.5f, \
  \
     .blend_shadow = MA_BS_SOLID, \
+    \
+    .lineart.mat_occlusion = 1, \
   }
 
 /** \} */
diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h
index b7354aaa724..568ab212d32 100644
--- a/source/blender/makesdna/DNA_material_types.h
+++ b/source/blender/makesdna/DNA_material_types.h
@@ -160,6 +160,8 @@ typedef struct MaterialLineArt {
 
 typedef enum eMaterialLineArtFlags {
   LRT_MATERIAL_MASK_ENABLED = (1 << 0),
+
+  /* Deprecated, kept for versioning code. */
   LRT_MATERIAL_CUSTOM_OCCLUSION_EFFECTIVENESS = (1 << 1),
 } eMaterialLineArtFlags;
 
diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c
index 6096ad9de22..e9da97353b6 100644
--- a/source/blender/makesrna/intern/rna_gpencil_modifier.c
+++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c
@@ -656,6 +656,24 @@ static void rna_TextureGpencilModifier_material_set(PointerRNA *ptr,
   rna_GpencilModifier_material_set(ptr, value, ma_target, reports);
 }
 
+static void rna_Lineart_start_level_set(PointerRNA *ptr, int value)
+{
+  LineartGpencilModifierData *lmd = (LineartGpencilModifierData *)ptr->data;
+
+  CLAMP(value, 0, 128);
+  lmd->level_start = value;
+  lmd->level_end = MAX2(value, lmd->level_end);
+}
+
+static void rna_Lineart_end_level_set(PointerRNA *ptr, int value)
+{
+  LineartGpencilModifierData *lmd = (LineartGpencilModifierData *)ptr->data;
+
+  CLAMP(value, 0, 128);
+  lmd->level_end = value;
+  lmd->level_start = MIN2(value, lmd->level_start);
+}
+
 #else
 
 static void rna_def_modifier_gpencilnoise(BlenderRNA *brna)
@@ -3126,12 +3144,14 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna)
   RNA_def_property_ui_text(
       prop, "Level Start", "Minimum number of occlusions for the generated strokes");
   RNA_def_property_range(prop, 0, 128);
+  RNA_def_property_int_funcs(prop, NULL, "rna_Lineart_start_level_set", NULL);
   RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
 
   prop = RNA_def_property(srna, "level_end", PROP_INT, PROP_NONE);
   RNA_def_property_ui_text(
       prop, "Leve

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list