[Bf-blender-cvs] [2b5e21fe00e] master: Sculpt: Add extra deform types to Smear

Pablo Dobarro noreply at git.blender.org
Mon Jul 13 17:53:59 CEST 2020


Commit: 2b5e21fe00e861e40339cf3b4c6927c46525d3f6
Author: Pablo Dobarro
Date:   Sat Jul 11 00:19:45 2020 +0200
Branches: master
https://developer.blender.org/rB2b5e21fe00e861e40339cf3b4c6927c46525d3f6

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

===================================================================

M	release/scripts/startup/bl_ui/properties_paint_common.py
M	source/blender/editors/sculpt_paint/sculpt_paint_color.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/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py
index 58f188d0999..004bcaf819b 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -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")
diff --git a/source/blender/editors/sculpt_paint/sculpt_paint_color.c b/source/blender/editors/sculpt_paint/sculpt_paint_color.c
index 5cf6a053382..608ba1b934e 100644
--- a/source/blender/editors/sculpt_paint/sculpt_paint_color.c
+++ b/source/blender/editors/sculpt_paint/sculpt_paint_color.c
@@ -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);
 
diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h
index 4056faf359f..0ad249ef2cd 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -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;
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index b139e4609cd..b4703ab9aa2 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -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");



More information about the Bf-blender-cvs mailing list