Fix #115313: GPencil brush direction is not kept

The core of the issue was that `sculpt_flag` was used by three different enums (`eGP_Sculpt_Flag`, `eGP_Sculpt_Mode_Flag`, and `eBrushFlags`). This resulted in the flag getting overriden because `ENUM_OPERATORS` expected the maximum value of `eGP_Sculpt_Flag` to be `(1 << 3)` which it wasn't.

The `sculpt_flag` was exposed through python as `"direction"`.
In the UI this meant that it was effectively used as `brush.direction`. This fix replaces `brush.gpencil_settings.direction` with `brush.direction`.
It also makes sure `sculpt_flag` is only ever used with values from `eGP_Sculpt_Flag`.

Pull Request: https://projects.blender.org/blender/blender/pulls/119373
This commit is contained in:
Falk David
2024-03-12 14:22:52 +01:00
committed by Falk David
parent 7c74a042f2
commit 998514af7b
9 changed files with 53 additions and 33 deletions
@@ -1409,20 +1409,12 @@ def brush_basic_gpencil_sculpt_settings(layout, _context, brush, *, compact=Fals
if compact:
if tool in {'THICKNESS', 'STRENGTH', 'PINCH', 'TWIST'}:
row.separator()
row.prop(gp_settings, "direction", expand=True, text="")
row.prop(brush, "direction", expand=True, text="")
else:
use_property_split_prev = layout.use_property_split
layout.use_property_split = False
if tool in {'THICKNESS', 'STRENGTH'}:
layout.row().prop(gp_settings, "direction", expand=True)
elif tool == 'PINCH':
row = layout.row(align=True)
row.prop_enum(gp_settings, "direction", value='ADD', text="Pinch")
row.prop_enum(gp_settings, "direction", value='SUBTRACT', text="Inflate")
elif tool == 'TWIST':
row = layout.row(align=True)
row.prop_enum(gp_settings, "direction", value='ADD', text="CCW")
row.prop_enum(gp_settings, "direction", value='SUBTRACT', text="CW")
if tool in {'THICKNESS', 'STRENGTH', 'PINCH', 'TWIST'}:
layout.row().prop(brush, "direction", expand=True)
layout.use_property_split = use_property_split_prev
@@ -1436,8 +1428,7 @@ def brush_basic_gpencil_weight_settings(layout, _context, brush, *, compact=Fals
if brush.gpencil_weight_tool in {'WEIGHT'}:
layout.prop(brush, "weight", slider=True)
gp_settings = brush.gpencil_settings
layout.prop(gp_settings, "direction", expand=True, text="" if compact else "Direction")
layout.prop(brush, "direction", expand=True, text="" if compact else "Direction")
def brush_basic_gpencil_vertex_settings(layout, _context, brush, *, compact=False):