Merging r58475 through r58700 from trunk into soc-2013-depsgraph_mt
[blender.git] / source / blender / blenkernel / intern / mesh.c
index 095957b40d5a83788f08544922ffda35674c1823..f1729b8e098c65ab8f94bdfbbeb83e17fbaa0fc1 100644 (file)
@@ -657,6 +657,8 @@ void BKE_mesh_boundbox_calc(Mesh *me, float r_loc[3], float r_size[3])
        r_size[2] = (max[2] - min[2]) / 2.0f;
        
        BKE_boundbox_init_from_minmax(bb, min, max);
+
+       bb->flag &= ~BOUNDBOX_INVALID;
 }
 
 void BKE_mesh_texspace_calc(Mesh *me)
@@ -686,15 +688,16 @@ BoundBox *BKE_mesh_boundbox_get(Object *ob)
        if (ob->bb)
                return ob->bb;
 
-       if (!me->bb)
+       if (me->bb == NULL || (me->bb->flag & BOUNDBOX_INVALID)) {
                BKE_mesh_texspace_calc(me);
+       }
 
        return me->bb;
 }
 
 void BKE_mesh_texspace_get(Mesh *me, float r_loc[3], float r_rot[3], float r_size[3])
 {
-       if (!me->bb) {
+       if (me->bb == NULL || (me->bb->flag & BOUNDBOX_INVALID)) {
                BKE_mesh_texspace_calc(me);
        }
 
@@ -1307,7 +1310,13 @@ int BKE_mesh_nurbs_to_mdata(Object *ob, MVert **allvert, int *totvert,
                             MEdge **alledge, int *totedge, MLoop **allloop, MPoly **allpoly,
                             int *totloop, int *totpoly)
 {
-       return BKE_mesh_nurbs_displist_to_mdata(ob, &ob->disp,
+       ListBase disp = {NULL, NULL};
+
+       if (ob->curve_cache) {
+               disp = ob->curve_cache->disp;
+       }
+
+       return BKE_mesh_nurbs_displist_to_mdata(ob, &disp,
                                                allvert, totvert,
                                                alledge, totedge,
                                                allloop, allpoly, NULL,
@@ -1653,8 +1662,13 @@ void BKE_mesh_from_nurbs(Object *ob)
 {
        Curve *cu = (Curve *) ob->data;
        bool use_orco_uv = (cu->flag & CU_UV_ORCO) != 0;
+       ListBase disp = {NULL, NULL};
+
+       if (ob->curve_cache) {
+               disp = ob->curve_cache->disp;
+       }
 
-       BKE_mesh_from_nurbs_displist(ob, &ob->disp, use_orco_uv);
+       BKE_mesh_from_nurbs_displist(ob, &disp, use_orco_uv);
 }
 
 typedef struct EdgeLink {