Curves: show sculpt tool settings in panels

Ref T97444.

Differential Revision: https://developer.blender.org/D14700
This commit is contained in:
Jacques Lucke 2022-04-21 14:51:37 +02:00
parent 2882cbe685
commit ed971a19fa
Notes: blender-bot 2023-02-14 00:20:19 +01:00
Referenced by issue #97445, Expose custom brush falloff in curves sculpt mode
Referenced by issue #97444, Show curves sculpt tool settings in panels
12 changed files with 61 additions and 45 deletions

View File

@ -432,7 +432,7 @@ class FalloffPanel(BrushPanel):
row.operator("brush.curve_preset", icon='LINCURVE', text="").shape = 'LINE'
row.operator("brush.curve_preset", icon='NOCURVE', text="").shape = 'MAX'
if mode in {'SCULPT', 'PAINT_VERTEX', 'PAINT_WEIGHT'} and brush.sculpt_tool != 'POSE':
if mode in {'SCULPT', 'PAINT_VERTEX', 'PAINT_WEIGHT', 'SCULPT_CURVES'} and brush.sculpt_tool != 'POSE':
col.separator()
row = col.row(align=True)
row.use_property_split = True
@ -823,6 +823,11 @@ def brush_shared_settings(layout, context, brush, popover=False):
size = True
strength = True
# Sculpt Curves #
if mode == 'SCULPT_CURVES':
size = True
strength = True
### Draw settings. ###
ups = context.scene.tool_settings.unified_paint_settings
@ -920,6 +925,16 @@ def brush_settings_advanced(layout, context, brush, popover=False):
col.prop(brush, "use_original_plane", text="Plane")
layout.separator()
elif mode == 'SCULPT_CURVES':
if brush.curves_sculpt_tool == 'ADD':
layout.prop(brush.curves_sculpt_settings, "add_amount")
layout.prop(brush.curves_sculpt_settings, "curve_length")
layout.prop(brush.curves_sculpt_settings, "interpolate_length")
layout.prop(brush.curves_sculpt_settings, "interpolate_shape")
elif brush.curves_sculpt_tool == 'GROW_SHRINK':
layout.prop(brush.curves_sculpt_settings, "scale_uniform")
layout.prop(brush.curves_sculpt_settings, "minimum_length")
# 3D and 2D Texture Paint.
elif mode in {'PAINT_TEXTURE', 'PAINT_2D'}:
capabilities = brush.image_paint_capabilities

View File

@ -514,9 +514,9 @@ class _draw_tool_settings_context_mode:
layout.prop(brush, "use_frontface")
layout.prop(brush, "falloff_shape", expand=True)
layout.prop(brush.curves_sculpt_settings, "add_amount")
layout.prop(tool_settings.curves_sculpt, "curve_length")
layout.prop(tool_settings.curves_sculpt, "interpolate_length")
layout.prop(tool_settings.curves_sculpt, "interpolate_shape")
layout.prop(brush.curves_sculpt_settings, "curve_length")
layout.prop(brush.curves_sculpt_settings, "interpolate_length")
layout.prop(brush.curves_sculpt_settings, "interpolate_shape")
if brush.curves_sculpt_tool == 'GROW_SHRINK':
layout.prop(brush, "direction", expand=True, text="")

View File

@ -1557,8 +1557,10 @@ void BKE_brush_init_curves_sculpt_settings(Brush *brush)
if (brush->curves_sculpt_settings == NULL) {
brush->curves_sculpt_settings = MEM_callocN(sizeof(BrushCurvesSculptSettings), __func__);
}
brush->curves_sculpt_settings->add_amount = 1;
brush->curves_sculpt_settings->minimum_length = 0.01f;
BrushCurvesSculptSettings *settings = brush->curves_sculpt_settings;
settings->add_amount = 1;
settings->minimum_length = 0.01f;
settings->curve_length = 0.3f;
}
struct Brush *BKE_brush_first_search(struct Main *bmain, const eObjectMode ob_mode)

View File

@ -1101,7 +1101,6 @@ bool BKE_paint_ensure(ToolSettings *ts, struct Paint **r_paint)
}
else if ((CurvesSculpt **)r_paint == &ts->curves_sculpt) {
CurvesSculpt *data = MEM_callocN(sizeof(*data), __func__);
data->curve_length = 0.3f;
paint = &data->paint;
}
else if (*r_paint == &ts->imapaint.paint) {

View File

@ -2529,12 +2529,6 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
brush->curves_sculpt_settings = MEM_callocN(sizeof(BrushCurvesSculptSettings), __func__);
brush->curves_sculpt_settings->add_amount = 1;
}
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
if (scene->toolsettings && scene->toolsettings->curves_sculpt &&
scene->toolsettings->curves_sculpt->curve_length == 0.0f) {
scene->toolsettings->curves_sculpt->curve_length = 0.3f;
}
}
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
@ -2737,5 +2731,15 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
LISTBASE_FOREACH (Brush *, brush, &bmain->brushes) {
BrushCurvesSculptSettings *settings = brush->curves_sculpt_settings;
if (settings == NULL) {
continue;
}
if (settings->curve_length == 0.0f) {
settings->curve_length = 0.3f;
}
}
}
}

View File

@ -96,6 +96,7 @@ struct AddOperationExecutor {
CurvesSculpt *curves_sculpt_ = nullptr;
Brush *brush_ = nullptr;
BrushCurvesSculptSettings *brush_settings_ = nullptr;
float brush_radius_re_;
float2 brush_pos_re_;
@ -162,17 +163,18 @@ struct AddOperationExecutor {
curves_sculpt_ = scene_->toolsettings->curves_sculpt;
brush_ = BKE_paint_brush(&curves_sculpt_->paint);
brush_settings_ = brush_->curves_sculpt_settings;
brush_radius_re_ = BKE_brush_size_get(scene_, brush_);
brush_pos_re_ = stroke_extension.mouse_position;
use_front_face_ = brush_->flag & BRUSH_FRONTFACE;
const eBrushFalloffShape falloff_shape = static_cast<eBrushFalloffShape>(
brush_->falloff_shape);
add_amount_ = std::max(0, brush_->curves_sculpt_settings->add_amount);
interpolate_length_ = curves_sculpt_->flag & CURVES_SCULPT_FLAG_INTERPOLATE_LENGTH;
interpolate_shape_ = curves_sculpt_->flag & CURVES_SCULPT_FLAG_INTERPOLATE_SHAPE;
add_amount_ = std::max(0, brush_settings_->add_amount);
interpolate_length_ = brush_settings_->flag & BRUSH_CURVES_SCULPT_FLAG_INTERPOLATE_LENGTH;
interpolate_shape_ = brush_settings_->flag & BRUSH_CURVES_SCULPT_FLAG_INTERPOLATE_SHAPE;
use_interpolation_ = interpolate_length_ || interpolate_shape_;
new_curve_length_ = curves_sculpt_->curve_length;
new_curve_length_ = brush_settings_->curve_length;
tot_old_curves_ = curves_->curves_num();
tot_old_points_ = curves_->points_num();

View File

@ -1628,7 +1628,7 @@ void ED_view3d_buttons_region_layout_ex(const bContext *C,
ARRAY_SET_ITEMS(contexts, ".greasepencil_vertex");
break;
case CTX_MODE_SCULPT_CURVES:
ARRAY_SET_ITEMS(contexts, ".curves_sculpt");
ARRAY_SET_ITEMS(contexts, ".paint_common", ".curves_sculpt");
break;
default:
break;

View File

@ -610,6 +610,8 @@ typedef enum eBrushFalloffShape {
typedef enum eBrushCurvesSculptFlag {
BRUSH_CURVES_SCULPT_FLAG_SCALE_UNIFORM = (1 << 0),
BRUSH_CURVES_SCULPT_FLAG_GROW_SHRINK_INVERT = (1 << 1),
BRUSH_CURVES_SCULPT_FLAG_INTERPOLATE_LENGTH = (1 << 2),
BRUSH_CURVES_SCULPT_FLAG_INTERPOLATE_SHAPE = (1 << 3),
} eBrushCurvesSculptFlag;
#define MAX_BRUSH_PIXEL_RADIUS 500

View File

@ -144,6 +144,8 @@ typedef struct BrushCurvesSculptSettings {
uint32_t flag;
/** When shrinking curves, they shouldn't become shorter than this length. */
float minimum_length;
/** Length of newly added curves when it is not interpolated from other curves. */
float curve_length;
} BrushCurvesSculptSettings;
typedef struct Brush {

View File

@ -1014,17 +1014,8 @@ typedef struct Sculpt {
struct Object *gravity_object;
} Sculpt;
typedef enum CurvesSculptFlag {
CURVES_SCULPT_FLAG_INTERPOLATE_LENGTH = (1 << 0),
CURVES_SCULPT_FLAG_INTERPOLATE_SHAPE = (1 << 1),
} CurvesSculptFlag;
typedef struct CurvesSculpt {
Paint paint;
/** CurvesSculptFlag. */
uint32_t flag;
/** Length of newly added curves when it is not interpolated from other curves. */
float curve_length;
} CurvesSculpt;
typedef struct UvSculpt {

View File

@ -1944,6 +1944,23 @@ static void rna_def_curves_sculpt_options(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_ui_text(
prop, "Minimum Length", "Avoid shrinking curves shorter than this length");
prop = RNA_def_property(srna, "interpolate_length", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_CURVES_SCULPT_FLAG_INTERPOLATE_LENGTH);
RNA_def_property_ui_text(
prop, "Interpolate Length", "Use length of the curves in close proximity");
prop = RNA_def_property(srna, "interpolate_shape", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_CURVES_SCULPT_FLAG_INTERPOLATE_SHAPE);
RNA_def_property_ui_text(
prop, "Interpolate Shape", "Use shape of the curves in close proximity");
prop = RNA_def_property(srna, "curve_length", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_range(prop, 0.0, FLT_MAX);
RNA_def_property_ui_text(
prop,
"Curve Length",
"Length of newly added curves when it is not interpolated from other curves");
}
static void rna_def_brush(BlenderRNA *brna)

View File

@ -1565,28 +1565,10 @@ static void rna_def_gpencil_sculpt(BlenderRNA *brna)
static void rna_def_curves_sculpt(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
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", "");
prop = RNA_def_property(srna, "interpolate_length", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CURVES_SCULPT_FLAG_INTERPOLATE_LENGTH);
RNA_def_property_ui_text(
prop, "Interpolate Length", "Use length of the curves in close proximity");
prop = RNA_def_property(srna, "interpolate_shape", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CURVES_SCULPT_FLAG_INTERPOLATE_SHAPE);
RNA_def_property_ui_text(
prop, "Interpolate Shape", "Use shape of the curves in close proximity");
prop = RNA_def_property(srna, "curve_length", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_range(prop, 0.0, FLT_MAX);
RNA_def_property_ui_text(
prop,
"Curve Length",
"Length of newly added curves when it is not interpolated from other curves");
}
void RNA_def_sculpt_paint(BlenderRNA *brna)