diff options
author | Antonio Vazquez <blendergit@gmail.com> | 2020-02-05 13:23:58 +0300 |
---|---|---|
committer | Antonio Vazquez <blendergit@gmail.com> | 2020-02-05 17:56:50 +0300 |
commit | 1bc2a98a9d609e54c928672f148edfba9d5f8c5a (patch) | |
tree | 0884042019d5c886348e643d30744b4bdcf5a60f /source/blender/editors | |
parent | 06c560864607562acdc1e61b13369f24b22c102c (diff) |
T73589: Code Quality: Renaming on BKE_material.h
Old Name New Name
========= =========
init_def_material BKE_materials_init
BKE_material_gpencil_default_free BKE_materials_exit
test_object_materials BKE_object_materials_test
test_all_objects_materials BKE_objects_materials_test_all
give_matarar BKE_object_material_array
give_totcolp BKE_object_material_num
give_current_material_p BKE_object_material_get_p
give_current_material BKE_object_material_get
assign_material BKE_object_material_assign
assign_matarar BKE_object_material_array_assign
give_matarar_id BKE_id_material_array
give_totcolp_id BKE_id_material_num
assign_material_id BKE_id_material_assign
clear_matcopybuf BKE_material_copybuf_clear
free_matcopybuf BKE_material_copybuf_free
copy_matcopybuf BKE_material_copybuf_copy
paste_matcopybuf BKE_material_copybuf_paste
BKE_material_init_gpencil_settings BKE_gpencil_material_attr_init
BKE_material_add_gpencil BKE_gpencil_material_add
BKE_material_gpencil_get BKE_gpencil_material
BKE_material_gpencil_default_get BKE_gpencil_material_default
BKE_material_gpencil_settings_get BKE_gpencil_material_settings
Diffstat (limited to 'source/blender/editors')
26 files changed, 97 insertions, 97 deletions
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 4c81df8b71d..b3a9353bb74 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -2296,7 +2296,7 @@ static size_t animdata_filter_ds_materials( /* First pass: take the materials referenced via the Material slots of the object. */ for (a = 1; a <= ob->totcol; a++) { - Material *ma = give_current_material(ob, a); + Material *ma = BKE_object_material_get(ob, a); /* if material is valid, try to add relevant contents from here */ if (ma) { @@ -2319,7 +2319,7 @@ static size_t animdata_filter_ds_materials( */ if (has_nested) { for (a = 1; a <= ob->totcol; a++) { - Material *base = give_current_material(ob, a); + Material *base = BKE_object_material_get(ob, a); Material *ma = give_node_material(base); /* add channels from the nested material if it exists diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 14b1f6523d9..188192e10ae 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -2848,7 +2848,7 @@ static bool object_frame_has_keyframe(Object *ob, float frame, short filter) if (!(filter & ANIMFILTER_KEYS_LOCAL) && !(filter & ANIMFILTER_KEYS_NOMAT)) { /* if only active, then we can skip a lot of looping */ if (filter & ANIMFILTER_KEYS_ACTIVE) { - Material *ma = give_current_material(ob, (ob->actcol + 1)); + Material *ma = BKE_object_material_get(ob, (ob->actcol + 1)); /* we only retrieve the active material... */ if (id_frame_has_keyframe((ID *)ma, frame, filter)) { @@ -2860,7 +2860,7 @@ static bool object_frame_has_keyframe(Object *ob, float frame, short filter) /* loop over materials */ for (a = 0; a < ob->totcol; a++) { - Material *ma = give_current_material(ob, a + 1); + Material *ma = BKE_object_material_get(ob, a + 1); if (id_frame_has_keyframe((ID *)ma, frame, filter)) { return true; diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index 06e5f36637b..3fb2e1135e8 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -430,7 +430,7 @@ static void gp_draw_stroke_fill(bGPdata *gpd, BLI_assert(gps->totpoints >= 3); const bool use_mat = (gpd->mat != NULL); - Material *ma = (use_mat) ? gpd->mat[gps->mat_nr] : BKE_material_gpencil_default_get(); + Material *ma = (use_mat) ? gpd->mat[gps->mat_nr] : BKE_gpencil_material_default(); MaterialGPencilStyle *gp_style = (ma) ? ma->gp_style : NULL; /* Calculate triangles cache for filling area (must be done only after changes) */ @@ -884,7 +884,7 @@ static void gp_draw_strokes(tGPDdraw *tgpw) continue; } /* check if the color is visible */ - Material *ma = (use_mat) ? tgpw->gpd->mat[gps->mat_nr] : BKE_material_gpencil_default_get(); + Material *ma = (use_mat) ? tgpw->gpd->mat[gps->mat_nr] : BKE_gpencil_material_default(); MaterialGPencilStyle *gp_style = (ma) ? ma->gp_style : NULL; if ((gp_style == NULL) || (gp_style->flag & GP_STYLE_COLOR_HIDE) || diff --git a/source/blender/editors/gpencil/gpencil_add_monkey.c b/source/blender/editors/gpencil/gpencil_add_monkey.c index 139697ad0e3..7dc3aa1273f 100644 --- a/source/blender/editors/gpencil/gpencil_add_monkey.c +++ b/source/blender/editors/gpencil/gpencil_add_monkey.c @@ -51,10 +51,10 @@ typedef struct ColorTemplate { static int gpencil_monkey_color( Main *bmain, Object *ob, const ColorTemplate *pct, bool stroke, bool fill) { - short *totcol = give_totcolp(ob); + short *totcol = BKE_object_material_num(ob); Material *ma = NULL; for (short i = 0; i < *totcol; i++) { - ma = BKE_material_gpencil_get(ob, i + 1); + ma = BKE_gpencil_material(ob, i + 1); if (STREQ(ma->id.name, pct->name)) { return i; } diff --git a/source/blender/editors/gpencil/gpencil_add_stroke.c b/source/blender/editors/gpencil/gpencil_add_stroke.c index 74617599eaa..539f80846fd 100644 --- a/source/blender/editors/gpencil/gpencil_add_stroke.c +++ b/source/blender/editors/gpencil/gpencil_add_stroke.c @@ -50,10 +50,10 @@ typedef struct ColorTemplate { /* Add color an ensure duplications (matched by name) */ static int gp_stroke_material(Main *bmain, Object *ob, const ColorTemplate *pct, const bool fill) { - short *totcol = give_totcolp(ob); + short *totcol = BKE_object_material_num(ob); Material *ma = NULL; for (short i = 0; i < *totcol; i++) { - ma = BKE_material_gpencil_get(ob, i + 1); + ma = BKE_gpencil_material(ob, i + 1); if (STREQ(ma->id.name, pct->name)) { return i; } diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c index fa23dd5e059..77f7df25316 100644 --- a/source/blender/editors/gpencil/gpencil_data.c +++ b/source/blender/editors/gpencil/gpencil_data.c @@ -572,7 +572,7 @@ static int gp_layer_duplicate_object_exec(bContext *C, wmOperator *op) /* Check if material is in destination object, * otherwise add the slot with the material. */ - Material *ma_src = give_current_material(ob_src, gps_src->mat_nr + 1); + Material *ma_src = BKE_object_material_get(ob_src, gps_src->mat_nr + 1); if (ma_src != NULL) { int idx = BKE_gpencil_object_material_ensure(bmain, ob_dst, ma_src); @@ -1460,7 +1460,7 @@ static int gp_stroke_change_color_exec(bContext *C, wmOperator *op) bGPdata *gpd = ED_gpencil_data_get_active(C); Object *ob = CTX_data_active_object(C); if (name[0] == '\0') { - ma = BKE_material_gpencil_get(ob, ob->actcol); + ma = BKE_gpencil_material(ob, ob->actcol); } else { ma = (Material *)BKE_libblock_find_name(bmain, ID_MA, name); @@ -1551,7 +1551,7 @@ static int gp_stroke_lock_color_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob = CTX_data_active_object(C); - short *totcol = give_totcolp(ob); + short *totcol = BKE_object_material_num(ob); /* sanity checks */ if (ELEM(NULL, gpd)) { @@ -1560,7 +1560,7 @@ static int gp_stroke_lock_color_exec(bContext *C, wmOperator *UNUSED(op)) /* first lock all colors */ for (short i = 0; i < *totcol; i++) { - Material *tmp_ma = give_current_material(ob, i + 1); + Material *tmp_ma = BKE_object_material_get(ob, i + 1); if (tmp_ma) { tmp_ma->gp_style->flag |= GP_STYLE_COLOR_LOCKED; DEG_id_tag_update(&tmp_ma->id, ID_RECALC_COPY_ON_WRITE); @@ -1579,7 +1579,7 @@ static int gp_stroke_lock_color_exec(bContext *C, wmOperator *UNUSED(op)) continue; } /* unlock color */ - Material *tmp_ma = give_current_material(ob, gps->mat_nr + 1); + Material *tmp_ma = BKE_object_material_get(ob, gps->mat_nr + 1); if (tmp_ma) { tmp_ma->gp_style->flag &= ~GP_STYLE_COLOR_LOCKED; DEG_id_tag_update(&tmp_ma->id, ID_RECALC_COPY_ON_WRITE); @@ -2343,10 +2343,10 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op) } /* add missing materials reading source materials and checking in destination object */ - short *totcol = give_totcolp(ob_src); + short *totcol = BKE_object_material_num(ob_src); for (short i = 0; i < *totcol; i++) { - Material *tmp_ma = BKE_material_gpencil_get(ob_src, i + 1); + Material *tmp_ma = BKE_gpencil_material(ob_src, i + 1); BKE_gpencil_object_material_ensure(bmain, ob_dst, tmp_ma); } @@ -2380,7 +2380,7 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op) for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) { /* Reassign material. Look old material and try to find in destination. */ - ma_src = BKE_material_gpencil_get(ob_src, gps->mat_nr + 1); + ma_src = BKE_gpencil_material(ob_src, gps->mat_nr + 1); gps->mat_nr = BKE_gpencil_object_material_ensure(bmain, ob_dst, ma_src); bGPDspoint *pt; @@ -2462,7 +2462,7 @@ static bool gpencil_active_color_poll(bContext *C) { Object *ob = CTX_data_active_object(C); if (ob && ob->data && (ob->type == OB_GPENCIL)) { - short *totcolp = give_totcolp(ob); + short *totcolp = BKE_object_material_num(ob); return *totcolp > 0; } return false; @@ -2482,13 +2482,13 @@ static int gpencil_lock_layer_exec(bContext *C, wmOperator *UNUSED(op)) /* first lock and hide all colors */ Material *ma = NULL; - short *totcol = give_totcolp(ob); + short *totcol = BKE_object_material_num(ob); if (totcol == 0) { return OPERATOR_CANCELLED; } for (short i = 0; i < *totcol; i++) { - ma = BKE_material_gpencil_get(ob, i + 1); + ma = BKE_gpencil_material(ob, i + 1); if (ma) { gp_style = ma->gp_style; gp_style->flag |= GP_STYLE_COLOR_LOCKED; @@ -2508,7 +2508,7 @@ static int gpencil_lock_layer_exec(bContext *C, wmOperator *UNUSED(op)) continue; } - ma = BKE_material_gpencil_get(ob, gps->mat_nr + 1); + ma = BKE_gpencil_material(ob, gps->mat_nr + 1); DEG_id_tag_update(&ma->id, ID_RECALC_COPY_ON_WRITE); gp_style = ma->gp_style; @@ -2551,8 +2551,8 @@ static int gpencil_color_isolate_exec(bContext *C, wmOperator *op) { bGPdata *gpd = ED_gpencil_data_get_active(C); Object *ob = CTX_data_active_object(C); - Material *active_ma = BKE_material_gpencil_get(ob, ob->actcol); - MaterialGPencilStyle *active_color = BKE_material_gpencil_settings_get(ob, ob->actcol); + Material *active_ma = BKE_gpencil_material(ob, ob->actcol); + MaterialGPencilStyle *active_color = BKE_gpencil_material_settings(ob, ob->actcol); MaterialGPencilStyle *gp_style; int flags = GP_STYLE_COLOR_LOCKED; @@ -2569,9 +2569,9 @@ static int gpencil_color_isolate_exec(bContext *C, wmOperator *op) /* Test whether to isolate or clear all flags */ Material *ma = NULL; - short *totcol = give_totcolp(ob); + short *totcol = BKE_object_material_num(ob); for (short i = 0; i < *totcol; i++) { - ma = BKE_material_gpencil_get(ob, i + 1); + ma = BKE_gpencil_material(ob, i + 1); /* Skip if this is the active one */ if ((ma == NULL) || (ma == active_ma)) { continue; @@ -2591,7 +2591,7 @@ static int gpencil_color_isolate_exec(bContext *C, wmOperator *op) if (isolate) { /* Set flags on all "other" colors */ for (short i = 0; i < *totcol; i++) { - ma = BKE_material_gpencil_get(ob, i + 1); + ma = BKE_gpencil_material(ob, i + 1); if (ma == NULL) { continue; } @@ -2608,7 +2608,7 @@ static int gpencil_color_isolate_exec(bContext *C, wmOperator *op) else { /* Clear flags - Restore everything else */ for (short i = 0; i < *totcol; i++) { - ma = BKE_material_gpencil_get(ob, i + 1); + ma = BKE_gpencil_material(ob, i + 1); if (ma == NULL) { continue; } @@ -2659,12 +2659,12 @@ static int gpencil_color_hide_exec(bContext *C, wmOperator *op) { Object *ob = CTX_data_active_object(C); bGPdata *gpd = (bGPdata *)ob->data; - MaterialGPencilStyle *active_color = BKE_material_gpencil_settings_get(ob, ob->actcol); + MaterialGPencilStyle *active_color = BKE_gpencil_material_settings(ob, ob->actcol); bool unselected = RNA_boolean_get(op->ptr, "unselected"); Material *ma = NULL; - short *totcol = give_totcolp(ob); + short *totcol = BKE_object_material_num(ob); if (totcol == 0) { return OPERATOR_CANCELLED; } @@ -2673,7 +2673,7 @@ static int gpencil_color_hide_exec(bContext *C, wmOperator *op) /* hide unselected */ MaterialGPencilStyle *color = NULL; for (short i = 0; i < *totcol; i++) { - ma = BKE_material_gpencil_get(ob, i + 1); + ma = BKE_gpencil_material(ob, i + 1); if (ma) { color = ma->gp_style; if (active_color != color) { @@ -2726,7 +2726,7 @@ static int gpencil_color_reveal_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob = CTX_data_active_object(C); bGPdata *gpd = (bGPdata *)ob->data; Material *ma = NULL; - short *totcol = give_totcolp(ob); + short *totcol = BKE_object_material_num(ob); if (totcol == 0) { return OPERATOR_CANCELLED; @@ -2736,7 +2736,7 @@ static int gpencil_color_reveal_exec(bContext *C, wmOperator *UNUSED(op)) MaterialGPencilStyle *gp_style = NULL; for (short i = 0; i < *totcol; i++) { - ma = BKE_material_gpencil_get(ob, i + 1); + ma = BKE_gpencil_material(ob, i + 1); if (ma) { gp_style = ma->gp_style; gp_style->flag &= ~GP_STYLE_COLOR_HIDE; @@ -2779,7 +2779,7 @@ static int gpencil_color_lock_all_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob = CTX_data_active_object(C); bGPdata *gpd = (bGPdata *)ob->data; Material *ma = NULL; - short *totcol = give_totcolp(ob); + short *totcol = BKE_object_material_num(ob); if (totcol == 0) { return OPERATOR_CANCELLED; @@ -2789,7 +2789,7 @@ static int gpencil_color_lock_all_exec(bContext *C, wmOperator *UNUSED(op)) MaterialGPencilStyle *gp_style = NULL; for (short i = 0; i < *totcol; i++) { - ma = BKE_material_gpencil_get(ob, i + 1); + ma = BKE_gpencil_material(ob, i + 1); if (ma) { gp_style = ma->gp_style; gp_style->flag |= GP_STYLE_COLOR_LOCKED; @@ -2832,7 +2832,7 @@ static int gpencil_color_unlock_all_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob = CTX_data_active_object(C); bGPdata *gpd = (bGPdata *)ob->data; Material *ma = NULL; - short *totcol = give_totcolp(ob); + short *totcol = BKE_object_material_num(ob); if (totcol == 0) { return OPERATOR_CANCELLED; @@ -2842,7 +2842,7 @@ static int gpencil_color_unlock_all_exec(bContext *C, wmOperator *UNUSED(op)) MaterialGPencilStyle *gp_style = NULL; for (short i = 0; i < *totcol; i++) { - ma = BKE_material_gpencil_get(ob, i + 1); + ma = BKE_gpencil_material(ob, i + 1); if (ma) { gp_style = ma->gp_style; gp_style->flag &= ~GP_STYLE_COLOR_LOCKED; @@ -2883,7 +2883,7 @@ static int gpencil_color_select_exec(bContext *C, wmOperator *op) { bGPdata *gpd = ED_gpencil_data_get_active(C); Object *ob = CTX_data_active_object(C); - MaterialGPencilStyle *gp_style = BKE_material_gpencil_settings_get(ob, ob->actcol); + MaterialGPencilStyle *gp_style = BKE_gpencil_material_settings(ob, ob->actcol); const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd); const bool deselected = RNA_boolean_get(op->ptr, "deselect"); diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 8d0fe73572f..7f7778639d6 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -1223,7 +1223,7 @@ static int gp_strokes_copy_exec(bContext *C, wmOperator *op) GHash *ma_to_name = gp_strokes_copypastebuf_colors_material_to_name_create(bmain); for (bGPDstroke *gps = gp_strokes_copypastebuf.first; gps; gps = gps->next) { if (ED_gpencil_stroke_can_use(C, gps)) { - Material *ma = give_current_material(ob, gps->mat_nr + 1); + Material *ma = BKE_object_material_get(ob, gps->mat_nr + 1); /* Avoid default material. */ if (ma == NULL) { continue; @@ -2853,7 +2853,7 @@ static int gp_stroke_cyclical_set_exec(bContext *C, wmOperator *op) } for (gps = gpf->strokes.first; gps; gps = gps->next) { - MaterialGPencilStyle *gp_style = BKE_material_gpencil_settings_get(ob, gps->mat_nr + 1); + MaterialGPencilStyle *gp_style = BKE_gpencil_material_settings(ob, gps->mat_nr + 1); /* skip strokes that are not selected or invalid for current view */ if (((gps->flag & GP_STROKE_SELECT) == 0) || ED_gpencil_stroke_can_use(C, gps) == false) { @@ -2967,7 +2967,7 @@ static int gp_stroke_caps_set_exec(bContext *C, wmOperator *op) } for (bGPDstroke *gps = gpl->actframe->strokes.last; gps; gps = gps->prev) { - MaterialGPencilStyle *gp_style = BKE_material_gpencil_settings_get(ob, gps->mat_nr + 1); + MaterialGPencilStyle *gp_style = BKE_gpencil_material_settings(ob, gps->mat_nr + 1); /* skip strokes that are not selected or invalid for current view */ if (((gps->flag & GP_STROKE_SELECT) == 0) || (ED_gpencil_stroke_can_use(C, gps) == false)) { @@ -4136,7 +4136,7 @@ static int gp_stroke_separate_exec(bContext *C, wmOperator *op) /* add duplicate materials */ /* XXX same material can be in multiple slots. */ - ma = BKE_material_gpencil_get(ob, gps->mat_nr + 1); + ma = BKE_gpencil_material(ob, gps->mat_nr + 1); idx = BKE_gpencil_object_material_ensure(bmain, ob_dst, ma); @@ -4209,7 +4209,7 @@ static int gp_stroke_separate_exec(bContext *C, wmOperator *op) if (ED_gpencil_stroke_can_use(C, gps) == false) { continue; } - ma = BKE_material_gpencil_get(ob, gps->mat_nr + 1); + ma = BKE_gpencil_material(ob, gps->mat_nr + 1); gps->mat_nr = BKE_gpencil_object_material_ensure(bmain, ob_dst, ma); } } diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c index 993ec15248f..d3811a61b2a 100644 --- a/source/blender/editors/gpencil/gpencil_fill.c +++ b/source/blender/editors/gpencil/gpencil_fill.c @@ -273,7 +273,7 @@ static void gp_draw_datablock(tGPDfill *tgpf, const float ink[4]) continue; } /* check if the color is visible */ - MaterialGPencilStyle *gp_style = BKE_material_gpencil_settings_get(ob, gps->mat_nr + 1); + MaterialGPencilStyle *gp_style = BKE_gpencil_material_settings(ob, gps->mat_nr + 1); if ((gp_style == NULL) || (gp_style->flag & GP_STYLE_COLOR_HIDE)) { continue; } @@ -1367,7 +1367,7 @@ static int gpencil_fill_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE } } else { - if (give_current_material(ob, ob->actcol) == NULL) { + if (BKE_object_material_get(ob, ob->actcol) == NULL) { valid = false; } } diff --git a/source/blender/editors/gpencil/gpencil_merge.c b/source/blender/editors/gpencil/gpencil_merge.c index 36cef3ccdc0..91339709162 100644 --- a/source/blender/editors/gpencil/gpencil_merge.c +++ b/source/blender/editors/gpencil/gpencil_merge.c @@ -451,7 +451,7 @@ static bool gp_strokes_merge_poll(bContext *C) /* check material */ Material *ma = NULL; - ma = BKE_material_gpencil_get(ob, ob->actcol); + ma = BKE_gpencil_material(ob, ob->actcol); if ((ma == NULL) || (ma->gp_style == NULL)) { return false; } diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c index 4e4ec274a39..413aa6c7394 100644 --- a/source/blender/editors/gpencil/gpencil_utils.c +++ b/source/blender/editors/gpencil/gpencil_utils.c @@ -550,7 +550,7 @@ bool ED_gpencil_stroke_can_use(const bContext *C, const bGPDstroke *gps) bool ED_gpencil_stroke_color_use(Object *ob, const bGPDlayer *gpl, const bGPDstroke *gps) { /* check if the color is editable */ - MaterialGPencilStyle *gp_style = BKE_material_gpencil_settings_get(ob, gps->mat_nr + 1); + MaterialGPencilStyle *gp_style = BKE_gpencil_material_settings(ob, gps->mat_nr + 1); if (gp_style != NULL) { if (gp_style->flag & GP_STYLE_COLOR_HIDE) { @@ -2036,7 +2036,7 @@ void ED_gpencil_calc_stroke_uv(Object *ob, bGPDstroke *gps) if (gps == NULL) { return; } - MaterialGPencilStyle *gp_style = BKE_material_gpencil_settings_get(ob, gps->mat_nr + 1); + MaterialGPencilStyle *gp_style = BKE_gpencil_material_settings(ob, gps->mat_nr + 1); float pixsize; if (gp_style) { pixsize = gp_style->texture_pixsize / 1000000.0f; @@ -2108,7 +2108,7 @@ void ED_gpencil_update_color_uv(Main *bmain, Material *mat) if (ED_gpencil_stroke_color_use(ob, gpl, gps) == false) { continue; } - gps_ma = BKE_material_gpencil_get(ob, gps->mat_nr + 1); + gps_ma = BKE_gpencil_material(ob, gps->mat_nr + 1); /* update */ if ((gps_ma) && (gps_ma == mat)) { ED_gpencil_calc_stroke_uv(ob, gps); diff --git a/source/blender/editors/interface/interface_eyedropper_gpencil_color.c b/source/blender/editors/interface/interface_eyedropper_gpencil_color.c index 02d4596e93c..51467ae9695 100644 --- a/source/blender/editors/interface/interface_eyedropper_gpencil_color.c +++ b/source/blender/editors/interface/interface_eyedropper_gpencil_color.c @@ -127,9 +127,9 @@ static void eyedropper_gpencil_color_set(bContext *C, const wmEvent *event, Eyed } /* Look for a similar material in grease pencil slots. */ - short *totcol = give_totcolp(ob); + short *totcol = BKE_object_material_num(ob); for (short i = 0; i < *totcol; i++) { - ma = give_current_material(ob, i + 1); + ma = BKE_object_material_get(ob, i + 1); if (ma == NULL) { continue; } diff --git a/source/blender/editors/mesh/editmesh_select_similar.c b/source/blender/editors/mesh/editmesh_select_similar.c index cee048b9513..e7ee36387d2 100644 --- a/source/blender/editors/mesh/editmesh_select_similar.c +++ b/source/blender/editors/mesh/editmesh_select_similar.c @@ -229,7 +229,7 @@ static int similar_face_select_exec(bContext *C, wmOperator *op) if (ob->totcol == 0) { continue; } - material_array = give_matarar(ob); + material_array = BKE_object_material_array(ob); break; } case SIMFACE_FREESTYLE: { @@ -353,7 +353,7 @@ static int similar_face_select_exec(bContext *C, wmOperator *op) if (ob->totcol == 0) { continue; } - material_array = give_matarar(ob); + material_array = BKE_object_material_array(ob); break; } case SIMFACE_FREESTYLE: { diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 0fea21710e9..0c564bb7593 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -3935,7 +3935,7 @@ static Base *mesh_separate_tagged( /* DAG_relations_tag_update(bmain); */ /* new in 2.5 */ - assign_matarar(bmain, base_new->object, give_matarar(obedit), *give_totcolp(obedit)); + BKE_object_material_array_assign(bmain, base_new->object, BKE_object_material_array(obedit), *BKE_object_material_num(obedit)); ED_object_base_select(base_new, BA_SELECT); @@ -4002,7 +4002,7 @@ static Base *mesh_separate_arrays(Main *bmain, /* DAG_relations_tag_update(bmain); */ /* new in 2.5 */ - assign_matarar(bmain, base_new->object, give_matarar(obedit), *give_totcolp(obedit)); + BKE_object_material_array_assign(bmain, base_new->object, BKE_object_material_array(obedit), *BKE_object_material_num(obedit)); ED_object_base_select(base_new, BA_SELECT); @@ -4046,8 +4046,8 @@ static void mesh_separate_material_assign_mat_nr(Main *bmain, Object *ob, const Material ***matarar; const short *totcolp; - totcolp = give_totcolp_id(obdata); - matarar = give_matarar_id(obdata); + totcolp = BKE_id_material_num(obdata); + matarar = BKE_id_material_array(obdata); if ((totcolp && matarar) == 0) { BLI_assert(0); diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 380d9100ed4..fa282612a8e 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -250,7 +250,7 @@ static void join_mesh_single(Depsgraph *depsgraph, if (matmap) { /* make mapping for materials */ for (a = 1; a <= ob_src->totcol; a++) { - Material *ma = give_current_material(ob_src, a); + Material *ma = BKE_object_material_get(ob_src, a); for (b = 0; b < totcol; b++) { if (ma == matar[b]) { @@ -391,7 +391,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) /* obact materials in new main array, is nicer start! */ for (a = 0; a < ob->totcol; a++) { - matar[a] = give_current_material(ob, a + 1); + matar[a] = BKE_object_material_get(ob, a + 1); id_us_plus((ID *)matar[a]); /* increase id->us : will be lowered later */ } @@ -457,7 +457,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) * (but only if limits not exceeded yet) */ if (totcol < MAXMAT) { for (a = 1; a <= ob_iter->totcol; a++) { - ma = give_current_material(ob_iter, a); + ma = BKE_object_material_get(ob_iter, a); for (b = 0; b < totcol; b++) { if (ma == matar[b]) { @@ -669,7 +669,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) ob->totcol = me->totcol = totcol; /* other mesh users */ - test_all_objects_materials(bmain, (ID *)me); + BKE_objects_materials_test_all(bmain, (ID *)me); /* free temp copy of destination shapekeys (if applicable) */ if (nkey) { diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index f55a4c7f5f9..04323972666 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -2443,7 +2443,7 @@ static int convert_exec(bContext *C, wmOperator *op) /* Ensure new object has consistent material data with its new obdata. */ if (newob) { - test_object_materials(bmain, newob, newob->data); + BKE_object_materials_test(bmain, newob, newob->data); } /* tag obdata if it was been changed */ diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c index acecbc47c28..5d7a0efb7bf 100644 --- a/source/blender/editors/object/object_bake_api.c +++ b/source/blender/editors/object/object_bake_api.c @@ -481,7 +481,7 @@ static bool bake_object_check(ViewLayer *view_layer, Object *ob, ReportList *rep } } else { - Material *mat = give_current_material(ob, i); + Material *mat = BKE_object_material_get(ob, i); if (mat != NULL) { BKE_reportf(reports, RPT_INFO, diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index f9e2a2b8a1a..e00b7fd2dc5 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -1534,16 +1534,16 @@ static int make_links_data_exec(bContext *C, wmOperator *op) ob_dst->data = obdata_id; /* if amount of material indices changed: */ - test_object_materials(bmain, ob_dst, ob_dst->data); + BKE_object_materials_test(bmain, ob_dst, ob_dst->data); DEG_id_tag_update(&ob_dst->id, ID_RECALC_GEOMETRY); break; case MAKE_LINKS_MATERIALS: /* new approach, using functions from kernel */ for (a = 0; a < ob_src->totcol; a++) { - Material *ma = give_current_material(ob_src, a + 1); + Material *ma = BKE_object_material_get(ob_src, a + 1); /* also works with `ma == NULL` */ - assign_material(bmain, ob_dst, ma, a + 1, BKE_MAT_ASSIGN_USERPREF); + BKE_object_material_assign(bmain, ob_dst, ma, a + 1, BKE_MAT_ASSIGN_USERPREF); } DEG_id_tag_update(&ob_dst->id, ID_RECALC_GEOMETRY); break; @@ -1950,7 +1950,7 @@ static void single_mat_users( FOREACH_OBJECT_FLAG_BEGIN (scene, view_layer, v3d, flag, ob) { if (!ID_IS_LINKED(ob)) { for (a = 1; a <= ob->totcol; a++) { - ma = give_current_material(ob, a); + ma = BKE_object_material_get(ob, a); if (ma) { /* do not test for LIB_TAG_NEW or use newid: * this functions guaranteed delivers single_users! */ @@ -1960,7 +1960,7 @@ static void single_mat_users( BKE_animdata_copy_id_action(bmain, &man->id, false); man->id.us = 0; - assign_material(bmain, ob, man, a, BKE_MAT_ASSIGN_USERPREF); + BKE_object_material_assign(bmain, ob, man, a, BKE_MAT_ASSIGN_USERPREF); } } } @@ -2262,7 +2262,7 @@ static int make_local_exec(bContext *C, wmOperator *op) } } - matarar = (Material ***)give_matarar(ob); + matarar = (Material ***)BKE_object_material_array(ob); if (matarar) { for (a = 0; a < ob->totcol; a++) { ma = (*matarar)[a]; @@ -2676,7 +2676,7 @@ static int drop_named_material_invoke(bContext *C, wmOperator *op, const wmEvent return OPERATOR_CANCELLED; } - assign_material(CTX_data_main(C), base->object, ma, 1, BKE_MAT_ASSIGN_USERPREF); + BKE_object_material_assign(CTX_data_main(C), base->object, ma, 1, BKE_MAT_ASSIGN_USERPREF); DEG_id_tag_update(&base->object->id, ID_RECALC_TRANSFORM); diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index 40fa11994f4..63362f7a86d 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -523,7 +523,7 @@ static bool object_select_all_by_material(bContext *C, Material *mat) int a; for (a = 1; a <= ob->totcol; a++) { - mat1 = give_current_material(ob, a); + mat1 = BKE_object_material_get(ob, a); if (mat1 == mat) { ED_object_base_select(base, BA_SELECT); @@ -681,7 +681,7 @@ static int object_select_linked_exec(bContext *C, wmOperator *op) else if (nr == OBJECT_SELECT_LINKED_MATERIAL) { Material *mat = NULL; - mat = give_current_material(ob, ob->actcol); + mat = BKE_object_material_get(ob, ob->actcol); if (mat == NULL) { return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 0ed37bbc5af..3ea583e5b1f 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -465,8 +465,8 @@ static Scene *preview_prepare_scene( copy_v4_v4(base->object->color, sp->color); if (OB_TYPE_SUPPORT_MATERIAL(base->object->type)) { - /* don't use assign_material, it changed mat->id.us, which shows in the UI */ - Material ***matar = give_matarar(base->object); + /* don't use BKE_object_material_assign, it changed mat->id.us, which shows in the UI */ + Material ***matar = BKE_object_material_array(base->object); int actcol = max_ii(base->object->actcol - 1, 0); if (matar && actcol < base->object->totcol) { diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index 7970d491877..3a3c60a6dd4 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -294,7 +294,7 @@ static int material_slot_de_select(bContext *C, bool select) { bool changed_multi = false; Object *obact = CTX_data_active_object(C); - const Material *mat_active = obact ? give_current_material(obact, obact->actcol) : NULL; + const Material *mat_active = obact ? BKE_object_material_get(obact, obact->actcol) : NULL; uint objects_len = 0; Object **objects = object_array_for_shading(C, &objects_len); @@ -305,7 +305,7 @@ static int material_slot_de_select(bContext *C, bool select) if (ob->totcol == 0) { continue; } - if (obact && (mat_active == give_current_material(ob, obact->actcol))) { + if (obact && (mat_active == BKE_object_material_get(ob, obact->actcol))) { /* Avoid searching since there may be multiple slots with the same material. * For the active object or duplicates: match the material slot index first. */ mat_nr_active = obact->actcol - 1; @@ -314,7 +314,7 @@ static int material_slot_de_select(bContext *C, bool select) /* Find the first matching material. * Note: there may be multiple but that's not a common use case. */ for (short i = 0; i < ob->totcol; i++) { - const Material *mat = give_current_material(ob, i + 1); + const Material *mat = BKE_object_material_get(ob, i + 1); if (mat_active == mat) { mat_nr_active = i; break; @@ -441,14 +441,14 @@ static int material_slot_copy_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob = ED_object_context(C); Material ***matar; - if (!ob || !(matar = give_matarar(ob))) { + if (!ob || !(matar = BKE_object_material_array(ob))) { return OPERATOR_CANCELLED; } CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects) { - if (ob != ob_iter && give_matarar(ob_iter)) { + if (ob != ob_iter && BKE_object_material_array(ob_iter)) { if (ob->data != ob_iter->data) { - assign_matarar(bmain, ob_iter, matar, ob->totcol); + BKE_object_material_array_assign(bmain, ob_iter, matar, ob->totcol); } if (ob_iter->totcol == ob->totcol) { @@ -644,7 +644,7 @@ static int new_material_exec(bContext *C, wmOperator *UNUSED(op)) ma = BKE_material_add(bmain, name); } else { - ma = BKE_material_add_gpencil(bmain, name); + ma = BKE_gpencil_material_add(bmain, name); } ED_node_shader_default(C, &ma->id); ma->use_nodes = true; @@ -654,7 +654,7 @@ static int new_material_exec(bContext *C, wmOperator *UNUSED(op)) if (ob != NULL) { /* Add slot follows user-preferences for creating new slots, * RNA pointer assignment doesn't, see: T60014. */ - if (give_current_material_p(ob, ob->actcol) == NULL) { + if (BKE_object_material_get_p(ob, ob->actcol) == NULL) { BKE_object_material_slot_add(bmain, ob); } } @@ -1915,7 +1915,7 @@ static int copy_material_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; } - copy_matcopybuf(CTX_data_main(C), ma); + BKE_material_copybuf_copy(CTX_data_main(C), ma); return OPERATOR_FINISHED; } @@ -1943,7 +1943,7 @@ static int paste_material_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; } - paste_matcopybuf(CTX_data_main(C), ma); + BKE_material_copybuf_paste(CTX_data_main(C), ma); DEG_id_tag_update(&ma->id, ID_RECALC_COPY_ON_WRITE); WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_LINKS, ma); diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 6d1a32d1c45..a36da7a17e6 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -1170,7 +1170,7 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op) /* entering paint mode also sets image to editors */ if (imapaint->mode == IMAGEPAINT_MODE_MATERIAL) { /* set the current material active paint slot on image editor */ - Material *ma = give_current_material(ob, ob->actcol); + Material *ma = BKE_object_material_get(ob, ob->actcol); if (ma && ma->texpaintslot) { ima = ma->texpaintslot[ma->paint_active_slot].ima; diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index d649f5017eb..8faf5cba341 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -4088,7 +4088,7 @@ static bool proj_paint_state_mesh_eval_init(const bContext *C, ProjPaintState *p * the materials by using the mf->mat_nr directly and leaving the last * material as NULL in case no materials exist on mesh, so indexing will not fail. */ for (int i = 0; i < totmat - 1; i++) { - ps->mat_array[i] = give_current_material(ob, i + 1); + ps->mat_array[i] = BKE_object_material_get(ob, i + 1); } ps->mat_array[totmat - 1] = NULL; @@ -6381,7 +6381,7 @@ bool BKE_paint_proj_mesh_data_check( hastex = false; for (i = 1; i < ob->totcol + 1; i++) { - Material *ma = give_current_material(ob, i); + Material *ma = BKE_object_material_get(ob, i); if (ma) { hasmat = true; @@ -6573,7 +6573,7 @@ static bool proj_paint_add_slot(bContext *C, wmOperator *op) return false; } - ma = give_current_material(ob, ob->actcol); + ma = BKE_object_material_get(ob, ob->actcol); if (ma) { Main *bmain = CTX_data_main(C); @@ -6686,11 +6686,11 @@ static int get_texture_layer_type(wmOperator *op, const char *prop_name) static Material *get_or_create_current_material(bContext *C, Object *ob) { - Material *ma = give_current_material(ob, ob->actcol); + Material *ma = BKE_object_material_get(ob, ob->actcol); if (!ma) { Main *bmain = CTX_data_main(C); ma = BKE_material_add(bmain, "Material"); - assign_material(bmain, ob, ma, ob->actcol, BKE_MAT_ASSIGN_USERPREF); + BKE_object_material_assign(bmain, ob, ma, ob->actcol, BKE_MAT_ASSIGN_USERPREF); } return ma; } @@ -6716,7 +6716,7 @@ static void get_default_texture_layer_name_for_object(Object *ob, char *dst, int dst_length) { - Material *ma = give_current_material(ob, ob->actcol); + Material *ma = BKE_object_material_get(ob, ob->actcol); const char *base_name = ma ? &ma->id.name[2] : &ob->id.name[2]; BLI_snprintf(dst, dst_length, "%s %s", base_name, layer_type_items[texture_type].name); } diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index db22729e8b0..e799e54188d 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -348,7 +348,7 @@ static void imapaint_pick_uv(Mesh *me_eval, const Material *ma; const TexPaintSlot *slot; - ma = give_current_material(ob_eval, mp->mat_nr + 1); + ma = BKE_object_material_get(ob_eval, mp->mat_nr + 1); slot = &ma->texpaintslot[ma->paint_active_slot]; if (!(slot && slot->uvname && @@ -405,7 +405,7 @@ static Image *imapaint_face_image(Object *ob, Mesh *me, int face_index) { Image *ima; MPoly *mp = me->mpoly + face_index; - Material *ma = give_current_material(ob, mp->mat_nr + 1); + Material *ma = BKE_object_material_get(ob, mp->mat_nr + 1); ima = ma && ma->texpaintslot ? ma->texpaintslot[ma->paint_active_slot].ima : NULL; return ima; diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index ecd2b5a3697..813290cbe97 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -312,7 +312,7 @@ static int buttons_context_path_material(ButsContextPath *path) ob = path->ptr[path->len - 1].data; if (ob && OB_TYPE_SUPPORT_MATERIAL(ob->type)) { - ma = give_current_material(ob, ob->actcol); + ma = BKE_object_material_get(ob, ob->actcol); RNA_id_pointer_create(&ma->id, &path->ptr[path->len]); path->len++; return 1; diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.c b/source/blender/editors/space_outliner/outliner_dragdrop.c index 602031a6854..a4a6aadde77 100644 --- a/source/blender/editors/space_outliner/outliner_dragdrop.c +++ b/source/blender/editors/space_outliner/outliner_dragdrop.c @@ -602,7 +602,7 @@ static int material_drop_invoke(bContext *C, wmOperator *UNUSED(op), const wmEve return OPERATOR_CANCELLED; } - assign_material(bmain, ob, ma, ob->totcol + 1, BKE_MAT_ASSIGN_USERPREF); + BKE_object_material_assign(bmain, ob, ma, ob->totcol + 1, BKE_MAT_ASSIGN_USERPREF); WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, CTX_wm_view3d(C)); WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_LINKS, ma); diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 5be3f676658..ffa142dfcf3 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -165,7 +165,7 @@ bool ED_object_get_active_image(Object *ob, bNode **r_node, bNodeTree **r_ntree) { - Material *ma = give_current_material(ob, mat_nr); + Material *ma = BKE_object_material_get(ob, mat_nr); bNodeTree *ntree = (ma && ma->use_nodes) ? ma->nodetree : NULL; bNode *node = (ntree) ? nodeGetActiveTexture(ntree) : NULL; @@ -211,7 +211,7 @@ bool ED_object_get_active_image(Object *ob, void ED_object_assign_active_image(Main *bmain, Object *ob, int mat_nr, Image *ima) { - Material *ma = give_current_material(ob, mat_nr); + Material *ma = BKE_object_material_get(ob, mat_nr); bNode *node = (ma && ma->use_nodes) ? nodeGetActiveTexture(ma->nodetree) : NULL; if (node && is_image_texture_node(node)) { |