From 8f386cd30862a8846b8b05ee7db7de265c80a7f4 Mon Sep 17 00:00:00 2001 From: casey bianco-davis Date: Fri, 16 Aug 2024 19:50:34 +0200 Subject: [PATCH] GPv3: Edit Mode: "Scale Thickness" option This implements the `use_scale_thickness` setting for GPv3. Pull Request: https://projects.blender.org/blender/blender/pulls/126213 --- scripts/startup/bl_ui/space_view3d.py | 9 +++++++-- .../transform/transform_convert_grease_pencil.cc | 5 ++++- source/blender/editors/transform/transform_mode.cc | 13 +++++++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/scripts/startup/bl_ui/space_view3d.py b/scripts/startup/bl_ui/space_view3d.py index ab0b240a597..813436e9167 100644 --- a/scripts/startup/bl_ui/space_view3d.py +++ b/scripts/startup/bl_ui/space_view3d.py @@ -6129,8 +6129,12 @@ class VIEW3D_MT_edit_greasepencil(Menu): class VIEW3D_MT_edit_greasepencil_stroke(Menu): bl_label = "Stroke" - def draw(self, _context): + def draw(self, context): layout = self.layout + + tool_settings = context.tool_settings + settings = tool_settings.gpencil_sculpt + layout.operator("grease_pencil.stroke_subdivide", text="Subdivide") layout.operator("grease_pencil.stroke_subdivide_smooth", text="Subdivide and Smooth") layout.operator("grease_pencil.stroke_simplify", text="Simplify") @@ -6153,6 +6157,7 @@ class VIEW3D_MT_edit_greasepencil_stroke(Menu): layout.operator("grease_pencil.set_uniform_thickness") layout.operator("grease_pencil.set_uniform_opacity") + layout.prop(settings, "use_scale_thickness", text="Scale Thickness") layout.separator() @@ -6359,7 +6364,7 @@ class VIEW3D_MT_pivot_pie(Menu): pie.prop_enum(tool_settings, "transform_pivot_point", value='ACTIVE_ELEMENT') if (obj is None) or (mode in {'OBJECT', 'POSE', 'WEIGHT_PAINT'}): pie.prop(tool_settings, "use_transform_pivot_point_align") - if mode == 'EDIT_GPENCIL': + if mode in ['EDIT_GPENCIL', 'EDIT_GREASE_PENCIL']: pie.prop(tool_settings.gpencil_sculpt, "use_scale_thickness") diff --git a/source/blender/editors/transform/transform_convert_grease_pencil.cc b/source/blender/editors/transform/transform_convert_grease_pencil.cc index ecae854b512..73d1e143205 100644 --- a/source/blender/editors/transform/transform_convert_grease_pencil.cc +++ b/source/blender/editors/transform/transform_convert_grease_pencil.cc @@ -32,6 +32,9 @@ static void createTransGreasePencilVerts(bContext *C, TransInfo *t) MutableSpan trans_data_contrainers(t->data_container, t->data_container_len); const bool use_proportional_edit = (t->flag & T_PROP_EDIT_ALL) != 0; const bool use_connected_only = (t->flag & T_PROP_CONNECTED) != 0; + ToolSettings *ts = scene->toolsettings; + const bool is_scale_thickness = ((t->mode == TFM_CURVE_SHRINKFATTEN) || + (ts->gp_sculpt.flag & GP_SCULPT_SETT_FLAG_SCALE_THICKNESS)); Vector handle_selection; @@ -181,7 +184,7 @@ static void createTransGreasePencilVerts(bContext *C, TransInfo *t) bke::CurvesGeometry &curves = info.drawing.strokes_for_write(); std::optional> value_attribute; - if (t->mode == TFM_CURVE_SHRINKFATTEN) { + if (is_scale_thickness) { MutableSpan radii = info.drawing.radii_for_write(); value_attribute = radii; } diff --git a/source/blender/editors/transform/transform_mode.cc b/source/blender/editors/transform/transform_mode.cc index caddf43dcb2..67c54baf605 100644 --- a/source/blender/editors/transform/transform_mode.cc +++ b/source/blender/editors/transform/transform_mode.cc @@ -1065,6 +1065,19 @@ void ElementResize(const TransInfo *t, } else if (t->obedit_type == OB_GREASE_PENCIL) { mul_v3_fl(vec, td->factor); + + /* Scale stroke thickness. */ + if (td->val) { + NumInput num_evil = t->num; + float values_final_evil[4]; + copy_v4_v4(values_final_evil, t->values_final); + transform_snap_increment(t, values_final_evil); + applyNumInput(&num_evil, values_final_evil); + + float ratio = values_final_evil[0]; + float transformed_value = td->ival * fabs(ratio); + *td->val = transformed_value; + } } } else {