From 2fb4de1f8c1b3117da47aff39972d92cc078dd29 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 5 Mar 2020 08:08:23 +1100 Subject: Cleanup: material API naming - Use 'BKE_object_material_*', 'BKE_id_material_*' prefix for functions that operate on Object and ID types. - Use '_len' suffix for length (matching BLI naming). - Use '_p' suffix for functions that return a pointer to values where the value would typically be returned. Functions renamed: - BKE_object_material_resize was BKE_material_resize_object - BKE_object_material_remap was BKE_material_remap_object - BKE_object_material_remap_calc was BKE_material_remap_object_calc - BKE_object_material_array_p was BKE_object_material_array - BKE_object_material_len_p was BKE_object_material_num - BKE_id_material_array_p was BKE_id_material_array - BKE_id_material_len_p was BKE_id_material_num - BKE_id_material_resize was BKE_material_resize_id - BKE_id_material_append was BKE_material_append_id - BKE_id_material_pop was BKE_material_pop_id - BKE_id_material_clear was BKE_material_clear_id --- .../blender/editors/gpencil/gpencil_add_monkey.c | 2 +- .../blender/editors/gpencil/gpencil_add_stroke.c | 2 +- source/blender/editors/gpencil/gpencil_data.c | 18 ++++++++-------- .../interface/interface_eyedropper_gpencil_color.c | 2 +- .../blender/editors/mesh/editmesh_select_similar.c | 4 ++-- source/blender/editors/mesh/editmesh_tools.c | 24 +++++++++++----------- source/blender/editors/object/object_relations.c | 2 +- source/blender/editors/render/render_preview.c | 2 +- source/blender/editors/render/render_shading.c | 6 +++--- 9 files changed, 31 insertions(+), 31 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/gpencil/gpencil_add_monkey.c b/source/blender/editors/gpencil/gpencil_add_monkey.c index 1277d28e915..8b4620d233b 100644 --- a/source/blender/editors/gpencil/gpencil_add_monkey.c +++ b/source/blender/editors/gpencil/gpencil_add_monkey.c @@ -51,7 +51,7 @@ typedef struct ColorTemplate { static int gpencil_monkey_color( Main *bmain, Object *ob, const ColorTemplate *pct, bool stroke, bool fill) { - short *totcol = BKE_object_material_num(ob); + short *totcol = BKE_object_material_len_p(ob); Material *ma = NULL; for (short i = 0; i < *totcol; i++) { ma = BKE_gpencil_material(ob, i + 1); diff --git a/source/blender/editors/gpencil/gpencil_add_stroke.c b/source/blender/editors/gpencil/gpencil_add_stroke.c index 068416595a4..dfcf7f6e765 100644 --- a/source/blender/editors/gpencil/gpencil_add_stroke.c +++ b/source/blender/editors/gpencil/gpencil_add_stroke.c @@ -50,7 +50,7 @@ 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 = BKE_object_material_num(ob); + short *totcol = BKE_object_material_len_p(ob); Material *ma = NULL; for (short i = 0; i < *totcol; i++) { ma = BKE_gpencil_material(ob, i + 1); diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c index 9987e7decff..0c57e9560bc 100644 --- a/source/blender/editors/gpencil/gpencil_data.c +++ b/source/blender/editors/gpencil/gpencil_data.c @@ -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 = BKE_object_material_num(ob); + short *totcol = BKE_object_material_len_p(ob); /* sanity checks */ if (ELEM(NULL, gpd)) { @@ -2343,7 +2343,7 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op) } /* add missing materials reading source materials and checking in destination object */ - short *totcol = BKE_object_material_num(ob_src); + short *totcol = BKE_object_material_len_p(ob_src); for (short i = 0; i < *totcol; i++) { Material *tmp_ma = BKE_gpencil_material(ob_src, i + 1); @@ -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 = BKE_object_material_num(ob); + short *totcolp = BKE_object_material_len_p(ob); return *totcolp > 0; } return false; @@ -2482,7 +2482,7 @@ static int gpencil_lock_layer_exec(bContext *C, wmOperator *UNUSED(op)) /* first lock and hide all colors */ Material *ma = NULL; - short *totcol = BKE_object_material_num(ob); + short *totcol = BKE_object_material_len_p(ob); if (totcol == 0) { return OPERATOR_CANCELLED; } @@ -2569,7 +2569,7 @@ static int gpencil_color_isolate_exec(bContext *C, wmOperator *op) /* Test whether to isolate or clear all flags */ Material *ma = NULL; - short *totcol = BKE_object_material_num(ob); + short *totcol = BKE_object_material_len_p(ob); for (short i = 0; i < *totcol; i++) { ma = BKE_gpencil_material(ob, i + 1); /* Skip if this is the active one */ @@ -2664,7 +2664,7 @@ static int gpencil_color_hide_exec(bContext *C, wmOperator *op) bool unselected = RNA_boolean_get(op->ptr, "unselected"); Material *ma = NULL; - short *totcol = BKE_object_material_num(ob); + short *totcol = BKE_object_material_len_p(ob); if (totcol == 0) { return OPERATOR_CANCELLED; } @@ -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 = BKE_object_material_num(ob); + short *totcol = BKE_object_material_len_p(ob); if (totcol == 0) { return OPERATOR_CANCELLED; @@ -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 = BKE_object_material_num(ob); + short *totcol = BKE_object_material_len_p(ob); if (totcol == 0) { return OPERATOR_CANCELLED; @@ -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 = BKE_object_material_num(ob); + short *totcol = BKE_object_material_len_p(ob); if (totcol == 0) { return OPERATOR_CANCELLED; diff --git a/source/blender/editors/interface/interface_eyedropper_gpencil_color.c b/source/blender/editors/interface/interface_eyedropper_gpencil_color.c index 51467ae9695..790609a17d8 100644 --- a/source/blender/editors/interface/interface_eyedropper_gpencil_color.c +++ b/source/blender/editors/interface/interface_eyedropper_gpencil_color.c @@ -127,7 +127,7 @@ static void eyedropper_gpencil_color_set(bContext *C, const wmEvent *event, Eyed } /* Look for a similar material in grease pencil slots. */ - short *totcol = BKE_object_material_num(ob); + short *totcol = BKE_object_material_len_p(ob); for (short i = 0; i < *totcol; i++) { ma = BKE_object_material_get(ob, i + 1); if (ma == NULL) { diff --git a/source/blender/editors/mesh/editmesh_select_similar.c b/source/blender/editors/mesh/editmesh_select_similar.c index e7ee36387d2..5106108a16c 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 = BKE_object_material_array(ob); + material_array = BKE_object_material_array_p(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 = BKE_object_material_array(ob); + material_array = BKE_object_material_array_p(ob); break; } case SIMFACE_FREESTYLE: { diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 2176bbceb5f..71f045bd265 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -3939,8 +3939,8 @@ static Base *mesh_separate_tagged( /* new in 2.5 */ BKE_object_material_array_assign(bmain, base_new->object, - BKE_object_material_array(obedit), - *BKE_object_material_num(obedit)); + BKE_object_material_array_p(obedit), + *BKE_object_material_len_p(obedit)); ED_object_base_select(base_new, BA_SELECT); @@ -4011,8 +4011,8 @@ static Base *mesh_separate_arrays(Main *bmain, /* new in 2.5 */ BKE_object_material_array_assign(bmain, base_new->object, - BKE_object_material_array(obedit), - *BKE_object_material_num(obedit)); + BKE_object_material_array_p(obedit), + *BKE_object_material_len_p(obedit)); ED_object_base_select(base_new, BA_SELECT); @@ -4056,8 +4056,8 @@ static void mesh_separate_material_assign_mat_nr(Main *bmain, Object *ob, const Material ***matarar; const short *totcolp; - totcolp = BKE_id_material_num(obdata); - matarar = BKE_id_material_array(obdata); + totcolp = BKE_id_material_len_p(obdata); + matarar = BKE_id_material_array_p(obdata); if ((totcolp && matarar) == 0) { BLI_assert(0); @@ -4085,9 +4085,9 @@ static void mesh_separate_material_assign_mat_nr(Main *bmain, Object *ob, const ma_obdata = NULL; } - BKE_material_clear_id(bmain, obdata); - BKE_material_resize_object(bmain, ob, 1, true); - BKE_material_resize_id(bmain, obdata, 1, true); + BKE_id_material_clear(bmain, obdata); + BKE_object_material_resize(bmain, ob, 1, true); + BKE_id_material_resize(bmain, obdata, 1, true); ob->mat[0] = ma_ob; id_us_plus((ID *)ma_ob); @@ -4096,9 +4096,9 @@ static void mesh_separate_material_assign_mat_nr(Main *bmain, Object *ob, const id_us_plus((ID *)ma_obdata); } else { - BKE_material_clear_id(bmain, obdata); - BKE_material_resize_object(bmain, ob, 0, true); - BKE_material_resize_id(bmain, obdata, 0, true); + BKE_id_material_clear(bmain, obdata); + BKE_object_material_resize(bmain, ob, 0, true); + BKE_id_material_resize(bmain, obdata, 0, true); } } diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 0ce2b21cbbd..13844a4f7b4 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -2260,7 +2260,7 @@ static int make_local_exec(bContext *C, wmOperator *op) } } - matarar = (Material ***)BKE_object_material_array(ob); + matarar = (Material ***)BKE_object_material_array_p(ob); if (matarar) { for (a = 0; a < ob->totcol; a++) { ma = (*matarar)[a]; diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index a42064ff7b9..e2841f01ab5 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -471,7 +471,7 @@ static Scene *preview_prepare_scene( if (OB_TYPE_SUPPORT_MATERIAL(base->object->type)) { /* 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); + Material ***matar = BKE_object_material_array_p(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 8ecaeefbd5f..94e210b7243 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -466,12 +466,12 @@ static int material_slot_copy_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob = ED_object_context(C); Material ***matar; - if (!ob || !(matar = BKE_object_material_array(ob))) { + if (!ob || !(matar = BKE_object_material_array_p(ob))) { return OPERATOR_CANCELLED; } CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects) { - if (ob != ob_iter && BKE_object_material_array(ob_iter)) { + if (ob != ob_iter && BKE_object_material_array_p(ob_iter)) { if (ob->data != ob_iter->data) { BKE_object_material_array_assign(bmain, ob_iter, matar, ob->totcol); } @@ -538,7 +538,7 @@ static int material_slot_move_exec(bContext *C, wmOperator *op) slot_remap[index_pair[0]] = index_pair[1]; slot_remap[index_pair[1]] = index_pair[0]; - BKE_material_remap_object(ob, slot_remap); + BKE_object_material_remap(ob, slot_remap); MEM_freeN(slot_remap); -- cgit v1.2.3