Sculpt: Add extra deform types to Smear

The smear brush was using the stroke direction to slide colors across
the mesh surface (this is called drag in other sculpt tools). Similarly,
other deformations can be included. The most common ones in image
editing are pinch and expand, which can be used to sharpen transitions
between colors.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D8270
This commit is contained in:
Pablo Dobarro 2020-07-11 00:19:45 +02:00
parent 1076952209
commit 2b5e21fe00
4 changed files with 37 additions and 2 deletions

View File

@ -682,6 +682,10 @@ def brush_settings(layout, context, brush, popover=False):
col.prop(brush, "tip_roundness")
col.prop(brush, "tip_scale_x")
if brush.sculpt_tool == 'SMEAR':
col = layout.column()
col.prop(brush, "smear_deform_type")
if brush.sculpt_tool == 'MULTIPLANE_SCRAPE':
col = layout.column()
col.prop(brush, "multiplane_scrape_angle")

View File

@ -388,7 +388,17 @@ static void do_smear_brush_task_cb_exec(void *__restrict userdata,
float interp_color[4];
copy_v4_v4(interp_color, ss->cache->prev_colors[vd.index]);
sub_v3_v3v3(current_disp, ss->cache->location, ss->cache->last_location);
switch (brush->smear_deform_type) {
case BRUSH_SMEAR_DEFORM_DRAG:
sub_v3_v3v3(current_disp, ss->cache->location, ss->cache->last_location);
break;
case BRUSH_SMEAR_DEFORM_PINCH:
sub_v3_v3v3(current_disp, ss->cache->location, vd.co);
break;
case BRUSH_SMEAR_DEFORM_EXPAND:
sub_v3_v3v3(current_disp, vd.co, ss->cache->location);
break;
}
normalize_v3_v3(current_disp_norm, current_disp);
mul_v3_v3fl(current_disp, current_disp_norm, ss->cache->bstrength);

View File

@ -343,6 +343,12 @@ typedef enum eBrushPoseOriginType {
BRUSH_POSE_ORIGIN_FACE_SETS_FK = 2,
} eBrushPoseOriginType;
typedef enum eBrushSmearDeformType {
BRUSH_SMEAR_DEFORM_DRAG = 0,
BRUSH_SMEAR_DEFORM_PINCH = 1,
BRUSH_SMEAR_DEFORM_EXPAND = 2,
} eBrushSmearDeformType;
/* Gpencilsettings.Vertex_mode */
typedef enum eGp_Vertex_Mode {
/* Affect to Stroke only. */
@ -500,7 +506,7 @@ typedef struct Brush {
char gpencil_sculpt_tool;
/** Active grease pencil weight tool. */
char gpencil_weight_tool;
char _pad1[2];
char _pad1[6];
float autosmooth_factor;
@ -555,6 +561,9 @@ typedef struct Brush {
/* multiplane scrape */
float multiplane_scrape_angle;
/* smear */
int smear_deform_type;
/* overlay */
int texture_overlay_alpha;
int mask_overlay_alpha;

View File

@ -1997,6 +1997,13 @@ static void rna_def_brush(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL},
};
static const EnumPropertyItem brush_smear_deform_type_items[] = {
{BRUSH_SMEAR_DEFORM_DRAG, "DRAG", 0, "Drag", ""},
{BRUSH_SMEAR_DEFORM_PINCH, "PINCH", 0, "Pinch", ""},
{BRUSH_SMEAR_DEFORM_EXPAND, "EXPAND", 0, "Expand", ""},
{0, NULL, 0, NULL, NULL},
};
srna = RNA_def_struct(brna, "Brush", "ID");
RNA_def_struct_ui_text(
srna, "Brush", "Brush data-block for storing brush settings for painting and sculpting");
@ -2117,6 +2124,11 @@ static void rna_def_brush(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Deformation", "Deformation type that is used in the brush");
RNA_def_property_update(prop, 0, "rna_Brush_update");
prop = RNA_def_property(srna, "smear_deform_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, brush_smear_deform_type_items);
RNA_def_property_ui_text(prop, "Deformation", "Deformation type that is used in the brush");
RNA_def_property_update(prop, 0, "rna_Brush_update");
prop = RNA_def_property(srna, "pose_deform_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, brush_pose_deform_type_items);
RNA_def_property_ui_text(prop, "Deformation", "Deformation type that is used in the brush");