[Bf-blender-cvs] [73a191d0cb2] greasepencil-object: WIP: Initial steps to implement Sculpt brushes in Toolbar
Antonio Vazquez
noreply at git.blender.org
Tue Jul 10 10:12:20 CEST 2018
Commit: 73a191d0cb23e9ba7320b5e033595f8ada33f8f3
Author: Antonio Vazquez
Date: Tue Jul 10 09:38:24 2018 +0200
Branches: greasepencil-object
https://developer.blender.org/rB73a191d0cb23e9ba7320b5e033595f8ada33f8f3
WIP: Initial steps to implement Sculpt brushes in Toolbar
This is not working yet and can produce segment faults.
===================================================================
M release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
M source/blender/editors/gpencil/gpencil_brush.c
M source/blender/editors/space_buttons/space_buttons.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index ab733a12952..b098499ac28 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -952,6 +952,165 @@ class _defs_uv_select:
)
+class _defs_gpencil_sculpt:
+ @classmethod
+ def draw_settings_common(cls, context, layout, tool):
+ ob = context.active_object
+ if ob and ob.mode in {'GPENCIL_SCULPT', 'GPENCIL_WEIGHT'}:
+ settings = context.tool_settings.gpencil_sculpt
+ brush = settings.brush
+
+ layout.prop(brush, "size", slider=True)
+
+ row = layout.row(align=True)
+ row.prop(brush, "strength", slider=True)
+ row.prop(brush, "use_pressure_strength", text="")
+
+ @ToolDef.from_fn
+ def smooth():
+ def draw_settings(context, layout, tool):
+ _defs_gpencil_sculpt.draw_settings_common(context, layout, tool)
+
+ return dict(
+ text="Smooth",
+ icon="ops.gpencil.sculpt_smooth",
+ keymap=(
+ ("gpencil.brush_paint",
+ dict(mode='SMOOTH', wait_for_input=False),
+ dict(type='EVT_TWEAK_A', value='ANY')),
+ ),
+ draw_settings=draw_settings,
+ )
+
+ @ToolDef.from_fn
+ def thickness():
+ def draw_settings(context, layout, tool):
+ _defs_gpencil_sculpt.draw_settings_common(context, layout, tool)
+
+ return dict(
+ text="Thickness",
+ icon="ops.gpencil.sculpt_thickness",
+ keymap=(
+ ("gpencil.brush_paint",
+ dict(mode='THICKNESS', wait_for_input=False),
+ dict(type='EVT_TWEAK_A', value='ANY')),
+ ),
+ draw_settings=draw_settings,
+ )
+
+ @ToolDef.from_fn
+ def strength():
+ def draw_settings(context, layout, tool):
+ _defs_gpencil_sculpt.draw_settings_common(context, layout, tool)
+
+ return dict(
+ text="Strength",
+ icon="ops.gpencil.sculpt_strength",
+ keymap=(
+ ("gpencil.brush_paint",
+ dict(mode='STRENGTH', wait_for_input=False),
+ dict(type='EVT_TWEAK_A', value='ANY')),
+ ),
+ draw_settings=draw_settings,
+ )
+
+ @ToolDef.from_fn
+ def grab():
+ def draw_settings(context, layout, tool):
+ _defs_gpencil_sculpt.draw_settings_common(context, layout, tool)
+
+ return dict(
+ text="Grab",
+ icon="ops.gpencil.sculpt_grab",
+ keymap=(
+ ("gpencil.brush_paint",
+ dict(mode='GRAB', wait_for_input=False),
+ dict(type='EVT_TWEAK_A', value='ANY')),
+ ),
+ draw_settings=draw_settings,
+ )
+
+ @ToolDef.from_fn
+ def push():
+ def draw_settings(context, layout, tool):
+ _defs_gpencil_sculpt.draw_settings_common(context, layout, tool)
+
+ return dict(
+ text="Push",
+ icon="ops.gpencil.sculpt_push",
+ keymap=(
+ ("gpencil.brush_paint",
+ dict(mode='PUSH', wait_for_input=False),
+ dict(type='EVT_TWEAK_A', value='ANY')),
+ ),
+ draw_settings=draw_settings,
+ )
+
+ @ToolDef.from_fn
+ def twist():
+ def draw_settings(context, layout, tool):
+ _defs_gpencil_sculpt.draw_settings_common(context, layout, tool)
+
+ return dict(
+ text="Twist",
+ icon="ops.gpencil.sculpt_twist",
+ keymap=(
+ ("gpencil.brush_paint",
+ dict(mode='TWIST', wait_for_input=False),
+ dict(type='EVT_TWEAK_A', value='ANY')),
+ ),
+ draw_settings=draw_settings,
+ )
+
+ @ToolDef.from_fn
+ def pinch():
+ def draw_settings(context, layout, tool):
+ _defs_gpencil_sculpt.draw_settings_common(context, layout, tool)
+
+ return dict(
+ text="Pinch",
+ icon="ops.gpencil.sculpt_pinch",
+ keymap=(
+ ("gpencil.brush_paint",
+ dict(mode='PINCH', wait_for_input=False),
+ dict(type='EVT_TWEAK_A', value='ANY')),
+ ),
+ draw_settings=draw_settings,
+ )
+
+ @ToolDef.from_fn
+ def randomize():
+ def draw_settings(context, layout, tool):
+ _defs_gpencil_sculpt.draw_settings_common(context, layout, tool)
+
+ return dict(
+ text="Randomize",
+ icon="ops.gpencil.sculpt_randomize",
+ keymap=(
+ ("gpencil.brush_paint",
+ dict(mode='RANDOMIZE', wait_for_input=False),
+ dict(type='EVT_TWEAK_A', value='ANY')),
+ ),
+ draw_settings=draw_settings,
+ )
+
+ @ToolDef.from_fn
+ def clone():
+ def draw_settings(context, layout, tool):
+ _defs_gpencil_sculpt.draw_settings_common(context, layout, tool)
+
+ return dict(
+ text="Clone",
+ icon="ops.gpencil.sculpt_clone",
+ keymap=(
+ ("gpencil.brush_paint",
+ dict(mode='CLONE', wait_for_input=False),
+ dict(type='EVT_TWEAK_A', value='ANY')),
+ ),
+ draw_settings=draw_settings,
+ )
+
+
class IMAGE_PT_tools_active(ToolSelectPanelHelper, Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'TOOLS'
@@ -1179,6 +1338,19 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
None,
_defs_weight_paint.gradient,
],
+ 'GPENCIL_SCULPT': [
+ _defs_gpencil_sculpt.smooth,
+ _defs_gpencil_sculpt.thickness,
+ _defs_gpencil_sculpt.strength,
+ _defs_gpencil_sculpt.grab,
+ _defs_gpencil_sculpt.push,
+ _defs_gpencil_sculpt.twist,
+ _defs_gpencil_sculpt.pinch,
+ _defs_gpencil_sculpt.randomize,
+ _defs_gpencil_sculpt.clone,
+ None,
+ *_tools_annotate,
+ ],
}
diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c
index e4a23b0b65c..d685e2d5743 100644
--- a/source/blender/editors/gpencil/gpencil_brush.c
+++ b/source/blender/editors/gpencil/gpencil_brush.c
@@ -1173,6 +1173,15 @@ static bool gpsculpt_brush_init(bContext *C, wmOperator *op)
Object *ob = CTX_data_active_object(C);
const bool is_weight_mode = ob->mode == OB_MODE_GPENCIL_WEIGHT;
+ /* set the brush using the tool */
+ GP_BrushEdit_Settings *gset = &ts->gp_sculpt;
+ eGP_EditBrush_Types mode = RNA_enum_get(op->ptr, "mode");
+ if (is_weight_mode) {
+ gset->weighttype = mode;
+ }
+ else {
+ gset->brushtype = mode;
+ }
tGP_BrushEditData *gso;
@@ -2057,6 +2066,19 @@ static int gpsculpt_brush_modal(bContext *C, wmOperator *op, const wmEvent *even
/* Operator --------------------------------------------- */
+static const EnumPropertyItem prop_gpencil_sculpt_brush_items[] = {
+ {GP_EDITBRUSH_TYPE_SMOOTH, "SMOOTH", 0, "Smooth", "Smooth stroke points" },
+ {GP_EDITBRUSH_TYPE_THICKNESS, "THICKNESS", 0, "Thickness", "Adjust thickness of strokes" },
+ {GP_EDITBRUSH_TYPE_STRENGTH, "STRENGTH", 0, "Strength", "Adjust color strength of strokes" },
+ {GP_EDITBRUSH_TYPE_GRAB, "GRAB", 0, "Grab", "Translate the set of points initially within the brush circle" },
+ {GP_EDITBRUSH_TYPE_PUSH, "PUSH", 0, "Push", "Move points out of the way, as if combing them" },
+ {GP_EDITBRUSH_TYPE_TWIST, "TWIST", 0, "Twist", "Rotate points around the midpoint of the brush" },
+ {GP_EDITBRUSH_TYPE_PINCH, "PINCH", 0, "Pinch", "Pull points towards the midpoint of the brush" },
+ {GP_EDITBRUSH_TYPE_RANDOMIZE, "RANDOMIZE", 0, "Randomize", "Introduce jitter/randomness into strokes" },
+ {GP_EDITBRUSH_TYPE_CLONE, "CLONE", 0, "Clone", "Paste copies of the strokes stored on the clipboard" },
+ {GP_EDITBRUSH_TYPE_WEIGHT, "WEIGHT", 0, "Weight", "Weight Paint" },
+ {0, NULL, 0, NULL, NULL }
+};
void GPENCIL_OT_brush_paint(wmOperatorType *ot)
{
@@ -2076,13 +2098,15 @@ void GPENCIL_OT_brush_paint(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* properties */
+ ot->prop = RNA_def_enum(ot->srna, "mode", prop_gpencil_sculpt_brush_items, 0, "Mode", "Brush mode");
+
PropertyRNA *prop;
prop = RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", "");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
prop = RNA_def_boolean(ot->srna, "wait_for_input", true, "Wait for Input",
"Enter a mini 'sculpt-mode' if enabled, otherwise, exit after drawing a single stroke");
- RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+ RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
}
/* ************************************************ */
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index b7aba7110a8..246d4f877d5 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -249,6 +249,12 @@ static void buttons_main_region_layout_tool(const bContext *C, ARegion *ar)
case CTX_MODE_OBJECT:
ARRAY_SET_ITEMS(contexts, ".objectmode");
break;
+ case CTX_MODE_GPENCIL_SCULPT:
+ ARRAY_SET_ITEMS(contexts, ".greasepencil_sculpt");
+ break;
+ case CTX_MODE_GPENCIL_WEIGHT:
+ ARRAY_SET_ITEMS(contexts, ".greasepencil_weight");
+ break;
}
}
else if (workspace->tools_space_type == SPACE_IMAGE) {
@@ -265,12 +271,6 @@ static void buttons_main_region_layout_tool(const bContext *C, ARegion *ar)
case CTX_MODE_GPENCIL_EDIT:
ARRAY_SET_ITEMS(contexts, ".greasepencil_edit");
break;
- case CTX_MODE_GPENCIL_SCULPT:
- ARRAY_SET_ITEMS(contexts, ".greasepencil_sculpt");
- break;
- case CTX_MODE_GPENCIL_WEIGHT:
- ARRAY_SET_ITEMS(contexts,
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list