Mesh: remove DerivedMesh for boundbox calculation
Fixes edit-mesh not having a boundbox calculated for it.
This commit is contained in:
@@ -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 */
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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}};
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user