Commit: 9c816eec2662f749f97bd6801a8fc8d8b3bd808a Author: Antonio Vazquez Date: Sat Nov 9 12:09:42 2019 +0100 Branches: greasepencil-object https://developer.blender.org/rB9c816eec2662f749f97bd6801a8fc8d8b3bd808a
GPencil: Initialize Brush only if the brush is new =================================================================== M source/blender/blenkernel/intern/brush.c =================================================================== diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 881e70d60ad..3f5a9bbd411 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -241,29 +241,29 @@ static void brush_gpencil_curvemap_reset(CurveMap *cuma, int tot, int preset) } } -static Brush *gpencil_brush_ensure(Main *bmain, - ToolSettings *ts, - char *brush_name, - eObjectMode mode) +static Brush *gpencil_brush_ensure( + Main *bmain, ToolSettings *ts, char *brush_name, eObjectMode mode, bool *new) { + *new = false; Brush *brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2); if (brush == NULL) { brush = BKE_brush_add_gpencil(bmain, ts, brush_name, mode); + *new = true; + + /* Set default at brush level. */ + brush->rgb[0] = 0.498f; + brush->rgb[1] = 1.0f; + brush->rgb[2] = 0.498f; + + brush->secondary_rgb[0] = 1.0f; + brush->secondary_rgb[1] = 1.0f; + brush->secondary_rgb[2] = 1.0f; } if (brush->gpencil_settings == NULL) { BKE_brush_init_gpencil_settings(brush); } - /* Set default at brush level. */ - brush->rgb[0] = 0.498f; - brush->rgb[1] = 1.0f; - brush->rgb[2] = 0.498f; - - brush->secondary_rgb[0] = 1.0f; - brush->secondary_rgb[1] = 1.0f; - brush->secondary_rgb[2] = 1.0f; - /* Set vertex mix factor. */ if (brush->gpencil_settings) { brush->gpencil_settings->vertex_mode = GPPAINT_MODE_STROKE; @@ -285,9 +285,9 @@ void BKE_brush_gpencil_presets(Main *bmain, ToolSettings *ts) Brush *brush, *deft_draw, *deft_vertex; CurveMapping *custom_curve; - + bool new_brush = false; /* Airbrush brush. */ - brush = gpencil_brush_ensure(bmain, ts, "Airbrush", OB_MODE_PAINT_GPENCIL); + brush = gpencil_brush_ensure(bmain, ts, "Airbrush", OB_MODE_PAINT_GPENCIL, &new_brush); brush->size = 300.0f; brush->gpencil_settings->flag |= (GP_BRUSH_USE_PRESSURE | GP_BRUSH_ENABLE_CURSOR); @@ -321,7 +321,7 @@ void BKE_brush_gpencil_presets(Main *bmain, ToolSettings *ts) brush->gpencil_settings->flag |= GP_BRUSH_MATERIAL_PINNED; /* Ink Pen brush. */ - brush = gpencil_brush_ensure(bmain, ts, "Ink Pen", OB_MODE_PAINT_GPENCIL); + brush = gpencil_brush_ensure(bmain, ts, "Ink Pen", OB_MODE_PAINT_GPENCIL, &new_brush); brush->size = 60.0f; brush->gpencil_settings->flag |= (GP_BRUSH_USE_PRESSURE | GP_BRUSH_ENABLE_CURSOR); @@ -359,7 +359,7 @@ void BKE_brush_gpencil_presets(Main *bmain, ToolSettings *ts) brush->smooth_stroke_factor = SMOOTH_STROKE_FACTOR; /* Ink Pen Rough brush. */ - brush = gpencil_brush_ensure(bmain, ts, "Ink Pen Rough", OB_MODE_PAINT_GPENCIL); + brush = gpencil_brush_ensure(bmain, ts, "Ink Pen Rough", OB_MODE_PAINT_GPENCIL, &new_brush); brush->size = 60.0f; brush->gpencil_settings->flag |= (GP_BRUSH_USE_PRESSURE | GP_BRUSH_ENABLE_CURSOR); @@ -399,7 +399,7 @@ void BKE_brush_gpencil_presets(Main *bmain, ToolSettings *ts) brush->smooth_stroke_factor = SMOOTH_STROKE_FACTOR; /* Marker Bold brush. */ - brush = gpencil_brush_ensure(bmain, ts, "Marker Bold", OB_MODE_PAINT_GPENCIL); + brush = gpencil_brush_ensure(bmain, ts, "Marker Bold", OB_MODE_PAINT_GPENCIL, &new_brush); brush->size = 150.0f; brush->gpencil_settings->flag &= ~GP_BRUSH_USE_PRESSURE; @@ -439,7 +439,7 @@ void BKE_brush_gpencil_presets(Main *bmain, ToolSettings *ts) brush->smooth_stroke_factor = SMOOTH_STROKE_FACTOR; /* Marker Chisel brush. */ - brush = gpencil_brush_ensure(bmain, ts, "Marker Chisel", OB_MODE_PAINT_GPENCIL); + brush = gpencil_brush_ensure(bmain, ts, "Marker Chisel", OB_MODE_PAINT_GPENCIL, &new_brush); brush->size = 80.0f; brush->gpencil_settings->flag |= (GP_BRUSH_USE_PRESSURE | GP_BRUSH_ENABLE_CURSOR); @@ -472,7 +472,7 @@ void BKE_brush_gpencil_presets(Main *bmain, ToolSettings *ts) brush->smooth_stroke_factor = SMOOTH_STROKE_FACTOR; /* Pen brush. */ - brush = gpencil_brush_ensure(bmain, ts, "Pen", OB_MODE_PAINT_GPENCIL); + brush = gpencil_brush_ensure(bmain, ts, "Pen", OB_MODE_PAINT_GPENCIL, &new_brush); brush->size = 30.0f; brush->gpencil_settings->flag |= (GP_BRUSH_USE_PRESSURE | GP_BRUSH_ENABLE_CURSOR); @@ -506,7 +506,7 @@ void BKE_brush_gpencil_presets(Main *bmain, ToolSettings *ts) brush->smooth_stroke_factor = SMOOTH_STROKE_FACTOR; /* Pencil Soft brush. */ - brush = gpencil_brush_ensure(bmain, ts, "Pencil Soft", OB_MODE_PAINT_GPENCIL); + brush = gpencil_brush_ensure(bmain, ts, "Pencil Soft", OB_MODE_PAINT_GPENCIL, &new_brush); brush->size = 80.0f; brush->gpencil_settings->flag |= (GP_BRUSH_USE_PRESSURE | GP_BRUSH_ENABLE_CURSOR); @@ -540,7 +540,7 @@ void BKE_brush_gpencil_presets(Main *bmain, ToolSettings *ts) brush->smooth_stroke_factor = SMOOTH_STROKE_FACTOR; /* Pencil brush. */ - brush = gpencil_brush_ensure(bmain, ts, "Pencil", OB_MODE_PAINT_GPENCIL); + brush = gpencil_brush_ensure(bmain, ts, "Pencil", OB_MODE_PAINT_GPENCIL, &new_brush); deft_draw = brush; /* save default brush. */ brush->size = 25.0f; @@ -574,7 +574,7 @@ void BKE_brush_gpencil_presets(Main *bmain, ToolSettings *ts) brush->smooth_stroke_factor = SMOOTH_STROKE_FACTOR; /* Fill brush. */ - brush = gpencil_brush_ensure(bmain, ts, "Fill Area", OB_MODE_PAINT_GPENCIL); + brush = gpencil_brush_ensure(bmain, ts, "Fill Area", OB_MODE_PAINT_GPENCIL, &new_brush); brush->size = 20.0f; brush->gpencil_settings->flag |= GP_BRUSH_ENABLE_CURSOR; @@ -600,7 +600,7 @@ void BKE_brush_gpencil_presets(Main *bmain, ToolSettings *ts) brush->smooth_stroke_factor = SMOOTH_STROKE_FACTOR; /* Soft Eraser brush. */ - brush = gpencil_brush_ensure(bmain, ts, "Eraser Soft", OB_MODE_PAINT_GPENCIL); + brush = gpencil_brush_ensure(bmain, ts, "Eraser Soft", OB_MODE_PAINT_GPENCIL, &new_brush); brush->size = 30.0f; brush->gpencil_settings->draw_strength = 0.5f; @@ -614,7 +614,7 @@ void BKE_brush_gpencil_presets(Main *bmain, ToolSettings *ts) brush->gpencil_settings->era_thickness_f = 10.0f; /* Hard Eraser brush. */ - brush = gpencil_brush_ensure(bmain, ts, "Eraser Hard", OB_MODE_PAINT_GPENCIL); + brush = gpencil_brush_ensure(bmain, ts, "Eraser Hard", OB_MODE_PAINT_GPENCIL, &new_brush); brush->size = 30.0f; brush->gpencil_settings->draw_strength = 1.0f; @@ -627,7 +627,7 @@ void BKE_brush_gpencil_presets(Main *bmain, ToolSettings *ts) brush->gpencil_tool = GPAINT_TOOL_ERASE; /* Point Eraser brush. */ - brush = gpencil_brush_ensure(bmain, ts, "Eraser Point", OB_MODE_PAINT_GPENCIL); + brush = gpencil_brush_ensure(bmain, ts, "Eraser Point", OB_MODE_PAINT_GPENCIL, &new_brush); brush->size = 30.0f; brush->gpencil_settings->flag |= GP_BRUSH_ENABLE_CURSOR; @@ -637,7 +637,7 @@ void BKE_brush_gpencil_presets(Main *bmain, ToolSettings *ts) brush->gpencil_tool = GPAINT_TOOL_ERASE; /* Stroke Eraser brush. */ - brush = gpencil_brush_ensure(bmain, ts, "Eraser Stroke", OB_MODE_PAINT_GPENCIL); + brush = gpencil_brush_ensure(bmain, ts, "Eraser Stroke", OB_MODE_PAINT_GPENCIL, &new_brush); brush->size = 30.0f; brush->gpencil_settings->flag |= GP_BRUSH_ENABLE_CURSOR; @@ -647,109 +647,90 @@ void BKE_brush_gpencil_presets(Main *bmain, ToolSettings *ts) brush->gpencil_tool = GPAINT_TOOL_ERASE; /* Tint brush. */ - brush = gpencil_brush_ensure(bmain, ts, "Tint", OB_MODE_PAINT_GPENCIL); - - brush->size = 25.0f; - brush->gpencil_settings->flag |= (GP_BRUSH_USE_PRESSURE | GP_BRUSH_ENABLE_CURSOR); - - brush->gpencil_settings->draw_strength = 0.8f; - brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE; - brush->rgb[0] = 0.757f; - brush->rgb[1] = 0.659f; - brush->rgb[2] = 0.824f; - - zero_v3(brush->secondary_rgb); - + brush = gpencil_brush_ensure(bmain, ts, "Tint", OB_MODE_PAINT_GPENCIL, &new_brush); brush->gpencil_settings->icon_id = GP_BRUSH_ICON_TINT; brush->gpencil_tool = GPAINT_TOOL_TINT; - /* Vertex Paint Brushes. */ - /* Vertex Draw brush. */ - brush = gpencil_brush_ensure(bmain, ts, "Vertex Draw", OB_MODE_VERTEX_GPENCIL); - deft_vertex = brush; /* save default brush. */ + if (new_brush) { + brush->size = 25.0f; + brush->gpencil_settings->flag |= (GP_BRUSH_USE_PRESSURE | GP_BRUSH_ENABLE_CURSOR); - brush->size = 25.0f; - brush->gpencil_settings->flag |= (GP_BRUSH_USE_PRESSURE | GP_BRUSH_ENABLE_CURSOR); - - brush->gpencil_settings->draw_strength = 0.8f; - brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE; - brush->rgb[0] = 0.757f; - brush->rgb[1] = 0.659f; - brush->rgb[2] = 0.824f; - - zero_v3(brush->secondary_rgb); + brush->gpencil_settings->draw_strength = 0.8f; + brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE; + brush->rgb[0] = 0.757f; + brush->rgb[1] = 0.659f; + brush->rgb[2] = 0.824f; + zero_v3(brush->secondary_rgb); + } + /* Vertex Paint Brushes. */ + /* Vertex Draw brush. */ + brush = gpencil_brush_ensure(bmain, ts, "Vertex Draw", OB_MODE_VERTEX_GPENCIL, &new_brush); brush->gpencil_settings->icon_id = GP_BRUSH_ICON_VERTEX_DRAW; brush->gpencil_vertex_tool = GPVERTEX_TOOL_DRAW; + deft_vertex = brush; /* save default brush. */ - /* Vertex Blur brush. */ - brush = gpencil_brush_ensure(bmain, ts, "Vertex Blur", OB_MODE_VERTEX_GPENCIL); - - brush->size = 25.0f; - brush->gpencil_settings->flag |= (GP_BRUSH_USE_PRESSURE | GP_BRUSH_ENABLE_CURSOR); - - brush->gpencil_settings->draw_strength = 0.8f; - brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE; - brush->rgb[0] = 0.757f; - brush->rgb[1] = 0.659f; - brush->rgb[2] = 0.824f; + if (new_brush) { + brush->size = 25.0f; + brush->gpencil_settings->flag |= (GP_BRUSH_USE_PRESSURE | GP_BRUSH_ENABLE_CURSOR); - zero_v3(brush->secondary_rgb); + brush->gpencil_settings->draw_strength = 0.8f; + brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE; + brush->rgb[0] = 0.757f; + brush->rgb[1] = 0.659f; + brush->rgb[2] = 0.824f; + zero_v3(brush->secondary_rgb); + } + /* Vertex Blur brush. */ + brush = gpencil_brush_ensure(bmain, ts, "Vertex Blur", OB_MODE_VERTEX_GPENCIL, &new_br @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs