diff options
author | Antonioya <blendergit@gmail.com> | 2018-08-28 00:16:02 +0300 |
---|---|---|
committer | Antonioya <blendergit@gmail.com> | 2018-08-28 00:16:02 +0300 |
commit | 9195b5b3b138a8c5c18196bd7b1f421574e46d02 (patch) | |
tree | 173b25827c15a3ba1a7cf7e2731ef0687ae5a526 /source/blender/editors/gpencil | |
parent | 35c1baef27b81959d2c16f9f5e935fc91fb02667 (diff) |
GP: Replace custom function by standard API
Replace BKE_gpencil_get_material_index by BKE_object_material_slot_find_index
Diffstat (limited to 'source/blender/editors/gpencil')
7 files changed, 14 insertions, 14 deletions
diff --git a/source/blender/editors/gpencil/gpencil_add_monkey.c b/source/blender/editors/gpencil/gpencil_add_monkey.c index 78286e3f672..0f19485b3f7 100644 --- a/source/blender/editors/gpencil/gpencil_add_monkey.c +++ b/source/blender/editors/gpencil/gpencil_add_monkey.c @@ -72,7 +72,7 @@ static int gpencil_monkey_color(Main *bmain, Object *ob, const ColorTemplate *pc copy_v4_v4(ma->gp_style->stroke_rgba, pct->line); copy_v4_v4(ma->gp_style->fill_rgba, pct->fill); - return BKE_gpencil_get_material_index(ob, ma) - 1; + return BKE_object_material_slot_find_index(ob, ma) - 1; } /* ***************************************************************** */ diff --git a/source/blender/editors/gpencil/gpencil_add_stroke.c b/source/blender/editors/gpencil/gpencil_add_stroke.c index 310abbe60f1..c99c93d4ac7 100644 --- a/source/blender/editors/gpencil/gpencil_add_stroke.c +++ b/source/blender/editors/gpencil/gpencil_add_stroke.c @@ -72,7 +72,7 @@ static int gp_stroke_material(Main *bmain, Object *ob, const ColorTemplate *pct) copy_v4_v4(ma->gp_style->stroke_rgba, pct->line); copy_v4_v4(ma->gp_style->fill_rgba, pct->fill); - return BKE_gpencil_get_material_index(ob, ma) - 1; + return BKE_object_material_slot_find_index(ob, ma) - 1; } /* ***************************************************************** */ diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c index 6eff4d3687f..b7fc911100f 100644 --- a/source/blender/editors/gpencil/gpencil_brush.c +++ b/source/blender/editors/gpencil/gpencil_brush.c @@ -1066,8 +1066,8 @@ static void gp_brush_clone_add(bContext *C, tGP_BrushEditData *gso) /* Fix color references */ Material *ma = BLI_ghash_lookup(data->new_colors, &new_stroke->mat_nr); - if ((ma) && (BKE_gpencil_get_material_index(ob, ma) > 0)) { - gps->mat_nr = BKE_gpencil_get_material_index(ob, ma) - 1; + if ((ma) && (BKE_object_material_slot_find_index(ob, ma) > 0)) { + gps->mat_nr = BKE_object_material_slot_find_index(ob, ma) - 1; CLAMP_MIN(gps->mat_nr, 0); } else { diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c index 954d012fd24..8533dbbba4c 100644 --- a/source/blender/editors/gpencil/gpencil_data.c +++ b/source/blender/editors/gpencil/gpencil_data.c @@ -1373,7 +1373,7 @@ static int gp_stroke_change_color_exec(bContext *C, wmOperator *op) } } /* try to find slot */ - int idx = BKE_gpencil_get_material_index(ob, ma) - 1; + int idx = BKE_object_material_slot_find_index(ob, ma) - 1; if (idx <= 0) { return OPERATOR_CANCELLED; } @@ -2123,7 +2123,7 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op) for (short i = 0; i < *totcol; i++) { Material *tmp_ma = give_current_material(ob_src, i + 1); - if (BKE_gpencil_get_material_index(ob_dst, tmp_ma) == 0) { + if (BKE_object_material_slot_find_index(ob_dst, tmp_ma) == 0) { BKE_object_material_slot_add(bmain, ob_dst); assign_material(bmain, ob_dst, tmp_ma, ob_dst->totcol, BKE_MAT_ASSIGN_USERPREF); } @@ -2163,7 +2163,7 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op) /* reasign material. Look old material and try to find in dst */ ma_src = give_current_material(ob_src, gps->mat_nr + 1); if (ma_src != NULL) { - idx = BKE_gpencil_get_material_index(ob_dst, ma_src); + idx = BKE_object_material_slot_find_index(ob_dst, ma_src); if (idx > 0) { gps->mat_nr = idx - 1; } diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 3d169dceb4c..17853182c18 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -768,7 +768,7 @@ GHash *gp_copybuf_validate_colormap(bContext *C) char *ma_name = BLI_ghashIterator_getValue(&gh_iter); Material *ma = BLI_ghash_lookup(name_to_ma, ma_name); - if (ma != NULL && BKE_gpencil_get_material_index(ob, ma) == 0) { + if (ma != NULL && BKE_object_material_slot_find_index(ob, ma) == 0) { BKE_object_material_slot_add(bmain, ob); assign_material(bmain, ob, ma, ob->totcol, BKE_MAT_ASSIGN_USERPREF); } @@ -1022,8 +1022,8 @@ static int gp_strokes_paste_exec(bContext *C, wmOperator *op) /* Remap material */ Material *ma = BLI_ghash_lookup(new_colors, &new_stroke->mat_nr); - if ((ma) && (BKE_gpencil_get_material_index(ob, ma) > 0)) { - gps->mat_nr = BKE_gpencil_get_material_index(ob, ma) - 1; + if ((ma) && (BKE_object_material_slot_find_index(ob, ma) > 0)) { + gps->mat_nr = BKE_object_material_slot_find_index(ob, ma) - 1; CLAMP_MIN(gps->mat_nr, 0); } else { @@ -3240,7 +3240,7 @@ static int gp_stroke_separate_exec(bContext *C, wmOperator *op) /* add duplicate materials */ ma = give_current_material(ob, gps->mat_nr + 1); - idx = BKE_gpencil_get_material_index(ob_dst, ma); + idx = BKE_object_material_slot_find_index(ob_dst, ma); if (idx == 0) { totadd++; diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index aa163e02cfe..113950075fc 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -1164,7 +1164,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) } /* Save material index */ - gps->mat_nr = BKE_gpencil_get_material_index(p->ob, p->material) - 1; + gps->mat_nr = BKE_object_material_slot_find_index(p->ob, p->material) - 1; /* calculate UVs along the stroke */ ED_gpencil_calc_stroke_uv(obact, gps); @@ -1616,7 +1616,7 @@ static void gp_init_colors(tGPsdata *p) } /* check if the material is already on object material slots and add it if missing */ - if (BKE_gpencil_get_material_index(p->ob, p->material) == 0) { + if (BKE_object_material_slot_find_index(p->ob, p->material) == 0) { BKE_object_material_slot_add(p->bmain, p->ob); assign_material(p->bmain, p->ob, ma, p->ob->totcol, BKE_MAT_ASSIGN_USERPREF); } diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c index 6fa7d0b7a81..28c6f83522d 100644 --- a/source/blender/editors/gpencil/gpencil_primitive.c +++ b/source/blender/editors/gpencil/gpencil_primitive.c @@ -177,7 +177,7 @@ static void gp_primitive_set_initdata(bContext *C, tGPDprimitive *tgpi) gps->flag |= GP_STROKE_CYCLIC; gps->flag |= GP_STROKE_3DSPACE; - gps->mat_nr = BKE_gpencil_get_material_index(tgpi->ob, tgpi->mat) - 1; + gps->mat_nr = BKE_object_material_slot_find_index(tgpi->ob, tgpi->mat) - 1; /* allocate memory for storage points, but keep empty */ gps->totpoints = 0; |