GPencil: Set samples to 10 for Soft brush
[blender.git] / source / blender / blenkernel / intern / brush.c
index 56a6de62dab1c13cf7436cbd4badc3c23f8bab29..78d965564e64091a0448e8dba57343c36f602c18 100644 (file)
@@ -140,12 +140,16 @@ void BKE_brush_init(Brush *brush)
 
   brush->sculpt_tool = SCULPT_TOOL_DRAW; /* sculpting defaults to the draw tool for new brushes */
 
+  /* A kernel radius of 1 has almost no effect (T63233). */
+  brush->blur_kernel_radius = 2;
+
   /* the default alpha falloff curve */
   BKE_brush_curve_preset(brush, CURVE_PRESET_SMOOTH);
 }
 
 /**
- * \note Resulting brush will have two users: one as a fake user, another is assumed to be used by the caller.
+ * \note Resulting brush will have two users: one as a fake user,
+ * another is assumed to be used by the caller.
  */
 Brush *BKE_brush_add(Main *bmain, const char *name, const eObjectMode ob_mode)
 {
@@ -212,8 +216,9 @@ typedef enum eGPCurveMappingPreset {
 
 static void brush_gpencil_curvemap_reset(CurveMap *cuma, int tot, int preset)
 {
-  if (cuma->curve)
+  if (cuma->curve) {
     MEM_freeN(cuma->curve);
+  }
 
   cuma->totpoint = tot;
   cuma->curve = MEM_callocN(cuma->totpoint * sizeof(CurveMapPoint), __func__);
@@ -496,9 +501,46 @@ void BKE_brush_gpencil_presets(bContext *C)
   brush->gpencil_settings->gradient_s[0] = 1.0f;
   brush->gpencil_settings->gradient_s[1] = 1.0f;
 
+  /* Soft brush */
+  brush = BKE_brush_add_gpencil(bmain, ts, "Draw Soft");
+  deft = brush; /* save default brush */
+  brush->size = 300.0f;
+  brush->gpencil_settings->flag |= (GP_BRUSH_USE_PRESSURE | GP_BRUSH_ENABLE_CURSOR);
+  brush->gpencil_settings->draw_sensitivity = 1.0f;
+
+  brush->gpencil_settings->draw_strength = 0.4f;
+  brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+
+  brush->gpencil_settings->draw_random_press = 0.0f;
+  brush->gpencil_settings->draw_random_strength = 0.0f;
+
+  brush->gpencil_settings->draw_jitter = 0.0f;
+  brush->gpencil_settings->flag |= GP_BRUSH_USE_JITTER_PRESSURE;
+
+  brush->gpencil_settings->draw_angle = 0.0f;
+  brush->gpencil_settings->draw_angle_factor = 0.0f;
+
+  brush->gpencil_settings->input_samples = 10;
+  brush->gpencil_settings->active_smooth = 0.98f;
+  brush->gpencil_settings->draw_smoothfac = 0.1f;
+  brush->gpencil_settings->draw_smoothlvl = 1;
+  brush->gpencil_settings->draw_subdivide = 1;
+  brush->gpencil_settings->thick_smoothfac = 1.0f;
+  brush->gpencil_settings->thick_smoothlvl = 3;
+  brush->gpencil_settings->draw_random_sub = 0.0f;
+  brush->gpencil_settings->icon_id = GP_BRUSH_ICON_MARKER;
+  brush->gpencil_tool = GPAINT_TOOL_DRAW;
+
+  brush->smooth_stroke_radius = SMOOTH_STROKE_RADIUS;
+  brush->smooth_stroke_factor = SMOOTH_STROKE_FACTOR;
+
+  brush->gpencil_settings->gradient_f = 0.211f;
+  brush->gpencil_settings->gradient_s[0] = 1.0f;
+  brush->gpencil_settings->gradient_s[1] = 0.91f;
+
   /* Fill brush */
   brush = BKE_brush_add_gpencil(bmain, ts, "Fill Area");
-  brush->size = 1.0f;
+  brush->size = 20.0f;
   brush->gpencil_settings->flag |= GP_BRUSH_ENABLE_CURSOR;
   brush->gpencil_settings->draw_sensitivity = 1.0f;
   brush->gpencil_settings->fill_leak = 3;
@@ -572,15 +614,18 @@ struct Brush *BKE_brush_first_search(struct Main *bmain, const eObjectMode ob_mo
   Brush *brush;
 
   for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
-    if (brush->ob_mode & ob_mode)
+    if (brush->ob_mode & ob_mode) {
       return brush;
+    }
   }
   return NULL;
 }
 
 /**
- * Only copy internal data of Brush ID from source to already allocated/initialized destination.
- * You probably never want to use that directly, use BKE_id_copy or BKE_id_copy_ex for typical needs.
+ * Only copy internal data of Brush ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
  *
  * WARNING! This function will not handle ID user count!
  *
@@ -869,8 +914,9 @@ void BKE_brush_curve_preset(Brush *b, eCurveMappingPreset preset)
 {
   CurveMap *cm = NULL;
 
-  if (!b->curve)
+  if (!b->curve) {
     b->curve = curvemapping_add(1, 0, 0, 1, 1);
+  }
 
   cm = b->curve->cm;
   cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE;
@@ -1156,10 +1202,12 @@ void BKE_brush_color_set(struct Scene *scene, struct Brush *brush, const float c
 {
   UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
 
-  if (ups->flag & UNIFIED_PAINT_COLOR)
+  if (ups->flag & UNIFIED_PAINT_COLOR) {
     copy_v3_v3(ups->rgb, color);
-  else
+  }
+  else {
     copy_v3_v3(brush->rgb, color);
+  }
 }
 
 void BKE_brush_size_set(Scene *scene, Brush *brush, int size)
@@ -1169,10 +1217,12 @@ void BKE_brush_size_set(Scene *scene, Brush *brush, int size)
   /* make sure range is sane */
   CLAMP(size, 1, MAX_BRUSH_PIXEL_RADIUS);
 
-  if (ups->flag & UNIFIED_PAINT_SIZE)
+  if (ups->flag & UNIFIED_PAINT_SIZE) {
     ups->size = size;
-  else
+  }
+  else {
     brush->size = size;
+  }
 }
 
 int BKE_brush_size_get(const Scene *scene, const Brush *brush)
@@ -1228,10 +1278,12 @@ void BKE_brush_unprojected_radius_set(Scene *scene, Brush *brush, float unprojec
 {
   UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
 
-  if (ups->flag & UNIFIED_PAINT_SIZE)
+  if (ups->flag & UNIFIED_PAINT_SIZE) {
     ups->unprojected_radius = unprojected_radius;
-  else
+  }
+  else {
     brush->unprojected_radius = unprojected_radius;
+  }
 }
 
 float BKE_brush_unprojected_radius_get(const Scene *scene, const Brush *brush)
@@ -1245,10 +1297,12 @@ void BKE_brush_alpha_set(Scene *scene, Brush *brush, float alpha)
 {
   UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
 
-  if (ups->flag & UNIFIED_PAINT_ALPHA)
+  if (ups->flag & UNIFIED_PAINT_ALPHA) {
     ups->alpha = alpha;
-  else
+  }
+  else {
     brush->alpha = alpha;
+  }
 }
 
 float BKE_brush_alpha_get(const Scene *scene, const Brush *brush)
@@ -1269,10 +1323,12 @@ void BKE_brush_weight_set(const Scene *scene, Brush *brush, float value)
 {
   UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
 
-  if (ups->flag & UNIFIED_PAINT_WEIGHT)
+  if (ups->flag & UNIFIED_PAINT_WEIGHT) {
     ups->weight = value;
-  else
+  }
+  else {
     brush->weight = value;
+  }
 }
 
 /* scale unprojected radius to reflect a change in the brush's 2D size */
@@ -1282,8 +1338,9 @@ void BKE_brush_scale_unprojected_radius(float *unprojected_radius,
 {
   float scale = new_brush_size;
   /* avoid division by zero */
-  if (old_brush_size != 0)
+  if (old_brush_size != 0) {
     scale /= (float)old_brush_size;
+  }
   (*unprojected_radius) *= scale;
 }
 
@@ -1294,8 +1351,9 @@ void BKE_brush_scale_size(int *r_brush_size,
 {
   float scale = new_unprojected_radius;
   /* avoid division by zero */
-  if (old_unprojected_radius != 0)
+  if (old_unprojected_radius != 0) {
     scale /= new_unprojected_radius;
+  }
   (*r_brush_size) = (int)((float)(*r_brush_size) * scale);
 }
 
@@ -1342,10 +1400,12 @@ float BKE_brush_curve_strength(const Brush *br, float p, const float len)
 {
   float strength;
 
-  if (p >= len)
+  if (p >= len) {
     return 0;
-  else
+  }
+  else {
     p = p / len;
+  }
 
   strength = curvemapping_evaluateF(br->curve, 0, p);