[Bf-blender-cvs] [1a6119c8e46] blender-v2.83-release: GPencil: More changes to improve Chisel brush

Antonio Vazquez noreply at git.blender.org
Sun May 3 13:34:38 CEST 2020


Commit: 1a6119c8e467f23ae83be12c66b30c5e785700aa
Author: Antonio Vazquez
Date:   Sun May 3 13:33:58 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rB1a6119c8e467f23ae83be12c66b30c5e785700aa

GPencil: More changes to improve Chisel brush

More small tweaks to get the right "feeling" when drawing.

The defaults has been tested by @pepeland.

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

M	source/blender/blenkernel/intern/brush.c
M	source/blender/editors/gpencil/gpencil_paint.c

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

diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 2cc1d869e4c..8041779880e 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -344,7 +344,8 @@ typedef enum eGPCurveMappingPreset {
   GPCURVE_PRESET_INK = 1,
   GPCURVE_PRESET_INKNOISE = 2,
   GPCURVE_PRESET_MARKER = 3,
-  GPCURVE_PRESET_CHISEL = 4,
+  GPCURVE_PRESET_CHISEL_SENSIVITY = 4,
+  GPCURVE_PRESET_CHISEL_STRENGTH = 5,
 } eGPCurveMappingPreset;
 
 static void brush_gpencil_curvemap_reset(CurveMap *cuma, int tot, int preset)
@@ -391,11 +392,25 @@ static void brush_gpencil_curvemap_reset(CurveMap *cuma, int tot, int preset)
       cuma->curve[3].x = 1.0f;
       cuma->curve[3].y = 1.0f;
       break;
-    case GPCURVE_PRESET_CHISEL:
+    case GPCURVE_PRESET_CHISEL_SENSIVITY:
       cuma->curve[0].x = 0.0f;
       cuma->curve[0].y = 0.0f;
-      cuma->curve[1].x = 0.8f;
-      cuma->curve[1].y = 1.0f;
+      cuma->curve[1].x = 0.25f;
+      cuma->curve[1].y = 0.40f;
+      cuma->curve[2].x = 1.0f;
+      cuma->curve[2].y = 1.0f;
+      break;
+    case GPCURVE_PRESET_CHISEL_STRENGTH:
+      cuma->curve[0].x = 0.0f;
+      cuma->curve[0].y = 0.0f;
+      cuma->curve[1].x = 0.31f;
+      cuma->curve[1].y = 0.22f;
+      cuma->curve[2].x = 0.61f;
+      cuma->curve[2].y = 0.88f;
+      cuma->curve[3].x = 1.0f;
+      cuma->curve[3].y = 1.0f;
+      break;
+    default:
       break;
   }
 
@@ -582,14 +597,14 @@ void BKE_gpencil_brush_preset_set(Main *bmain, Brush *brush, const short type)
     }
     case GP_BRUSH_PRESET_MARKER_CHISEL: {
       brush->size = 150.0f;
-      brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
+      brush->gpencil_settings->flag &= ~GP_BRUSH_USE_PRESSURE;
 
       brush->gpencil_settings->draw_strength = 1.0f;
 
       brush->gpencil_settings->input_samples = 10;
-      brush->gpencil_settings->active_smooth = ACTIVE_SMOOTH;
-      brush->gpencil_settings->draw_angle = DEG2RAD(20.0f);
-      brush->gpencil_settings->draw_angle_factor = 1.0f;
+      brush->gpencil_settings->active_smooth = 0.3f;
+      brush->gpencil_settings->draw_angle = DEG2RAD(35.0f);
+      brush->gpencil_settings->draw_angle_factor = 0.5f;
       brush->gpencil_settings->hardeness = 1.0f;
       copy_v2_fl(brush->gpencil_settings->aspect_ratio, 1.0f);
 
@@ -608,7 +623,12 @@ void BKE_gpencil_brush_preset_set(Main *bmain, Brush *brush, const short type)
       custom_curve = brush->gpencil_settings->curve_sensitivity;
       BKE_curvemapping_set_defaults(custom_curve, 0, 0.0f, 0.0f, 1.0f, 1.0f);
       BKE_curvemapping_initialize(custom_curve);
-      brush_gpencil_curvemap_reset(custom_curve->cm, 2, GPCURVE_PRESET_CHISEL);
+      brush_gpencil_curvemap_reset(custom_curve->cm, 3, GPCURVE_PRESET_CHISEL_SENSIVITY);
+
+      custom_curve = brush->gpencil_settings->curve_strength;
+      BKE_curvemapping_set_defaults(custom_curve, 0, 0.0f, 0.0f, 1.0f, 1.0f);
+      BKE_curvemapping_initialize(custom_curve);
+      brush_gpencil_curvemap_reset(custom_curve->cm, 4, GPCURVE_PRESET_CHISEL_STRENGTH);
 
       brush->gpencil_settings->icon_id = GP_BRUSH_ICON_CHISEL;
       brush->gpencil_tool = GPAINT_TOOL_DRAW;
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 561104b0b98..961c4e05a28 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -515,7 +515,6 @@ static void gp_brush_angle(bGPdata *gpd, Brush *brush, tGPspoint *pt, const floa
   float mvec[2];
   float sen = brush->gpencil_settings->draw_angle_factor; /* sensitivity */
   float fac;
-  float mpressure;
 
   /* default angle of brush in radians */
   float angle = brush->gpencil_settings->draw_angle;
@@ -543,9 +542,7 @@ static void gp_brush_angle(bGPdata *gpd, Brush *brush, tGPspoint *pt, const floa
 
     fac = 1.0f - fabs(dot_v2v2(v0, mvec)); /* 0.0 to 1.0 */
     /* interpolate with previous point for smoother transitions */
-    mpressure = interpf(pt->pressure - (sen * fac), (pt - 1)->pressure, 0.3f);
-    pt->pressure = mpressure;
-
+    pt->pressure = interpf(pt->pressure - (sen * fac), (pt - 1)->pressure, 0.3f);
     CLAMP(pt->pressure, GPENCIL_ALPHA_OPACITY_THRESH, 1.0f);
   }
 }
@@ -3160,9 +3157,8 @@ static void gp_brush_angle_segment(tGPsdata *p, tGPspoint *pt_prev, tGPspoint *p
   normalize_v2(mvec);
   fac = 1.0f - fabs(dot_v2v2(v0, mvec)); /* 0.0 to 1.0 */
   /* interpolate with previous point for smoother transitions */
-  pt->pressure = interpf(pt->pressure - (sen * fac), pt_prev->pressure, 0.5f);
-
-  CLAMP(pt->pressure, pt_prev->pressure * 0.5f, 1.0f);
+  pt->pressure = interpf(pt->pressure - (sen * fac), pt_prev->pressure, 0.3f);
+  CLAMP(pt->pressure, GPENCIL_ALPHA_OPACITY_THRESH, 1.0f);
 }
 
 /* Add arc points between two mouse events using the previous segment to determine the vertice of
@@ -3251,7 +3247,7 @@ static void gpencil_add_arc_points(tGPsdata *p, float mval[2], int segments)
     /* Apply angle of stroke to brush size to interpolated points but slightly attenuated.. */
     if (brush_settings->draw_angle_factor != 0.0f) {
       gp_brush_angle_segment(p, pt_step, pt);
-      CLAMP(pt->pressure, pt_prev->pressure * 0.8f, 1.0f);
+      CLAMP(pt->pressure, pt_prev->pressure * 0.5f, 1.0f);
       /* Use the previous interpolated point for next segment. */
       pt_step = pt;
     }



More information about the Bf-blender-cvs mailing list