diff --git a/release/datafiles/icons_svg/gp_cyclic_stroke.svg b/release/datafiles/icons_svg/gp_cyclic_stroke.svg new file mode 100644 index 00000000000..d909af720f7 --- /dev/null +++ b/release/datafiles/icons_svg/gp_cyclic_stroke.svg @@ -0,0 +1,17 @@ + + diff --git a/scripts/startup/bl_ui/properties_paint_common.py b/scripts/startup/bl_ui/properties_paint_common.py index ef7f06de16f..e261c8ea484 100644 --- a/scripts/startup/bl_ui/properties_paint_common.py +++ b/scripts/startup/bl_ui/properties_paint_common.py @@ -1955,6 +1955,12 @@ def brush_basic_grease_pencil_paint_settings(layout, context, brush, props, *, c else: row.prop(brush.gpencil_settings, "stroke_type") + row = layout.row(align=True) + if compact: + row.prop(gp_settings, "use_cyclic_stroke", text="") + else: + row.prop(gp_settings, "use_cyclic_stroke", text="Cyclic") + row = layout.row(align=True) if compact: row.prop(gp_settings, "caps_type", text="", expand=True) diff --git a/source/blender/editors/datafiles/CMakeLists.txt b/source/blender/editors/datafiles/CMakeLists.txt index 02f9d5432e0..1598be95ebb 100644 --- a/source/blender/editors/datafiles/CMakeLists.txt +++ b/source/blender/editors/datafiles/CMakeLists.txt @@ -417,6 +417,7 @@ if(WITH_BLENDER) gizmo gp_caps_flat gp_caps_round + gp_cyclic_stroke gp_draw_stroke gp_draw_fill gp_draw_both diff --git a/source/blender/editors/include/UI_icons.hh b/source/blender/editors/include/UI_icons.hh index e63d31bfed3..4345e2a7ffb 100644 --- a/source/blender/editors/include/UI_icons.hh +++ b/source/blender/editors/include/UI_icons.hh @@ -300,6 +300,7 @@ DEF_ICON(UGLYPACKAGE) DEF_ICON(GP_DRAW_STROKE) DEF_ICON(GP_DRAW_FILL) DEF_ICON(GP_DRAW_BOTH) +DEF_ICON(GP_CYCLIC_STROKE) /* Careful, order is narrow to wide. */ /* INPUT */ diff --git a/source/blender/editors/sculpt_paint/grease_pencil/paint.cc b/source/blender/editors/sculpt_paint/grease_pencil/paint.cc index 2dfcac4f04a..776f49faf2b 100644 --- a/source/blender/editors/sculpt_paint/grease_pencil/paint.cc +++ b/source/blender/editors/sculpt_paint/grease_pencil/paint.cc @@ -361,6 +361,7 @@ struct PaintOperationExecutor { const bool on_back = (scene_->toolsettings->gpencil_flags & GP_TOOL_FLAG_PAINT_ONBACK) != 0; const bool hide_fill_while_drawing = (settings_->flag & GP_BRUSH_DISSABLE_LASSO) != 0; + const bool cyclic_stroke = (settings_->flag & GP_BRUSH_USE_CYCLIC_STROKE) != 0; self.screen_space_coords_orig_.append(start_coords); self.screen_space_curve_fitted_coords_.append(Vector({start_coords})); @@ -405,7 +406,7 @@ struct PaintOperationExecutor { "material_index", bke::AttrDomain::Curve); bke::SpanAttributeWriter cyclic = attributes.convert_or_add_for_write_span( "cyclic", bke::AttrDomain::Curve); - cyclic.span[active_curve] = use_fill && !use_stroke; + cyclic.span[active_curve] = cyclic_stroke; materials.span[active_curve] = material_index; curve_attributes_to_skip.add_multiple({"material_index", "cyclic"}); cyclic.finish(); diff --git a/source/blender/makesdna/DNA_brush_enums.h b/source/blender/makesdna/DNA_brush_enums.h index 8c25022eb4e..8c31ecfc280 100644 --- a/source/blender/makesdna/DNA_brush_enums.h +++ b/source/blender/makesdna/DNA_brush_enums.h @@ -59,6 +59,8 @@ enum eGPDbrush_Flag : int { GP_BRUSH_FILL_AUTO_REMOVE_FILL_GUIDES = (1 << 21), /* Fill Tool create internal gaps. */ GP_BRUSH_FILL_INTERNAL_GAPS = (1 << 22), + /* Create a cylic stroke. */ + GP_BRUSH_USE_CYCLIC_STROKE = (1 << 23), }; ENUM_OPERATORS(eGPDbrush_Flag) diff --git a/source/blender/makesrna/intern/rna_brush.cc b/source/blender/makesrna/intern/rna_brush.cc index c09573e816c..d28d63ca3e2 100644 --- a/source/blender/makesrna/intern/rna_brush.cc +++ b/source/blender/makesrna/intern/rna_brush.cc @@ -1910,6 +1910,14 @@ static void rna_def_gpencil_options(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_update(prop, 0, "rna_BrushGpencilSettings_update"); + prop = RNA_def_property(srna, "use_cyclic_stroke", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, nullptr, "flag", GP_BRUSH_USE_CYCLIC_STROKE); + RNA_def_property_boolean_default(prop, false); + RNA_def_property_ui_icon(prop, ICON_GP_CYCLIC_STROKE, 0); + RNA_def_property_ui_text(prop, "Cyclic", "Create a cyclic stroke"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_update(prop, 0, "rna_BrushGpencilSettings_update"); + prop = RNA_def_property(srna, "eraser_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, nullptr, "eraser_mode"); RNA_def_property_enum_items(prop, rna_enum_gpencil_brush_eraser_modes_items);