Sculpt: Add extra deform types to Slide

This adds extra deform modes to the slide mode of the Topology
Slide/Relax brush (both slide and smear are almost identical).
This is useful to move topology to a specific area to add more localized
details

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D8349
This commit is contained in:
Pablo Dobarro 2020-07-21 22:57:50 +02:00
parent 46b126a2c8
commit 878d191bae
5 changed files with 42 additions and 4 deletions

View File

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

View File

@ -1484,6 +1484,7 @@ void BKE_brush_sculpt_reset(Brush *br)
case SCULPT_TOOL_SLIDE_RELAX:
br->spacing = 10;
br->alpha = 1.0f;
br->slide_deform_type = BRUSH_SLIDE_DEFORM_DRAG;
break;
case SCULPT_TOOL_CLAY:
br->flag |= BRUSH_SIZE_PRESSURE;

View File

@ -3100,11 +3100,23 @@ static void do_topology_slide_task_cb_ex(void *__restrict userdata,
thread_id);
float current_disp[3];
float current_disp_norm[3];
float final_disp[3];
zero_v3(final_disp);
sub_v3_v3v3(current_disp, ss->cache->location, ss->cache->last_location);
float final_disp[3] = {0.0f, 0.0f, 0.0f};
switch (brush->slide_deform_type) {
case BRUSH_SLIDE_DEFORM_DRAG:
sub_v3_v3v3(current_disp, ss->cache->location, ss->cache->last_location);
break;
case BRUSH_SLIDE_DEFORM_PINCH:
sub_v3_v3v3(current_disp, ss->cache->location, vd.co);
break;
case BRUSH_SLIDE_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);
SculptVertexNeighborIter ni;
SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, vd.index, ni) {
float vertex_disp[3];

View File

@ -349,6 +349,12 @@ typedef enum eBrushSmearDeformType {
BRUSH_SMEAR_DEFORM_EXPAND = 2,
} eBrushSmearDeformType;
typedef enum eBrushSlideDeformType {
BRUSH_SLIDE_DEFORM_DRAG = 0,
BRUSH_SLIDE_DEFORM_PINCH = 1,
BRUSH_SLIDE_DEFORM_EXPAND = 2,
} eBrushSlideDeformType;
/* Gpencilsettings.Vertex_mode */
typedef enum eGp_Vertex_Mode {
/* Affect to Stroke only. */
@ -494,7 +500,7 @@ typedef struct Brush {
/** Source for fill tool color gradient application. */
char gradient_fill_mode;
char _pad0[5];
char _pad0[1];
/** Projection shape (sphere, circle). */
char falloff_shape;
@ -578,6 +584,9 @@ typedef struct Brush {
/* smear */
int smear_deform_type;
/* slide/relax */
int slide_deform_type;
/* overlay */
int texture_overlay_alpha;
int mask_overlay_alpha;

View File

@ -2004,6 +2004,13 @@ static void rna_def_brush(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL},
};
static const EnumPropertyItem brush_slide_deform_type_items[] = {
{BRUSH_SLIDE_DEFORM_DRAG, "DRAG", 0, "Drag", ""},
{BRUSH_SLIDE_DEFORM_PINCH, "PINCH", 0, "Pinch", ""},
{BRUSH_SLIDE_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");
@ -2129,6 +2136,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, "slide_deform_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, brush_slide_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");