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:
authorAntonioya <blendergit@gmail.com>2018-08-28 09:16:30 +0300
committerAntonioya <blendergit@gmail.com>2018-08-28 09:18:09 +0300
commit9a9b1e98849131358041cf2bb83bf7b7c9828119 (patch)
tree290cba0b98a1c6937670d8f578c189039123700a
parent039b11f3497731572e36904b03550438b706df34 (diff)
GP: Revert replace custom function by standard API
Using custom api breaks material at object level
-rw-r--r--source/blender/blenkernel/BKE_gpencil.h1
-rw-r--r--source/blender/blenkernel/intern/gpencil.c15
-rw-r--r--source/blender/editors/gpencil/gpencil_add_monkey.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_add_stroke.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_brush.c4
-rw-r--r--source/blender/editors/gpencil/gpencil_data.c6
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c8
-rw-r--r--source/blender/editors/gpencil/gpencil_fill.c2
-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/gpencil_modifiers/intern/MOD_gpencil_util.c2
-rw-r--r--source/blender/makesrna/intern/rna_brush.c3
12 files changed, 33 insertions, 18 deletions
diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h
index 443d3426868..0aa7a0de7e6 100644
--- a/source/blender/blenkernel/BKE_gpencil.h
+++ b/source/blender/blenkernel/BKE_gpencil.h
@@ -94,6 +94,7 @@ 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 4f126e065d0..6d771148723 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -1543,3 +1543,18 @@ 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 0f19485b3f7..78286e3f672 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_object_material_slot_find_index(ob, ma) - 1;
+ return BKE_gpencil_get_material_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 c99c93d4ac7..310abbe60f1 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_object_material_slot_find_index(ob, ma) - 1;
+ return BKE_gpencil_get_material_index(ob, ma) - 1;
}
/* ***************************************************************** */
diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c
index b7fc911100f..6eff4d3687f 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_object_material_slot_find_index(ob, ma) > 0)) {
- gps->mat_nr = BKE_object_material_slot_find_index(ob, ma) - 1;
+ if ((ma) && (BKE_gpencil_get_material_index(ob, ma) > 0)) {
+ gps->mat_nr = BKE_gpencil_get_material_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 14c5d35c78a..84706966c60 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_object_material_slot_find_index(ob, ma) - 1;
+ int idx = BKE_gpencil_get_material_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_object_material_slot_find_index(ob_dst, tmp_ma) == 0) {
+ if (BKE_gpencil_get_material_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_object_material_slot_find_index(ob_dst, ma_src);
+ idx = BKE_gpencil_get_material_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 49202149d31..df786b4e675 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_object_material_slot_find_index(ob, ma) == 0) {
+ if (ma != NULL && BKE_gpencil_get_material_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_object_material_slot_find_index(ob, ma) > 0)) {
- gps->mat_nr = BKE_object_material_slot_find_index(ob, ma) - 1;
+ if ((ma) && (BKE_gpencil_get_material_index(ob, ma) > 0)) {
+ gps->mat_nr = BKE_gpencil_get_material_index(ob, ma) - 1;
CLAMP_MIN(gps->mat_nr, 0);
}
else {
@@ -3239,7 +3239,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_object_material_slot_find_index(ob_dst, ma);
+ idx = BKE_gpencil_get_material_index(ob_dst, ma);
if (idx == 0) {
totadd++;
diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c
index 6d1c2c56d7b..09a21cbca1e 100644
--- a/source/blender/editors/gpencil/gpencil_fill.c
+++ b/source/blender/editors/gpencil/gpencil_fill.c
@@ -841,7 +841,7 @@ static void gpencil_stroke_from_buffer(tGPDfill *tgpf)
gps->flag |= GP_STROKE_CYCLIC;
gps->flag |= GP_STROKE_3DSPACE;
- gps->mat_nr = BKE_object_material_slot_find_index(tgpf->ob, tgpf->mat) - 1;
+ gps->mat_nr = BKE_gpencil_get_material_index(tgpf->ob, tgpf->mat) - 1;
if (gps->mat_nr < 0) {
BKE_object_material_slot_add(tgpf->bmain, tgpf->ob);
assign_material(tgpf->bmain, tgpf->ob, tgpf->mat, tgpf->ob->totcol, BKE_MAT_ASSIGN_USERPREF);
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 113950075fc..aa163e02cfe 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_object_material_slot_find_index(p->ob, p->material) - 1;
+ gps->mat_nr = BKE_gpencil_get_material_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_object_material_slot_find_index(p->ob, p->material) == 0) {
+ if (BKE_gpencil_get_material_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 28c6f83522d..6fa7d0b7a81 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_object_material_slot_find_index(tgpi->ob, tgpi->mat) - 1;
+ gps->mat_nr = BKE_gpencil_get_material_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 5c2e5e89d0b..9ddc6a1e3e4 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_object_material_slot_find_index(ob, newmat);
+ int idx = BKE_gpencil_get_material_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 bc5b1fa7f13..3df84a3a85b 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -171,7 +171,6 @@ 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"
@@ -426,7 +425,7 @@ static void rna_Brush_material_update(bContext *C, PointerRNA *ptr)
BrushGpencilSettings *gpencil_settings = br->gpencil_settings;
if (gpencil_settings->material != NULL) {
- index = BKE_object_material_slot_find_index(ob, gpencil_settings->material);
+ index = BKE_gpencil_get_material_index(ob, gpencil_settings->material);
if ((index > 0) && (ob->actcol != index)) {
ob->actcol = index;
/* update other brushes to keep all synchro */