Curves: use paint cursor in curves sculpt mode
Also adds radius and strength control to the tool settings in the ui.
This commit is contained in:
parent
fcb84e32e0
commit
e2ffe88983
|
@ -5467,6 +5467,7 @@ def km_sculpt_curves(params):
|
|||
|
||||
items.extend([
|
||||
("sculpt_curves.brush_stroke", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
|
||||
*_template_paint_radial_control("curves_sculpt"),
|
||||
])
|
||||
|
||||
return keymap
|
||||
|
|
|
@ -79,6 +79,8 @@ class UnifiedPaintPanel:
|
|||
return tool_settings.gpencil_weight_paint
|
||||
elif mode == 'VERTEX_GPENCIL':
|
||||
return tool_settings.gpencil_vertex_paint
|
||||
elif mode == 'SCULPT_CURVES':
|
||||
return tool_settings.curves_sculpt
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
|
|
|
@ -468,6 +468,38 @@ class _draw_tool_settings_context_mode:
|
|||
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def SCULPT_CURVES(context, layout, tool):
|
||||
if (tool is None) or (not tool.has_datablock):
|
||||
return False
|
||||
|
||||
paint = context.tool_settings.curves_sculpt
|
||||
layout.template_ID_preview(paint, "brush", rows=3, cols=8, hide_buttons=True)
|
||||
|
||||
brush = paint.brush
|
||||
if brush is None:
|
||||
return False
|
||||
|
||||
UnifiedPaintPanel.prop_unified(
|
||||
layout,
|
||||
context,
|
||||
brush,
|
||||
"size",
|
||||
unified_name="use_unified_size",
|
||||
text="Radius",
|
||||
slider=True,
|
||||
header=True
|
||||
)
|
||||
|
||||
UnifiedPaintPanel.prop_unified(
|
||||
layout,
|
||||
context,
|
||||
brush,
|
||||
"strength",
|
||||
unified_name="use_unified_strength",
|
||||
header=True
|
||||
)
|
||||
|
||||
|
||||
class VIEW3D_HT_header(Header):
|
||||
bl_space_type = 'VIEW_3D'
|
||||
|
|
|
@ -9,6 +9,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
bool CURVES_SCULPT_mode_poll(struct bContext *C);
|
||||
bool CURVES_SCULPT_mode_poll_view3d(struct bContext *C);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -14,12 +14,23 @@
|
|||
#include "curves_sculpt_intern.h"
|
||||
#include "paint_intern.h"
|
||||
|
||||
bool CURVES_SCULPT_mode_poll(struct bContext *C)
|
||||
bool CURVES_SCULPT_mode_poll(bContext *C)
|
||||
{
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
return ob && ob->mode & OB_MODE_SCULPT_CURVES;
|
||||
}
|
||||
|
||||
bool CURVES_SCULPT_mode_poll_view3d(bContext *C)
|
||||
{
|
||||
if (!CURVES_SCULPT_mode_poll(C)) {
|
||||
return false;
|
||||
}
|
||||
if (CTX_wm_region_view3d(C) == nullptr) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
namespace blender::ed::sculpt_paint {
|
||||
|
||||
/* --------------------------------------------------------------------
|
||||
|
@ -108,9 +119,26 @@ static bool curves_sculptmode_toggle_poll(bContext *C)
|
|||
return true;
|
||||
}
|
||||
|
||||
static int curves_sculptmode_toggle_exec(bContext *C, wmOperator *op)
|
||||
static void curves_sculptmode_enter(bContext *C)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
BKE_paint_ensure(scene->toolsettings, (Paint **)&scene->toolsettings->curves_sculpt);
|
||||
CurvesSculpt *curves_sculpt = scene->toolsettings->curves_sculpt;
|
||||
|
||||
ob->mode = OB_MODE_SCULPT_CURVES;
|
||||
|
||||
paint_cursor_start(&curves_sculpt->paint, CURVES_SCULPT_mode_poll_view3d);
|
||||
}
|
||||
|
||||
static void curves_sculptmode_exit(bContext *C)
|
||||
{
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
ob->mode = OB_MODE_OBJECT;
|
||||
}
|
||||
|
||||
static int curves_sculptmode_toggle_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
const bool is_mode_set = ob->mode == OB_MODE_SCULPT_CURVES;
|
||||
|
||||
|
@ -121,11 +149,10 @@ static int curves_sculptmode_toggle_exec(bContext *C, wmOperator *op)
|
|||
}
|
||||
|
||||
if (is_mode_set) {
|
||||
ob->mode = OB_MODE_OBJECT;
|
||||
curves_sculptmode_exit(C);
|
||||
}
|
||||
else {
|
||||
BKE_paint_ensure(scene->toolsettings, (Paint **)&scene->toolsettings->curves_sculpt);
|
||||
ob->mode = OB_MODE_SCULPT_CURVES;
|
||||
curves_sculptmode_enter(C);
|
||||
}
|
||||
|
||||
WM_toolsystem_update_from_context_view3d(C);
|
||||
|
|
|
@ -2898,6 +2898,10 @@ static void rna_def_tool_settings(BlenderRNA *brna)
|
|||
RNA_def_property_struct_type(prop, "Sculpt");
|
||||
RNA_def_property_ui_text(prop, "Sculpt", "");
|
||||
|
||||
prop = RNA_def_property(srna, "curves_sculpt", PROP_POINTER, PROP_NONE);
|
||||
RNA_def_property_struct_type(prop, "CurvesSculpt");
|
||||
RNA_def_property_ui_text(prop, "Curves Sculpt", "");
|
||||
|
||||
prop = RNA_def_property(srna, "use_auto_normalize", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "auto_normalize", 1);
|
||||
|
|
|
@ -423,6 +423,11 @@ static char *rna_UvSculpt_path(PointerRNA *UNUSED(ptr))
|
|||
return BLI_strdup("tool_settings.uv_sculpt");
|
||||
}
|
||||
|
||||
static char *rna_CurvesSculpt_path(PointerRNA *UNUSED(ptr))
|
||||
{
|
||||
return BLI_strdup("tool_settings.curves_sculpt");
|
||||
}
|
||||
|
||||
static char *rna_GpPaint_path(PointerRNA *UNUSED(ptr))
|
||||
{
|
||||
return BLI_strdup("tool_settings.gpencil_paint");
|
||||
|
@ -1498,6 +1503,15 @@ static void rna_def_gpencil_sculpt(BlenderRNA *brna)
|
|||
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
}
|
||||
|
||||
static void rna_def_curves_sculpt(BlenderRNA *brna)
|
||||
{
|
||||
StructRNA *srna;
|
||||
|
||||
srna = RNA_def_struct(brna, "CurvesSculpt", "Paint");
|
||||
RNA_def_struct_path_func(srna, "rna_CurvesSculpt_path");
|
||||
RNA_def_struct_ui_text(srna, "Curves Sculpt Paint", "");
|
||||
}
|
||||
|
||||
void RNA_def_sculpt_paint(BlenderRNA *brna)
|
||||
{
|
||||
/* *** Non-Animated *** */
|
||||
|
@ -1516,6 +1530,7 @@ void RNA_def_sculpt_paint(BlenderRNA *brna)
|
|||
rna_def_particle_edit(brna);
|
||||
rna_def_gpencil_guides(brna);
|
||||
rna_def_gpencil_sculpt(brna);
|
||||
rna_def_curves_sculpt(brna);
|
||||
RNA_define_animate_sdna(true);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue