Fix T59087: Empty meshes have large bound-box

Initialize to default values for meshes w/o vertices,
note that zeroing for BKE_object_boundbox_calc_from_mesh
matches old derived mesh code.
This commit is contained in:
Campbell Barton
2018-12-10 19:27:49 +11:00
parent 979a5c34e4
commit 51dbf8d71a
2 changed files with 8 additions and 2 deletions

View File

@@ -922,7 +922,10 @@ BoundBox *BKE_mesh_boundbox_get(Object *ob)
float min[3], max[3];
INIT_MINMAX(min, max);
BKE_mesh_minmax(me, min, max);
if (!BKE_mesh_minmax(me, min, max)) {
min[0] = min[1] = min[2] = -1.0f;
max[0] = max[1] = max[2] = 1.0f;
}
if (ob->bb == NULL) {
ob->bb = MEM_mallocN(sizeof(*ob->bb), __func__);

View File

@@ -2516,7 +2516,10 @@ void BKE_object_boundbox_calc_from_mesh(struct Object *ob, struct Mesh *me_eval)
INIT_MINMAX(min, max);
BKE_mesh_minmax(me_eval, min, max);
if (!BKE_mesh_minmax(me_eval, min, max)) {
zero_v3(min);
zero_v3(max);
}
if (ob->bb == NULL) {
ob->bb = MEM_callocN(sizeof(BoundBox), "DM-BoundBox");