[Bf-blender-cvs] [0ef4c4e12a9] blender2.8: Mesh: remove DerivedMesh for displist conversion

Campbell Barton noreply at git.blender.org
Mon Oct 15 07:20:03 CEST 2018


Commit: 0ef4c4e12a95cbe49af6e42b6e20a6d69547796c
Author: Campbell Barton
Date:   Mon Oct 15 15:58:58 2018 +1100
Branches: blender2.8
https://developer.blender.org/rB0ef4c4e12a95cbe49af6e42b6e20a6d69547796c

Mesh: remove DerivedMesh for displist conversion

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

M	source/blender/blenkernel/BKE_displist.h
M	source/blender/blenkernel/intern/displist.c
M	source/blender/blenkernel/intern/mesh_convert.c

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

diff --git a/source/blender/blenkernel/BKE_displist.h b/source/blender/blenkernel/BKE_displist.h
index 034f9b2b6a8..02c86642b11 100644
--- a/source/blender/blenkernel/BKE_displist.h
+++ b/source/blender/blenkernel/BKE_displist.h
@@ -58,7 +58,7 @@ enum {
 /* prototypes */
 
 struct Depsgraph;
-struct DerivedMesh;
+struct Mesh;
 struct ListBase;
 struct Main;
 struct Object;
@@ -89,12 +89,12 @@ bool BKE_displist_has_faces(struct ListBase *lb);
 
 void BKE_displist_make_surf(
         struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct ListBase *dispbase,
-        struct DerivedMesh **r_dm_final, const bool for_render, const bool for_orco, const bool use_render_resolution);
+        struct Mesh **r_final, const bool for_render, const bool for_orco, const bool use_render_resolution);
 void BKE_displist_make_curveTypes(
         struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, const bool for_orco);
 void BKE_displist_make_curveTypes_forRender(
         struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct ListBase *dispbase,
-        struct DerivedMesh **r_dm_final, const bool for_orco, const bool use_render_resolution);
+        struct Mesh **r_final, const bool for_orco, const bool use_render_resolution);
 void BKE_displist_make_curveTypes_forOrco(
         struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct ListBase *dispbase);
 void BKE_displist_make_mball(
@@ -107,11 +107,6 @@ void BKE_displist_fill(struct ListBase *dispbase, struct ListBase *to, const flo
 
 float BKE_displist_calc_taper(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *taperobj, int cur, int tot);
 
-/* add Orco layer to the displist object which has got derived mesh and return orco */
-float *BKE_displist_make_orco(
-        struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct DerivedMesh *dm_final,
-        const bool for_render, const bool use_render_resolution);
-
 void BKE_displist_minmax(struct ListBase *dispbase, float min[3], float max[3]);
 
 #endif
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index 26a66dc9ce2..9887d902850 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -920,7 +920,7 @@ static void displist_apply_allverts(ListBase *dispbase, float (*allverts)[3])
 
 static void curve_calc_modifiers_post(
         Depsgraph *depsgraph, Scene *scene, Object *ob, ListBase *nurb,
-        ListBase *dispbase, DerivedMesh **r_dm_final,
+        ListBase *dispbase, Mesh **r_final,
         const bool for_render, const bool use_render_resolution)
 {
 	VirtualModifierData virtualModifierData;
@@ -955,8 +955,8 @@ static void curve_calc_modifiers_post(
 		md = pretessellatePoint->next;
 	}
 
-	if (r_dm_final && *r_dm_final) {
-		(*r_dm_final)->release(*r_dm_final);
+	if (r_final && *r_final) {
+		BKE_id_free(NULL, r_final);
 	}
 
 	for (; md; md = md->next) {
@@ -982,7 +982,7 @@ static void curve_calc_modifiers_post(
 			}
 		}
 		else {
-			if (!r_dm_final) {
+			if (!r_final) {
 				/* makeDisplistCurveTypes could be used for beveling, where derived mesh
 				 * is totally unnecessary, so we could stop modifiers applying
 				 * when we found constructive modifier but derived mesh is unwanted result
@@ -1055,7 +1055,7 @@ static void curve_calc_modifiers_post(
 		}
 	}
 
-	if (r_dm_final) {
+	if (r_final) {
 		if (modified) {
 			/* see: mesh_calc_modifiers */
 			if (modified->totface == 0) {
@@ -1070,11 +1070,10 @@ static void curve_calc_modifiers_post(
 			/* XXX2.8(Sybren): make sure the face normals are recalculated as well */
 			BKE_mesh_ensure_normals(modified);
 
-			(*r_dm_final) = CDDM_from_mesh_ex(modified, CD_DUPLICATE, CD_MASK_MESH);
-			BKE_id_free(NULL, modified);
+			(*r_final) = modified;
 		}
 		else {
-			(*r_dm_final) = NULL;
+			(*r_final) = NULL;
 		}
 
 	}
@@ -1230,7 +1229,7 @@ static void curve_calc_orcodm(
 
 void BKE_displist_make_surf(
         Depsgraph *depsgraph, Scene *scene, Object *ob, ListBase *dispbase,
-        DerivedMesh **r_dm_final,
+        Mesh **r_final,
         const bool for_render, const bool for_orco, const bool use_render_resolution)
 {
 	ListBase nubase = {NULL, NULL};
@@ -1315,7 +1314,7 @@ void BKE_displist_make_surf(
 
 	if (!for_orco) {
 		BKE_nurbList_duplicate(&ob->runtime.curve_cache->deformed_nurbs, &nubase);
-		curve_calc_modifiers_post(depsgraph, scene, ob, &nubase, dispbase, r_dm_final,
+		curve_calc_modifiers_post(depsgraph, scene, ob, &nubase, dispbase, r_final,
 		                          for_render, use_render_resolution);
 	}
 
@@ -1543,7 +1542,7 @@ static void calc_bevfac_mapping(Curve *cu, BevList *bl, Nurb *nu,
 
 static void do_makeDispListCurveTypes(
         Depsgraph *depsgraph, Scene *scene, Object *ob, ListBase *dispbase,
-        DerivedMesh **r_dm_final,
+        Mesh **r_final,
         const bool for_render, const bool for_orco, const bool use_render_resolution)
 {
 	Curve *cu = ob->data;
@@ -1552,7 +1551,7 @@ static void do_makeDispListCurveTypes(
 	if (!ELEM(ob->type, OB_SURF, OB_CURVE, OB_FONT)) return;
 
 	if (ob->type == OB_SURF) {
-		BKE_displist_make_surf(depsgraph, scene, ob, dispbase, r_dm_final, for_render, for_orco, use_render_resolution);
+		BKE_displist_make_surf(depsgraph, scene, ob, dispbase, r_final, for_render, for_orco, use_render_resolution);
 	}
 	else if (ELEM(ob->type, OB_CURVE, OB_FONT)) {
 		ListBase dlbev;
@@ -1778,7 +1777,7 @@ static void do_makeDispListCurveTypes(
 
 		if (!for_orco) {
 			BKE_nurbList_duplicate(&ob->runtime.curve_cache->deformed_nurbs, &nubase);
-			curve_calc_modifiers_post(depsgraph, scene, ob, &nubase, dispbase, r_dm_final, for_render, use_render_resolution);
+			curve_calc_modifiers_post(depsgraph, scene, ob, &nubase, dispbase, r_final, for_render, use_render_resolution);
 		}
 
 		if (cu->flag & CU_DEFORM_FILL && !ob->derivedFinal) {
@@ -1807,21 +1806,21 @@ void BKE_displist_make_curveTypes(Depsgraph *depsgraph, Scene *scene, Object *ob
 
 	dispbase = &(ob->runtime.curve_cache->disp);
 
-	do_makeDispListCurveTypes(depsgraph, scene, ob, dispbase, &ob->derivedFinal, 0, for_orco, 0);
+	do_makeDispListCurveTypes(depsgraph, scene, ob, dispbase, &ob->runtime.mesh_eval, 0, for_orco, 0);
 
 	boundbox_displist_object(ob);
 }
 
 void BKE_displist_make_curveTypes_forRender(
         Depsgraph *depsgraph, Scene *scene, Object *ob, ListBase *dispbase,
-        DerivedMesh **r_dm_final, const bool for_orco,
+        Mesh **r_final, const bool for_orco,
         const bool use_render_resolution)
 {
 	if (ob->runtime.curve_cache == NULL) {
 		ob->runtime.curve_cache = MEM_callocN(sizeof(CurveCache), "CurveCache for Curve");
 	}
 
-	do_makeDispListCurveTypes(depsgraph, scene, ob, dispbase, r_dm_final, true, for_orco, use_render_resolution);
+	do_makeDispListCurveTypes(depsgraph, scene, ob, dispbase, r_final, true, for_orco, use_render_resolution);
 }
 
 void BKE_displist_make_curveTypes_forOrco(
@@ -1834,33 +1833,6 @@ void BKE_displist_make_curveTypes_forOrco(
 	do_makeDispListCurveTypes(depsgraph, scene, ob, dispbase, NULL, 1, 1, 1);
 }
 
-/* add Orco layer to the displist object which has got derived mesh and return orco */
-/* XXX2.8(Sybren): can be removed once DerivedMesh port is done */
-#ifdef WITH_DERIVEDMESH_DEPRECATED_FUNCS
-float *BKE_displist_make_orco(
-        Depsgraph *depsgraph, Scene *scene, Object *ob, DerivedMesh *dm_final,
-        const bool for_render,
-        const bool use_render_resolution)
-{
-	float *orco;
-
-	if (dm_final == NULL)
-		dm_final = ob->derivedFinal;
-
-	if (!dm_final->getVertDataArray(dm_final, CD_ORCO)) {
-		curve_calc_orcodm(depsgraph, scene, ob, dm_final, for_render, use_render_resolution);
-	}
-
-	orco = dm_final->getVertDataArray(dm_final, CD_ORCO);
-
-	if (orco) {
-		orco = MEM_dupallocN(orco);
-	}
-
-	return orco;
-}
-#endif
-
 void BKE_displist_minmax(ListBase *dispbase, float min[3], float max[3])
 {
 	DispList *dl;
diff --git a/source/blender/blenkernel/intern/mesh_convert.c b/source/blender/blenkernel/intern/mesh_convert.c
index b64cb8a1d0f..eed02dae824 100644
--- a/source/blender/blenkernel/intern/mesh_convert.c
+++ b/source/blender/blenkernel/intern/mesh_convert.c
@@ -857,7 +857,7 @@ Mesh *BKE_mesh_new_from_object(
 		case OB_SURF:
 		{
 			ListBase dispbase = {NULL, NULL};
-			DerivedMesh *derivedFinal = NULL;
+			Mesh *me_eval_final = NULL;
 			int uv_from_orco;
 
 			/* copies object and modifiers (but not the data) */
@@ -899,12 +899,12 @@ Mesh *BKE_mesh_new_from_object(
 			copycu->editnurb = tmpcu->editnurb;
 
 			/* get updated display list, and convert to a mesh */
-			BKE_displist_make_curveTypes_forRender(depsgraph, sce, tmpobj, &dispbase, &derivedFinal, false, render);
+			BKE_displist_make_curveTypes_forRender(depsgraph, sce, tmpobj, &dispbase, &me_eval_final, false, render);
 
 			copycu->editfont = NULL;
 			copycu->editnurb = NULL;
 
-			tmpobj->derivedFinal = derivedFinal;
+			tmpobj->runtime.mesh_eval = me_eval_final;
 
 			/* convert object type to mesh */
 			uv_from_orco = (tmpcu->flag & CU_UV_ORCO) != 0;



More information about the Bf-blender-cvs mailing list