diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_brush.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/brush.c | 414 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_defaults.c | 72 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_data.c | 4 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_edit.c | 2 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_merge.c | 4 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_paint.c | 3 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_primitive.c | 2 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_utils.c | 2 |
9 files changed, 332 insertions, 173 deletions
diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h index 26ab7f8ba0c..68fd1b1398d 100644 --- a/source/blender/blenkernel/BKE_brush.h +++ b/source/blender/blenkernel/BKE_brush.h @@ -56,7 +56,7 @@ void BKE_brush_make_local(struct Main *bmain, struct Brush *brush, const bool li void BKE_brush_free(struct Brush *brush); void BKE_brush_sculpt_reset(struct Brush *brush); -void BKE_brush_gpencil_presets(struct bContext *C); +void BKE_brush_gpencil_presets(struct Main *bmain, struct ToolSettings *ts); /* image icon function */ struct ImBuf *get_brush_icon(struct Brush *brush); diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 44853f74264..56ce658d9d7 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -26,6 +26,7 @@ #include "DNA_gpencil_types.h" #include "DNA_defaults.h" +#include "BLI_listbase.h" #include "BLI_math.h" #include "BLI_rand.h" @@ -36,6 +37,7 @@ #include "BKE_library_query.h" #include "BKE_library_remap.h" #include "BKE_main.h" +#include "BKE_material.h" #include "BKE_paint.h" #include "BKE_texture.h" #include "BKE_icons.h" @@ -239,306 +241,383 @@ static void brush_gpencil_curvemap_reset(CurveMap *cuma, int tot, int preset) } } -/* create a set of grease pencil presets */ -void BKE_brush_gpencil_presets(bContext *C) +/* create a set of grease pencil presets. */ +void BKE_brush_gpencil_presets(Main *bmain, ToolSettings *ts) { #define SMOOTH_STROKE_RADIUS 40 #define SMOOTH_STROKE_FACTOR 0.9f - ToolSettings *ts = CTX_data_tool_settings(C); Paint *paint = &ts->gp_paint->paint; - Main *bmain = CTX_data_main(C); Brush *brush, *deft; CurveMapping *custom_curve; - /* Pencil brush */ - brush = BKE_brush_add_gpencil(bmain, ts, "Draw Pencil"); - brush->size = 25.0f; + /* Airbrush brush. */ + brush = BLI_findstring(&bmain->brushes, "Airbrush", offsetof(ID, name) + 2); + if (brush == NULL) { + brush = BKE_brush_add_gpencil(bmain, ts, "Airbrush"); + } + + 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.6f; + 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_jitter = 0.0f; - brush->gpencil_settings->flag |= GP_BRUSH_USE_JITTER_PRESSURE; - + brush->gpencil_settings->input_samples = 10; + brush->gpencil_settings->active_smooth = 0.98f; brush->gpencil_settings->draw_angle = 0.0f; brush->gpencil_settings->draw_angle_factor = 0.0f; + brush->gpencil_settings->gradient_f = 0.211f; + brush->gpencil_settings->gradient_s[0] = 1.0f; + brush->gpencil_settings->gradient_s[1] = 1.0f; + + brush->gpencil_settings->draw_sensitivity = 1.0f; - brush->gpencil_settings->flag |= GP_BRUSH_GROUP_SETTINGS; - brush->gpencil_settings->draw_smoothfac = 0.1f; - brush->gpencil_settings->draw_smoothlvl = 1; - brush->gpencil_settings->thick_smoothfac = 1.0f; - brush->gpencil_settings->thick_smoothlvl = 3; - brush->gpencil_settings->draw_subdivide = 1; - brush->gpencil_settings->draw_random_sub = 0.0f; - brush->gpencil_settings->icon_id = GP_BRUSH_ICON_PENCIL; brush->gpencil_tool = GPAINT_TOOL_DRAW; + brush->gpencil_settings->icon_id = GP_BRUSH_ICON_AIRBRUSH; brush->smooth_stroke_radius = SMOOTH_STROKE_RADIUS; brush->smooth_stroke_factor = SMOOTH_STROKE_FACTOR; - brush->gpencil_settings->gradient_f = 1.0f; - brush->gpencil_settings->gradient_s[0] = 1.0f; - brush->gpencil_settings->gradient_s[1] = 1.0f; - - /* Pen brush */ - brush = BKE_brush_add_gpencil(bmain, ts, "Draw Pen"); - deft = brush; /* save default brush */ - brush->size = 30.0f; + /* Create and link Black Dots material to brush. + * This material is required because the brush uses the material to define how the stroke is + * drawn. */ + Material *ma = BLI_findstring(&bmain->materials, "Black Dots", offsetof(ID, name) + 2); + if (ma == NULL) { + ma = BKE_material_add_gpencil(bmain, "Black Dots"); + } + brush->gpencil_settings->material = ma; + /* Pin the matterial to the brush. */ + brush->gpencil_settings->flag |= GP_BRUSH_MATERIAL_PINNED; + + /* Ink Pen brush. */ + brush = BLI_findstring(&bmain->brushes, "Ink Pen", offsetof(ID, name) + 2); + if (brush == NULL) { + brush = BKE_brush_add_gpencil(bmain, ts, "Ink Pen"); + } + brush->size = 60.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 = 1.0f; - 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->input_samples = 10; + brush->gpencil_settings->active_smooth = 0.7f; brush->gpencil_settings->draw_angle = 0.0f; brush->gpencil_settings->draw_angle_factor = 0.0f; + brush->gpencil_settings->gradient_f = 1.0f; + brush->gpencil_settings->gradient_s[0] = 1.0f; + brush->gpencil_settings->gradient_s[1] = 1.0f; brush->gpencil_settings->flag |= GP_BRUSH_GROUP_SETTINGS; 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_subdivide = 0; brush->gpencil_settings->draw_random_sub = 0.0f; - brush->gpencil_settings->icon_id = GP_BRUSH_ICON_PEN; - 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 = 1.0f; - brush->gpencil_settings->gradient_s[0] = 1.0f; - brush->gpencil_settings->gradient_s[1] = 1.0f; - - /* Ink brush */ - brush = BKE_brush_add_gpencil(bmain, ts, "Draw Ink"); - brush->size = 60.0f; - brush->gpencil_settings->flag |= (GP_BRUSH_USE_PRESSURE | GP_BRUSH_ENABLE_CURSOR); - brush->gpencil_settings->draw_sensitivity = 1.6f; - - brush->gpencil_settings->draw_strength = 1.0f; + brush->gpencil_settings->simplify_f = 0.002f; brush->gpencil_settings->draw_random_press = 0.0f; - brush->gpencil_settings->draw_jitter = 0.0f; brush->gpencil_settings->flag |= GP_BRUSH_USE_JITTER_PRESSURE; + brush->gpencil_settings->draw_sensitivity = 1.0f; - brush->gpencil_settings->draw_angle = 0.0f; - brush->gpencil_settings->draw_angle_factor = 0.0f; + /* Curve. */ + 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, 3, GPCURVE_PRESET_INK); - brush->gpencil_settings->flag |= GP_BRUSH_GROUP_SETTINGS; - brush->gpencil_settings->draw_smoothfac = 0.1f; - brush->gpencil_settings->draw_smoothlvl = 1; - brush->gpencil_settings->thick_smoothfac = 1.0f; - brush->gpencil_settings->thick_smoothlvl = 3; - brush->gpencil_settings->draw_subdivide = 1; - brush->gpencil_settings->draw_random_sub = 0.0f; brush->gpencil_settings->icon_id = GP_BRUSH_ICON_INK; 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 = 1.0f; - brush->gpencil_settings->gradient_s[0] = 1.0f; - brush->gpencil_settings->gradient_s[1] = 1.0f; - - /* Curve */ - 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, 3, GPCURVE_PRESET_INK); + /* Ink Pen Rough brush. */ + brush = BLI_findstring(&bmain->brushes, "Ink Pen Rough", offsetof(ID, name) + 2); + if (brush == NULL) { + brush = BKE_brush_add_gpencil(bmain, ts, "Ink Pen Rough"); + } - /* Ink Noise brush */ - brush = BKE_brush_add_gpencil(bmain, ts, "Draw Noise"); brush->size = 60.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 = 1.0f; - brush->gpencil_settings->flag |= GP_BRUSH_GROUP_RANDOM; - brush->gpencil_settings->draw_random_press = 0.7f; - 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->input_samples = 10; + brush->gpencil_settings->active_smooth = 0.5f; brush->gpencil_settings->draw_angle = 0.0f; brush->gpencil_settings->draw_angle_factor = 0.0f; + brush->gpencil_settings->gradient_f = 1.0f; + brush->gpencil_settings->gradient_s[0] = 1.0f; + brush->gpencil_settings->gradient_s[1] = 1.0f; - brush->gpencil_settings->flag |= GP_BRUSH_GROUP_SETTINGS; - brush->gpencil_settings->draw_smoothfac = 0.1f; + brush->gpencil_settings->flag &= ~GP_BRUSH_GROUP_SETTINGS; + brush->gpencil_settings->draw_smoothfac = 0.0f; brush->gpencil_settings->draw_smoothlvl = 2; - brush->gpencil_settings->thick_smoothfac = 0.5f; + brush->gpencil_settings->thick_smoothfac = 0.0f; brush->gpencil_settings->thick_smoothlvl = 2; - brush->gpencil_settings->draw_subdivide = 1; + brush->gpencil_settings->draw_subdivide = 0; brush->gpencil_settings->draw_random_sub = 0.0f; - brush->gpencil_settings->icon_id = GP_BRUSH_ICON_INKNOISE; - brush->gpencil_tool = GPAINT_TOOL_DRAW; + brush->gpencil_settings->simplify_f = 0.000f; - brush->smooth_stroke_radius = SMOOTH_STROKE_RADIUS; - brush->smooth_stroke_factor = SMOOTH_STROKE_FACTOR; + brush->gpencil_settings->flag |= GP_BRUSH_GROUP_RANDOM; + brush->gpencil_settings->draw_random_press = 1.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_sensitivity = 1.0f; - /* Curve */ + /* Curve. */ 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, 3, GPCURVE_PRESET_INKNOISE); - brush->gpencil_settings->gradient_f = 1.0f; - brush->gpencil_settings->gradient_s[0] = 1.0f; - brush->gpencil_settings->gradient_s[1] = 1.0f; - - /* Block Basic brush */ - brush = BKE_brush_add_gpencil(bmain, ts, "Draw Block"); - brush->size = 150.0f; - brush->gpencil_settings->flag |= (GP_BRUSH_USE_PRESSURE | GP_BRUSH_ENABLE_CURSOR); - brush->gpencil_settings->draw_sensitivity = 1.0f; + brush->gpencil_settings->icon_id = GP_BRUSH_ICON_INKNOISE; + brush->gpencil_tool = GPAINT_TOOL_DRAW; - brush->gpencil_settings->draw_strength = 1.0f; + brush->smooth_stroke_radius = SMOOTH_STROKE_RADIUS; + brush->smooth_stroke_factor = SMOOTH_STROKE_FACTOR; - brush->gpencil_settings->draw_random_press = 0.0f; + /* Marker Bold brush. */ + brush = BLI_findstring(&bmain->brushes, "Marker Bold", offsetof(ID, name) + 2); + if (brush == NULL) { + brush = BKE_brush_add_gpencil(bmain, ts, "Marker Bold"); + } + brush->size = 150.0f; + brush->gpencil_settings->flag &= ~GP_BRUSH_USE_PRESSURE; - brush->gpencil_settings->draw_jitter = 0.0f; - brush->gpencil_settings->flag |= GP_BRUSH_USE_JITTER_PRESSURE; + brush->gpencil_settings->draw_strength = 0.3f; + brush->gpencil_settings->input_samples = 10; + brush->gpencil_settings->active_smooth = 0.6f; brush->gpencil_settings->draw_angle = 0.0f; brush->gpencil_settings->draw_angle_factor = 0.0f; + brush->gpencil_settings->gradient_f = 1.0f; + brush->gpencil_settings->gradient_s[0] = 1.0f; + brush->gpencil_settings->gradient_s[1] = 1.0f; + brush->gpencil_settings->flag |= GP_BRUSH_GROUP_SETTINGS; brush->gpencil_settings->draw_smoothfac = 0.1f; brush->gpencil_settings->draw_smoothlvl = 1; brush->gpencil_settings->thick_smoothfac = 1.0f; brush->gpencil_settings->thick_smoothlvl = 3; brush->gpencil_settings->draw_subdivide = 0; - brush->gpencil_settings->draw_random_sub = 0; - brush->gpencil_settings->icon_id = GP_BRUSH_ICON_BLOCK; + brush->gpencil_settings->draw_random_sub = 0.0f; + brush->gpencil_settings->simplify_f = 0.002f; + + brush->gpencil_settings->flag &= ~GP_BRUSH_GROUP_RANDOM; + 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_sensitivity = 1.0f; + + /* Curve. */ + 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, 4, GPCURVE_PRESET_MARKER); + + 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 = 1.0f; - brush->gpencil_settings->gradient_s[0] = 1.0f; - brush->gpencil_settings->gradient_s[1] = 1.0f; - - /* Marker brush */ - brush = BKE_brush_add_gpencil(bmain, ts, "Draw Marker"); + /* Marker Chisel brush. */ + brush = BLI_findstring(&bmain->brushes, "Marker Chisel", offsetof(ID, name) + 2); + if (brush == NULL) { + brush = BKE_brush_add_gpencil(bmain, ts, "Marker Chisel"); + } brush->size = 80.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 = 1.0f; - brush->gpencil_settings->flag |= GP_BRUSH_GROUP_RANDOM; - brush->gpencil_settings->draw_random_press = 0.374f; - 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->input_samples = 10; + brush->gpencil_settings->active_smooth = 0.5f; brush->gpencil_settings->draw_angle = DEG2RAD(20.0f); brush->gpencil_settings->draw_angle_factor = 1.0f; + brush->gpencil_settings->gradient_f = 1.0f; + brush->gpencil_settings->gradient_s[0] = 1.0f; + brush->gpencil_settings->gradient_s[1] = 1.0f; brush->gpencil_settings->flag |= GP_BRUSH_GROUP_SETTINGS; - brush->gpencil_settings->draw_smoothfac = 0.1f; + brush->gpencil_settings->draw_smoothfac = 0.0f; brush->gpencil_settings->draw_smoothlvl = 1; brush->gpencil_settings->thick_smoothfac = 1.0f; brush->gpencil_settings->thick_smoothlvl = 3; - brush->gpencil_settings->draw_subdivide = 1; - brush->gpencil_settings->draw_random_sub = 0.0f; - brush->gpencil_settings->icon_id = GP_BRUSH_ICON_MARKER; + brush->gpencil_settings->draw_subdivide = 0; + brush->gpencil_settings->draw_random_sub = 0; + brush->gpencil_settings->simplify_f = 0.002f; + + brush->gpencil_settings->flag &= ~GP_BRUSH_GROUP_RANDOM; + brush->gpencil_settings->draw_random_press = 0.0f; + brush->gpencil_settings->draw_jitter = 0.0f; + brush->gpencil_settings->flag |= GP_BRUSH_USE_JITTER_PRESSURE; + brush->gpencil_settings->draw_sensitivity = 1.0f; + + brush->gpencil_settings->icon_id = GP_BRUSH_ICON_CHISEL; brush->gpencil_tool = GPAINT_TOOL_DRAW; brush->smooth_stroke_radius = SMOOTH_STROKE_RADIUS; brush->smooth_stroke_factor = SMOOTH_STROKE_FACTOR; - /* Curve */ - 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, 4, GPCURVE_PRESET_MARKER); + /* Pen brush. */ + brush = BLI_findstring(&bmain->brushes, "Pen", offsetof(ID, name) + 2); + if (brush == NULL) { + brush = BKE_brush_add_gpencil(bmain, ts, "Pen"); + } + brush->size = 30.0f; + brush->gpencil_settings->flag |= (GP_BRUSH_USE_PRESSURE | GP_BRUSH_ENABLE_CURSOR); + + brush->gpencil_settings->draw_strength = 1.0f; + brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE; + + brush->gpencil_settings->input_samples = 10; + brush->gpencil_settings->active_smooth = 0.3f; + brush->gpencil_settings->draw_angle = 0.0f; + brush->gpencil_settings->draw_angle_factor = 0.0f; brush->gpencil_settings->gradient_f = 1.0f; 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->flag |= GP_BRUSH_GROUP_SETTINGS; + brush->gpencil_settings->draw_smoothfac = 0.0f; + brush->gpencil_settings->draw_smoothlvl = 1; + brush->gpencil_settings->thick_smoothfac = 1.0f; + brush->gpencil_settings->thick_smoothlvl = 1; + brush->gpencil_settings->draw_subdivide = 1; + brush->gpencil_settings->draw_random_sub = 0.0f; + brush->gpencil_settings->simplify_f = 0.002f; + + 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_sensitivity = 1.0f; + brush->gpencil_settings->icon_id = GP_BRUSH_ICON_PEN; + brush->gpencil_tool = GPAINT_TOOL_DRAW; + + brush->smooth_stroke_radius = SMOOTH_STROKE_RADIUS; + brush->smooth_stroke_factor = SMOOTH_STROKE_FACTOR; + + /* Pencil Soft brush. */ + brush = BLI_findstring(&bmain->brushes, "Pencil Soft", offsetof(ID, name) + 2); + if (brush == NULL) { + brush = BKE_brush_add_gpencil(bmain, ts, "Pencil Soft"); + } + + brush->size = 80.0f; + brush->gpencil_settings->flag |= (GP_BRUSH_USE_PRESSURE | GP_BRUSH_ENABLE_CURSOR); + brush->gpencil_settings->draw_strength = 0.4f; brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE; + brush->gpencil_settings->input_samples = 10; + brush->gpencil_settings->active_smooth = 0.64f; + brush->gpencil_settings->draw_angle = 0.0f; + brush->gpencil_settings->draw_angle_factor = 0.0f; + brush->gpencil_settings->gradient_f = 0.8f; + brush->gpencil_settings->gradient_s[0] = 1.0f; + brush->gpencil_settings->gradient_s[1] = 1.0f; + + brush->gpencil_settings->flag |= GP_BRUSH_GROUP_SETTINGS; + brush->gpencil_settings->draw_smoothfac = 0.0f; + brush->gpencil_settings->draw_smoothlvl = 1; + brush->gpencil_settings->thick_smoothfac = 1.0f; + brush->gpencil_settings->thick_smoothlvl = 3; + brush->gpencil_settings->draw_subdivide = 0; + brush->gpencil_settings->draw_random_sub = 0.0f; + brush->gpencil_settings->simplify_f = 0.000f; + 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_sensitivity = 1.0f; + + brush->gpencil_settings->icon_id = GP_BRUSH_ICON_PENCIL; + brush->gpencil_tool = GPAINT_TOOL_DRAW; + + brush->smooth_stroke_radius = SMOOTH_STROKE_RADIUS; + brush->smooth_stroke_factor = SMOOTH_STROKE_FACTOR; + + /* Pencil brush. */ + brush = BLI_findstring(&bmain->brushes, "Pencil", offsetof(ID, name) + 2); + if (brush == NULL) { + brush = BKE_brush_add_gpencil(bmain, ts, "Pencil"); + } + deft = brush; /* save default brush. */ + + brush->size = 25.0f; + brush->gpencil_settings->flag |= (GP_BRUSH_USE_PRESSURE | GP_BRUSH_ENABLE_CURSOR); + brush->gpencil_settings->draw_strength = 0.6f; + brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE; + + brush->gpencil_settings->input_samples = 10; + brush->gpencil_settings->active_smooth = 0.55f; brush->gpencil_settings->draw_angle = 0.0f; brush->gpencil_settings->draw_angle_factor = 0.0f; + brush->gpencil_settings->gradient_f = 1.0f; + brush->gpencil_settings->gradient_s[0] = 1.0f; + brush->gpencil_settings->gradient_s[1] = 1.0f; - brush->gpencil_settings->input_samples = 10; - brush->gpencil_settings->active_smooth = 0.98f; - brush->gpencil_settings->draw_smoothfac = 0.1f; + brush->gpencil_settings->flag |= GP_BRUSH_GROUP_SETTINGS; + brush->gpencil_settings->draw_smoothfac = 0.0f; 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_subdivide = 0; brush->gpencil_settings->draw_random_sub = 0.0f; - brush->gpencil_settings->icon_id = GP_BRUSH_ICON_MARKER; + brush->gpencil_settings->simplify_f = 0.002f; + + brush->gpencil_settings->draw_random_press = 0.0f; + brush->gpencil_settings->draw_jitter = 0.0f; + brush->gpencil_settings->flag |= GP_BRUSH_USE_JITTER_PRESSURE; + brush->gpencil_settings->draw_sensitivity = 1.0f; + + brush->gpencil_settings->icon_id = GP_BRUSH_ICON_PENCIL; 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 */ + /* Fill brush. */ brush = BKE_brush_add_gpencil(bmain, ts, "Fill Area"); 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; brush->gpencil_settings->fill_threshold = 0.1f; brush->gpencil_settings->fill_simplylvl = 1; brush->gpencil_settings->fill_factor = 1; - brush->gpencil_settings->icon_id = GP_BRUSH_ICON_FILL; - brush->gpencil_tool = GPAINT_TOOL_FILL; + brush->gpencil_settings->draw_strength = 1.0f; + brush->gpencil_settings->gradient_f = 1.0f; + brush->gpencil_settings->gradient_s[0] = 1.0f; + brush->gpencil_settings->gradient_s[1] = 1.0f; brush->gpencil_settings->draw_smoothfac = 0.1f; brush->gpencil_settings->draw_smoothlvl = 1; brush->gpencil_settings->thick_smoothfac = 1.0f; brush->gpencil_settings->thick_smoothlvl = 3; brush->gpencil_settings->draw_subdivide = 1; - brush->smooth_stroke_radius = SMOOTH_STROKE_RADIUS; - brush->smooth_stroke_factor = SMOOTH_STROKE_FACTOR; + brush->gpencil_settings->draw_sensitivity = 1.0f; - brush->gpencil_settings->draw_strength = 1.0f; + brush->gpencil_settings->icon_id = GP_BRUSH_ICON_FILL; + brush->gpencil_tool = GPAINT_TOOL_FILL; - brush->gpencil_settings->gradient_f = 1.0f; - brush->gpencil_settings->gradient_s[0] = 1.0f; - brush->gpencil_settings->gradient_s[1] = 1.0f; + brush->smooth_stroke_radius = SMOOTH_STROKE_RADIUS; + brush->smooth_stroke_factor = SMOOTH_STROKE_FACTOR; - /* Soft Eraser brush */ + /* Soft Eraser brush. */ brush = BKE_brush_add_gpencil(bmain, ts, "Eraser Soft"); brush->size = 30.0f; brush->gpencil_settings->draw_strength = 0.5f; @@ -551,34 +630,37 @@ void BKE_brush_gpencil_presets(bContext *C) brush->gpencil_settings->era_strength_f = 100.0f; brush->gpencil_settings->era_thickness_f = 10.0f; - /* Hard Eraser brush */ + /* Hard Eraser brush. */ brush = BKE_brush_add_gpencil(bmain, ts, "Eraser Hard"); brush->size = 30.0f; brush->gpencil_settings->draw_strength = 1.0f; brush->gpencil_settings->flag |= (GP_BRUSH_ENABLE_CURSOR | GP_BRUSH_DEFAULT_ERASER); - brush->gpencil_settings->icon_id = GP_BRUSH_ICON_ERASE_HARD; - brush->gpencil_tool = GPAINT_TOOL_ERASE; brush->gpencil_settings->eraser_mode = GP_BRUSH_ERASER_SOFT; brush->gpencil_settings->era_strength_f = 100.0f; brush->gpencil_settings->era_thickness_f = 50.0f; - /* Point Eraser brush */ + brush->gpencil_settings->icon_id = GP_BRUSH_ICON_ERASE_HARD; + brush->gpencil_tool = GPAINT_TOOL_ERASE; + + /* Point Eraser brush. */ brush = BKE_brush_add_gpencil(bmain, ts, "Eraser Point"); brush->size = 30.0f; brush->gpencil_settings->flag |= GP_BRUSH_ENABLE_CURSOR; + brush->gpencil_settings->eraser_mode = GP_BRUSH_ERASER_HARD; + brush->gpencil_settings->icon_id = GP_BRUSH_ICON_ERASE_HARD; brush->gpencil_tool = GPAINT_TOOL_ERASE; - brush->gpencil_settings->eraser_mode = GP_BRUSH_ERASER_HARD; - /* Stroke Eraser brush */ + /* Stroke Eraser brush. */ brush = BKE_brush_add_gpencil(bmain, ts, "Eraser Stroke"); brush->size = 30.0f; brush->gpencil_settings->flag |= GP_BRUSH_ENABLE_CURSOR; + brush->gpencil_settings->eraser_mode = GP_BRUSH_ERASER_STROKE; + brush->gpencil_settings->icon_id = GP_BRUSH_ICON_ERASE_STROKE; brush->gpencil_tool = GPAINT_TOOL_ERASE; - brush->gpencil_settings->eraser_mode = GP_BRUSH_ERASER_STROKE; - /* set default brush */ + /* set default brush. */ BKE_paint_brush_set(paint, deft); } diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c index 7da2272ce14..7bae0ede55b 100644 --- a/source/blender/blenloader/intern/versioning_defaults.c +++ b/source/blender/blenloader/intern/versioning_defaults.c @@ -47,6 +47,7 @@ #include "BKE_library.h" #include "BKE_main.h" #include "BKE_node.h" +#include "BKE_paint.h" #include "BKE_screen.h" #include "BKE_workspace.h" @@ -357,6 +358,12 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template) scene->audio.flag &= ~AUDIO_SYNC; scene->flag &= ~SCE_FRAME_DROP; } + + /* Change default selection mode for Grease Pencil. */ + if (app_template && STREQ(app_template, "2D_Animation")) { + ToolSettings *ts = scene->toolsettings; + ts->gpencil_selectmode_edit = GP_SELECTMODE_STROKE; + } } /* Objects */ @@ -464,4 +471,69 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template) } } } + + if (app_template && STREQ(app_template, "2D_Animation")) { + /* Update Grease Pencil brushes. */ + Brush *brush; + + /* Pencil brush. */ + brush = BLI_findstring(&bmain->brushes, "Draw Pencil", offsetof(ID, name) + 2); + if (brush) { + /* Change brush name. */ + rename_id_for_versioning(bmain, ID_BR, "Draw Pencil", "Pencil"); + } + + /* Pen brush. */ + brush = BLI_findstring(&bmain->brushes, "Draw Pen", offsetof(ID, name) + 2); + if (brush) { + /* Change brush name. */ + rename_id_for_versioning(bmain, ID_BR, "Draw Pen", "Pen"); + } + + /* Pen Soft brush. */ + brush = BLI_findstring(&bmain->brushes, "Draw Soft", offsetof(ID, name) + 2); + if (brush) { + brush->gpencil_settings->icon_id = GP_BRUSH_ICON_PEN; + /* Change brush name. */ + rename_id_for_versioning(bmain, ID_BR, "Draw Soft", "Pencil Soft"); + } + + /* Ink Pen brush. */ + brush = BLI_findstring(&bmain->brushes, "Draw Ink", offsetof(ID, name) + 2); + if (brush) { + /* Change brush name. */ + rename_id_for_versioning(bmain, ID_BR, "Draw Ink", "Ink Pen"); + } + + /* Ink Pen Rough brush. */ + brush = BLI_findstring(&bmain->brushes, "Draw Noise", offsetof(ID, name) + 2); + if (brush) { + /* Change brush name. */ + rename_id_for_versioning(bmain, ID_BR, "Draw Noise", "Ink Pen Rough"); + } + + /* Marker Bold brush. */ + brush = BLI_findstring(&bmain->brushes, "Draw Marker", offsetof(ID, name) + 2); + if (brush) { + /* Change brush name. */ + rename_id_for_versioning(bmain, ID_BR, "Draw Marker", "Marker Bold"); + } + + /* Marker Chisel brush. */ + brush = BLI_findstring(&bmain->brushes, "Draw Block", offsetof(ID, name) + 2); + if (brush) { + /* Change brush name. */ + rename_id_for_versioning(bmain, ID_BR, "Draw Block", "Marker Chisel"); + } + + /* Remove useless Fill Area.001 brush. */ + brush = BLI_findstring(&bmain->brushes, "Fill Area.001", offsetof(ID, name) + 2); + if (brush) { + BKE_id_delete(bmain, brush); + } + + /* Reset all grease pencil brushes. */ + Scene *scene = bmain->scenes.first; + BKE_brush_gpencil_presets(bmain, scene->toolsettings); + } } diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c index fdbbd899366..67ffc6adc9f 100644 --- a/source/blender/editors/gpencil/gpencil_data.c +++ b/source/blender/editors/gpencil/gpencil_data.c @@ -1580,7 +1580,9 @@ void GPENCIL_OT_stroke_lock_color(wmOperatorType *ot) /* ******************* Brush create presets ************************** */ static int gp_brush_presets_create_exec(bContext *C, wmOperator *UNUSED(op)) { - BKE_brush_gpencil_presets(C); + Main *bmain = CTX_data_main(C); + ToolSettings *ts = CTX_data_tool_settings(C); + BKE_brush_gpencil_presets(bmain, ts); /* notifiers */ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 2aea1084ad6..c4f18c60f4d 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -355,7 +355,7 @@ static int gpencil_paintmode_toggle_exec(bContext *C, wmOperator *op) Paint *paint = &ts->gp_paint->paint; /* if not exist, create a new one */ if ((paint->brush == NULL) || (paint->brush->gpencil_settings == NULL)) { - BKE_brush_gpencil_presets(C); + BKE_brush_gpencil_presets(bmain, ts); } BKE_paint_toolslots_brush_validate(bmain, &ts->gp_paint->paint); } diff --git a/source/blender/editors/gpencil/gpencil_merge.c b/source/blender/editors/gpencil/gpencil_merge.c index 930911ffac5..36cef3ccdc0 100644 --- a/source/blender/editors/gpencil/gpencil_merge.c +++ b/source/blender/editors/gpencil/gpencil_merge.c @@ -35,6 +35,7 @@ #include "BKE_brush.h" #include "BKE_context.h" #include "BKE_gpencil.h" +#include "BKE_main.h" #include "BKE_material.h" #include "WM_api.h" @@ -97,6 +98,7 @@ static void gpencil_insert_points_to_stroke(bGPDstroke *gps, static bGPDstroke *gpencil_prepare_stroke(bContext *C, wmOperator *op, int totpoints) { + Main *bmain = CTX_data_main(C); ToolSettings *ts = CTX_data_tool_settings(C); Object *ob = CTX_data_active_object(C); bGPDlayer *gpl = CTX_data_active_gpencil_layer(C); @@ -111,7 +113,7 @@ static bGPDstroke *gpencil_prepare_stroke(bContext *C, wmOperator *op, int totpo /* if not exist, create a new one */ if ((paint->brush == NULL) || (paint->brush->gpencil_settings == NULL)) { /* create new brushes */ - BKE_brush_gpencil_presets(C); + BKE_brush_gpencil_presets(bmain, ts); } Brush *brush = paint->brush; diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index d8f1663a6c1..f29e782c618 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -2012,6 +2012,7 @@ static void gp_set_default_eraser(Main *bmain, Brush *brush_dft) /* initialize a drawing brush */ static void gp_init_drawing_brush(bContext *C, tGPsdata *p) { + Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); ToolSettings *ts = CTX_data_tool_settings(C); @@ -2020,7 +2021,7 @@ static void gp_init_drawing_brush(bContext *C, tGPsdata *p) /* if not exist, create a new one */ if ((paint->brush == NULL) || (paint->brush->gpencil_settings == NULL)) { /* create new brushes */ - BKE_brush_gpencil_presets(C); + BKE_brush_gpencil_presets(bmain, ts); changed = true; } /* be sure curves are initializated */ diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c index e5b1a82630b..c42c1c4d4c0 100644 --- a/source/blender/editors/gpencil/gpencil_primitive.c +++ b/source/blender/editors/gpencil/gpencil_primitive.c @@ -1134,7 +1134,7 @@ static void gpencil_primitive_init(bContext *C, wmOperator *op) /* if brush doesn't exist, create a new set (fix damaged files from old versions) */ if ((paint->brush == NULL) || (paint->brush->gpencil_settings == NULL)) { - BKE_brush_gpencil_presets(C); + BKE_brush_gpencil_presets(bmain, ts); } /* Set Draw brush. */ diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c index 89a2a987f60..b194d28a8b8 100644 --- a/source/blender/editors/gpencil/gpencil_utils.c +++ b/source/blender/editors/gpencil/gpencil_utils.c @@ -1391,7 +1391,7 @@ void ED_gpencil_add_defaults(bContext *C, Object *ob) /* if not exist, create a new one */ if ((paint->brush == NULL) || (paint->brush->gpencil_settings == NULL)) { /* create new brushes */ - BKE_brush_gpencil_presets(C); + BKE_brush_gpencil_presets(bmain, ts); } /* ensure a color exists and is assigned to object */ |