[Bf-blender-cvs] [cce16df10f5] blender2.8: Fix Cycles viewport render stuck with curve objects.

Brecht Van Lommel noreply at git.blender.org
Wed May 30 18:27:02 CEST 2018


Commit: cce16df10f55c8ba1e719cb20ec22dea7d37da58
Author: Brecht Van Lommel
Date:   Wed May 30 18:16:35 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBcce16df10f55c8ba1e719cb20ec22dea7d37da58

Fix Cycles viewport render stuck with curve objects.

We should solve this better by making the depsgraph convert all curves to
meshes, for now ensure we don't to depsgraph tags during export.

===================================================================

M	source/blender/blenkernel/BKE_mesh.h
M	source/blender/blenkernel/intern/mesh_convert.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index 499bea1dd51..e9ace0bb19b 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -140,7 +140,7 @@ int BKE_mesh_nurbs_displist_to_mdata(
         struct MLoop **r_allloop, struct MPoly **r_allpoly,
         struct MLoopUV **r_alluv, int *r_totloop, int *r_totpoly);
 void BKE_mesh_from_nurbs_displist(
-        struct Object *ob, struct ListBase *dispbase, const bool use_orco_uv, const char *obdata_name);
+        struct Object *ob, struct ListBase *dispbase, const bool use_orco_uv, const char *obdata_name, bool temporary);
 void BKE_mesh_from_nurbs(struct Object *ob);
 void BKE_mesh_to_curve_nurblist(struct DerivedMesh *dm, struct ListBase *nurblist, const int edge_users_test);
 void BKE_mesh_to_curve(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob);
diff --git a/source/blender/blenkernel/intern/mesh_convert.c b/source/blender/blenkernel/intern/mesh_convert.c
index a48a74f2d67..b441c3f7a40 100644
--- a/source/blender/blenkernel/intern/mesh_convert.c
+++ b/source/blender/blenkernel/intern/mesh_convert.c
@@ -534,7 +534,7 @@ Mesh *BKE_mesh_new_nomain_from_curve(Object *ob)
 }
 
 /* this may fail replacing ob->data, be sure to check ob->type */
-void BKE_mesh_from_nurbs_displist(Object *ob, ListBase *dispbase, const bool use_orco_uv, const char *obdata_name)
+void BKE_mesh_from_nurbs_displist(Object *ob, ListBase *dispbase, const bool use_orco_uv, const char *obdata_name, bool temporary)
 {
 	Main *bmain = G.main;
 	Object *ob1;
@@ -620,7 +620,16 @@ void BKE_mesh_from_nurbs_displist(Object *ob, ListBase *dispbase, const bool use
 		ob1 = ob1->id.next;
 	}
 
-	BKE_libblock_free_us(bmain, cu);
+	if (temporary) {
+		/* For temporary objects in BKE_mesh_new_from_object don't remap
+		 * the entire scene with associated depsgraph updates, which are
+		 * problematic for renderers exporting data. */
+		id_us_min(&cu->id);
+		BKE_libblock_free(bmain, cu);
+	}
+	else {
+		BKE_libblock_free_us(bmain, cu);
+	}
 }
 
 void BKE_mesh_from_nurbs(Object *ob)
@@ -633,7 +642,7 @@ void BKE_mesh_from_nurbs(Object *ob)
 		disp = ob->curve_cache->disp;
 	}
 
-	BKE_mesh_from_nurbs_displist(ob, &disp, use_orco_uv, cu->id.name);
+	BKE_mesh_from_nurbs_displist(ob, &disp, use_orco_uv, cu->id.name, false);
 }
 
 typedef struct EdgeLink {
@@ -856,9 +865,8 @@ Mesh *BKE_mesh_new_from_object(
 			/* copies object and modifiers (but not the data) */
 			Object *tmpobj;
 			/* TODO: make it temp copy outside bmain! */
-			BKE_id_copy_ex(bmain, &ob->id, (ID **)&tmpobj, LIB_ID_COPY_CACHES, false);
+			BKE_id_copy_ex(bmain, &ob->id, (ID **)&tmpobj, LIB_ID_COPY_CACHES | LIB_ID_CREATE_NO_DEG_TAG, false);
 			tmpcu = (Curve *)tmpobj->data;
-			id_us_min(&tmpcu->id);
 
 			/* Copy cached display list, it might be needed by the stack evaluation.
 			 * Ideally stack should be able to use render-time display list, but doing
@@ -878,7 +886,8 @@ Mesh *BKE_mesh_new_from_object(
 				BKE_object_free_modifiers(tmpobj, 0);
 
 			/* copies the data */
-			copycu = tmpobj->data = BKE_curve_copy(bmain, (Curve *) ob->data);
+			BKE_id_copy_ex(bmain,ob->data, (ID **)&copycu, LIB_ID_CREATE_NO_DEG_TAG, false);
+			tmpobj->data = copycu;
 
 			/* make sure texture space is calculated for a copy of curve,
 			 * it will be used for the final result.
@@ -901,7 +910,7 @@ Mesh *BKE_mesh_new_from_object(
 
 			/* convert object type to mesh */
 			uv_from_orco = (tmpcu->flag & CU_UV_ORCO) != 0;
-			BKE_mesh_from_nurbs_displist(tmpobj, &dispbase, uv_from_orco, tmpcu->id.name + 2);
+			BKE_mesh_from_nurbs_displist(tmpobj, &dispbase, uv_from_orco, tmpcu->id.name + 2, true);
 
 			tmpmesh = tmpobj->data;
 
@@ -911,11 +920,11 @@ Mesh *BKE_mesh_new_from_object(
 			 * if it didn't the curve did not have any segments or otherwise
 			 * would have generated an empty mesh */
 			if (tmpobj->type != OB_MESH) {
-				BKE_libblock_free_us(bmain, tmpobj);
+				BKE_libblock_free(bmain, tmpobj);
 				return NULL;
 			}
 
-			BKE_libblock_free_us(bmain, tmpobj);
+			BKE_libblock_free(bmain, tmpobj);
 
 			/* 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



More information about the Bf-blender-cvs mailing list