diff options
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/RNA_access.h | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/CMakeLists.txt | 11 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_collection.c | 29 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_gpencil_modifier.c | 225 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_material.c | 79 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_object.c | 80 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 202 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 3 |
8 files changed, 629 insertions, 2 deletions
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 74b8517f538..8e3c94a3ff9 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -454,6 +454,7 @@ extern StructRNA RNA_NormalEditModifier; extern StructRNA RNA_Object; extern StructRNA RNA_ObjectBase; extern StructRNA RNA_ObjectDisplay; +extern StructRNA RNA_ObjectLineArt; extern StructRNA RNA_OceanModifier; extern StructRNA RNA_OceanTexData; extern StructRNA RNA_OffsetGpencilModifier; @@ -515,6 +516,7 @@ extern StructRNA RNA_SPHFluidSettings; extern StructRNA RNA_Scene; extern StructRNA RNA_SceneDisplay; extern StructRNA RNA_SceneEEVEE; +extern StructRNA RNA_SceneLineArt; extern StructRNA RNA_SceneObjects; extern StructRNA RNA_SceneRenderLayer; extern StructRNA RNA_SceneSequence; diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index 94cfd8464ae..141fe7945d0 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -331,6 +331,10 @@ if(WITH_FREESTYLE) add_definitions(-DWITH_FREESTYLE) endif() +if(WITH_LINEART) + add_definitions(-DWITH_LINEART) +endif() + if(WITH_OPENSUBDIV) list(APPEND INC ../../../../intern/opensubdiv @@ -443,6 +447,13 @@ set(LIB bf_editor_undo ) +if(WITH_LINEART) + list(APPEND LIB + bf_editor_lineart + ) +endif() + +add_definitions(${GL_DEFINITIONS}) blender_add_lib(bf_rna "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/makesrna/intern/rna_collection.c b/source/blender/makesrna/intern/rna_collection.c index 20a455f5312..b0aa3ddfb54 100644 --- a/source/blender/makesrna/intern/rna_collection.c +++ b/source/blender/makesrna/intern/rna_collection.c @@ -22,8 +22,12 @@ #include "DNA_collection_types.h" +#include "DNA_lineart_types.h" + #include "BLI_utildefines.h" +#include "MEM_guardedalloc.h" + #include "RNA_define.h" #include "RNA_enum_types.h" @@ -517,6 +521,31 @@ void RNA_def_collections(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Disable in Renders", "Globally disable in renders"); RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_Collection_flag_update"); + static const EnumPropertyItem rna_collection_lineart_usage[] = { + {COLLECTION_LRT_INCLUDE, "INCLUDE", 0, "Include", "Collection will produce feature lines"}, + {COLLECTION_LRT_OCCLUSION_ONLY, + "OCCLUSION_ONLY", + 0, + "Occlusion Only", + "Only use the collection to produce occlusion"}, + {COLLECTION_LRT_EXCLUDE, "EXCLUDE", 0, "Exclude", "Don't use this collection in LRT"}, + {COLLECTION_LRT_INTERSECTION_ONLY, + "INTERSECTION_ONLY", + 0, + "Intersection Only", + "Only generate intersection lines with this collection"}, + {COLLECTION_LRT_NO_INTERSECTION, + "NO_INTERSECTION", + 0, + "No Intersection", + "Do not generate intersection lines for this collection"}, + {0, NULL, 0, NULL, NULL}}; + + prop = RNA_def_property(srna, "lineart_usage", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, rna_collection_lineart_usage); + RNA_def_property_ui_text(prop, "Usage", "How to use this collection in LRT"); + RNA_def_property_update(prop, NC_SCENE, NULL); + prop = RNA_def_property(srna, "color_tag", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "color_tag"); RNA_def_property_enum_funcs( diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c index 71d5a53adb2..1a385a03fc6 100644 --- a/source/blender/makesrna/intern/rna_gpencil_modifier.c +++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c @@ -88,6 +88,11 @@ const EnumPropertyItem rna_enum_object_greasepencil_modifier_type_items[] = { ICON_MOD_SUBSURF, "Subdivide", "Subdivide stroke adding more control points"}, + {eGpencilModifierType_Lineart, + "GP_LINEART", + ICON_MOD_EDGESPLIT, + "Line Art", + "Generate Line Art strokes from selected source"}, {0, "", 0, N_("Deform"), ""}, {eGpencilModifierType_Armature, "GP_ARMATURE", @@ -241,6 +246,8 @@ static StructRNA *rna_GpencilModifier_refine(struct PointerRNA *ptr) return &RNA_MultiplyGpencilModifier; case eGpencilModifierType_Texture: return &RNA_TextureGpencilModifier; + case eGpencilModifierType_Lineart: + return &RNA_LineartGpencilModifier; /* Default */ case eGpencilModifierType_None: case NUM_GREASEPENCIL_MODIFIER_TYPES: @@ -307,10 +314,11 @@ RNA_GP_MOD_VGROUP_NAME_SET(Opacity, vgname); RNA_GP_MOD_VGROUP_NAME_SET(Lattice, vgname); RNA_GP_MOD_VGROUP_NAME_SET(Smooth, vgname); RNA_GP_MOD_VGROUP_NAME_SET(Hook, vgname); +RNA_GP_MOD_VGROUP_NAME_SET(Tint, vgname); RNA_GP_MOD_VGROUP_NAME_SET(Offset, vgname); RNA_GP_MOD_VGROUP_NAME_SET(Armature, vgname); RNA_GP_MOD_VGROUP_NAME_SET(Texture, vgname); -RNA_GP_MOD_VGROUP_NAME_SET(Tint, vgname); +RNA_GP_MOD_VGROUP_NAME_SET(Lineart, vgname); # undef RNA_GP_MOD_VGROUP_NAME_SET @@ -2305,6 +2313,220 @@ static void rna_def_modifier_gpenciltexture(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update"); } +static void rna_def_modifier_gpencillineart(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static const EnumPropertyItem modifier_lineart_source_type[] = { + {LRT_SOURCE_COLLECTION, "COLLECTION", 0, "Collection", ""}, + {LRT_SOURCE_OBJECT, "OBJECT", 0, "Object", ""}, + {LRT_SOURCE_SCENE, "SCENE", 0, "Scene", ""}, + {0, NULL, 0, NULL, NULL}, + }; + + srna = RNA_def_struct(brna, "LineartGpencilModifier", "GpencilModifier"); + RNA_def_struct_ui_text( + srna, "Line Art Modifier", "Genreate Line Art strokes from selected source"); + RNA_def_struct_sdna(srna, "LineartGpencilModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_EDGESPLIT); + + prop = RNA_def_property(srna, "source_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, modifier_lineart_source_type); + RNA_def_property_ui_text(prop, "Source Type", "Lineart stroke source type"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update"); + + prop = RNA_def_property(srna, "source_object", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); + RNA_def_property_struct_type(prop, "Object"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); + RNA_def_property_ui_text( + prop, "Source Object", "Source object that this modifier grabs data from"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update"); + + prop = RNA_def_property(srna, "source_collection", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); + RNA_def_property_struct_type(prop, "Collection"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); + RNA_def_property_ui_text( + prop, "Source Collection", "Source collection that this modifier uses data from"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update"); + + /* 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_ui_text(prop, "Use Contour", "Include contour lines in the result"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_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_ui_text(prop, "Use Crease", "Include sharp edges in the result"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_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_ui_text( + prop, "Use Material", "Include material separation lines in the result"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_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_ui_text(prop, "Use Edge Mark", "Include freestyle edge marks in the result"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "use_intersection", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "line_types", LRT_EDGE_FLAG_INTERSECTION); + RNA_def_property_ui_text(prop, "Use Intersection", "Include intersection lines in the result"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "use_multiple_levels", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "use_multiple_levels", 0); + RNA_def_property_ui_text( + prop, "Use Multiple Levels", "Select lines from multiple occlusion levels"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "level_start", PROP_INT, PROP_NONE); + RNA_def_property_int_default(prop, 0); + RNA_def_property_ui_text( + prop, "Level Start", "Minimum level of occlusion level that gets selected"); + RNA_def_property_range(prop, 0, 128); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "level_end", PROP_INT, PROP_NONE); + RNA_def_property_int_default(prop, 0); + RNA_def_property_ui_text( + prop, "Level End", "Maximum level of occlusion level that gets selected"); + RNA_def_property_range(prop, 0, 128); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "target_material", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); + RNA_def_property_struct_type(prop, "Material"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); + RNA_def_property_ui_text( + prop, "Target Material", "Grease Pencil material assigned to the generated strokes"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "target_layer", PROP_STRING, PROP_NONE); + RNA_def_property_ui_text( + prop, "Target Layer", "Grease Pencil layer assigned to the generated strokes"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "source_vertex_group", PROP_STRING, PROP_NONE); + RNA_def_property_ui_text( + prop, + "Source Vertex Group", + "Matches the beginning of vertex group names from mesh objects, match all when left empty"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "vgname"); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_LineartGpencilModifier_vgname_set"); + RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group name for selected strokes"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "invert_source_vertex_group", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_boolean_sdna(prop, NULL, "flags", LRT_GPENCIL_INVERT_SOURCE_VGROUP); + RNA_def_property_ui_text(prop, "Invert Source", "Invert source vertex group values"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "match_output_vertex_group", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_default(prop, 1); + RNA_def_property_boolean_sdna(prop, NULL, "flags", LRT_GPENCIL_MATCH_OUTPUT_VGROUP); + RNA_def_property_ui_text(prop, "Match Output", "Match output vertex group"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "soft_selection", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_default(prop, 1); + RNA_def_property_boolean_sdna(prop, NULL, "flags", LRT_GPENCIL_SOFT_SELECTION); + RNA_def_property_ui_text( + prop, "Soft selection", "Preserve original vertex weight instead of clipping to 0/1"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "thickness", PROP_INT, PROP_NONE); + RNA_def_property_int_default(prop, 20); + RNA_def_property_ui_text(prop, "Thickness", "The thickness that used to generate strokes"); + RNA_def_property_ui_range(prop, 1, 100, 1, 1); + RNA_def_property_range(prop, 1, 200); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "opacity", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_default(prop, 0.1f); + RNA_def_property_ui_text(prop, "Opacity", "The strength value used to generate strokes"); + RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.01f, 2); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "pre_sample_length", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_default(prop, 0.0f); + RNA_def_property_ui_text(prop, "Pre Sample Length", "Sample strokes before sending out"); + RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.01f, 2); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "use_transparency", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "transparency_flags", LRT_GPENCIL_TRANSPARENCY_ENABLE); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_ui_text( + prop, "Use Transparency", "Use transparency mask from this material in Line Art"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "transparency_match", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "transparency_flags", LRT_GPENCIL_TRANSPARENCY_MATCH); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_ui_text(prop, "Match Transparency", "Match all transparency bits"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "transparency_mask_0", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_boolean_sdna(prop, NULL, "transparency_mask", 1 << 0); + RNA_def_property_ui_text(prop, "Mask 0", "Mask bit 0"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "transparency_mask_1", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_boolean_sdna(prop, NULL, "transparency_mask", 1 << 1); + RNA_def_property_ui_text(prop, "Mask 1", "Mask bit 1"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "transparency_mask_2", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_boolean_sdna(prop, NULL, "transparency_mask", 1 << 2); + RNA_def_property_ui_text(prop, "Mask 2", "Mask bit 2"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "transparency_mask_3", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_boolean_sdna(prop, NULL, "transparency_mask", 1 << 3); + RNA_def_property_ui_text(prop, "Mask 3", "Mask bit 3"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "transparency_mask_4", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_boolean_sdna(prop, NULL, "transparency_mask", 1 << 4); + RNA_def_property_ui_text(prop, "Mask 4", "Mask bit 4"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "transparency_mask_5", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_boolean_sdna(prop, NULL, "transparency_mask", 1 << 5); + RNA_def_property_ui_text(prop, "Mask 5", "Mask bit 5"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "transparency_mask_6", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_boolean_sdna(prop, NULL, "transparency_mask", 1 << 6); + RNA_def_property_ui_text(prop, "mask 6", "Mask bit 6"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "transparency_mask_7", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_boolean_sdna(prop, NULL, "transparency_mask", 1 << 7); + RNA_def_property_ui_text(prop, "Mask 7", "Mask bit 7"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); +} + void RNA_def_greasepencil_modifier(BlenderRNA *brna) { StructRNA *srna; @@ -2379,6 +2601,7 @@ void RNA_def_greasepencil_modifier(BlenderRNA *brna) rna_def_modifier_gpencilarmature(brna); rna_def_modifier_gpencilmultiply(brna); rna_def_modifier_gpenciltexture(brna); + rna_def_modifier_gpencillineart(brna); } #endif diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 84c831a178e..a6b2015c666 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -87,6 +87,7 @@ const EnumPropertyItem rna_enum_ramp_blend_items[] = { # include "ED_gpencil.h" # include "ED_image.h" +# include "ED_lineart.h" # include "ED_node.h" # include "ED_screen.h" @@ -127,6 +128,14 @@ static void rna_MaterialGpencil_update(Main *bmain, Scene *scene, PointerRNA *pt WM_main_add_notifier(NC_GPENCIL | ND_DATA, ma); } +static void rna_MaterialLineArt_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + rna_Material_update(bmain, scene, ptr); + if (ED_lineart_modifier_sync_flag_check(LRT_SYNC_IDLE)) { + ED_lineart_modifier_sync_flag_set(LRT_SYNC_WAITING, false); + } +} + static void rna_Material_draw_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { Material *ma = (Material *)ptr->owner_id; @@ -671,6 +680,70 @@ static void rna_def_material_greasepencil(BlenderRNA *brna) RNA_def_property_ui_text( prop, "Is Fill Visible", "True when opacity of fill is set high enough to be visible"); } +static void rna_def_material_lineart(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "MaterialLineArt", NULL); + RNA_def_struct_sdna(srna, "MaterialLineArt"); + RNA_def_struct_ui_text(srna, "Material Line Art", ""); + + prop = RNA_def_property(srna, "use_transparency", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_boolean_sdna(prop, NULL, "flags", LRT_MATERIAL_TRANSPARENCY_ENABLED); + RNA_def_property_ui_text( + prop, "Use Transparency", "Use transparency mask from this material in Line Art"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialLineArt_update"); + + prop = RNA_def_property(srna, "transparency_mask_0", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_boolean_sdna(prop, NULL, "transparency_mask", 1 << 0); + RNA_def_property_ui_text(prop, "Mask 0", "Mask bit 0"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialLineArt_update"); + + prop = RNA_def_property(srna, "transparency_mask_1", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_boolean_sdna(prop, NULL, "transparency_mask", 1 << 1); + RNA_def_property_ui_text(prop, "Mask 1", "Mask bit 1"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialLineArt_update"); + + prop = RNA_def_property(srna, "transparency_mask_2", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_boolean_sdna(prop, NULL, "transparency_mask", 1 << 2); + RNA_def_property_ui_text(prop, "Mask 2", "Mask bit 2"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialLineArt_update"); + + prop = RNA_def_property(srna, "transparency_mask_3", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_boolean_sdna(prop, NULL, "transparency_mask", 1 << 3); + RNA_def_property_ui_text(prop, "Mask 3", "Mask bit 3"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialLineArt_update"); + + prop = RNA_def_property(srna, "transparency_mask_4", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_boolean_sdna(prop, NULL, "transparency_mask", 1 << 4); + RNA_def_property_ui_text(prop, "Mask 4", "Mask bit 4"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialLineArt_update"); + + prop = RNA_def_property(srna, "transparency_mask_5", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_boolean_sdna(prop, NULL, "transparency_mask", 1 << 5); + RNA_def_property_ui_text(prop, "Mask 5", "Mask bit 5"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialLineArt_update"); + + prop = RNA_def_property(srna, "transparency_mask_6", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_boolean_sdna(prop, NULL, "transparency_mask", 1 << 6); + RNA_def_property_ui_text(prop, "mask 6", "Mask bit 6"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialLineArt_update"); + + prop = RNA_def_property(srna, "transparency_mask_7", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_boolean_sdna(prop, NULL, "transparency_mask", 1 << 7); + RNA_def_property_ui_text(prop, "Mask 7", "Mask bit 7"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialLineArt_update"); +} void RNA_def_material(BlenderRNA *brna) { @@ -836,7 +909,13 @@ void RNA_def_material(BlenderRNA *brna) RNA_def_property_ui_text( prop, "Is Grease Pencil", "True if this material has grease pencil data"); + /* line art */ + prop = RNA_def_property(srna, "lineart", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "lineart"); + RNA_def_property_ui_text(prop, "Line Art Settings", "Line Art settings for material"); + rna_def_material_greasepencil(brna); + rna_def_material_lineart(brna); RNA_api_material(srna); } diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index a70b776b07a..09727428024 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -36,6 +36,7 @@ #include "DNA_shader_fx_types.h" #include "DNA_workspace_types.h" +#include "BLI_math.h" #include "BLI_utildefines.h" #include "BLT_translation.h" @@ -159,6 +160,21 @@ const EnumPropertyItem rna_enum_object_gpencil_type_items[] = { {GP_EMPTY, "EMPTY", ICON_EMPTY_AXIS, "Blank", "Create an empty grease pencil object"}, {GP_STROKE, "STROKE", ICON_STROKE, "Stroke", "Create a simple stroke with basic colors"}, {GP_MONKEY, "MONKEY", ICON_MONKEY, "Monkey", "Construct a Suzanne grease pencil object"}, + {GP_LRT_SCENE, + "LRT_SCENE", + ICON_SCENE, + "Scene Line Art", + "Quickly set up Line Art for the whole scene"}, + {GP_LRT_COLLECTION, + "LRT_COLLECTION", + ICON_OUTLINER_COLLECTION, + "Collection Line Art", + "Quickly set up Line Art for active collection"}, + {GP_LRT_OBJECT, + "LRT_OBJECT", + ICON_CUBE, + "Object Line Art", + "Quickly set up Line Art for active collection"}, {0, NULL, 0, NULL, NULL}}; static const EnumPropertyItem parent_type_items[] = { @@ -2083,6 +2099,12 @@ int rna_Object_use_dynamic_topology_sculpting_get(PointerRNA *ptr) return (ss && ss->bm); } +static void rna_object_lineart_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +{ + DEG_id_tag_update(ptr->owner_id, ID_RECALC_GEOMETRY); + WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ptr->owner_id); +} + #else static void rna_def_vertex_group(BlenderRNA *brna) @@ -2644,6 +2666,58 @@ static void rna_def_object_display(BlenderRNA *brna) RNA_define_lib_overridable(false); } +static void rna_def_object_lineart(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem prop_feature_line_usage_items[] = { + {OBJECT_LRT_INHERENT, + "INHEREIT", + 0, + "Inhereit", + "Follow settings from the parent collection"}, + {OBJECT_LRT_INCLUDE, "INCLUDE", 0, "Include", "Include this object into LRT calculation"}, + {OBJECT_LRT_OCCLUSION_ONLY, + "OCCLUSION_ONLY", + 0, + "Occlusion Only", + "Don't produce lines, only used as occlusion object"}, + {OBJECT_LRT_EXCLUDE, "EXCLUDE", 0, "Exclude", "Don't use this object for LRT rendering"}, + {OBJECT_LRT_INTERSECTION_ONLY, + "INTERSECTION_ONLY", + 0, + "Intersection Only", + "Only to generate intersection lines with this object"}, + {OBJECT_LRT_NO_INTERSECTION, + "NO_INTERSECTION", + 0, + "No Intersection", + "Include this object but do not generate intersection lines"}, + {0, NULL, 0, NULL, NULL}, + }; + + srna = RNA_def_struct(brna, "ObjectLineArt", NULL); + RNA_def_struct_ui_text(srna, "Object Line Art", "Object lineart settings"); + RNA_def_struct_sdna(srna, "ObjectLineArt"); + + prop = RNA_def_property(srna, "usage", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, prop_feature_line_usage_items); + RNA_def_property_ui_text(prop, "Usage", "How to use this object in line art calculation"); + RNA_def_property_update(prop, 0, "rna_object_lineart_update"); + + prop = RNA_def_property(srna, "use_crease_override", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", OBJECT_LRT_OWN_CREASE); + RNA_def_property_ui_text(prop, "Own Crease", "Use own crease setting to overwrite scene global"); + RNA_def_property_update(prop, 0, "rna_object_lineart_update"); + + prop = RNA_def_property(srna, "crease_threshold", PROP_FLOAT, PROP_ANGLE); + RNA_def_property_range(prop, 0, DEG2RAD(180.0f)); + RNA_def_property_ui_range(prop, 0.0f, DEG2RAD(180.0f), 0.01f, 1); + RNA_def_property_ui_text( + prop, "Own Crease", "Angles smaller than this will be treated as creases"); + RNA_def_property_update(prop, 0, "rna_object_lineart_update"); +} static void rna_def_object(BlenderRNA *brna) { @@ -3414,6 +3488,11 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_pointer_funcs(prop, "rna_Object_display_get", NULL, NULL, NULL); RNA_def_property_ui_text(prop, "Object Display", "Object display settings for 3D viewport"); + /* Line Art */ + prop = RNA_def_property(srna, "lineart", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "ObjectLineArt"); + RNA_def_property_ui_text(prop, "Line Art", "Line Art settings for the object"); + RNA_define_lib_overridable(false); /* anim */ @@ -3434,6 +3513,7 @@ void RNA_def_object(BlenderRNA *brna) rna_def_face_map(brna); rna_def_material_slot(brna); rna_def_object_display(brna); + rna_def_object_lineart(brna); RNA_define_animate_sdna(true); } diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 1ac224b27e4..d1971c9f315 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -24,6 +24,7 @@ #include "DNA_collection_types.h" #include "DNA_gpencil_types.h" #include "DNA_layer_types.h" +#include "DNA_lineart_types.h" #include "DNA_linestyle_types.h" #include "DNA_modifier_types.h" #include "DNA_particle_types.h" @@ -47,6 +48,7 @@ #include "BKE_volume.h" #include "ED_gpencil.h" +#include "ED_lineart.h" #include "ED_object.h" #include "RNA_define.h" @@ -2596,6 +2598,29 @@ static char *rna_UnitSettings_path(PointerRNA *UNUSED(ptr)) return BLI_strdup("unit_settings"); } +/* lineart */ + +static void rna_lineart_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) +{ + if (ED_lineart_modifier_sync_flag_check(LRT_SYNC_IDLE)) { + ED_lineart_modifier_sync_flag_set(LRT_SYNC_WAITING, false); + } +} + +static void rna_lineart_auto_update_set(PointerRNA *ptr, bool value) +{ + SceneLineArt *data = (SceneLineArt *)ptr->data; + + if (value) { + data->flags |= LRT_AUTO_UPDATE; + } + else { + data->flags &= (~LRT_AUTO_UPDATE); + ED_lineart_calculation_flag_set(LRT_RENDER_CANCELING); + ED_lineart_destroy_render_data_external(); + } +} + static char *rna_FFmpegSettings_path(PointerRNA *UNUSED(ptr)) { return BLI_strdup("render.ffmpeg"); @@ -7468,6 +7493,177 @@ static void rna_def_scene_gpencil(BlenderRNA *brna) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); } +static void rna_def_scene_lineart(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "SceneLineArt", NULL); + RNA_def_struct_sdna(srna, "SceneLineArt"); + RNA_def_struct_ui_text(srna, "Scene Line Art Config", "Line Art global settings"); + + prop = RNA_def_property(srna, "auto_update", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", LRT_AUTO_UPDATE); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_ui_text( + prop, "Auto Update", "Automatically update Line Art cache when frame changes"); + + RNA_def_property_boolean_funcs(prop, NULL, "rna_lineart_auto_update_set"); + /* Also use this update callback to trigger the modifier to clear the frame. */ + RNA_def_property_update(prop, NC_SCENE, "rna_lineart_update"); + + prop = RNA_def_property(srna, "gpencil_overwrite", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", LRT_GPENCIL_OVERWRITE); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_ui_text( + prop, + "GPencil Overwrite", + "Overwrite existing strokes in existing frames of target GPencil objects"); + + prop = RNA_def_property(srna, "fuzzy_intersections", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", LRT_INTERSECTION_AS_CONTOUR); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_ui_text( + prop, + "Intersection As Contour", + "Treat intersection lines as contour so those lines can be chained together"); + RNA_def_property_update(prop, NC_SCENE, "rna_lineart_update"); + + prop = RNA_def_property(srna, "fuzzy_everything", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", LRT_EVERYTHING_AS_CONTOUR); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_ui_text(prop, + "All Lines As Contour", + "Treat all lines as contour so those lines can be chained together"); + RNA_def_property_update(prop, NC_SCENE, "rna_lineart_update"); + + prop = RNA_def_property(srna, "allow_duplication", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", LRT_ALLOW_DUPLI_OBJECTS); + RNA_def_property_boolean_default(prop, 1); + RNA_def_property_ui_text( + prop, + "Instanced Objects", + "Allow particle objects and face/vertiex duplication to show in line art"); + RNA_def_property_update(prop, NC_SCENE, "rna_lineart_update"); + + prop = RNA_def_property(srna, "allow_overlapping_edges", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", LRT_ALLOW_OVERLAPPING_EDGES); + RNA_def_property_boolean_default(prop, 1); + RNA_def_property_ui_text(prop, + "Handle Overlapping Edges", + "Allow lines from edge split to show properly, may run slower"); + RNA_def_property_update(prop, NC_SCENE, "rna_lineart_update"); + + prop = RNA_def_property(srna, "allow_clipping_boundaries", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", LRT_ALLOW_CLIPPING_BOUNDARIES); + RNA_def_property_boolean_default(prop, 1); + RNA_def_property_ui_text( + prop, "Clipping Boundaries", "Allow lines on near/far clipping plane to be shown"); + RNA_def_property_update(prop, NC_SCENE, "rna_lineart_update"); + + prop = RNA_def_property(srna, "crease_threshold", PROP_FLOAT, PROP_ANGLE); + RNA_def_property_range(prop, 0, DEG2RAD(180.0f)); + RNA_def_property_ui_range(prop, 0.0f, DEG2RAD(180.0f), 0.01f, 1); + RNA_def_property_ui_text( + prop, "Crease Threshold", "Angles smaller than this will be treated as creases"); + RNA_def_property_update(prop, NC_SCENE, "rna_lineart_update"); + + prop = RNA_def_property(srna, "angle_splitting_threshold", PROP_FLOAT, PROP_ANGLE); + RNA_def_property_float_default(prop, DEG2RAD(60.0f)); + RNA_def_property_ui_text( + prop, "Angle Splitting", "Angle in screen space below which a stroke is split in two"); + /* Don't allow value very close to PI, or we get a lot of small segments.*/ + RNA_def_property_ui_range(prop, 0.0f, DEG2RAD(179.5f), 0.01f, 1); + RNA_def_property_range(prop, 0.0f, DEG2RAD(180.0f)); + RNA_def_property_update(prop, NC_SCENE, "rna_lineart_update"); + + prop = RNA_def_property(srna, "remove_doubles", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", LRT_REMOVE_DOUBLES); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_ui_text( + prop, "Remove Doubles", "Remove doubles when line art is loading geometries"); + RNA_def_property_update(prop, NC_SCENE, "rna_lineart_update"); + + /* 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 lines from object silhouettes 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 sharp edges 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_EDGE_FLAG_INTERSECTION); + RNA_def_property_boolean_default(prop, true); + RNA_def_property_ui_text( + prop, "Calculate Intersections", "Calculate intersections lines when enabled"); + RNA_def_property_update(prop, NC_SCENE, "rna_lineart_update"); + + /* Below these two are only for grease pencil, thus no viewport updates. */ + + prop = RNA_def_property(srna, "chaining_geometry_threshold", PROP_FLOAT, PROP_DISTANCE); + RNA_def_property_float_default(prop, 0.01f); + RNA_def_property_ui_text(prop, + "Geometry Threshold", + "Segments where their geometric distance between them lower than this " + "will be chained together"); + RNA_def_property_ui_range(prop, 0.0f, 0.5f, 0.001f, 3); + RNA_def_property_range(prop, 0.0f, 0.5f); + RNA_def_property_update(prop, NC_SCENE, "rna_lineart_update"); + + prop = RNA_def_property(srna, "chaining_image_threshold", PROP_FLOAT, PROP_DISTANCE); + RNA_def_property_float_default(prop, 0.01f); + RNA_def_property_ui_text( + prop, + "Image Threshold", + "Segments with an image distance smaller than this will be chained together"); + RNA_def_property_ui_range(prop, 0.0f, 0.3f, 0.001f, 4); + RNA_def_property_range(prop, 0.0f, 0.3f); + RNA_def_property_update(prop, NC_SCENE, "rna_lineart_update"); + + prop = RNA_def_property(srna, "baking_final_range", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", LRT_BAKING_FINAL_RANGE); + RNA_def_property_boolean_default(prop, 1); + RNA_def_property_ui_text( + prop, "Final Range", "Bake with the scene frame range instead of a preview range"); + + prop = RNA_def_property(srna, "baking_keyframes_only", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", LRT_BAKING_KEYFRAMES_ONLY); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_ui_text(prop, "Keyframes Only", "Only fill in existing gpencil key frames"); + + prop = RNA_def_property(srna, "baking_preview_start", PROP_INT, PROP_NONE); + RNA_def_property_ui_text(prop, "Preview start", "First frame to be baked in preview"); + RNA_def_property_range(prop, 0, MAXFRAME); + + prop = RNA_def_property(srna, "baking_preview_end", PROP_INT, PROP_NONE); + RNA_def_property_ui_text(prop, "Preview end", "Last frame to be baked in preview"); + RNA_def_property_range(prop, 0, MAXFRAME); + + prop = RNA_def_property(srna, "baking_skip", PROP_INT, PROP_NONE); + RNA_def_property_ui_text(prop, "Skip", "Number of frames to skip per baked frame"); + RNA_def_property_ui_range(prop, 0, 100, 1, 1); +} + void RNA_def_scene(BlenderRNA *brna) { StructRNA *srna; @@ -7943,6 +8139,11 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_struct_type(prop, "SceneEEVEE"); RNA_def_property_ui_text(prop, "Eevee", "Eevee settings for the scene"); + /* Line Art */ + prop = RNA_def_property(srna, "lineart", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "SceneLineArt"); + RNA_def_property_ui_text(prop, "Line Art", "Line Art settings for the scene"); + /* Grease Pencil */ prop = RNA_def_property(srna, "grease_pencil_settings", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "SceneGpencil"); @@ -7966,6 +8167,7 @@ void RNA_def_scene(BlenderRNA *brna) rna_def_display_safe_areas(brna); rna_def_scene_display(brna); rna_def_scene_eevee(brna); + rna_def_scene_lineart(brna); rna_def_view_layer_aov(brna); rna_def_view_layer_eevee(brna); rna_def_scene_gpencil(brna); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index affb17c7d8c..447e11594a7 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -453,13 +453,14 @@ static const EnumPropertyItem buttons_context_items[] = { {BCONTEXT_OUTPUT, "OUTPUT", ICON_OUTPUT, "Output", "Output Properties"}, {BCONTEXT_VIEW_LAYER, "VIEW_LAYER", ICON_RENDER_RESULT, "View Layer", "View Layer Properties"}, {BCONTEXT_WORLD, "WORLD", ICON_WORLD, "World", "World Properties"}, + {BCONTEXT_COLLECTION, "COLLECTION", ICON_GROUP, "Collection", "Collection Properties"}, {BCONTEXT_OBJECT, "OBJECT", ICON_OBJECT_DATA, "Object", "Object Properties"}, {BCONTEXT_CONSTRAINT, "CONSTRAINT", ICON_CONSTRAINT, "Constraints", "Object Constraint Properties"}, - {BCONTEXT_MODIFIER, "MODIFIER", ICON_MODIFIER, "Modifiers", "Modifier Properties"}, + {BCONTEXT_MODIFIER, "MODIFIER", ICON_MODIFIER, "Modifiers", "Modifiers Properties"}, {BCONTEXT_DATA, "DATA", ICON_NONE, "Data", "Object Data Properties"}, {BCONTEXT_BONE, "BONE", ICON_BONE_DATA, "Bone", "Bone Properties"}, {BCONTEXT_BONE_CONSTRAINT, |