Merging r58196 through r58265 from trunk into soc-2013-depsgraph_mt
[blender.git] / source / blender / blenkernel / intern / mesh.c
index 1b5b7101c7178ff0571be9d1c1e8b069664e4fb8..77cf9e48631201d99ad8dd881dd0550390449c54 100644 (file)
@@ -656,6 +656,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)
@@ -685,15 +687,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);
        }
 
@@ -1306,7 +1309,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,
@@ -1652,8 +1661,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 {