Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/material.c')
-rw-r--r--source/blender/blenkernel/intern/material.c60
1 files changed, 12 insertions, 48 deletions
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index 17811893c03..0be32c9b84c 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -243,14 +243,11 @@ Material *BKE_material_copy(Main *bmain, Material *ma)
man->nodetree = ntreeCopyTree(bmain, ma->nodetree);
}
- man->preview = BKE_previewimg_copy(ma->preview);
+ BKE_previewimg_id_copy(&man->id, &ma->id);
BLI_listbase_clear(&man->gpumaterial);
- if (ID_IS_LINKED_DATABLOCK(ma)) {
- BKE_id_expand_local(&man->id);
- BKE_id_lib_local_paths(bmain, ma->id.lib, &man->id);
- }
+ BKE_id_copy_ensure_local(bmain, &ma->id, &man->id);
return man;
}
@@ -285,34 +282,9 @@ Material *localize_material(Material *ma)
return man;
}
-void BKE_material_make_local(Main *bmain, Material *ma)
+void BKE_material_make_local(Main *bmain, Material *ma, const bool lib_local)
{
- bool is_local = false, is_lib = false;
-
- /* - only lib users: do nothing
- * - only local users: set flag
- * - mixed: make copy
- */
-
- if (!ID_IS_LINKED_DATABLOCK(ma)) {
- return;
- }
-
- BKE_library_ID_test_usages(bmain, ma, &is_local, &is_lib);
-
- if (is_local) {
- if (!is_lib) {
- id_clear_lib_data(bmain, &ma->id);
- BKE_id_expand_local(&ma->id);
- }
- else {
- Material *ma_new = BKE_material_copy(bmain, ma);
-
- ma_new->id.us = 0;
-
- BKE_libblock_remap(bmain, ma, ma_new, ID_REMAP_SKIP_INDIRECT_USAGE);
- }
- }
+ BKE_id_make_local_generic(bmain, &ma->id, true, lib_local);
}
Material ***give_matarar(Object *ob)
@@ -569,18 +541,6 @@ Material *give_current_material(Object *ob, short act)
return ma;
}
-ID *material_from(Object *ob, short act)
-{
-
- if (ob == NULL) return NULL;
-
- if (ob->totcol == 0) return ob->data;
- if (act == 0) act = 1;
-
- if (ob->matbits[act - 1]) return (ID *)ob;
- else return ob->data;
-}
-
Material *give_node_material(Material *ma)
{
if (ma && ma->use_nodes && ma->nodetree) {
@@ -886,7 +846,11 @@ void assign_matarar(struct Object *ob, struct Material ***matar, short totcol)
int actcol_orig = ob->actcol;
short i;
- while (object_remove_material_slot(ob)) {}
+ while ((ob->totcol > totcol) &&
+ BKE_object_material_slot_remove(ob))
+ {
+ /* pass */
+ }
/* now we have the right number of slots */
for (i = 0; i < totcol; i++)
@@ -899,7 +863,7 @@ void assign_matarar(struct Object *ob, struct Material ***matar, short totcol)
}
-short find_material_index(Object *ob, Material *ma)
+short BKE_object_material_slot_find_index(Object *ob, Material *ma)
{
Material ***matarar;
short a, *totcolp;
@@ -919,7 +883,7 @@ short find_material_index(Object *ob, Material *ma)
return 0;
}
-bool object_add_material_slot(Object *ob)
+bool BKE_object_material_slot_add(Object *ob)
{
if (ob == NULL) return false;
if (ob->totcol >= MAXMAT) return false;
@@ -1201,7 +1165,7 @@ void material_drivers_update(Scene *scene, Material *ma, float ctime)
ma->id.tag &= ~LIB_TAG_DOIT;
}
-bool object_remove_material_slot(Object *ob)
+bool BKE_object_material_slot_remove(Object *ob)
{
Material *mao, ***matarar;
Object *obt;