Commit: 9195b5b3b138a8c5c18196bd7b1f421574e46d02
Author: Antonioya
Date:   Mon Aug 27 23:16:02 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB9195b5b3b138a8c5c18196bd7b1f421574e46d02

GP: Replace custom function by standard API

Replace BKE_gpencil_get_material_index by BKE_object_material_slot_find_index

===================================================================

M       release/scripts/addons
M       release/scripts/addons_contrib
M       source/blender/blenkernel/BKE_gpencil.h
M       source/blender/blenkernel/intern/gpencil.c
M       source/blender/editors/gpencil/gpencil_add_monkey.c
M       source/blender/editors/gpencil/gpencil_add_stroke.c
M       source/blender/editors/gpencil/gpencil_brush.c
M       source/blender/editors/gpencil/gpencil_data.c
M       source/blender/editors/gpencil/gpencil_edit.c
M       source/blender/editors/gpencil/gpencil_paint.c
M       source/blender/editors/gpencil/gpencil_primitive.c
M       source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
M       source/blender/makesrna/intern/rna_brush.c
M       source/tools

===================================================================

diff --git a/release/scripts/addons b/release/scripts/addons
index 9ae033c49c1..371960484a3 160000
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit 9ae033c49c1b16718eac6306bdc271a5e6e6bf38
+Subproject commit 371960484a38fc64e0a2635170a41a0d8ab2f6bd
diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib
index f178e6c933a..15b25a42783 160000
--- a/release/scripts/addons_contrib
+++ b/release/scripts/addons_contrib
@@ -1 +1 @@
-Subproject commit f178e6c933a25c621a5cc7d92935b66cd2ec2f5d
+Subproject commit 15b25a42783d1e516b5298d70b582fae2559ae17
diff --git a/source/blender/blenkernel/BKE_gpencil.h 
b/source/blender/blenkernel/BKE_gpencil.h
index 0aa7a0de7e6..443d3426868 100644
--- a/source/blender/blenkernel/BKE_gpencil.h
+++ b/source/blender/blenkernel/BKE_gpencil.h
@@ -94,7 +94,6 @@ void BKE_gpencil_frame_delete_laststroke(struct bGPDlayer 
*gpl, struct bGPDframe
 /* materials */
 void BKE_gpencil_material_index_remove(struct bGPdata *gpd, int index);
 void BKE_gpencil_material_remap(struct bGPdata *gpd, const unsigned int 
*remap, unsigned int remap_len);
-int BKE_gpencil_get_material_index(struct Object *ob, struct Material *ma);
 
 /* statistics functions */
 void BKE_gpencil_stats_update(struct bGPdata *gpd);
diff --git a/source/blender/blenkernel/intern/gpencil.c 
b/source/blender/blenkernel/intern/gpencil.c
index 6d771148723..4f126e065d0 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -1543,18 +1543,3 @@ void BKE_gpencil_stats_update(bGPdata *gpd)
        }
 
 }
-
-/* get material index */
-int BKE_gpencil_get_material_index(Object *ob, Material *ma)
-{
-       short *totcol = give_totcolp(ob);
-       Material *read_ma = NULL;
-       for (short i = 0; i < *totcol; i++) {
-               read_ma = give_current_material(ob, i + 1);
-               if (ma == read_ma) {
-                       return i + 1;
-               }
-       }
-
-       return 0;
-}
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;
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c 
b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
index 610465c4c94..8a57d0c6740 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
@@ -171,7 +171,7 @@ void gpencil_apply_modifier_material(
                        DEG_id_tag_update(&newmat->id, DEG_TAG_COPY_ON_WRITE);
                }
                /* reasign color index */
-               int idx = BKE_gpencil_get_material_index(ob, newmat);
+               int idx = BKE_object_material_slot_find_index(ob, newmat);
                gps->mat_nr = idx - 1;
        }
        else {
diff --git a/source/blender/makesrna/intern/rna_brush.c 
b/source/blender/makesrna/intern/rna_brush.c
index 3df84a3a85b..bc5b1fa7f13 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -171,6 +171,7 @@ static EnumPropertyItem 
rna_enum_gpencil_brush_icons_items[] = {
 #include "BKE_colorband.h"
 #include "BKE_brush.h"
 #include "BKE_icons.h"
+#include "BKE_material.h"
 #include "BKE_gpencil.h"
 #include "BKE_paint.h"
 
@@ -425,7 +426,7 @@ static void rna_Brush_material_update(bContext *C, 
PointerRNA *ptr)
                BrushGpencilSettings *gpencil_settings = br->gpencil_settings;
                if (gpencil_settings->material != NULL) {
 
-                       index = BKE_gpencil_get_material_index(ob, 
gpencil_settings->material);
+                       index = BKE_object_material_slot_find_index(ob, 
gpencil_settings->material);
                        if ((index > 0) && (ob->actcol != index)) {
                                ob->actcol = index;
                                /* update 

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to