From 1bc2a98a9d609e54c928672f148edfba9d5f8c5a Mon Sep 17 00:00:00 2001 From: Antonio Vazquez Date: Wed, 5 Feb 2020 11:23:58 +0100 Subject: 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 --- source/blender/alembic/intern/abc_mesh.cc | 6 +- source/blender/blenkernel/BKE_material.h | 44 +++---- source/blender/blenkernel/intern/brush.c | 2 +- source/blender/blenkernel/intern/gpencil.c | 32 +++--- .../blender/blenkernel/intern/gpencil_modifier.c | 2 +- source/blender/blenkernel/intern/library_remap.c | 2 +- source/blender/blenkernel/intern/material.c | 126 ++++++++++----------- source/blender/blenkernel/intern/mesh.c | 2 +- source/blender/blenkernel/intern/mesh_convert.c | 2 +- source/blender/blenkernel/intern/object.c | 4 +- source/blender/blenkernel/intern/particle.c | 4 +- source/blender/blenkernel/intern/particle_system.c | 2 +- source/blender/blenloader/intern/readfile.c | 4 +- source/blender/collada/AnimationExporter.cpp | 2 +- source/blender/collada/AnimationImporter.cpp | 2 +- source/blender/collada/BCAnimationCurve.cpp | 4 +- source/blender/collada/BCAnimationSampler.cpp | 4 +- source/blender/collada/EffectExporter.cpp | 2 +- source/blender/collada/GeometryExporter.cpp | 2 +- source/blender/collada/InstanceWriter.cpp | 2 +- source/blender/collada/MaterialExporter.cpp | 2 +- source/blender/collada/MaterialExporter.h | 2 +- source/blender/collada/MeshImporter.cpp | 2 +- source/blender/collada/collada_utils.cpp | 2 +- .../depsgraph/intern/builder/deg_builder_nodes.cc | 4 +- .../intern/builder/deg_builder_relations.cc | 4 +- .../blender/draw/engines/eevee/eevee_materials.c | 2 +- source/blender/draw/engines/eevee/eevee_volumes.c | 2 +- .../draw/engines/gpencil/gpencil_draw_utils.c | 14 +-- .../blender/draw/engines/gpencil/gpencil_engine.c | 2 +- .../blender/draw/engines/overlay/overlay_extra.c | 2 +- .../draw/engines/overlay/overlay_particle.c | 2 +- .../draw/engines/workbench/workbench_deferred.c | 4 +- .../draw/engines/workbench/workbench_forward.c | 4 +- .../draw/engines/workbench/workbench_materials.c | 2 +- source/blender/editors/animation/anim_filter.c | 4 +- source/blender/editors/animation/keyframing.c | 4 +- source/blender/editors/gpencil/drawgpencil.c | 4 +- .../blender/editors/gpencil/gpencil_add_monkey.c | 4 +- .../blender/editors/gpencil/gpencil_add_stroke.c | 4 +- source/blender/editors/gpencil/gpencil_data.c | 56 ++++----- source/blender/editors/gpencil/gpencil_edit.c | 10 +- source/blender/editors/gpencil/gpencil_fill.c | 4 +- source/blender/editors/gpencil/gpencil_merge.c | 2 +- source/blender/editors/gpencil/gpencil_utils.c | 6 +- .../interface/interface_eyedropper_gpencil_color.c | 4 +- .../blender/editors/mesh/editmesh_select_similar.c | 4 +- source/blender/editors/mesh/editmesh_tools.c | 8 +- source/blender/editors/mesh/meshtools.c | 8 +- source/blender/editors/object/object_add.c | 2 +- source/blender/editors/object/object_bake_api.c | 2 +- source/blender/editors/object/object_relations.c | 14 +-- source/blender/editors/object/object_select.c | 4 +- source/blender/editors/render/render_preview.c | 4 +- source/blender/editors/render/render_shading.c | 20 ++-- source/blender/editors/sculpt_paint/paint_image.c | 2 +- .../editors/sculpt_paint/paint_image_proj.c | 12 +- source/blender/editors/sculpt_paint/paint_utils.c | 4 +- .../editors/space_buttons/buttons_context.c | 2 +- .../editors/space_outliner/outliner_dragdrop.c | 2 +- source/blender/editors/uvedit/uvedit_ops.c | 4 +- .../intern/blender_interface/BlenderFileLoader.cpp | 2 +- .../blender_interface/BlenderStrokeRenderer.cpp | 2 +- .../gpencil_modifiers/intern/MOD_gpencil_util.c | 4 +- .../gpencil_modifiers/intern/MOD_gpencilcolor.c | 2 +- .../gpencil_modifiers/intern/MOD_gpencilopacity.c | 2 +- .../gpencil_modifiers/intern/MOD_gpenciltint.c | 2 +- source/blender/makesrna/intern/rna_ID.c | 6 +- source/blender/makesrna/intern/rna_brush.c | 2 +- source/blender/makesrna/intern/rna_main_api.c | 4 +- source/blender/makesrna/intern/rna_object.c | 14 +-- source/blender/makesrna/intern/rna_particle.c | 2 +- source/blender/nodes/shader/node_shader_tree.c | 2 +- source/blender/usd/intern/usd_writer_mesh.cc | 4 +- source/blender/windowmanager/intern/wm_init_exit.c | 8 +- source/blender/windowmanager/intern/wm_operators.c | 2 +- source/creator/creator.c | 2 +- 77 files changed, 277 insertions(+), 277 deletions(-) (limited to 'source') diff --git a/source/blender/alembic/intern/abc_mesh.cc b/source/blender/alembic/intern/abc_mesh.cc index 3eee390d7d3..f7a18b0325e 100644 --- a/source/blender/alembic/intern/abc_mesh.cc +++ b/source/blender/alembic/intern/abc_mesh.cc @@ -589,7 +589,7 @@ void AbcGenericMeshWriter::getGeoGroups(struct Mesh *mesh, MPoly ¤t_poly = polygons[i]; short mnr = current_poly.mat_nr; - Material *mat = give_current_material(m_object, mnr + 1); + Material *mat = BKE_object_material_get(m_object, mnr + 1); if (!mat) { continue; @@ -606,7 +606,7 @@ void AbcGenericMeshWriter::getGeoGroups(struct Mesh *mesh, } if (geo_groups.size() == 0) { - Material *mat = give_current_material(m_object, 1); + Material *mat = BKE_object_material_get(m_object, 1); std::string name = (mat) ? get_id_name(&mat->id) : "default"; @@ -691,7 +691,7 @@ static void assign_materials(Main *bmain, assigned_mat = mat_iter->second; } - assign_material(bmain, ob, assigned_mat, it->second, BKE_MAT_ASSIGN_OBDATA); + BKE_object_material_assign(bmain, ob, assigned_mat, it->second, BKE_MAT_ASSIGN_OBDATA); } } } diff --git a/source/blender/blenkernel/BKE_material.h b/source/blender/blenkernel/BKE_material.h index d7b037a8189..a0a41a048e3 100644 --- a/source/blender/blenkernel/BKE_material.h +++ b/source/blender/blenkernel/BKE_material.h @@ -37,11 +37,11 @@ struct bNode; /* materials */ -void init_def_material(void); -void BKE_material_gpencil_default_free(void); +void BKE_materials_init(void); +void BKE_materials_exit(void); void BKE_material_free(struct Material *ma); -void test_object_materials(struct Main *bmain, struct Object *ob, struct ID *id); -void test_all_objects_materials(struct Main *bmain, struct ID *id); +void BKE_object_materials_test(struct Main *bmain, struct Object *ob, struct ID *id); +void BKE_objects_materials_test_all(struct Main *bmain, struct ID *id); void BKE_material_resize_object(struct Main *bmain, struct Object *ob, const short totcol, @@ -53,7 +53,7 @@ void BKE_material_remap_object_calc(struct Object *ob_dst, struct Object *ob_src, short *remap_src_to_dst); struct Material *BKE_material_add(struct Main *bmain, const char *name); -struct Material *BKE_material_add_gpencil(struct Main *bmain, const char *name); +struct Material *BKE_gpencil_material_add(struct Main *bmain, const char *name); void BKE_material_copy_data(struct Main *bmain, struct Material *ma_dst, const struct Material *ma_src, @@ -62,17 +62,17 @@ struct Material *BKE_material_copy(struct Main *bmain, const struct Material *ma struct Material *BKE_material_localize(struct Material *ma); struct Material *give_node_material(struct Material *ma); /* returns node material or self */ void BKE_material_make_local(struct Main *bmain, struct Material *ma, const bool lib_local); -void BKE_material_init_gpencil_settings(struct Material *ma); +void BKE_gpencil_material_attr_init(struct Material *ma); /* UNUSED */ // void automatname(struct Material *); /* material slots */ -struct Material ***give_matarar(struct Object *ob); -short *give_totcolp(struct Object *ob); -struct Material ***give_matarar_id(struct ID *id); /* same but for ID's */ -short *give_totcolp_id(struct ID *id); +struct Material ***BKE_object_material_array(struct Object *ob); +short *BKE_object_material_num(struct Object *ob); +struct Material ***BKE_id_material_array(struct ID *id); /* same but for ID's */ +short *BKE_id_material_num(struct ID *id); enum { /* use existing link option */ @@ -82,21 +82,21 @@ enum { BKE_MAT_ASSIGN_OBJECT, }; -struct Material **give_current_material_p(struct Object *ob, short act); -struct Material *give_current_material(struct Object *ob, short act); -void assign_material_id(struct Main *bmain, struct ID *id, struct Material *ma, short act); -void assign_material( +struct Material **BKE_object_material_get_p(struct Object *ob, short act); +struct Material *BKE_object_material_get(struct Object *ob, short act); +void BKE_id_material_assign(struct Main *bmain, struct ID *id, struct Material *ma, short act); +void BKE_object_material_assign( struct Main *bmain, struct Object *ob, struct Material *ma, short act, int assign_type); -void assign_matarar(struct Main *bmain, struct Object *ob, struct Material ***matar, short totcol); +void BKE_object_material_array_assign(struct Main *bmain, struct Object *ob, struct Material ***matar, short totcol); short BKE_object_material_slot_find_index(struct Object *ob, struct Material *ma); bool BKE_object_material_slot_add(struct Main *bmain, struct Object *ob); bool BKE_object_material_slot_remove(struct Main *bmain, struct Object *ob); bool BKE_object_material_slot_used(struct ID *id, short actcol); -struct Material *BKE_material_gpencil_get(struct Object *ob, short act); -struct Material *BKE_material_gpencil_default_get(void); -struct MaterialGPencilStyle *BKE_material_gpencil_settings_get(struct Object *ob, short act); +struct Material *BKE_gpencil_material(struct Object *ob, short act); +struct Material *BKE_gpencil_material_default(void); +struct MaterialGPencilStyle *BKE_gpencil_material_settings(struct Object *ob, short act); void BKE_texpaint_slot_refresh_cache(struct Scene *scene, struct Material *ma); void BKE_texpaint_slots_refresh_object(struct Scene *scene, struct Object *ob); @@ -115,10 +115,10 @@ void BKE_material_clear_id(struct Main *bmain, struct ID *id); void ramp_blend(int type, float r_col[3], const float fac, const float col[3]); /* copy/paste */ -void clear_matcopybuf(void); -void free_matcopybuf(void); -void copy_matcopybuf(struct Main *bmain, struct Material *ma); -void paste_matcopybuf(struct Main *bmain, struct Material *ma); +void BKE_material_copybuf_clear(void); +void BKE_material_copybuf_free(void); +void BKE_material_copybuf_copy(struct Main *bmain, struct Material *ma); +void BKE_material_copybuf_paste(struct Main *bmain, struct Material *ma); /* Dependency graph evaluation. */ diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 721eb9a2a37..4f98290874e 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -290,7 +290,7 @@ void BKE_brush_gpencil_presets(Main *bmain, ToolSettings *ts) * drawn. */ Material *ma = BLI_findstring(&bmain->materials, "Black Dots", offsetof(ID, name) + 2); if (ma == NULL) { - ma = BKE_material_add_gpencil(bmain, "Black Dots"); + ma = BKE_gpencil_material_add(bmain, "Black Dots"); } brush->gpencil_settings->material = ma; /* Pin the matterial to the brush. */ diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index b1cf8ad8570..e7242ca11a4 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -1121,14 +1121,14 @@ Material *BKE_gpencil_object_material_ensure_from_brush(Main *bmain, Object *ob, /* check if the material is already on object material slots and add it if missing */ if (ma && BKE_gpencil_object_material_get_index(ob, ma) < 0) { BKE_object_material_slot_add(bmain, ob); - assign_material(bmain, ob, ma, ob->totcol, BKE_MAT_ASSIGN_USERPREF); + BKE_object_material_assign(bmain, ob, ma, ob->totcol, BKE_MAT_ASSIGN_USERPREF); } return ma; } else { /* using active material instead */ - return give_current_material(ob, ob->actcol); + return BKE_object_material_get(ob, ob->actcol); } } @@ -1141,7 +1141,7 @@ int BKE_gpencil_object_material_ensure(Main *bmain, Object *ob, Material *materi int index = BKE_gpencil_object_material_get_index(ob, material); if (index < 0) { BKE_object_material_slot_add(bmain, ob); - assign_material(bmain, ob, material, ob->totcol, BKE_MAT_ASSIGN_USERPREF); + BKE_object_material_assign(bmain, ob, material, ob->totcol, BKE_MAT_ASSIGN_USERPREF); return ob->totcol - 1; } return index; @@ -1154,11 +1154,11 @@ int BKE_gpencil_object_material_ensure(Main *bmain, Object *ob, Material *materi */ Material *BKE_gpencil_object_material_new(Main *bmain, Object *ob, const char *name, int *r_index) { - Material *ma = BKE_material_add_gpencil(bmain, name); + Material *ma = BKE_gpencil_material_add(bmain, name); id_us_min(&ma->id); /* no users yet */ BKE_object_material_slot_add(bmain, ob); - assign_material(bmain, ob, ma, ob->totcol, BKE_MAT_ASSIGN_USERPREF); + BKE_object_material_assign(bmain, ob, ma, ob->totcol, BKE_MAT_ASSIGN_USERPREF); if (r_index) { *r_index = ob->actcol - 1; @@ -1175,7 +1175,7 @@ Material *BKE_gpencil_object_material_get_from_brush(Object *ob, Brush *brush) return ma; } else { - return give_current_material(ob, ob->actcol); + return BKE_object_material_get(ob, ob->actcol); } } @@ -1228,7 +1228,7 @@ Material *BKE_gpencil_object_material_ensure_from_active_input_brush(Main *bmain */ Material *BKE_gpencil_object_material_ensure_from_active_input_material(Object *ob) { - Material *ma = give_current_material(ob, ob->actcol); + Material *ma = BKE_object_material_get(ob, ob->actcol); if (ma) { return ma; } @@ -1248,7 +1248,7 @@ Material *BKE_gpencil_object_material_ensure_active(Object *ob) ma = BKE_gpencil_object_material_ensure_from_active_input_material(ob); if (ma->gp_style == NULL) { - BKE_material_init_gpencil_settings(ma); + BKE_gpencil_material_attr_init(ma); } return ma; @@ -2368,10 +2368,10 @@ void BKE_gpencil_stats_update(bGPdata *gpd) /* get material index (0-based like mat_nr not actcol) */ int BKE_gpencil_object_material_get_index(Object *ob, Material *ma) { - short *totcol = give_totcolp(ob); + short *totcol = BKE_object_material_num(ob); Material *read_ma = NULL; for (short i = 0; i < *totcol; i++) { - read_ma = give_current_material(ob, i + 1); + read_ma = BKE_object_material_get(ob, i + 1); if (ma == read_ma) { return i; } @@ -3027,7 +3027,7 @@ static int gpencil_check_same_material_color(Object *ob_gp, float color[4], Mate hsv1[3] = color[3]; for (int i = 1; i <= ob_gp->totcol; i++) { - ma = give_current_material(ob_gp, i); + ma = BKE_object_material_get(ob_gp, i); MaterialGPencilStyle *gp_style = ma->gp_style; /* Check color with small tolerance (better in HSV). */ float hsv2[4]; @@ -3194,7 +3194,7 @@ static void gpencil_convert_spline(Main *bmain, */ bool do_stroke = false; if (ob_cu->totcol == 1) { - Material *ma_stroke = give_current_material(ob_cu, 1); + Material *ma_stroke = BKE_object_material_get(ob_cu, 1); if ((ma_stroke) && (strstr(ma_stroke->id.name, "_stroke") != NULL)) { do_stroke = true; } @@ -3202,7 +3202,7 @@ static void gpencil_convert_spline(Main *bmain, int r_idx = gpencil_check_same_material_color(ob_gp, color, &mat_gp); if ((ob_cu->totcol > 0) && (r_idx < 0)) { - Material *mat_curve = give_current_material(ob_cu, 1); + Material *mat_curve = BKE_object_material_get(ob_cu, 1); mat_gp = gpencil_add_from_curve_material(bmain, ob_gp, color, gpencil_lines, fill, &r_idx); if ((mat_curve) && (mat_curve->gp_style != NULL)) { @@ -3216,8 +3216,8 @@ static void gpencil_convert_spline(Main *bmain, } /* If object has more than 1 material, use second material for stroke color. */ - if ((!only_stroke) && (ob_cu->totcol > 1) && (give_current_material(ob_cu, 2))) { - mat_curve = give_current_material(ob_cu, 2); + if ((!only_stroke) && (ob_cu->totcol > 1) && (BKE_object_material_get(ob_cu, 2))) { + mat_curve = BKE_object_material_get(ob_cu, 2); if (mat_curve) { linearrgb_to_srgb_v3_v3(mat_gp->gp_style->stroke_rgba, &mat_curve->r); mat_gp->gp_style->stroke_rgba[3] = mat_curve->a; @@ -3226,7 +3226,7 @@ static void gpencil_convert_spline(Main *bmain, else if ((only_stroke) || (do_stroke)) { /* Also use the first color if the fill is none for stroke color. */ if (ob_cu->totcol > 0) { - mat_curve = give_current_material(ob_cu, 1); + mat_curve = BKE_object_material_get(ob_cu, 1); if (mat_curve) { linearrgb_to_srgb_v3_v3(mat_gp->gp_style->stroke_rgba, &mat_curve->r); mat_gp->gp_style->stroke_rgba[3] = mat_curve->a; diff --git a/source/blender/blenkernel/intern/gpencil_modifier.c b/source/blender/blenkernel/intern/gpencil_modifier.c index bc0c54ed96e..181cb2d38a9 100644 --- a/source/blender/blenkernel/intern/gpencil_modifier.c +++ b/source/blender/blenkernel/intern/gpencil_modifier.c @@ -813,7 +813,7 @@ static void gpencil_frame_copy_noalloc(Object *ob, bGPDframe *gpf, bGPDframe *gp bGPDstroke *gps_dst = BKE_gpencil_stroke_duplicate(gps_src); /* copy color to temp fields to apply temporal changes in the stroke */ - MaterialGPencilStyle *gp_style = BKE_material_gpencil_settings_get(ob, gps_src->mat_nr + 1); + MaterialGPencilStyle *gp_style = BKE_gpencil_material_settings(ob, gps_src->mat_nr + 1); if (gp_style) { copy_v4_v4(gps_dst->runtime.tmp_stroke_rgba, gp_style->stroke_rgba); copy_v4_v4(gps_dst->runtime.tmp_fill_rgba, gp_style->fill_rgba); diff --git a/source/blender/blenkernel/intern/library_remap.c b/source/blender/blenkernel/intern/library_remap.c index e1b3212a92c..72b94e7b356 100644 --- a/source/blender/blenkernel/intern/library_remap.c +++ b/source/blender/blenkernel/intern/library_remap.c @@ -398,7 +398,7 @@ static void libblock_remap_data_postprocess_obdata_relink(Main *bmain, Object *o break; } test_object_modifiers(ob); - test_object_materials(bmain, ob, new_id); + BKE_object_materials_test(bmain, ob, new_id); } } diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 54432c8da74..91fc0519c07 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -77,14 +77,14 @@ Material defgpencil_material; static CLG_LogRef LOG = {"bke.material"}; /* called on startup, creator.c */ -void init_def_material(void) +void BKE_materials_init(void) { BKE_material_init(&defmaterial); BKE_material_gpencil_init(&defgpencil_material); } /* Free the GPencil data of the default material, creator.c */ -void BKE_material_gpencil_default_free(void) +void BKE_materials_exit(void) { MEM_SAFE_FREE(defgpencil_material.gp_style); } @@ -112,7 +112,7 @@ void BKE_material_free(Material *ma) BKE_previewimg_free(&ma->preview); } -void BKE_material_init_gpencil_settings(Material *ma) +void BKE_gpencil_material_attr_init(Material *ma) { if ((ma) && (ma->gp_style == NULL)) { ma->gp_style = MEM_callocN(sizeof(MaterialGPencilStyle), "Grease Pencil Material Settings"); @@ -146,7 +146,7 @@ void BKE_material_gpencil_init(Material *ma) /* grease pencil settings */ strcpy(ma->id.name, "MADefault GPencil"); - BKE_material_init_gpencil_settings(ma); + BKE_gpencil_material_attr_init(ma); add_v3_fl(&ma->gp_style->stroke_rgba[0], 0.6f); } @@ -161,7 +161,7 @@ Material *BKE_material_add(Main *bmain, const char *name) return ma; } -Material *BKE_material_add_gpencil(Main *bmain, const char *name) +Material *BKE_gpencil_material_add(Main *bmain, const char *name) { Material *ma; @@ -169,7 +169,7 @@ Material *BKE_material_add_gpencil(Main *bmain, const char *name) /* grease pencil settings */ if (ma != NULL) { - BKE_material_init_gpencil_settings(ma); + BKE_gpencil_material_attr_init(ma); } return ma; } @@ -260,7 +260,7 @@ void BKE_material_make_local(Main *bmain, Material *ma, const bool lib_local) BKE_id_make_local_generic(bmain, &ma->id, true, lib_local); } -Material ***give_matarar(Object *ob) +Material ***BKE_object_material_array(Object *ob) { Mesh *me; Curve *cu; @@ -286,7 +286,7 @@ Material ***give_matarar(Object *ob) return NULL; } -short *give_totcolp(Object *ob) +short *BKE_object_material_num(Object *ob) { Mesh *me; Curve *cu; @@ -313,7 +313,7 @@ short *give_totcolp(Object *ob) } /* same as above but for ID's */ -Material ***give_matarar_id(ID *id) +Material ***BKE_id_material_array(ID *id) { /* ensure we don't try get materials from non-obdata */ BLI_assert(OB_DATA_SUPPORT_ID(GS(id->name))); @@ -333,7 +333,7 @@ Material ***give_matarar_id(ID *id) return NULL; } -short *give_totcolp_id(ID *id) +short *BKE_id_material_num(ID *id) { /* ensure we don't try get materials from non-obdata */ BLI_assert(OB_DATA_SUPPORT_ID(GS(id->name))); @@ -415,8 +415,8 @@ static void material_data_index_clear_id(ID *id) void BKE_material_resize_id(Main *bmain, ID *id, short totcol, bool do_id_user) { - Material ***matar = give_matarar_id(id); - short *totcolp = give_totcolp_id(id); + Material ***matar = BKE_id_material_array(id); + short *totcolp = BKE_id_material_num(id); if (matar == NULL) { return; @@ -447,8 +447,8 @@ void BKE_material_resize_id(Main *bmain, ID *id, short totcol, bool do_id_user) void BKE_material_append_id(Main *bmain, ID *id, Material *ma) { Material ***matar; - if ((matar = give_matarar_id(id))) { - short *totcol = give_totcolp_id(id); + if ((matar = BKE_id_material_array(id))) { + short *totcol = BKE_id_material_num(id); Material **mat = MEM_callocN(sizeof(void *) * ((*totcol) + 1), "newmatar"); if (*totcol) { memcpy(mat, *matar, sizeof(void *) * (*totcol)); @@ -461,7 +461,7 @@ void BKE_material_append_id(Main *bmain, ID *id, Material *ma) (*matar)[(*totcol)++] = ma; id_us_plus((ID *)ma); - test_all_objects_materials(bmain, id); + BKE_objects_materials_test_all(bmain, id); DEG_id_tag_update(id, ID_RECALC_COPY_ON_WRITE); DEG_relations_tag_update(bmain); @@ -473,8 +473,8 @@ Material *BKE_material_pop_id(Main *bmain, ID *id, int index_i) short index = (short)index_i; Material *ret = NULL; Material ***matar; - if ((matar = give_matarar_id(id))) { - short *totcol = give_totcolp_id(id); + if ((matar = BKE_id_material_array(id))) { + short *totcol = BKE_id_material_num(id); if (index >= 0 && index < (*totcol)) { ret = (*matar)[index]; id_us_min((ID *)ret); @@ -493,7 +493,7 @@ Material *BKE_material_pop_id(Main *bmain, ID *id, int index_i) (*totcol)--; *matar = MEM_reallocN(*matar, sizeof(void *) * (*totcol)); - test_all_objects_materials(bmain, id); + BKE_objects_materials_test_all(bmain, id); } material_data_index_remove_id(id, index); @@ -509,8 +509,8 @@ Material *BKE_material_pop_id(Main *bmain, ID *id, int index_i) void BKE_material_clear_id(Main *bmain, ID *id) { Material ***matar; - if ((matar = give_matarar_id(id))) { - short *totcol = give_totcolp_id(id); + if ((matar = BKE_id_material_array(id))) { + short *totcol = BKE_id_material_num(id); while ((*totcol)--) { id_us_min((ID *)((*matar)[*totcol])); @@ -521,7 +521,7 @@ void BKE_material_clear_id(Main *bmain, ID *id) *matar = NULL; } - test_all_objects_materials(bmain, id); + BKE_objects_materials_test_all(bmain, id); material_data_index_clear_id(id); DEG_id_tag_update(id, ID_RECALC_COPY_ON_WRITE); @@ -529,7 +529,7 @@ void BKE_material_clear_id(Main *bmain, ID *id) } } -Material **give_current_material_p(Object *ob, short act) +Material **BKE_object_material_get_p(Object *ob, short act) { Material ***matarar, **ma_p; const short *totcolp; @@ -539,7 +539,7 @@ Material **give_current_material_p(Object *ob, short act) } /* if object cannot have material, (totcolp == NULL) */ - totcolp = give_totcolp(ob); + totcolp = BKE_object_material_num(ob); if (totcolp == NULL || ob->totcol == 0) { return NULL; } @@ -568,7 +568,7 @@ Material **give_current_material_p(Object *ob, short act) act = ob->totcol; } - matarar = give_matarar(ob); + matarar = BKE_object_material_array(ob); if (matarar && *matarar) { ma_p = &(*matarar)[act - 1]; @@ -581,15 +581,15 @@ Material **give_current_material_p(Object *ob, short act) return ma_p; } -Material *give_current_material(Object *ob, short act) +Material *BKE_object_material_get(Object *ob, short act) { - Material **ma_p = give_current_material_p(ob, act); + Material **ma_p = BKE_object_material_get_p(ob, act); return ma_p ? *ma_p : NULL; } -Material *BKE_material_gpencil_get(Object *ob, short act) +Material *BKE_gpencil_material(Object *ob, short act) { - Material *ma = give_current_material(ob, act); + Material *ma = BKE_object_material_get(ob, act); if (ma != NULL) { return ma; } @@ -598,17 +598,17 @@ Material *BKE_material_gpencil_get(Object *ob, short act) } } -struct Material *BKE_material_gpencil_default_get(void) +struct Material *BKE_gpencil_material_default(void) { return &defgpencil_material; } -MaterialGPencilStyle *BKE_material_gpencil_settings_get(Object *ob, short act) +MaterialGPencilStyle *BKE_gpencil_material_settings(Object *ob, short act) { - Material *ma = give_current_material(ob, act); + Material *ma = BKE_object_material_get(ob, act); if (ma != NULL) { if (ma->gp_style == NULL) { - BKE_material_init_gpencil_settings(ma); + BKE_gpencil_material_attr_init(ma); } return ma->gp_style; @@ -677,25 +677,25 @@ void BKE_material_resize_object(Main *bmain, Object *ob, const short totcol, boo DEG_relations_tag_update(bmain); } -void test_object_materials(Main *bmain, Object *ob, ID *id) +void BKE_object_materials_test(Main *bmain, Object *ob, ID *id) { /* make the ob mat-array same size as 'ob->data' mat-array */ const short *totcol; - if (id == NULL || (totcol = give_totcolp_id(id)) == NULL) { + if (id == NULL || (totcol = BKE_id_material_num(id)) == NULL) { return; } BKE_material_resize_object(bmain, ob, *totcol, false); } -void test_all_objects_materials(Main *bmain, ID *id) +void BKE_objects_materials_test_all(Main *bmain, ID *id) { /* make the ob mat-array same size as 'ob->data' mat-array */ Object *ob; const short *totcol; - if (id == NULL || (totcol = give_totcolp_id(id)) == NULL) { + if (id == NULL || (totcol = BKE_id_material_num(id)) == NULL) { return; } @@ -708,7 +708,7 @@ void test_all_objects_materials(Main *bmain, ID *id) BKE_main_unlock(bmain); } -void assign_material_id(Main *bmain, ID *id, Material *ma, short act) +void BKE_id_material_assign(Main *bmain, ID *id, Material *ma, short act) { Material *mao, **matar, ***matarar; short *totcolp; @@ -722,8 +722,8 @@ void assign_material_id(Main *bmain, ID *id, Material *ma, short act) /* test arraylens */ - totcolp = give_totcolp_id(id); - matarar = give_matarar_id(id); + totcolp = BKE_id_material_num(id); + matarar = BKE_id_material_array(id); if (totcolp == NULL || matarar == NULL) { return; @@ -752,10 +752,10 @@ void assign_material_id(Main *bmain, ID *id, Material *ma, short act) id_us_plus(&ma->id); } - test_all_objects_materials(bmain, id); + BKE_objects_materials_test_all(bmain, id); } -void assign_material(Main *bmain, Object *ob, Material *ma, short act, int assign_type) +void BKE_object_material_assign(Main *bmain, Object *ob, Material *ma, short act, int assign_type) { Material *mao, **matar, ***matarar; short *totcolp; @@ -776,8 +776,8 @@ void assign_material(Main *bmain, Object *ob, Material *ma, short act, int assig /* test arraylens */ - totcolp = give_totcolp(ob); - matarar = give_matarar(ob); + totcolp = BKE_object_material_num(ob); + matarar = BKE_object_material_array(ob); if (totcolp == NULL || matarar == NULL) { return; @@ -836,7 +836,7 @@ void assign_material(Main *bmain, Object *ob, Material *ma, short act, int assig id_us_min(&mao->id); } ob->mat[act - 1] = ma; - test_object_materials(bmain, ob, ob->data); + BKE_object_materials_test(bmain, ob, ob->data); } else { /* in data */ mao = (*matarar)[act - 1]; @@ -844,7 +844,7 @@ void assign_material(Main *bmain, Object *ob, Material *ma, short act, int assig id_us_min(&mao->id); } (*matarar)[act - 1] = ma; - test_all_objects_materials(bmain, ob->data); /* Data may be used by several objects... */ + BKE_objects_materials_test_all(bmain, ob->data); /* Data may be used by several objects... */ } if (ma) { @@ -854,8 +854,8 @@ void assign_material(Main *bmain, Object *ob, Material *ma, short act, int assig void BKE_material_remap_object(Object *ob, const unsigned int *remap) { - Material ***matar = give_matarar(ob); - const short *totcol_p = give_totcolp(ob); + Material ***matar = BKE_object_material_array(ob); + const short *totcol_p = BKE_object_material_num(ob); BLI_array_permute(ob->mat, ob->totcol, remap); @@ -897,7 +897,7 @@ void BKE_material_remap_object_calc(Object *ob_dst, Object *ob_src, short *remap GHash *gh_mat_map = BLI_ghash_ptr_new_ex(__func__, ob_src->totcol); for (int i = 0; i < ob_dst->totcol; i++) { - Material *ma_src = give_current_material(ob_dst, i + 1); + Material *ma_src = BKE_object_material_get(ob_dst, i + 1); BLI_ghash_reinsert(gh_mat_map, ma_src, POINTER_FROM_INT(i), NULL, NULL); } @@ -920,9 +920,9 @@ void BKE_material_remap_object_calc(Object *ob_dst, Object *ob_src, short *remap } for (int i = 0; i < ob_src->totcol; i++) { - Material *ma_src = give_current_material(ob_src, i + 1); + Material *ma_src = BKE_object_material_get(ob_src, i + 1); - if ((i < ob_dst->totcol) && (ma_src == give_current_material(ob_dst, i + 1))) { + if ((i < ob_dst->totcol) && (ma_src == BKE_object_material_get(ob_dst, i + 1))) { /* when objects have exact matching materials - keep existing index */ } else { @@ -937,7 +937,7 @@ void BKE_material_remap_object_calc(Object *ob_dst, Object *ob_src, short *remap } /* XXX - this calls many more update calls per object then are needed, could be optimized */ -void assign_matarar(Main *bmain, struct Object *ob, struct Material ***matar, short totcol) +void BKE_object_material_array_assign(Main *bmain, struct Object *ob, struct Material ***matar, short totcol) { int actcol_orig = ob->actcol; short i; @@ -948,7 +948,7 @@ void assign_matarar(Main *bmain, struct Object *ob, struct Material ***matar, sh /* now we have the right number of slots */ for (i = 0; i < totcol; i++) { - assign_material(bmain, ob, (*matar)[i], i + 1, BKE_MAT_ASSIGN_USERPREF); + BKE_object_material_assign(bmain, ob, (*matar)[i], i + 1, BKE_MAT_ASSIGN_USERPREF); } if (actcol_orig > ob->totcol) { @@ -967,8 +967,8 @@ short BKE_object_material_slot_find_index(Object *ob, Material *ma) return 0; } - totcolp = give_totcolp(ob); - matarar = give_matarar(ob); + totcolp = BKE_object_material_num(ob); + matarar = BKE_object_material_array(ob); if (totcolp == NULL || matarar == NULL) { return 0; @@ -994,7 +994,7 @@ bool BKE_object_material_slot_add(Main *bmain, Object *ob) return false; } - assign_material(bmain, ob, NULL, ob->totcol + 1, BKE_MAT_ASSIGN_USERPREF); + BKE_object_material_assign(bmain, ob, NULL, ob->totcol + 1, BKE_MAT_ASSIGN_USERPREF); ob->actcol = ob->totcol; return true; } @@ -1024,8 +1024,8 @@ bool BKE_object_material_slot_remove(Main *bmain, Object *ob) * after that check indices in mesh/curve/mball!!! */ - totcolp = give_totcolp(ob); - matarar = give_matarar(ob); + totcolp = BKE_object_material_num(ob); + matarar = BKE_object_material_array(ob); if (ELEM(NULL, matarar, *matarar)) { return false; @@ -1264,7 +1264,7 @@ void BKE_texpaint_slots_refresh_object(Scene *scene, struct Object *ob) int i; for (i = 1; i < ob->totcol + 1; i++) { - Material *ma = give_current_material(ob, i); + Material *ma = BKE_object_material_get(ob, i); BKE_texpaint_slot_refresh_cache(scene, ma); } } @@ -1555,13 +1555,13 @@ void ramp_blend(int type, float r_col[3], const float fac, const float col[3]) static Material matcopybuf; static short matcopied = 0; -void clear_matcopybuf(void) +void BKE_material_copybuf_clear(void) { memset(&matcopybuf, 0, sizeof(Material)); matcopied = 0; } -void free_matcopybuf(void) +void BKE_material_copybuf_free(void) { if (matcopybuf.nodetree) { ntreeFreeLocalTree(matcopybuf.nodetree); @@ -1572,10 +1572,10 @@ void free_matcopybuf(void) matcopied = 0; } -void copy_matcopybuf(Main *bmain, Material *ma) +void BKE_material_copybuf_copy(Main *bmain, Material *ma) { if (matcopied) { - free_matcopybuf(); + BKE_material_copybuf_free(); } memcpy(&matcopybuf, ma, sizeof(Material)); @@ -1590,7 +1590,7 @@ void copy_matcopybuf(Main *bmain, Material *ma) matcopied = 1; } -void paste_matcopybuf(Main *bmain, Material *ma) +void BKE_material_copybuf_paste(Main *bmain, Material *ma) { ID id; diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index ba139c654d3..3835e405630 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1092,7 +1092,7 @@ void BKE_mesh_assign_object(Main *bmain, Object *ob, Mesh *me) id_us_plus((ID *)me); } - test_object_materials(bmain, ob, (ID *)me); + BKE_object_materials_test(bmain, ob, (ID *)me); test_object_modifiers(ob); } diff --git a/source/blender/blenkernel/intern/mesh_convert.c b/source/blender/blenkernel/intern/mesh_convert.c index fba84aaad42..c48b3b511d9 100644 --- a/source/blender/blenkernel/intern/mesh_convert.c +++ b/source/blender/blenkernel/intern/mesh_convert.c @@ -1073,7 +1073,7 @@ static Mesh *mesh_new_from_mball_object(Object *object) mesh_result->mat = MEM_dupallocN(mball->mat); if (mball->mat != NULL) { for (int i = mball->totcol; i-- > 0;) { - mesh_result->mat[i] = give_current_material(object, i + 1); + mesh_result->mat[i] = BKE_object_material_get(object, i + 1); } } diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 90205286a72..cf43dec132a 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1677,7 +1677,7 @@ Object *BKE_object_duplicate(Main *bmain, const Object *ob, const int dupflag) } if (dupflag & USER_DUP_MAT) { - matarar = give_matarar(obn); + matarar = BKE_object_material_array(obn); if (matarar) { for (a = 0; a < obn->totcol; a++) { id = (ID *)(*matarar)[a]; @@ -1907,7 +1907,7 @@ void BKE_object_make_proxy(Main *bmain, Object *ob, Object *target, Object *cob) ob->mat = MEM_dupallocN(target->mat); ob->matbits = MEM_dupallocN(target->matbits); for (i = 0; i < target->totcol; i++) { - /* don't need to run test_object_materials + /* don't need to run BKE_object_materials_test * since we know this object is new and not used elsewhere */ id_us_plus((ID *)ob->mat[i]); } diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 97fcef4fd27..7a352f8c9f8 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -2926,7 +2926,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra, const bool use_re &psys->pathcachebufs, totpart, segments + 1); psys->lattice_deform_data = psys_create_lattice_deform_data(sim); - ma = give_current_material(sim->ob, psys->part->omat); + ma = BKE_object_material_get(sim->ob, psys->part->omat); if (ma && (psys->part->draw_col == PART_DRAW_COL_MAT)) { copy_v3_v3(col, &ma->r); } @@ -4309,7 +4309,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, PARTICLE_PSMD; ParticleSystem *psys = sim->psys; ParticleSettings *part = sim->psys->part; - Material *ma = give_current_material(sim->ob, part->omat); + Material *ma = BKE_object_material_get(sim->ob, part->omat); ParticleData *pa; ChildParticle *cpa; ParticleTexture ptex; diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 172940760f9..95726e145b4 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -465,7 +465,7 @@ void psys_thread_context_init(ParticleThreadContext *ctx, ParticleSimulationData memset(ctx, 0, sizeof(ParticleThreadContext)); ctx->sim = *sim; ctx->mesh = ctx->sim.psmd->mesh_final; - ctx->ma = give_current_material(sim->ob, sim->psys->part->omat); + ctx->ma = BKE_object_material_get(sim->ob, sim->psys->part->omat); } void psys_tasks_create(ParticleThreadContext *ctx, diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 6db32ef120f..e55e96e31d9 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -5339,7 +5339,7 @@ static void lib_link_object(FileData *fd, Main *main) /* When the object is local and the data is library its possible * the material list size gets out of sync. [#22663] */ if (ob->data && ob->id.lib != ((ID *)ob->data)->lib) { - const short *totcol_data = give_totcolp(ob); + const short *totcol_data = BKE_object_material_num(ob); /* Only expand so as not to loose any object materials that might be set. */ if (totcol_data && (*totcol_data > ob->totcol)) { /* printf("'%s' %d -> %d\n", ob->id.name, ob->totcol, *totcol_data); */ @@ -9205,7 +9205,7 @@ static void placeholders_ensure_valid(Main *bmain) for (Object *ob = bmain->objects.first; ob != NULL; ob = ob->id.next) { ID *obdata = ob->data; if (obdata != NULL && obdata->tag & LIB_TAG_MISSING) { - test_object_materials(bmain, ob, obdata); + BKE_object_materials_test(bmain, ob, obdata); } } } diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index 9d0d075cade..cd4319e3101 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -356,7 +356,7 @@ void AnimationExporter::export_curve_animation(Object *ob, BCAnimationCurve &cur if (curve.is_of_animation_type(BC_ANIMATION_TYPE_MATERIAL)) { int material_index = curve.get_subindex(); - Material *ma = give_current_material(ob, material_index + 1); + Material *ma = BKE_object_material_get(ob, material_index + 1); if (ma) { collada_target = translate_id(id_name(ma)) + "-effect/common/" + get_collada_sid(curve, axis); diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index b17f647bf14..18ca6ae7a0f 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -1207,7 +1207,7 @@ void AnimationImporter::translate_Animations( } if (animType->material != 0) { - Material *ma = give_current_material(ob, 1); + Material *ma = BKE_object_material_get(ob, 1); if (!ma->adt || !ma->adt->action) { act = verify_adt_action(bmain, (ID *)&ma->id, 1); } diff --git a/source/blender/collada/BCAnimationCurve.cpp b/source/blender/collada/BCAnimationCurve.cpp index f944a77196c..36800d611d2 100644 --- a/source/blender/collada/BCAnimationCurve.cpp +++ b/source/blender/collada/BCAnimationCurve.cpp @@ -69,7 +69,7 @@ void BCAnimationCurve::init_pointer_rna(Object *ob) RNA_id_pointer_create(&ob->id, &id_ptr); } break; case BC_ANIMATION_TYPE_MATERIAL: { - Material *ma = give_current_material(ob, curve_key.get_subindex() + 1); + Material *ma = BKE_object_material_get(ob, curve_key.get_subindex() + 1); RNA_id_pointer_create(&ma->id, &id_ptr); } break; case BC_ANIMATION_TYPE_CAMERA: { @@ -189,7 +189,7 @@ const std::string BCAnimationCurve::get_animation_name(Object *ob) const } break; case BC_ANIMATION_TYPE_MATERIAL: { - Material *ma = give_current_material(ob, this->curve_key.get_subindex() + 1); + Material *ma = BKE_object_material_get(ob, this->curve_key.get_subindex() + 1); name = id_name(ob) + "-" + id_name(ma) + "-material"; } break; diff --git a/source/blender/collada/BCAnimationSampler.cpp b/source/blender/collada/BCAnimationSampler.cpp index 5262d0b3672..f1282e6a347 100644 --- a/source/blender/collada/BCAnimationSampler.cpp +++ b/source/blender/collada/BCAnimationSampler.cpp @@ -428,7 +428,7 @@ void BCAnimationSampler::initialize_keyframes(BCFrameSet &frameset, Object *ob) add_keyframes_from(bc_getSceneLightAction(ob), frameset); for (int a = 0; a < ob->totcol; a++) { - Material *ma = give_current_material(ob, a + 1); + Material *ma = BKE_object_material_get(ob, a + 1); add_keyframes_from(bc_getSceneMaterialAction(ma), frameset); } } @@ -490,7 +490,7 @@ void BCAnimationSampler::initialize_curves(BCAnimationCurveMap &curves, Object * object_type = BC_ANIMATION_TYPE_MATERIAL; for (int a = 0; a < ob->totcol; a++) { /* Export Material parameter animations. */ - Material *ma = give_current_material(ob, a + 1); + Material *ma = BKE_object_material_get(ob, a + 1); if (ma) { action = bc_getSceneMaterialAction(ma); if (action) { diff --git a/source/blender/collada/EffectExporter.cpp b/source/blender/collada/EffectExporter.cpp index 2d69fae035f..a1174fdff56 100644 --- a/source/blender/collada/EffectExporter.cpp +++ b/source/blender/collada/EffectExporter.cpp @@ -65,7 +65,7 @@ bool EffectsExporter::hasEffects(Scene *sce) FOREACH_SCENE_OBJECT_BEGIN (sce, ob) { int a; for (a = 0; a < ob->totcol; a++) { - Material *ma = give_current_material(ob, a + 1); + Material *ma = BKE_object_material_get(ob, a + 1); // no material, but check all of the slots if (!ma) { diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp index a172e2a53e3..1c8123e8384 100644 --- a/source/blender/collada/GeometryExporter.cpp +++ b/source/blender/collada/GeometryExporter.cpp @@ -352,7 +352,7 @@ void GeometryExporter::create_mesh_primitive_list(short material_index, return; } - Material *ma = ob->totcol ? give_current_material(ob, material_index + 1) : NULL; + Material *ma = ob->totcol ? BKE_object_material_get(ob, material_index + 1) : NULL; COLLADASW::PrimitivesBase *primitive_list = create_primitive_list(is_triangulated, mSW); /* sets count attribute in */ diff --git a/source/blender/collada/InstanceWriter.cpp b/source/blender/collada/InstanceWriter.cpp index 5c4f574c1b7..c9390d23fe7 100644 --- a/source/blender/collada/InstanceWriter.cpp +++ b/source/blender/collada/InstanceWriter.cpp @@ -38,7 +38,7 @@ void InstanceWriter::add_material_bindings(COLLADASW::BindMaterial &bind_materia bool active_uv_only) { for (int a = 0; a < ob->totcol; a++) { - Material *ma = give_current_material(ob, a + 1); + Material *ma = BKE_object_material_get(ob, a + 1); COLLADASW::InstanceMaterialList &iml = bind_material.getInstanceMaterialList(); diff --git a/source/blender/collada/MaterialExporter.cpp b/source/blender/collada/MaterialExporter.cpp index 9b16d44d67f..488d1833e48 100644 --- a/source/blender/collada/MaterialExporter.cpp +++ b/source/blender/collada/MaterialExporter.cpp @@ -49,7 +49,7 @@ bool MaterialsExporter::hasMaterials(Scene *sce) Object *ob = (Object *)node->link; int a; for (a = 0; a < ob->totcol; a++) { - Material *ma = give_current_material(ob, a + 1); + Material *ma = BKE_object_material_get(ob, a + 1); // no material, but check all of the slots if (!ma) { diff --git a/source/blender/collada/MaterialExporter.h b/source/blender/collada/MaterialExporter.h index 36047626ad2..be0d939b68a 100644 --- a/source/blender/collada/MaterialExporter.h +++ b/source/blender/collada/MaterialExporter.h @@ -66,7 +66,7 @@ template class ForEachMaterialFunctor { int a; 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 (!ma) { continue; diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp index 8ed30a0dc81..c76cb8c80a6 100644 --- a/source/blender/collada/MeshImporter.cpp +++ b/source/blender/collada/MeshImporter.cpp @@ -1076,7 +1076,7 @@ void MeshImporter::assign_material_to_geom( // Attention! This temporarily assigns material to object on purpose! // See note above. ob->actcol = 0; - assign_material(m_bmain, ob, ma, mat_index + 1, BKE_MAT_ASSIGN_OBJECT); + BKE_object_material_assign(m_bmain, ob, ma, mat_index + 1, BKE_MAT_ASSIGN_OBJECT); MaterialIdPrimitiveArrayMap &mat_prim_map = geom_uid_mat_mapping_map[*geom_uid]; COLLADAFW::MaterialId mat_id = cmaterial.getMaterialId(); diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp index 63dad6b7ac0..df79d863391 100644 --- a/source/blender/collada/collada_utils.cpp +++ b/source/blender/collada/collada_utils.cpp @@ -943,7 +943,7 @@ bool bc_has_animations(Object *ob) /* Check Material Effect parameter animations. */ for (int a = 0; a < ob->totcol; a++) { - Material *ma = give_current_material(ob, a + 1); + Material *ma = BKE_object_material_get(ob, a + 1); if (!ma) { continue; } diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index 6382772c8db..8ec8ccb3d4d 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -717,9 +717,9 @@ void DepsgraphNodeBuilder::build_object_data(Object *object, bool is_object_visi } } /* Materials. */ - Material ***materials_ptr = give_matarar(object); + Material ***materials_ptr = BKE_object_material_array(object); if (materials_ptr != nullptr) { - short *num_materials_ptr = give_totcolp(object); + short *num_materials_ptr = BKE_object_material_num(object); build_materials(*materials_ptr, *num_materials_ptr); } } diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 5214fdbd246..98864b11c4a 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -809,9 +809,9 @@ void DepsgraphRelationBuilder::build_object_data(Object *object) build_nested_shapekey(&object->id, key); } /* Materials. */ - Material ***materials_ptr = give_matarar(object); + Material ***materials_ptr = BKE_object_material_array(object); if (materials_ptr != nullptr) { - short *num_materials_ptr = give_totcolp(object); + short *num_materials_ptr = BKE_object_material_num(object); build_materials(*materials_ptr, *num_materials_ptr); } } diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c index 2e0afc5d8d7..6da7621c6c7 100644 --- a/source/blender/draw/engines/eevee/eevee_materials.c +++ b/source/blender/draw/engines/eevee/eevee_materials.c @@ -1433,7 +1433,7 @@ static void material_transparent(Material *ma, /* Return correct material or &defmaterial if slot is empty. */ BLI_INLINE Material *eevee_object_material_get(Object *ob, int slot) { - Material *ma = give_current_material(ob, slot + 1); + Material *ma = BKE_object_material_get(ob, slot + 1); if (ma == NULL) { ma = &defmaterial; } diff --git a/source/blender/draw/engines/eevee/eevee_volumes.c b/source/blender/draw/engines/eevee/eevee_volumes.c index 423cc64da36..7026894076a 100644 --- a/source/blender/draw/engines/eevee/eevee_volumes.c +++ b/source/blender/draw/engines/eevee/eevee_volumes.c @@ -395,7 +395,7 @@ void EEVEE_volumes_cache_object_add(EEVEE_ViewLayerData *sldata, float *texcoloc = NULL; float *texcosize = NULL; struct ModifierData *md = NULL; - Material *ma = give_current_material(ob, 1); + Material *ma = BKE_object_material_get(ob, 1); if (ma == NULL) { return; diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c index 2c6b1315ad4..f270fde0533 100644 --- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c +++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c @@ -905,7 +905,7 @@ static void gpencil_add_fill_vertexdata(GpencilBatchCache *cache, const bool onion, const bool custonion) { - 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 (gps->totpoints >= 3) { float tfill[4]; /* set color using material, tint color and opacity */ @@ -962,7 +962,7 @@ static void gpencil_add_stroke_vertexdata(GpencilBatchCache *cache, float tcolor[4]; float ink[4]; short sthickness; - 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); const int alignment_mode = (gp_style) ? gp_style->alignment_mode : GP_STYLE_FOLLOW_PATH; /* set color using base color, tint color and opacity */ @@ -1052,7 +1052,7 @@ static void gpencil_add_editpoints_vertexdata(GpencilBatchCache *cache, (GP_SCULPT_MASK_SELECTMODE_POINT | GP_SCULPT_MASK_SELECTMODE_SEGMENT))); - 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); /* alpha factor for edit points/line to make them more subtle */ float edit_alpha = v3d->vertex_opacity; @@ -1166,7 +1166,7 @@ static void gpencil_draw_strokes(GpencilBatchCache *cache, } 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); /* check if stroke can be drawn */ if (gpencil_can_draw_stroke(gp_style, gps, false, is_mat_preview) == false) { @@ -1281,7 +1281,7 @@ static void gpencil_draw_onion_strokes(GpencilBatchCache *cache, ED_gpencil_parent_location(depsgraph, ob, gpd, gpl, gpf->runtime.parent_obmat); for (bGPDstroke *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); if (gp_style == NULL) { continue; } @@ -1489,7 +1489,7 @@ void gpencil_populate_buffer_strokes(GPENCIL_e_data *e_data, } /* this is not common, but avoid any special situations when brush could be without material */ if (gp_style == NULL) { - gp_style = BKE_material_gpencil_settings_get(ob, ob->actcol); + gp_style = BKE_gpencil_material_settings(ob, ob->actcol); } static float unit_mat[4][4] = { @@ -1713,7 +1713,7 @@ static void gpencil_shgroups_create(GPENCIL_e_data *e_data, bGPDframe *gpf = elm->gpf; bGPDstroke *gps = elm->gps; - 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 the user switch used material from data to object, * the material could not be available */ if (gp_style == NULL) { diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c index f4baf2c7837..86183ef0ffb 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.c +++ b/source/blender/draw/engines/gpencil/gpencil_engine.c @@ -368,7 +368,7 @@ void GPENCIL_cache_init(void *vedata) } /* this is not common, but avoid any special situations when brush could be without material */ if (gp_style == NULL) { - gp_style = BKE_material_gpencil_settings_get(obact, obact->actcol); + gp_style = BKE_gpencil_material_settings(obact, obact->actcol); } } diff --git a/source/blender/draw/engines/overlay/overlay_extra.c b/source/blender/draw/engines/overlay/overlay_extra.c index fc52efb0174..688ecaf3946 100644 --- a/source/blender/draw/engines/overlay/overlay_extra.c +++ b/source/blender/draw/engines/overlay/overlay_extra.c @@ -1358,7 +1358,7 @@ static void OVERLAY_gpencil_color_names(Object *ob) continue; } for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) { - Material *ma = give_current_material(ob, gps->mat_nr + 1); + Material *ma = BKE_object_material_get(ob, gps->mat_nr + 1); if (ma == NULL) { continue; } diff --git a/source/blender/draw/engines/overlay/overlay_particle.c b/source/blender/draw/engines/overlay/overlay_particle.c index 3540de35e46..dc98c1b55c1 100644 --- a/source/blender/draw/engines/overlay/overlay_particle.c +++ b/source/blender/draw/engines/overlay/overlay_particle.c @@ -186,7 +186,7 @@ void OVERLAY_particle_cache_populate(OVERLAY_Data *vedata, Object *ob) /* TODO(fclem) Here would be a good place for preemptive culling. */ /* fclem: Is color even usefull in our modern context? */ - Material *ma = give_current_material(ob, part->omat); + Material *ma = BKE_object_material_get(ob, part->omat); float color[4] = {0.6f, 0.6f, 0.6f, part->draw_size}; if (ma != NULL) { copy_v3_v3(color, &ma->r); diff --git a/source/blender/draw/engines/workbench/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c index 26402e66318..3a62e150a9f 100644 --- a/source/blender/draw/engines/workbench/workbench_deferred.c +++ b/source/blender/draw/engines/workbench/workbench_deferred.c @@ -1119,7 +1119,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) struct DRWShadingGroup **shgrps = BLI_array_alloca(shgrps, materials_len); for (int i = 0; i < materials_len; i++) { - struct Material *mat = give_current_material(ob, i + 1); + struct Material *mat = BKE_object_material_get(ob, i + 1); if (mat != NULL && mat->a < 1.0f) { material = workbench_forward_get_or_create_material_data( vedata, ob, mat, NULL, NULL, V3D_SHADING_MATERIAL_COLOR, 0); @@ -1141,7 +1141,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) geoms = DRW_cache_object_surface_material_get(ob, gpumat_array, materials_len); for (int i = 0; i < materials_len; i++) { if (geoms != NULL && geoms[i] != NULL) { - Material *mat = give_current_material(ob, i + 1); + Material *mat = BKE_object_material_get(ob, i + 1); if (mat != NULL && mat->a < 1.0f) { material = workbench_forward_get_or_create_material_data( vedata, ob, mat, NULL, NULL, V3D_SHADING_MATERIAL_COLOR, 0); diff --git a/source/blender/draw/engines/workbench/workbench_forward.c b/source/blender/draw/engines/workbench/workbench_forward.c index 97bea58f31b..fcdf24d2d2f 100644 --- a/source/blender/draw/engines/workbench/workbench_forward.c +++ b/source/blender/draw/engines/workbench/workbench_forward.c @@ -741,7 +741,7 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob) struct DRWShadingGroup **shgrps = BLI_array_alloca(shgrps, materials_len); for (int i = 0; i < materials_len; i++) { - struct Material *mat = give_current_material(ob, i + 1); + struct Material *mat = BKE_object_material_get(ob, i + 1); material = workbench_forward_get_or_create_material_data( vedata, ob, mat, NULL, NULL, V3D_SHADING_MATERIAL_COLOR, 0); shgrps[i] = material->shgrp; @@ -764,7 +764,7 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob) continue; } - Material *mat = give_current_material(ob, i + 1); + Material *mat = BKE_object_material_get(ob, i + 1); material = workbench_forward_get_or_create_material_data( vedata, ob, mat, NULL, NULL, V3D_SHADING_MATERIAL_COLOR, 0); /* TODO(fclem) make this call optional */ diff --git a/source/blender/draw/engines/workbench/workbench_materials.c b/source/blender/draw/engines/workbench/workbench_materials.c index fc054b11d55..7adc74aab2d 100644 --- a/source/blender/draw/engines/workbench/workbench_materials.c +++ b/source/blender/draw/engines/workbench/workbench_materials.c @@ -334,7 +334,7 @@ void workbench_material_get_image_and_mat( Object *ob, int mat_nr, Image **r_image, ImageUser **r_iuser, int *r_interp, Material **r_mat) { bNode *node; - *r_mat = give_current_material(ob, mat_nr); + *r_mat = BKE_object_material_get(ob, mat_nr); ED_object_get_active_image(ob, mat_nr, r_image, r_iuser, &node, NULL); if (node && *r_image) { switch (node->type) { 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)) { diff --git a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp index 8bd4fda8e23..f49a664096a 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp +++ b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp @@ -519,7 +519,7 @@ void BlenderFileLoader::insertShapeNode(Object *ob, Mesh *me, int id) for (int a = 0; a < tottri; a++) { const MLoopTri *lt = &mlooptri[a]; const MPoly *mp = &mpoly[lt->poly]; - Material *mat = give_current_material(ob, mp->mat_nr + 1); + Material *mat = BKE_object_material_get(ob, mp->mat_nr + 1); copy_v3_v3(v1, mvert[mloop[lt->tri[0]].v].co); copy_v3_v3(v2, mvert[mloop[lt->tri[1]].v].co); diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp index f96f5f119c0..bb9655fa59c 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp +++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp @@ -838,7 +838,7 @@ void BlenderStrokeRenderer::GenerateStrokeMesh(StrokeGroup *group, bool hasTex) material_index++; } // loop over strokes - test_object_materials(freestyle_bmain, object_mesh, (ID *)mesh); + BKE_object_materials_test(freestyle_bmain, object_mesh, (ID *)mesh); #if 0 // XXX BLI_assert(mesh->totvert == vertex_index); diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c index 16e585705df..5069a9aa1cb 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c @@ -89,7 +89,7 @@ bool is_stroke_affected_by_modifier(Object *ob, const bool inv3, const bool inv4) { - Material *ma = BKE_material_gpencil_get(ob, gps->mat_nr + 1); + Material *ma = BKE_gpencil_material(ob, gps->mat_nr + 1); MaterialGPencilStyle *gp_style = ma->gp_style; /* omit if filter by layer */ @@ -201,7 +201,7 @@ void gpencil_apply_modifier_material( newmat = BKE_material_copy(bmain, mat); newmat->preview = NULL; - assign_material(bmain, ob, newmat, ob->totcol, BKE_MAT_ASSIGN_USERPREF); + BKE_object_material_assign(bmain, ob, newmat, ob->totcol, BKE_MAT_ASSIGN_USERPREF); copy_v4_v4(newmat->gp_style->stroke_rgba, gps->runtime.tmp_stroke_rgba); copy_v4_v4(newmat->gp_style->fill_rgba, gps->runtime.tmp_fill_rgba); diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c index cbe2d9a4c4f..d9869c92e06 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c @@ -119,7 +119,7 @@ static void bakeModifier(Main *bmain, Depsgraph *depsgraph, GpencilModifierData for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) { for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) { - Material *mat = BKE_material_gpencil_get(ob, gps->mat_nr + 1); + Material *mat = BKE_gpencil_material(ob, gps->mat_nr + 1); if (mat == NULL) { continue; } diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c index c0892a1d91a..b0fab5e8d69 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c @@ -155,7 +155,7 @@ static void bakeModifier(Main *bmain, Depsgraph *depsgraph, GpencilModifierData for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) { for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) { - Material *mat = BKE_material_gpencil_get(ob, gps->mat_nr + 1); + Material *mat = BKE_gpencil_material(ob, gps->mat_nr + 1); if (mat == NULL) { continue; } diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c b/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c index f03bc489521..8f3956276dd 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c @@ -125,7 +125,7 @@ static void bakeModifier(Main *bmain, Depsgraph *depsgraph, GpencilModifierData for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) { for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) { - Material *mat = BKE_material_gpencil_get(ob, gps->mat_nr + 1); + Material *mat = BKE_gpencil_material(ob, gps->mat_nr + 1); if (mat == NULL) { continue; } diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index 49fdf9c67d5..0b4ac400152 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -630,12 +630,12 @@ static int rna_IDPArray_length(PointerRNA *ptr) int rna_IDMaterials_assign_int(PointerRNA *ptr, int key, const PointerRNA *assign_ptr) { ID *id = ptr->owner_id; - short *totcol = give_totcolp_id(id); + short *totcol = BKE_id_material_num(id); Material *mat_id = (Material *)assign_ptr->owner_id; if (totcol && (key >= 0 && key < *totcol)) { BLI_assert(BKE_id_is_in_global_main(id)); BLI_assert(BKE_id_is_in_global_main(&mat_id->id)); - assign_material_id(G_MAIN, id, mat_id, key + 1); + BKE_id_material_assign(G_MAIN, id, mat_id, key + 1); return 1; } else { @@ -654,7 +654,7 @@ static void rna_IDMaterials_append_id(ID *id, Main *bmain, Material *ma) static Material *rna_IDMaterials_pop_id(ID *id, Main *bmain, ReportList *reports, int index_i) { Material *ma; - short *totcol = give_totcolp_id(id); + short *totcol = BKE_id_material_num(id); const short totcol_orig = *totcol; if (index_i < 0) { index_i += (*totcol); diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index b0ee5da82b3..edbaa13f80c 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -778,7 +778,7 @@ static void rna_BrushGpencilSettings_use_material_pin_update(bContext *C, Pointe Brush *brush = (Brush *)ptr->owner_id; if (brush->gpencil_settings->flag & GP_BRUSH_MATERIAL_PINNED) { - Material *material = give_current_material(ob, ob->actcol); + Material *material = BKE_object_material_get(ob, ob->actcol); BKE_gpencil_brush_material_set(brush, material); } else { diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index 9df21a16e90..31e696534fe 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -270,7 +270,7 @@ static Object *rna_Main_objects_new(Main *bmain, ReportList *reports, const char ob = BKE_object_add_only_object(bmain, type, safe_name); ob->data = data; - test_object_materials(bmain, ob, ob->data); + BKE_object_materials_test(bmain, ob, ob->data); return ob; } @@ -289,7 +289,7 @@ static void rna_Main_materials_gpencil_data(Main *UNUSED(bmain), PointerRNA *id_ { ID *id = id_ptr->data; Material *ma = (Material *)id; - BKE_material_init_gpencil_settings(ma); + BKE_gpencil_material_attr_init(ma); } static void rna_Main_materials_gpencil_remove(Main *UNUSED(bmain), PointerRNA *id_ptr) diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 70192198e14..64aca3ca442 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -489,7 +489,7 @@ static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value, struct Report id_us_plus(id); ob->data = id; - test_object_materials(G_MAIN, ob, id); + BKE_object_materials_test(G_MAIN, ob, id); if (GS(id->name) == ID_CU) { BKE_curve_type_test(ob); @@ -956,7 +956,7 @@ static PointerRNA rna_Object_active_material_get(PointerRNA *ptr) Object *ob = (Object *)ptr->owner_id; Material *ma; - ma = (ob->totcol) ? give_current_material(ob, ob->actcol) : NULL; + ma = (ob->totcol) ? BKE_object_material_get(ob, ob->actcol) : NULL; return rna_pointer_inherit_refine(ptr, &RNA_Material, ma); } @@ -969,7 +969,7 @@ static void rna_Object_active_material_set(PointerRNA *ptr, DEG_id_tag_update(value.data, 0); BLI_assert(BKE_id_is_in_global_main(&ob->id)); BLI_assert(BKE_id_is_in_global_main(value.data)); - assign_material(G_MAIN, ob, value.data, ob->actcol, BKE_MAT_ASSIGN_EXISTING); + BKE_object_material_assign(G_MAIN, ob, value.data, ob->actcol, BKE_MAT_ASSIGN_EXISTING); if (ob && ob->type == OB_GPENCIL) { /* notifying material property in topbar */ @@ -1173,7 +1173,7 @@ static PointerRNA rna_MaterialSlot_material_get(PointerRNA *ptr) Material *ma; const int index = (Material **)ptr->data - ob->mat; - ma = give_current_material(ob, index + 1); + ma = BKE_object_material_get(ob, index + 1); return rna_pointer_inherit_refine(ptr, &RNA_Material, ma); } @@ -1186,7 +1186,7 @@ static void rna_MaterialSlot_material_set(PointerRNA *ptr, BLI_assert(BKE_id_is_in_global_main(&ob->id)); BLI_assert(BKE_id_is_in_global_main(value.data)); - assign_material(G_MAIN, ob, value.data, index + 1, BKE_MAT_ASSIGN_EXISTING); + BKE_object_material_assign(G_MAIN, ob, value.data, index + 1, BKE_MAT_ASSIGN_EXISTING); } static bool rna_MaterialSlot_material_poll(PointerRNA *ptr, PointerRNA value) @@ -1233,7 +1233,7 @@ static int rna_MaterialSlot_name_length(PointerRNA *ptr) Material *ma; int index = (Material **)ptr->data - ob->mat; - ma = give_current_material(ob, index + 1); + ma = BKE_object_material_get(ob, index + 1); if (ma) { return strlen(ma->id.name + 2); @@ -1248,7 +1248,7 @@ static void rna_MaterialSlot_name_get(PointerRNA *ptr, char *str) Material *ma; int index = (Material **)ptr->data - ob->mat; - ma = give_current_material(ob, index + 1); + ma = BKE_object_material_get(ob, index + 1); if (ma) { strcpy(str, ma->id.name + 2); diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 29ec968fe2a..d779ae9178c 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -425,7 +425,7 @@ static const EnumPropertyItem *rna_Particle_Material_itemf(bContext *C, if (ob && ob->totcol > 0) { for (i = 1; i <= ob->totcol; i++) { - ma = give_current_material(ob, i); + ma = BKE_object_material_get(ob, i); tmp.value = i; tmp.icon = ICON_MATERIAL_DATA; if (ma) { diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c index 612cd0c9293..3a51239306e 100644 --- a/source/blender/nodes/shader/node_shader_tree.c +++ b/source/blender/nodes/shader/node_shader_tree.c @@ -95,7 +95,7 @@ static void shader_get_from_context(const bContext *C, *r_ntree = ((Light *)ob->data)->nodetree; } else { - Material *ma = give_current_material(ob, ob->actcol); + Material *ma = BKE_object_material_get(ob, ob->actcol); if (ma) { *r_id = &ma->id; *r_ntree = ma->nodetree; diff --git a/source/blender/usd/intern/usd_writer_mesh.cc b/source/blender/usd/intern/usd_writer_mesh.cc index 28e13013cfd..dc603f25b21 100644 --- a/source/blender/usd/intern/usd_writer_mesh.cc +++ b/source/blender/usd/intern/usd_writer_mesh.cc @@ -339,7 +339,7 @@ void USDGenericMeshWriter::assign_materials(const HierarchyContext &context, * https://github.com/PixarAnimationStudios/USD/issues/542 for more info. */ bool mesh_material_bound = false; for (short mat_num = 0; mat_num < context.object->totcol; mat_num++) { - Material *material = give_current_material(context.object, mat_num + 1); + Material *material = BKE_object_material_get(context.object, mat_num + 1); if (material == nullptr) { continue; } @@ -373,7 +373,7 @@ void USDGenericMeshWriter::assign_materials(const HierarchyContext &context, short material_number = face_group.first; const pxr::VtIntArray &face_indices = face_group.second; - Material *material = give_current_material(context.object, material_number + 1); + Material *material = BKE_object_material_get(context.object, material_number + 1); if (material == nullptr) { continue; } diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 2f4abbe20d8..32ef4ca8f95 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -72,7 +72,7 @@ #include "BKE_appdir.h" #include "BKE_sequencer.h" /* free seq clipboard */ #include "BKE_studiolight.h" -#include "BKE_material.h" /* clear_matcopybuf */ +#include "BKE_material.h" /* BKE_material_copybuf_clear */ #include "BKE_tracking.h" /* free tracking clipboard */ #include "BKE_mask.h" /* free mask clipboard */ @@ -350,7 +350,7 @@ void WM_init(bContext *C, int argc, const char **argv) GHOST_toggleConsole(3); } - clear_matcopybuf(); + BKE_material_copybuf_clear(); ED_render_clear_mtex_copybuf(); // glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); @@ -533,7 +533,7 @@ void WM_exit_ex(bContext *C, const bool do_python) BKE_addon_pref_type_free(); BKE_keyconfig_pref_type_free(); - BKE_material_gpencil_default_free(); + BKE_materials_exit(); wm_operatortype_free(); wm_dropbox_free(); @@ -582,7 +582,7 @@ void WM_exit_ex(bContext *C, const bool do_python) } BKE_blender_free(); /* blender.c, does entire library and spacetypes */ - // free_matcopybuf(); + // BKE_material_copybuf_free(); ANIM_fcurves_copybuf_free(); ANIM_drivers_copybuf_free(); ANIM_driver_vars_copybuf_free(); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 5837e8e952c..051d9959010 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -457,7 +457,7 @@ static const char *wm_context_member_from_ptr(bContext *C, const PointerRNA *ptr } case ID_MA: { # define ID_CAST_OBMATACT(id_pt) \ - (give_current_material(((Object *)id_pt), ((Object *)id_pt)->actcol)) + (BKE_object_material_get(((Object *)id_pt), ((Object *)id_pt)->actcol)) CTX_TEST_PTR_ID_CAST( C, "object", "object.active_material", ID_CAST_OBMATACT, ptr->owner_id); break; diff --git a/source/creator/creator.c b/source/creator/creator.c index 58d12527f1c..cf25be95472 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -424,7 +424,7 @@ int main(int argc, * rendered via ffmpeg. */ BKE_sound_init_once(); - init_def_material(); + BKE_materials_init(); #ifdef WITH_USD /* Tell USD which directory to search for its JSON files. If datafiles/usd -- cgit v1.2.3