Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-11-05 07:31:25 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-11-05 07:31:25 +0300
commit8b31f6fb2169e7163767e382adbef13587305aca (patch)
tree23609feb5da08a39f8009eb4390f69e6205fc2b1 /source/blender/editors
parent8fcc04edce53c5b3b01bf392e1667878ebcce0ef (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')
-rw-r--r--source/blender/editors/gpencil/gpencil_data.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c3
-rw-r--r--source/blender/editors/gpencil/gpencil_old.c8
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c4
-rw-r--r--source/blender/editors/gpencil/gpencil_primitive.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_utils.c3
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_uv.c7
7 files changed, 10 insertions, 19 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 */
diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c
index 897539bddd7..c5cebed0b8b 100644
--- a/source/blender/editors/sculpt_paint/sculpt_uv.c
+++ b/source/blender/editors/sculpt_paint/sculpt_uv.c
@@ -236,15 +236,12 @@ void ED_space_image_uv_sculpt_update(Main *bmain, wmWindowManager *wm, Scene *sc
{
ToolSettings *settings = scene->toolsettings;
if (settings->use_uv_sculpt) {
- if (!settings->uvsculpt) {
- settings->uvsculpt = MEM_callocN(sizeof(*settings->uvsculpt), "UV Smooth paint");
+ if (settings->uvsculpt == NULL) {
settings->uv_sculpt_tool = UV_SCULPT_TOOL_GRAB;
settings->uv_sculpt_settings = UV_SCULPT_LOCK_BORDERS | UV_SCULPT_ALL_ISLANDS;
settings->uv_relax_method = UV_SCULPT_TOOL_RELAX_LAPLACIAN;
- /* Uv sculpting does not include explicit brush view control yet, always enable */
- settings->uvsculpt->paint.flags |= PAINT_SHOW_BRUSH;
}
-
+ BKE_paint_ensure(settings, (Paint **)&settings->uvsculpt);
BKE_paint_init(bmain, scene, ePaintSculptUV, PAINT_CURSOR_SCULPT);
settings->uvsculpt->paint.paint_cursor = WM_paint_cursor_activate(