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:
authorBastien Montagne <montagne29@wanadoo.fr>2016-10-03 18:38:14 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2016-10-03 18:38:14 +0300
commitb9e82b5bfb992c36dd38bca1c9716167b4b9d750 (patch)
tree69342419046863796865d61619bde538284a1a0e
parent853d232928f2eb02b7bd2151946ee12c184158fd (diff)
Fix T49548: Entering Cycles Rendered Viewport Unlinks Material from Objects.
We *always* want to increase mat user count when from Object (and not Data), because in that case we are moving mat from object to temp generated mesh, material can never be 'borrowed' in that case. To be backported to 2.78a
-rw-r--r--source/blender/blenkernel/intern/mesh.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index 1cc8d8c381c..2c6ed0df04b 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -1359,7 +1359,7 @@ void BKE_mesh_from_nurbs_displist(Object *ob, ListBase *dispbase, const bool use
}
/* make mesh */
- me = BKE_mesh_add(G.main, "Mesh");
+ me = BKE_mesh_add(bmain, "Mesh");
me->totvert = totvert;
me->totedge = totedge;
me->totloop = totloop;
@@ -1379,7 +1379,7 @@ void BKE_mesh_from_nurbs_displist(Object *ob, ListBase *dispbase, const bool use
BKE_mesh_calc_normals(me);
}
else {
- me = BKE_mesh_add(G.main, "Mesh");
+ me = BKE_mesh_add(bmain, "Mesh");
DM_to_mesh(dm, me, ob, CD_MASK_MESH, false);
}
@@ -2200,7 +2200,7 @@ Mesh *BKE_mesh_new_from_object(
int i;
const bool render = (settings == eModifierMode_Render);
const bool cage = !apply_modifiers;
- bool do_mat_id_us = true;
+ bool do_mat_id_data_us = true;
/* perform the mesh extraction based on type */
switch (ob->type) {
@@ -2274,7 +2274,7 @@ Mesh *BKE_mesh_new_from_object(
/* XXX The curve to mesh conversion is convoluted... But essentially, BKE_mesh_from_nurbs_displist()
* already transfers the ownership of materials from the temp copy of the Curve ID to the new
* Mesh ID, so we do not want to increase materials' usercount later. */
- do_mat_id_us = false;
+ do_mat_id_data_us = false;
break;
}
@@ -2325,7 +2325,7 @@ Mesh *BKE_mesh_new_from_object(
tmpmesh = BKE_mesh_copy(bmain, ob->data);
/* XXX BKE_mesh_copy() already handles materials usercount. */
- do_mat_id_us = false;
+ do_mat_id_data_us = false;
}
/* if not getting the original caged mesh, get final derived mesh */
else {
@@ -2375,7 +2375,7 @@ Mesh *BKE_mesh_new_from_object(
tmpmesh->mat[i] = ob->matbits[i] ? ob->mat[i] : tmpcu->mat[i];
}
- if (do_mat_id_us && tmpmesh->mat[i]) {
+ if ((ob->matbits[i] || do_mat_id_data_us) && tmpmesh->mat[i]) {
id_us_plus(&tmpmesh->mat[i]->id);
}
}
@@ -2399,7 +2399,7 @@ Mesh *BKE_mesh_new_from_object(
tmpmesh->mat[i] = ob->matbits[i] ? ob->mat[i] : tmpmb->mat[i];
}
- if (do_mat_id_us && tmpmesh->mat[i]) {
+ if ((ob->matbits[i] || do_mat_id_data_us) && tmpmesh->mat[i]) {
id_us_plus(&tmpmesh->mat[i]->id);
}
}
@@ -2424,7 +2424,7 @@ Mesh *BKE_mesh_new_from_object(
tmpmesh->mat[i] = ob->matbits[i] ? ob->mat[i] : origmesh->mat[i];
}
- if (do_mat_id_us && tmpmesh->mat[i]) {
+ if ((ob->matbits[i] || do_mat_id_data_us) && tmpmesh->mat[i]) {
id_us_plus(&tmpmesh->mat[i]->id);
}
}