diff options
9 files changed, 78 insertions, 43 deletions
diff --git a/release/scripts/startup/bl_ui/properties_collection.py b/release/scripts/startup/bl_ui/properties_collection.py index b51d7157c06..3f7c0735eec 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) + row.prop(collection, "lineart_intersection_mask", index=i, text=" ", 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..1c7f3639f0a 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) + row.prop(lineart, "use_material_mask_bits", text=" ", 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 07a324181af..107871586da 100644 --- a/source/blender/blenloader/intern/versioning_300.c +++ b/source/blender/blenloader/intern/versioning_300.c @@ -31,6 +31,7 @@ #include "DNA_collection_types.h" #include "DNA_genfile.h" #include "DNA_listBase.h" +#include "DNA_material_types.h" #include "DNA_modifier_types.h" #include "DNA_text_types.h" #include "DNA_workspace_types.h" @@ -505,6 +506,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; + } + } } if (!MAIN_VERSION_ATLEAST(bmain, 300, 9)) { diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c index fcc44aab583..bc6a9e53f11 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c @@ -432,6 +432,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; @@ -439,6 +452,7 @@ static void material_mask_panel_draw_header(const bContext *UNUSED(C), Panel *pa const bool is_baked = RNA_boolean_get(ptr, "is_baked"); uiLayoutSetEnabled(layout, !is_baked); + uiLayoutSetActive(layout, anything_showing_through(ptr)); uiItemR(layout, ptr, "use_material_mask", 0, IFACE_("Material Mask"), ICON_NONE); } @@ -450,24 +464,24 @@ 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); uiLayoutSetEnabled(layout, RNA_boolean_get(ptr, "use_material_mask")); - uiLayout *row = uiLayoutRow(layout, true); - uiLayoutSetPropDecorate(row, false); - uiLayout *sub = uiLayoutRowWithHeading(row, true, IFACE_("Masks")); - char text[2] = "0"; + uiLayout *col = uiLayoutColumn(layout, true); + uiLayout *sub = uiLayoutRowWithHeading(col, true, IFACE_("Masks")); PropertyRNA *prop = RNA_struct_find_property(ptr, "use_material_mask_bits"); - for (int i = 0; i < 8; i++, text[0]++) { - uiItemFullR(sub, ptr, prop, i, 0, UI_ITEM_R_TOGGLE, text, ICON_NONE); + for (int i = 0; i < 8; i++) { + uiItemFullR(sub, ptr, prop, i, 0, UI_ITEM_R_TOGGLE, " ", ICON_NONE); + if (i == 3) { + sub = uiLayoutRow(col, true); + } } - 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(layout, ptr, "use_material_mask_match", 0, IFACE_("Exact Match"), ICON_NONE); } static void intersection_panel_draw(const bContext *UNUSED(C), Panel *panel) @@ -482,19 +496,18 @@ static void intersection_panel_draw(const bContext *UNUSED(C), Panel *panel) 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"; + uiLayout *col = uiLayoutColumn(layout, true); + uiLayout *sub = uiLayoutRowWithHeading(col, true, IFACE_("Collection Masks")); 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); + for (int i = 0; i < 8; i++) { + uiItemFullR(sub, ptr, prop, i, 0, UI_ITEM_R_TOGGLE, " ", ICON_NONE); + if (i == 3) { + sub = uiLayoutRow(col, true); + } } - 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(layout, ptr, "use_intersection_match", 0, IFACE_("Exact Match"), ICON_NONE); } static void face_mark_panel_draw_header(const bContext *UNUSED(C), Panel *panel) { @@ -566,7 +579,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_loose_as_contour", 0, NULL, 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 82fd85f5c65..f5f71278d43 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -1803,10 +1803,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 58c1bc6c5fd..f9974f14ab0 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 f1c05079d9c..b5dea7b019f 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) @@ -3068,12 +3086,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, "Level End", "Maximum number of occlusions for the generated strokes"); RNA_def_property_range(prop, 0, 128); + RNA_def_property_int_funcs(prop, NULL, "rna_Lineart_end_level_set", NULL); RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); prop = RNA_def_property(srna, "target_material", PROP_POINTER, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index b662f54ed4c..d91c0bfaf29 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -702,14 +702,6 @@ static void rna_def_material_lineart(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Mask", ""); RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialLineArt_update"); - prop = RNA_def_property(srna, "use_mat_occlusion", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_default(prop, 0); - RNA_def_property_boolean_sdna(prop, NULL, "flags", LRT_MATERIAL_CUSTOM_OCCLUSION_EFFECTIVENESS); - RNA_def_property_ui_text(prop, - "Custom Occlusion Effectiveness", - "Use custom occlusion effectiveness for this material"); - RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialLineArt_update"); - prop = RNA_def_property(srna, "mat_occlusion", PROP_INT, PROP_NONE); RNA_def_property_int_default(prop, 1); RNA_def_property_ui_range(prop, 0.0f, 5.0f, 1.0f, 1); |