[Bf-blender-cvs] [27389362a48] blender2.8: Mesh: remove DerivedMesh for boundbox calculation

Campbell Barton noreply at git.blender.org
Mon Oct 15 08:16:22 CEST 2018


Commit: 27389362a48a7d79df7c7f6df46760f27d421e6f
Author: Campbell Barton
Date:   Mon Oct 15 17:14:05 2018 +1100
Branches: blender2.8
https://developer.blender.org/rB27389362a48a7d79df7c7f6df46760f27d421e6f

Mesh: remove DerivedMesh for boundbox calculation

Fixes edit-mesh not having a boundbox calculated for it.

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

M	source/blender/blenkernel/BKE_DerivedMesh.h
M	source/blender/blenkernel/BKE_object.h
M	source/blender/blenkernel/intern/DerivedMesh.c
M	source/blender/blenkernel/intern/displist.c
M	source/blender/blenkernel/intern/object.c

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

diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h
index 3fea07162a0..4c43dd1e6d3 100644
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@ -564,9 +564,6 @@ void DM_calc_loop_tangents(
 
 void DM_calc_auto_bump_scale(DerivedMesh *dm);
 
-/** Set object's bounding box based on DerivedMesh min/max data */
-void DM_set_object_boundbox(struct Object *ob, DerivedMesh *dm);
-
 void DM_init_origspace(DerivedMesh *dm);
 
 /* debug only */
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index 6d7def8f93f..8085c541600 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -183,6 +183,7 @@ void BKE_object_dimensions_get(struct Object *ob, float vec[3]);
 void BKE_object_dimensions_set(struct Object *ob, const float value[3]);
 void BKE_object_empty_draw_type_set(struct Object *ob, const int value);
 void BKE_object_boundbox_flag(struct Object *ob, int flag, const bool set);
+void BKE_object_boundbox_calc_from_mesh(struct Object *ob, struct Mesh *me_eval);
 void BKE_object_minmax(struct Object *ob, float r_min[3], float r_max[3], const bool use_hidden);
 bool BKE_object_minmax_dupli(
         struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob,
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index e4ab70e52b3..01908031431 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -2218,13 +2218,11 @@ static void mesh_build_data(
 
 	mesh_finalize_eval(ob);
 
+	/* TODO(campbell): remove these copies, they are expected in various places over the code. */
 	ob->derivedDeform = CDDM_from_mesh_ex(ob->runtime.mesh_deform_eval, CD_REFERENCE, CD_MASK_MESH);
 	ob->derivedFinal = CDDM_from_mesh_ex(ob->runtime.mesh_eval, CD_REFERENCE, CD_MASK_MESH);
 
-	DM_set_object_boundbox(ob, ob->derivedFinal);
-	/* TODO(sergey): Convert bounding box calculation to use mesh, then
-	 * we can skip this copy.
-	 */
+	BKE_object_boundbox_calc_from_mesh(ob, ob->runtime.mesh_eval);
 	BKE_mesh_texspace_copy_from_object(ob->runtime.mesh_eval, ob);
 
 	ob->derivedFinal->needsFree = 0;
@@ -2262,9 +2260,7 @@ static void editbmesh_build_data(
 	em->mesh_eval_final = me_final;
 	em->mesh_eval_cage = me_cage;
 
-#if 0
-	DM_set_object_boundbox(obedit, em->derivedFinal);
-#endif
+	BKE_object_boundbox_calc_from_mesh(obedit, em->mesh_eval_final);
 
 	em->lastDataMask = dataMask;
 
@@ -2694,22 +2690,6 @@ void DM_calc_loop_tangents(
 	        &dm->tangent_mask);
 }
 
-/* Set object's bounding box based on DerivedMesh min/max data */
-void DM_set_object_boundbox(Object *ob, DerivedMesh *dm)
-{
-	float min[3], max[3];
-
-	INIT_MINMAX(min, max);
-	dm->getMinMax(dm, min, max);
-
-	if (!ob->bb)
-		ob->bb = MEM_callocN(sizeof(BoundBox), "DM-BoundBox");
-
-	BKE_boundbox_init_from_minmax(ob->bb, min, max);
-
-	ob->bb->flag &= ~BOUNDBOX_DIRTY;
-}
-
 void DM_init_origspace(DerivedMesh *dm)
 {
 	const float default_osf[4][2] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}};
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index 9887d902850..28dff341126 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -1868,8 +1868,8 @@ static void boundbox_displist_object(Object *ob)
 		if (ob->bb == NULL)
 			ob->bb = MEM_callocN(sizeof(BoundBox), "boundbox");
 
-		if (ob->derivedFinal) {
-			DM_set_object_boundbox(ob, ob->derivedFinal);
+		if (ob->runtime.mesh_eval) {
+			BKE_object_boundbox_calc_from_mesh(ob, ob->runtime.mesh_eval);
 		}
 		else {
 			float min[3], max[3];
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 1ff15ed19d5..fdb2e3a1180 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -2558,6 +2558,23 @@ void BKE_object_boundbox_flag(Object *ob, int flag, const bool set)
 	}
 }
 
+void BKE_object_boundbox_calc_from_mesh(struct Object *ob, struct Mesh *me_eval)
+{
+	float min[3], max[3];
+
+	INIT_MINMAX(min, max);
+
+	BKE_mesh_minmax(me_eval, min, max);
+
+	if (ob->bb == NULL) {
+		ob->bb = MEM_callocN(sizeof(BoundBox), "DM-BoundBox");
+	}
+
+	BKE_boundbox_init_from_minmax(ob->bb, min, max);
+
+	ob->bb->flag &= ~BOUNDBOX_DIRTY;
+}
+
 void BKE_object_dimensions_get(Object *ob, float vec[3])
 {
 	BoundBox *bb = NULL;



More information about the Bf-blender-cvs mailing list