From 29f3af95272590d26f610ae828b2eeee89c82a00 Mon Sep 17 00:00:00 2001 From: Antonio Vazquez Date: Mon, 9 Mar 2020 16:27:24 +0100 Subject: GPencil: Refactor of Draw Engine, Vertex Paint and all internal functions This commit is a full refactor of the grease pencil modules including Draw Engine, Modifiers, VFX, depsgraph update, improvements in operators and conversion of Sculpt and Weight paint tools to real brushes. Also, a huge code cleanup has been done at all levels. Thanks to @fclem for his work and yo @pepeland and @mendio for the testing and help in the development. Differential Revision: https://developer.blender.org/D6293 --- source/blender/makesrna/intern/rna_scene.c | 136 ++++++++++++++++++++++------- 1 file changed, 105 insertions(+), 31 deletions(-) (limited to 'source/blender/makesrna/intern/rna_scene.c') diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index a427267926d..0ead133b3a8 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -733,14 +733,8 @@ static void rna_GPencilInterpolateSettings_type_set(PointerRNA *ptr, int value) } } -static void rna_Gpencil_selectmode_update(bContext *C, PointerRNA *ptr) +static void rna_Gpencil_extend_selection(bContext *C, PointerRNA *UNUSED(ptr)) { - ToolSettings *ts = (ToolSettings *)ptr->data; - /* If the mode is not Stroke, don't extend selection. */ - if ((ts->gpencil_selectmode_edit & GP_SELECTMODE_STROKE) == 0) { - return; - } - /* Extend selection to all points in all selected strokes. */ ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = OBACT(view_layer); @@ -762,9 +756,18 @@ static void rna_Gpencil_selectmode_update(bContext *C, PointerRNA *ptr) } } -static void rna_Gpencil_mask_point_update(Main *UNUSED(bmain), - Scene *UNUSED(scene), - PointerRNA *ptr) +static void rna_Gpencil_selectmode_update(bContext *C, PointerRNA *ptr) +{ + ToolSettings *ts = (ToolSettings *)ptr->data; + /* If the mode is not Stroke, don't extend selection. */ + if ((ts->gpencil_selectmode_edit & GP_SELECTMODE_STROKE) == 0) { + return; + } + + rna_Gpencil_extend_selection(C, ptr); +} + +static void rna_Gpencil_mask_point_update(bContext *UNUSED(C), PointerRNA *ptr) { ToolSettings *ts = (ToolSettings *)ptr->data; @@ -772,19 +775,17 @@ static void rna_Gpencil_mask_point_update(Main *UNUSED(bmain), ts->gpencil_selectmode_sculpt &= ~GP_SCULPT_MASK_SELECTMODE_SEGMENT; } -static void rna_Gpencil_mask_stroke_update(Main *UNUSED(bmain), - Scene *UNUSED(scene), - PointerRNA *ptr) +static void rna_Gpencil_mask_stroke_update(bContext *C, PointerRNA *ptr) { ToolSettings *ts = (ToolSettings *)ptr->data; ts->gpencil_selectmode_sculpt &= ~GP_SCULPT_MASK_SELECTMODE_POINT; ts->gpencil_selectmode_sculpt &= ~GP_SCULPT_MASK_SELECTMODE_SEGMENT; + + rna_Gpencil_extend_selection(C, ptr); } -static void rna_Gpencil_mask_segment_update(Main *UNUSED(bmain), - Scene *UNUSED(scene), - PointerRNA *ptr) +static void rna_Gpencil_mask_segment_update(bContext *UNUSED(C), PointerRNA *ptr) { ToolSettings *ts = (ToolSettings *)ptr->data; @@ -792,6 +793,38 @@ static void rna_Gpencil_mask_segment_update(Main *UNUSED(bmain), ts->gpencil_selectmode_sculpt &= ~GP_SCULPT_MASK_SELECTMODE_STROKE; } +static void rna_Gpencil_vertex_mask_point_update(bContext *C, PointerRNA *ptr) +{ + ToolSettings *ts = (ToolSettings *)ptr->data; + + ts->gpencil_selectmode_vertex &= ~GP_VERTEX_MASK_SELECTMODE_STROKE; + ts->gpencil_selectmode_vertex &= ~GP_VERTEX_MASK_SELECTMODE_SEGMENT; + + ED_gpencil_tag_scene_gpencil(CTX_data_scene(C)); +} + +static void rna_Gpencil_vertex_mask_stroke_update(bContext *C, PointerRNA *ptr) +{ + ToolSettings *ts = (ToolSettings *)ptr->data; + + ts->gpencil_selectmode_vertex &= ~GP_VERTEX_MASK_SELECTMODE_POINT; + ts->gpencil_selectmode_vertex &= ~GP_VERTEX_MASK_SELECTMODE_SEGMENT; + + rna_Gpencil_extend_selection(C, ptr); + + ED_gpencil_tag_scene_gpencil(CTX_data_scene(C)); +} + +static void rna_Gpencil_vertex_mask_segment_update(bContext *C, PointerRNA *ptr) +{ + ToolSettings *ts = (ToolSettings *)ptr->data; + + ts->gpencil_selectmode_vertex &= ~GP_VERTEX_MASK_SELECTMODE_POINT; + ts->gpencil_selectmode_vertex &= ~GP_VERTEX_MASK_SELECTMODE_STROKE; + + ED_gpencil_tag_scene_gpencil(CTX_data_scene(C)); +} + /* Read-only Iterator of all the scene objects. */ static void rna_Scene_objects_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) @@ -2873,6 +2906,18 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "gp_paint"); RNA_def_property_ui_text(prop, "Grease Pencil Paint", ""); + prop = RNA_def_property(srna, "gpencil_vertex_paint", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "gp_vertexpaint"); + RNA_def_property_ui_text(prop, "Grease Pencil Vertex Paint", ""); + + prop = RNA_def_property(srna, "gpencil_sculpt_paint", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "gp_sculptpaint"); + RNA_def_property_ui_text(prop, "Grease Pencil Sculpt Paint", ""); + + prop = RNA_def_property(srna, "gpencil_weight_paint", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "gp_weightpaint"); + RNA_def_property_ui_text(prop, "Grease Pencil Weight Paint", ""); + prop = RNA_def_property(srna, "particle_edit", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "particle"); RNA_def_property_ui_text(prop, "Particle Edit", ""); @@ -3190,6 +3235,7 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Selection Mask", "Only sculpt selected stroke points"); RNA_def_property_ui_icon(prop, ICON_GP_SELECT_POINTS, 0); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_Gpencil_mask_point_update"); prop = RNA_def_property(srna, "use_gpencil_select_mask_stroke", PROP_BOOLEAN, PROP_NONE); @@ -3198,6 +3244,7 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Selection Mask", "Only sculpt selected stroke"); RNA_def_property_ui_icon(prop, ICON_GP_SELECT_STROKES, 0); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_Gpencil_mask_stroke_update"); prop = RNA_def_property(srna, "use_gpencil_select_mask_segment", PROP_BOOLEAN, PROP_NONE); @@ -3207,8 +3254,41 @@ static void rna_def_tool_settings(BlenderRNA *brna) prop, "Selection Mask", "Only sculpt selected stroke points between other strokes"); RNA_def_property_ui_icon(prop, ICON_GP_SELECT_BETWEEN_STROKES, 0); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_Gpencil_mask_segment_update"); + /* Grease Pencil - Select mode Vertex Paint */ + prop = RNA_def_property(srna, "use_gpencil_vertex_select_mask_point", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna( + prop, NULL, "gpencil_selectmode_vertex", GP_VERTEX_MASK_SELECTMODE_POINT); + RNA_def_property_ui_text(prop, "Selection Mask", "Only paint selected stroke points"); + RNA_def_property_ui_icon(prop, ICON_GP_SELECT_POINTS, 0); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update( + prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_Gpencil_vertex_mask_point_update"); + + prop = RNA_def_property(srna, "use_gpencil_vertex_select_mask_stroke", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna( + prop, NULL, "gpencil_selectmode_vertex", GP_VERTEX_MASK_SELECTMODE_STROKE); + RNA_def_property_ui_text(prop, "Selection Mask", "Only paint selected stroke"); + RNA_def_property_ui_icon(prop, ICON_GP_SELECT_STROKES, 0); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update( + prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_Gpencil_vertex_mask_stroke_update"); + + prop = RNA_def_property(srna, "use_gpencil_vertex_select_mask_segment", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna( + prop, NULL, "gpencil_selectmode_vertex", GP_VERTEX_MASK_SELECTMODE_SEGMENT); + RNA_def_property_ui_text( + prop, "Selection Mask", "Only paint selected stroke points between other strokes"); + RNA_def_property_ui_icon(prop, ICON_GP_SELECT_BETWEEN_STROKES, 0); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update( + prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_Gpencil_vertex_mask_segment_update"); + /* Annotations - 2D Views Stroke Placement */ prop = RNA_def_property(srna, "annotation_stroke_placement_view2d", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "gpencil_v2d_align"); @@ -6288,7 +6368,12 @@ static void rna_def_scene_render_data(BlenderRNA *brna) prop = RNA_def_property(srna, "simplify_gpencil_onplay", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "simplify_gpencil", SIMPLIFY_GPENCIL_ON_PLAY); RNA_def_property_ui_text( - prop, "Simplify Playback", "Simplify Grease Pencil only during animation playback"); + prop, "Playback Only", "Simplify Grease Pencil only during animation playback"); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + + prop = RNA_def_property(srna, "simplify_gpencil_antialiasing", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "simplify_gpencil", SIMPLIFY_GPENCIL_AA); + RNA_def_property_ui_text(prop, "Antialiasing", "Use Antialiasing to smooth stroke edges"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); prop = RNA_def_property(srna, "simplify_gpencil_view_fill", PROP_BOOLEAN, PROP_NONE); @@ -6296,26 +6381,15 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Fill", "Display fill strokes in the viewport"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); - prop = RNA_def_property(srna, "simplify_gpencil_remove_lines", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna( - prop, NULL, "simplify_gpencil", SIMPLIFY_GPENCIL_REMOVE_FILL_LINE); - RNA_def_property_ui_text(prop, "Disable Lines", "Display external lines of fill strokes"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); - - prop = RNA_def_property(srna, "simplify_gpencil_view_modifier", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "simplify_gpencil_modifier", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna( prop, NULL, "simplify_gpencil", SIMPLIFY_GPENCIL_MODIFIER); - RNA_def_property_ui_text(prop, "Disable Modifiers", "Display modifiers in the viewport"); + RNA_def_property_ui_text(prop, "Modifiers", "Display modifiers"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); prop = RNA_def_property(srna, "simplify_gpencil_shader_fx", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "simplify_gpencil", SIMPLIFY_GPENCIL_FX); - RNA_def_property_ui_text(prop, "Simplify Shaders", "Display Shader FX"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); - - prop = RNA_def_property(srna, "simplify_gpencil_blend", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "simplify_gpencil", SIMPLIFY_GPENCIL_BLEND); - RNA_def_property_ui_text(prop, "Layers Blending", "Display blend layers"); + RNA_def_property_ui_text(prop, "ShadersFX", "Display Shader FX"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); prop = RNA_def_property(srna, "simplify_gpencil_tint", PROP_BOOLEAN, PROP_NONE); -- cgit v1.2.3