diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-11-05 07:31:25 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-11-05 07:31:25 +0300 |
commit | 8b31f6fb2169e7163767e382adbef13587305aca (patch) | |
tree | 23609feb5da08a39f8009eb4390f69e6205fc2b1 /source/blender/editors/gpencil | |
parent | 8fcc04edce53c5b3b01bf392e1667878ebcce0ef (diff) |
Paint: add BKE_paint_ensure to initialize toolsettings
Each mode had its own logic for initializing paint structs,
move to a single function.
Also remove "BKE_brush_get_gpencil_paint", entering grease pencil
mode is responsible for ensuring the data is created.
Diffstat (limited to 'source/blender/editors/gpencil')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_data.c | 2 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_edit.c | 3 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_old.c | 8 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_paint.c | 4 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_primitive.c | 2 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_utils.c | 3 |
6 files changed, 8 insertions, 14 deletions
diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c index 4dcb3420bd6..8c7068c0a7c 100644 --- a/source/blender/editors/gpencil/gpencil_data.c +++ b/source/blender/editors/gpencil/gpencil_data.c @@ -1561,7 +1561,7 @@ static int gp_brush_select_exec(bContext *C, wmOperator *op) const int index = RNA_int_get(op->ptr, "index"); - Paint *paint = BKE_brush_get_gpencil_paint(ts); + Paint *paint = &ts->gp_paint->paint; int i = 0; for (Brush *brush = bmain->brush.first; brush; brush = brush->id.next) { if (brush->ob_mode == OB_MODE_GPENCIL_PAINT) { diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 12dc3451902..fc50fa7359f 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -319,7 +319,8 @@ static int gpencil_paintmode_toggle_exec(bContext *C, wmOperator *op) if (mode == OB_MODE_GPENCIL_PAINT) { /* be sure we have brushes */ - Paint *paint = BKE_brush_get_gpencil_paint(ts); + BKE_paint_ensure(ts, (Paint **)&ts->gp_paint); + Paint *paint = &ts->gp_paint->paint; /* if not exist, create a new one */ if (paint->brush == NULL) { BKE_brush_gpencil_presets(C); diff --git a/source/blender/editors/gpencil/gpencil_old.c b/source/blender/editors/gpencil/gpencil_old.c index 1474e948920..a2012be223d 100644 --- a/source/blender/editors/gpencil/gpencil_old.c +++ b/source/blender/editors/gpencil/gpencil_old.c @@ -105,7 +105,6 @@ static int gpencil_convert_old_files_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); - ToolSettings *ts = CTX_data_tool_settings(C); ViewLayer *view_layer = CTX_data_view_layer(C); /* Convert grease pencil scene datablock to GP object */ @@ -114,13 +113,6 @@ static int gpencil_convert_old_files_exec(bContext *C, wmOperator *UNUSED(op)) ob = BKE_object_add_for_data(bmain, view_layer, OB_GPENCIL, "GP_Scene", &scene->gpd->id, false); zero_v3(ob->loc); - Paint *paint = BKE_brush_get_gpencil_paint(ts); - /* if not exist, create a new one */ - if (paint->brush == NULL) { - /* create new brushes */ - BKE_brush_gpencil_presets(C); - } - /* convert grease pencil palettes (version >= 2.78) to materials and weights */ bGPdata *gpd = scene->gpd; for (const bGPDpalette *palette = gpd->palettes.first; palette; palette = palette->next) { diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index afd91d50e1f..a0cc149fd90 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -1641,7 +1641,7 @@ static void gp_session_validatebuffer(tGPsdata *p) static Brush *gp_get_default_eraser(Main *bmain, ToolSettings *ts) { Brush *brush_dft = NULL; - Paint *paint = BKE_brush_get_gpencil_paint(ts); + Paint *paint = &ts->gp_paint->paint; Brush *brush_old = paint->brush; for (Brush *brush = bmain->brush.first; brush; brush = brush->id.next) { if ((brush->ob_mode == OB_MODE_GPENCIL_PAINT) && @@ -1685,7 +1685,7 @@ static void gp_init_drawing_brush(bContext *C, tGPsdata *p) Scene *scene = CTX_data_scene(C); ToolSettings *ts = CTX_data_tool_settings(C); - Paint *paint = BKE_brush_get_gpencil_paint(ts); + Paint *paint = &ts->gp_paint->paint; /* if not exist, create a new one */ if (paint->brush == NULL) { diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c index 338fb7f5c6a..5f50c2f7a82 100644 --- a/source/blender/editors/gpencil/gpencil_primitive.c +++ b/source/blender/editors/gpencil/gpencil_primitive.c @@ -144,7 +144,7 @@ static void gp_primitive_set_initdata(bContext *C, tGPDprimitive *tgpi) Brush *brush; /* if brush doesn't exist, create a new one */ - Paint *paint = BKE_brush_get_gpencil_paint(ts); + Paint *paint = &ts->gp_paint->paint; /* if not exist, create a new one */ if (paint->brush == NULL) { /* create new brushes */ diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c index 5b8c11ac38c..41ea3a2138d 100644 --- a/source/blender/editors/gpencil/gpencil_utils.c +++ b/source/blender/editors/gpencil/gpencil_utils.c @@ -1201,7 +1201,8 @@ void ED_gpencil_add_defaults(bContext *C) /* ensure color exist */ BKE_gpencil_material_ensure(bmain, ob); - Paint *paint = BKE_brush_get_gpencil_paint(ts); + BKE_paint_ensure(ts, (Paint **)&ts->gp_paint); + Paint *paint = &ts->gp_paint->paint; /* if not exist, create a new one */ if (paint->brush == NULL) { /* create new brushes */ |