Bugfix for mysteriously disappearing left eyeball. Bounding boxes
used for clipping were being stored in the mesh, but modifiers can result in two objects with the same mesh having a different bounding box. Solution is to store bounding box in the object.
This commit is contained in:
@@ -75,7 +75,7 @@ int update_realtime_texture(struct MTFace *tface, double time);
|
||||
void mesh_delete_material_index(struct Mesh *me, int index);
|
||||
void mesh_set_smooth_flag(struct Object *meshOb, int enableSmooth);
|
||||
|
||||
struct BoundBox *mesh_get_bb(struct Mesh *me);
|
||||
struct BoundBox *mesh_get_bb(struct Object *ob);
|
||||
void mesh_get_texspace(struct Mesh *me, float *loc_r, float *rot_r, float *size_r);
|
||||
|
||||
/* if old, it converts mface->edcode to edge drawflags */
|
||||
|
||||
@@ -2422,6 +2422,10 @@ static void clear_mesh_caches(Object *ob)
|
||||
Mesh *me= ob->data;
|
||||
|
||||
/* also serves as signal to remake texspace */
|
||||
if (ob->bb) {
|
||||
MEM_freeN(ob->bb);
|
||||
ob->bb = NULL;
|
||||
}
|
||||
if (me->bb) {
|
||||
MEM_freeN(me->bb);
|
||||
me->bb = NULL;
|
||||
@@ -2477,7 +2481,9 @@ static void mesh_build_data(Object *ob, CustomDataMask dataMask)
|
||||
|
||||
ob->derivedFinal->getMinMax(ob->derivedFinal, min, max);
|
||||
|
||||
boundbox_set_from_min_max(mesh_get_bb(ob->data), min, max);
|
||||
if(!ob->bb)
|
||||
ob->bb= MEM_mallocN(sizeof(BoundBox), "bb");
|
||||
boundbox_set_from_min_max(ob->bb, min, max);
|
||||
|
||||
ob->derivedFinal->needsFree = 0;
|
||||
ob->derivedDeform->needsFree = 0;
|
||||
@@ -2513,7 +2519,9 @@ static void editmesh_build_data(CustomDataMask dataMask)
|
||||
|
||||
em->derivedFinal->getMinMax(em->derivedFinal, min, max);
|
||||
|
||||
boundbox_set_from_min_max(mesh_get_bb(G.obedit->data), min, max);
|
||||
if(!G.obedit->bb)
|
||||
G.obedit->bb= MEM_mallocN(sizeof(BoundBox), "bb");
|
||||
boundbox_set_from_min_max(G.obedit->bb, min, max);
|
||||
|
||||
em->derivedFinal->needsFree = 0;
|
||||
em->derivedCage->needsFree = 0;
|
||||
|
||||
@@ -454,11 +454,15 @@ void tex_space_mesh(Mesh *me)
|
||||
}
|
||||
}
|
||||
|
||||
BoundBox *mesh_get_bb(Mesh *me)
|
||||
BoundBox *mesh_get_bb(Object *ob)
|
||||
{
|
||||
if (!me->bb) {
|
||||
Mesh *me= ob->data;
|
||||
|
||||
if(ob->bb)
|
||||
return ob->bb;
|
||||
|
||||
if (!me->bb)
|
||||
tex_space_mesh(me);
|
||||
}
|
||||
|
||||
return me->bb;
|
||||
}
|
||||
|
||||
@@ -2025,7 +2025,7 @@ BoundBox *object_get_boundbox(Object *ob)
|
||||
BoundBox *bb= NULL;
|
||||
|
||||
if(ob->type==OB_MESH) {
|
||||
bb = mesh_get_bb(ob->data);
|
||||
bb = mesh_get_bb(ob);
|
||||
}
|
||||
else if ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT) {
|
||||
bb= ( (Curve *)ob->data )->bb;
|
||||
@@ -2087,7 +2087,7 @@ void minmax_object(Object *ob, float *min, float *max)
|
||||
me= get_mesh(ob);
|
||||
|
||||
if(me) {
|
||||
bb = *mesh_get_bb(me);
|
||||
bb = *mesh_get_bb(ob);
|
||||
|
||||
for(a=0; a<8; a++) {
|
||||
Mat4MulVecfl(ob->obmat, bb.vec[a]);
|
||||
|
||||
@@ -1484,7 +1484,7 @@ static PyObject *Object_getBoundBox( BPy_Object * self )
|
||||
switch ( self->object->type ) {
|
||||
case OB_MESH:
|
||||
me = self->object->data;
|
||||
vec = (float*) mesh_get_bb(me)->vec;
|
||||
vec = (float*) mesh_get_bb(self->object)->vec;
|
||||
break;
|
||||
case OB_CURVE:
|
||||
case OB_FONT:
|
||||
|
||||
@@ -2430,8 +2430,7 @@ static int draw_mesh_object(Base *base, int dt, int flag)
|
||||
}
|
||||
else {
|
||||
/* don't create boundbox here with mesh_get_bb(), the derived system will make it, puts deformed bb's OK */
|
||||
|
||||
if(me->totface<=4 || boundbox_clip(ob->obmat, me->bb)) {
|
||||
if(me->totface<=4 || boundbox_clip(ob->obmat, (ob->bb)? ob->bb: me->bb)) {
|
||||
if(dt==OB_SOLID) has_alpha= init_gl_materials(ob, (base->flag & OB_FROMDUPLI)==0);
|
||||
draw_mesh_fancy(base, dt, flag);
|
||||
|
||||
@@ -4481,7 +4480,7 @@ static void draw_bounding_volume(Object *ob)
|
||||
BoundBox *bb=0;
|
||||
|
||||
if(ob->type==OB_MESH) {
|
||||
bb= mesh_get_bb(ob->data);
|
||||
bb= mesh_get_bb(ob);
|
||||
}
|
||||
else if ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT) {
|
||||
bb= ( (Curve *)ob->data )->bb;
|
||||
|
||||
@@ -3306,7 +3306,7 @@ static int cached_dynamics(int sfra, int efra)
|
||||
Object *ob;
|
||||
ModifierData *md;
|
||||
ParticleSystem *psys;
|
||||
int i, stack_index, cached=1;
|
||||
int i, stack_index=-1, cached=1;
|
||||
|
||||
while(base && cached) {
|
||||
ob = base->object;
|
||||
|
||||
@@ -741,7 +741,7 @@ long mesh_octree_table(Object *ob, float *co, char mode)
|
||||
}
|
||||
else if(mode=='s') { /* start table */
|
||||
Mesh *me= ob->data;
|
||||
BoundBox *bb = mesh_get_bb(me);
|
||||
BoundBox *bb = mesh_get_bb(ob);
|
||||
|
||||
/* for quick unit coordinate calculus */
|
||||
VECCOPY(offs, bb->vec[0]);
|
||||
|
||||
Reference in New Issue
Block a user