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.c52
1 files changed, 13 insertions, 39 deletions
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index d8c0b5d6dce..8c09cb551a1 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -100,12 +100,20 @@ static void material_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const
Material *material_dst = (Material *)id_dst;
const Material *material_src = (const Material *)id_src;
+ const bool is_localized = (flag & LIB_ID_CREATE_LOCAL) != 0;
/* We always need allocation of our private ID data. */
const int flag_private_id_data = flag & ~LIB_ID_CREATE_NO_ALLOCATE;
- if (material_src->nodetree) {
- BKE_id_copy_ex(
- bmain, (ID *)material_src->nodetree, (ID **)&material_dst->nodetree, flag_private_id_data);
+ if (material_src->nodetree != NULL) {
+ if (is_localized) {
+ material_dst->nodetree = ntreeLocalize(material_src->nodetree);
+ }
+ else {
+ BKE_id_copy_ex(bmain,
+ (ID *)material_src->nodetree,
+ (ID **)&material_dst->nodetree,
+ flag_private_id_data);
+ }
}
if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0) {
@@ -116,7 +124,8 @@ static void material_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const
}
if (material_src->texpaintslot != NULL) {
- material_dst->texpaintslot = MEM_dupallocN(material_src->texpaintslot);
+ /* TODO: Think we can also skip copying this data in the more generic `NO_MAIN` case? */
+ material_dst->texpaintslot = is_localized ? NULL : MEM_dupallocN(material_src->texpaintslot);
}
if (material_src->gp_style != NULL) {
@@ -315,41 +324,6 @@ Material *BKE_material_copy(Main *bmain, const Material *ma)
return ma_copy;
}
-/* XXX (see above) material copy without adding to main dbase */
-Material *BKE_material_localize(Material *ma)
-{
- /* TODO(bastien): Replace with something like:
- *
- * Material *ma_copy;
- * BKE_id_copy_ex(bmain, &ma->id, (ID **)&ma_copy,
- * LIB_ID_COPY_NO_MAIN | LIB_ID_COPY_NO_PREVIEW | LIB_ID_COPY_NO_USER_REFCOUNT,
- * false);
- * return ma_copy;
- *
- * NOTE: Only possible once nested node trees are fully converted to that too. */
-
- Material *man = BKE_libblock_copy_for_localize(&ma->id);
-
- man->texpaintslot = NULL;
- man->preview = NULL;
-
- if (ma->nodetree != NULL) {
- man->nodetree = ntreeLocalize(ma->nodetree);
- }
-
- if (ma->gp_style != NULL) {
- man->gp_style = MEM_dupallocN(ma->gp_style);
- }
-
- BLI_listbase_clear(&man->gpumaterial);
-
- /* TODO Duplicate Engine Settings and set runtime to NULL */
-
- man->id.tag |= LIB_TAG_LOCALIZED;
-
- return man;
-}
-
Material ***BKE_object_material_array_p(Object *ob)
{
if (ob->type == OB_MESH) {