WIP: Brush assets project #106303
|
@ -1383,17 +1383,23 @@ class _defs_particle:
|
||||||
class _defs_sculpt:
|
class _defs_sculpt:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def generate_from_brushes(context):
|
def generate_brush_tool(context):
|
||||||
return generate_from_enum_ex(
|
if not context:
|
||||||
context,
|
return ()
|
||||||
idname_prefix="builtin_brush.",
|
brush = context.tool_settings.sculpt.brush
|
||||||
icon_prefix="brush.sculpt.",
|
if not brush:
|
||||||
type=bpy.types.Brush,
|
return ()
|
||||||
attr="sculpt_tool",
|
tool = brush.sculpt_tool
|
||||||
# TODO(@ideasman42): we may want to enable this,
|
return [
|
||||||
# it causes awkward grouping with 2x column button layout.
|
ToolDef.from_dict(
|
||||||
use_separators=False,
|
dict(
|
||||||
)
|
idname="builtin.brush",
|
||||||
|
label=brush.name,
|
||||||
|
icon="brush.sculpt.paint",
|
||||||
|
data_block=tool
|
||||||
|
)
|
||||||
|
)
|
||||||
|
]
|
||||||
|
|
||||||
@ToolDef.from_fn
|
@ToolDef.from_fn
|
||||||
def hide_border():
|
def hide_border():
|
||||||
|
@ -2442,18 +2448,23 @@ class _defs_gpencil_weight:
|
||||||
class _defs_curves_sculpt:
|
class _defs_curves_sculpt:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def generate_from_brushes(context):
|
def generate_brush_tool(context):
|
||||||
return generate_from_enum_ex(
|
if not context:
|
||||||
context,
|
return ()
|
||||||
idname_prefix="builtin_brush.",
|
brush = context.tool_settings.curves_sculpt.brush
|
||||||
icon_prefix="ops.curves.sculpt_",
|
if not brush:
|
||||||
type=bpy.types.Brush,
|
return ()
|
||||||
attr="curves_sculpt_tool",
|
tool = brush.curves_sculpt_tool
|
||||||
icon_map={
|
return [
|
||||||
# Use the generic icon for selection painting.
|
ToolDef.from_dict(
|
||||||
"ops.curves.sculpt_selection_paint": "ops.generic.select_paint",
|
dict(
|
||||||
},
|
idname="builtin.brush",
|
||||||
)
|
label=brush.name,
|
||||||
|
icon="brush.sculpt.paint",
|
||||||
|
data_block=tool
|
||||||
|
)
|
||||||
|
)
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class _defs_gpencil_vertex:
|
class _defs_gpencil_vertex:
|
||||||
|
@ -3089,7 +3100,9 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
|
||||||
_defs_particle.generate_from_brushes,
|
_defs_particle.generate_from_brushes,
|
||||||
],
|
],
|
||||||
'SCULPT': [
|
'SCULPT': [
|
||||||
_defs_sculpt.generate_from_brushes,
|
lambda context: (
|
||||||
|
_defs_sculpt.generate_brush_tool(context)
|
||||||
|
),
|
||||||
None,
|
None,
|
||||||
(
|
(
|
||||||
_defs_sculpt.mask_border,
|
_defs_sculpt.mask_border,
|
||||||
|
@ -3234,7 +3247,9 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
'SCULPT_CURVES': [
|
'SCULPT_CURVES': [
|
||||||
_defs_curves_sculpt.generate_from_brushes,
|
lambda context: (
|
||||||
|
_defs_curves_sculpt.generate_brush_tool(context)
|
||||||
|
),
|
||||||
None,
|
None,
|
||||||
*_tools_annotate,
|
*_tools_annotate,
|
||||||
],
|
],
|
||||||
|
|
|
@ -1188,6 +1188,7 @@ static int brush_asset_select_exec(bContext *C, wmOperator *op)
|
||||||
}
|
}
|
||||||
|
|
||||||
WM_main_add_notifier(NC_SCENE | ND_TOOLSETTINGS, nullptr);
|
WM_main_add_notifier(NC_SCENE | ND_TOOLSETTINGS, nullptr);
|
||||||
|
WM_toolsystem_ref_set_by_id(C, "builtin.brush");
|
||||||
|
|
||||||
return OPERATOR_FINISHED;
|
return OPERATOR_FINISHED;
|
||||||
}
|
}
|
||||||
|
|
|
@ -849,36 +849,6 @@ static Brush *brush_tool_toggle(Main *bmain, Paint *paint, Brush *brush_orig, co
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The name of the active tool is "builtin_brush." concatenated with the returned string. */
|
|
||||||
static blender::StringRefNull curves_active_tool_name_get(const eBrushCurvesSculptTool tool)
|
|
||||||
{
|
|
||||||
switch (tool) {
|
|
||||||
case CURVES_SCULPT_TOOL_COMB:
|
|
||||||
return "comb";
|
|
||||||
case CURVES_SCULPT_TOOL_DELETE:
|
|
||||||
return "delete";
|
|
||||||
case CURVES_SCULPT_TOOL_SNAKE_HOOK:
|
|
||||||
return "snake_hook";
|
|
||||||
case CURVES_SCULPT_TOOL_ADD:
|
|
||||||
return "add";
|
|
||||||
case CURVES_SCULPT_TOOL_GROW_SHRINK:
|
|
||||||
return "grow_shrink";
|
|
||||||
case CURVES_SCULPT_TOOL_SELECTION_PAINT:
|
|
||||||
return "selection_paint";
|
|
||||||
case CURVES_SCULPT_TOOL_PINCH:
|
|
||||||
return "pinch";
|
|
||||||
case CURVES_SCULPT_TOOL_SMOOTH:
|
|
||||||
return "smooth";
|
|
||||||
case CURVES_SCULPT_TOOL_PUFF:
|
|
||||||
return "puff";
|
|
||||||
case CURVES_SCULPT_TOOL_DENSITY:
|
|
||||||
return "density";
|
|
||||||
case CURVES_SCULPT_TOOL_SLIDE:
|
|
||||||
return "slide";
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool brush_generic_tool_set(bContext *C,
|
static bool brush_generic_tool_set(bContext *C,
|
||||||
Main *bmain,
|
Main *bmain,
|
||||||
Paint *paint,
|
Paint *paint,
|
||||||
|
@ -910,26 +880,7 @@ static bool brush_generic_tool_set(bContext *C,
|
||||||
BKE_paint_invalidate_overlay_all();
|
BKE_paint_invalidate_overlay_all();
|
||||||
|
|
||||||
WM_main_add_notifier(NC_BRUSH | NA_EDITED, brush);
|
WM_main_add_notifier(NC_BRUSH | NA_EDITED, brush);
|
||||||
|
WM_toolsystem_ref_set_by_id(C, "builtin.brush");
|
||||||
/* Tool System
|
|
||||||
* This is needed for when there is a non-sculpt tool active (transform for e.g.).
|
|
||||||
* In case we are toggling (and the brush changed to the toggle_brush), we need to get the
|
|
||||||
* tool_name again. */
|
|
||||||
int tool_result = brush_tool(brush, paint->runtime.tool_offset);
|
|
||||||
ePaintMode paint_mode = BKE_paintmode_get_active_from_context(C);
|
|
||||||
|
|
||||||
if (paint_mode == PAINT_MODE_SCULPT_CURVES) {
|
|
||||||
tool_name = curves_active_tool_name_get(eBrushCurvesSculptTool(tool)).c_str();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
const EnumPropertyItem *items = BKE_paint_get_tool_enum_from_paintmode(paint_mode);
|
|
||||||
RNA_enum_name_from_value(items, tool_result, &tool_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
char tool_id[MAX_NAME];
|
|
||||||
SNPRINTF(tool_id, "builtin_brush.%s", tool_name);
|
|
||||||
WM_toolsystem_ref_set_by_id(C, tool_id);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -976,14 +927,6 @@ static int brush_select_exec(bContext *C, wmOperator *op)
|
||||||
return OPERATOR_CANCELLED;
|
return OPERATOR_CANCELLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (paint_mode == PAINT_MODE_SCULPT_CURVES) {
|
|
||||||
tool_name = curves_active_tool_name_get(eBrushCurvesSculptTool(tool)).c_str();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
const EnumPropertyItem *items = BKE_paint_get_tool_enum_from_paintmode(paint_mode);
|
|
||||||
RNA_enum_name_from_value(items, tool, &tool_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (brush_generic_tool_set(C, bmain, paint, tool, tool_name, create_missing, toggle)) {
|
if (brush_generic_tool_set(C, bmain, paint, tool, tool_name, create_missing, toggle)) {
|
||||||
return OPERATOR_FINISHED;
|
return OPERATOR_FINISHED;
|
||||||
}
|
}
|
||||||
|
|
|
@ -713,6 +713,7 @@ static const char *toolsystem_default_tool(const bToolKey *tkey)
|
||||||
switch (tkey->mode) {
|
switch (tkey->mode) {
|
||||||
/* Use the names of the enums for each brush tool. */
|
/* Use the names of the enums for each brush tool. */
|
||||||
case CTX_MODE_SCULPT:
|
case CTX_MODE_SCULPT:
|
||||||
|
return "builtin.brush";
|
||||||
case CTX_MODE_PAINT_VERTEX:
|
case CTX_MODE_PAINT_VERTEX:
|
||||||
case CTX_MODE_PAINT_WEIGHT:
|
case CTX_MODE_PAINT_WEIGHT:
|
||||||
case CTX_MODE_PAINT_TEXTURE:
|
case CTX_MODE_PAINT_TEXTURE:
|
||||||
|
@ -726,7 +727,7 @@ static const char *toolsystem_default_tool(const bToolKey *tkey)
|
||||||
case CTX_MODE_VERTEX_GPENCIL_LEGACY:
|
case CTX_MODE_VERTEX_GPENCIL_LEGACY:
|
||||||
return "builtin_brush.Draw";
|
return "builtin_brush.Draw";
|
||||||
case CTX_MODE_SCULPT_CURVES:
|
case CTX_MODE_SCULPT_CURVES:
|
||||||
return "builtin_brush.Density";
|
return "builtin.brush";
|
||||||
/* end temporary hack. */
|
/* end temporary hack. */
|
||||||
|
|
||||||
case CTX_MODE_PARTICLE:
|
case CTX_MODE_PARTICLE:
|
||||||
|
|
Loading…
Reference in New Issue