Commit: a92fb8a04569a1faf19d97b2f07ca10f9f2ee6ef Author: Pablo Dobarro Date: Wed Mar 20 23:17:19 2019 +0100 Branches: sculpt-mode-features https://developer.blender.org/rBa92fb8a04569a1faf19d97b2f07ca10f9f2ee6ef
Add proportional editing presets to sculpt brushes When sculpting, I always found that the behavior of the current curve falloff system is not correct, so I added the same curves that proportional editing uses to the brush falloff calculation. Now, curves are easier to set up and they produce a much better result. You can easily compare it against the old method by changing the curve preset option from custom to smooth in the grab brush. To make the new dam brush behave correctly, you need to select the sharper curve preset. You can also use it to insert shapes using the stroke anchored option and changing the curve preset. =================================================================== M release/scripts/startup/bl_ui/space_view3d_toolbar.py M source/blender/editors/sculpt_paint/sculpt.c M source/blender/makesdna/DNA_brush_types.h M source/blender/makesrna/intern/rna_brush.c =================================================================== diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index 0ce68526e80..7e3855bbb44 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -275,6 +275,10 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel): row = col.row() row.prop(brush, "normal_radius_factor", slider=True) + col.separator() + row = col.row() + row.prop(brush, "curve_preset") + # topology_rake_factor if (capabilities.has_topology_rake and context.sculpt_object.use_dynamic_topology_sculpting diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 0f53d61a86b..bb1ec336979 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -1295,26 +1295,42 @@ float tex_strength(SculptSession *ss, const Brush *br, } /* Falloff curve */ - float dist_nrm, factor; - switch (br->sculpt_tool) { - case SCULPT_TOOL_GRAB: - dist_nrm = len/cache->radius; - factor = 3.0f * dist_nrm * dist_nrm - 2.0f * dist_nrm * dist_nrm * dist_nrm; - avg *= (1 - factor); - avg *= 0.5f; + float dist, factor; + dist = len/cache->radius; + dist = 1 - dist; + + switch (br->curve_preset) { + case BRUSH_CURVE_CUSTOM: + factor = BKE_brush_curve_strength(br, len, cache->radius); break; - case SCULPT_TOOL_DAM: - dist_nrm = len/cache->radius; - dist_nrm = 1 - dist_nrm; - factor = dist_nrm * dist_nrm * dist_nrm * dist_nrm; - factor = 1 - factor; - avg *= (1 - factor); - avg *= -2; - default: - avg *= BKE_brush_curve_strength(br, len, cache->radius); + case BRUSH_CURVE_SHARP: + factor = dist * dist; + break; + case BRUSH_CURVE_SMOOTH: + factor = 3.0f * dist * dist - 2.0f * dist * dist * dist; + break; + case BRUSH_CURVE_ROOT: + factor = sqrtf(dist); + break; + case BRUSH_CURVE_LIN: + factor = dist; + break; + case BRUSH_CURVE_CONSTANT: + factor = 1.0f; + break; + case BRUSH_CURVE_SPHERE: + factor = sqrtf(2 * dist - dist * dist); + break; + case BRUSH_CURVE_POW4: + factor = dist * dist * dist * dist; + break; + case BRUSH_CURVE_INVSQUARE: + factor = dist * (2.0f - dist); break; } + avg *= factor; + avg *= frontface(br, cache->view_normal, vno, fno); /* Paint mask */ diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h index a6b471a4842..72bc07518e4 100644 --- a/source/blender/makesdna/DNA_brush_types.h +++ b/source/blender/makesdna/DNA_brush_types.h @@ -182,6 +182,18 @@ typedef enum eGP_BrushIcons { GP_BRUSH_ICON_ERASE_STROKE = 10, } eGP_BrushIcons; +typedef enum eBrushCurvePreset { + BRUSH_CURVE_CUSTOM = 0, + BRUSH_CURVE_SMOOTH = 1, + BRUSH_CURVE_SPHERE = 2, + BRUSH_CURVE_ROOT = 3, + BRUSH_CURVE_SHARP = 4, + BRUSH_CURVE_LIN = 5, + BRUSH_CURVE_POW4 = 6, + BRUSH_CURVE_INVSQUARE = 7, + BRUSH_CURVE_CONSTANT = 8, +} eBrushCurvePreset; + typedef struct Brush { ID id; @@ -278,7 +290,8 @@ typedef struct Brush { float topology_rake_factor; float crease_pinch_factor; - char _pad1[4]; + + int curve_preset; float plane_trim; /** Affectable height of brush (layer height for layer tool, i.e.). */ diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index c318af6a09a..73611851bf9 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -1425,6 +1425,20 @@ static void rna_def_brush(BlenderRNA *brna) {0, NULL, 0, NULL, NULL}, }; + static const EnumPropertyItem brush_curve_preset_items[] = { + {BRUSH_CURVE_CUSTOM, "CUSTOM", 0, "Custom", ""}, + {BRUSH_CURVE_SMOOTH, "SMOOTH", 0, "Smooth", ""}, + {BRUSH_CURVE_SPHERE, "SPHERE", 0, "Sphere", ""}, + {BRUSH_CURVE_ROOT, "ROOT", 0, "Root", ""}, + {BRUSH_CURVE_SHARP, "SHARP", 0, "Sharp", ""}, + {BRUSH_CURVE_LIN, "LIN", 0, "Linear", ""}, + {BRUSH_CURVE_POW4, "POW4", 0, "Sharper", ""}, + {BRUSH_CURVE_INVSQUARE, "INVSQUARE", 0, "Inverse square", ""}, + {BRUSH_CURVE_CONSTANT, "CONSTANT", 0, "Constant", ""}, + {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"); RNA_def_struct_ui_icon(srna, ICON_BRUSH_DATA); @@ -1496,6 +1510,11 @@ static void rna_def_brush(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Mask Tool", ""); RNA_def_property_update(prop, 0, "rna_Brush_update"); + prop = RNA_def_property(srna, "curve_preset", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, brush_curve_preset_items); + RNA_def_property_ui_text(prop, "Curve Preset", ""); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + /* number values */ prop = RNA_def_property(srna, "size", PROP_INT, PROP_PIXEL); RNA_def_property_int_funcs(prop, NULL, "rna_Brush_set_size", NULL); _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs