Merging r58112 through r58124 from trunk into soc-2013-depsgraph_mt
[blender.git] / source / blender / editors / space_view3d / drawobject.c
index 55e1fae38e48927ccdf74d9cd283dbe7220269d2..d5860606b65ee8d4d2cb278d2ad2cc9d3f95917c 100644 (file)
@@ -1900,9 +1900,9 @@ static void drawlattice(Scene *scene, View3D *v3d, Object *ob)
        const bool is_edit = (lt->editlatt != NULL);
 
        /* now we default make displist, this will modifiers work for non animated case */
-       if (ob->disp.first == NULL)
+       if (ELEM(NULL, ob->curve_cache, ob->curve_cache->disp.first))
                BKE_lattice_modifiers_calc(scene, ob);
-       dl = BKE_displist_find(&ob->disp, DL_VERTS);
+       dl = BKE_displist_find(&ob->curve_cache->disp, DL_VERTS);
        
        if (is_edit) {
                lt = lt->editlatt->latt;
@@ -3946,7 +3946,7 @@ static bool drawDispList_nobackface(Scene *scene, View3D *v3d, RegionView3D *rv3
                case OB_CURVE:
                        cu = ob->data;
 
-                       lb = &ob->disp;
+                       lb = &ob->curve_cache->disp;
 
                        if (solid) {
                                dl = lb->first;
@@ -3996,7 +3996,7 @@ static bool drawDispList_nobackface(Scene *scene, View3D *v3d, RegionView3D *rv3
                        break;
                case OB_SURF:
 
-                       lb = &ob->disp;
+                       lb = &ob->curve_cache->disp;
 
                        if (solid) {
                                dl = lb->first;
@@ -4024,8 +4024,11 @@ static bool drawDispList_nobackface(Scene *scene, View3D *v3d, RegionView3D *rv3
                case OB_MBALL:
 
                        if (BKE_mball_is_basis(ob)) {
-                               lb = &ob->disp;
-                               if (lb->first == NULL) BKE_displist_make_mball(scene, ob);
+                               lb = ob->curve_cache ? &ob->curve_cache->disp : NULL;
+                               if (lb->first == NULL) {
+                                       BKE_displist_make_mball(scene, ob);
+                                       lb = &ob->curve_cache->disp;
+                               }
                                if (lb->first == NULL) {
                                        return true;
                                }
@@ -5615,7 +5618,7 @@ static void drawnurb(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
        if ((cu->flag & CU_3D) && (ts->normalsize > 0.0015f) && (cu->drawflag & CU_HIDE_NORMALS) == 0) {
 
                UI_ThemeColor(TH_WIRE_EDIT);
-               for (bl = cu->bev.first, nu = nurb; nu && bl; bl = bl->next, nu = nu->next) {
+               for (bl = ob->curve_cache->bev.first, nu = nurb; nu && bl; bl = bl->next, nu = nu->next) {
                        BevPoint *bevp = (BevPoint *)(bl + 1);
                        int nr = bl->nr;
                        int skip = nu->resolu / 16;
@@ -6038,7 +6041,7 @@ static void draw_forcefield(Object *ob, RegionView3D *rv3d,
        }
        else if (pd->forcefield == PFIELD_GUIDE && ob->type == OB_CURVE) {
                Curve *cu = ob->data;
-               if ((cu->flag & CU_PATH) && cu->path && cu->path->data) {
+               if ((cu->flag & CU_PATH) && ob->curve_cache->path && ob->curve_cache->path->data) {
                        float mindist, guidevec1[4], guidevec2[3];
 
                        //if (has_ipo_code(ob->ipo, OB_PD_FSTR))
@@ -6296,7 +6299,6 @@ static void drawObjectSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
        glDepthMask(0);
        
        if (ELEM3(ob->type, OB_FONT, OB_CURVE, OB_SURF)) {
-               Curve *cu = ob->data;
                DerivedMesh *dm = ob->derivedFinal;
                bool has_faces = false;
 
@@ -6304,16 +6306,16 @@ static void drawObjectSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
                        has_faces = dm->getNumTessFaces(dm);
                }
                else {
-                       has_faces = BKE_displist_has_faces(&ob->disp);
+                       has_faces = BKE_displist_has_faces(&ob->curve_cache->disp);
                }
 
-               if (has_faces && ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb ? ob->bb : cu->bb)) {
+               if (has_faces && ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb)) {
                        draw_index_wire = false;
                        if (dm) {
                                draw_mesh_object_outline(v3d, ob, dm);
                        }
                        else {
-                               drawDispListwire(&ob->disp);
+                               drawDispListwire(&ob->curve_cache->disp);
                        }
                        draw_index_wire = true;
                }
@@ -6321,7 +6323,7 @@ static void drawObjectSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
        else if (ob->type == OB_MBALL) {
                if (BKE_mball_is_basis(ob)) {
                        if ((base->flag & OB_FROMDUPLI) == 0)
-                               drawDispListwire(&ob->disp);
+                               drawDispListwire(&ob->curve_cache->disp);
                }
        }
        else if (ob->type == OB_ARMATURE) {
@@ -6348,8 +6350,7 @@ static void draw_wire_extra(Scene *scene, RegionView3D *rv3d, Object *ob, unsign
                glDepthMask(0);  /* disable write in zbuffer, selected edge wires show better */
 
                if (ELEM3(ob->type, OB_FONT, OB_CURVE, OB_SURF)) {
-                       Curve *cu = ob->data;
-                       if (ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb ? ob->bb : cu->bb)) {
+                       if (ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb)) {
                                if (ob->type == OB_CURVE)
                                        draw_index_wire = false;
 
@@ -6357,7 +6358,7 @@ static void draw_wire_extra(Scene *scene, RegionView3D *rv3d, Object *ob, unsign
                                        drawCurveDMWired(ob);
                                }
                                else {
-                                       drawDispListwire(&ob->disp);
+                                       drawDispListwire(&ob->curve_cache->disp);
                                }
 
                                if (ob->type == OB_CURVE)
@@ -6366,7 +6367,7 @@ static void draw_wire_extra(Scene *scene, RegionView3D *rv3d, Object *ob, unsign
                }
                else if (ob->type == OB_MBALL) {
                        if (BKE_mball_is_basis(ob)) {
-                               drawDispListwire(&ob->disp);
+                               drawDispListwire(&ob->curve_cache->disp);
                        }
                }
 
@@ -6676,7 +6677,9 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
        /* bad exception, solve this! otherwise outline shows too late */
        if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
                /* still needed for curves hidden in other layers. depgraph doesnt handle that yet */
-               if (ob->disp.first == NULL) BKE_displist_make_curveTypes(scene, ob, 0);
+               if (ELEM(NULL, ob->curve_cache, ob->curve_cache->disp.first)) {
+                       BKE_displist_make_curveTypes(scene, ob, 0);
+               }
        }
        
        /* draw outline for selected objects, mesh does itself */
@@ -6780,7 +6783,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
                                        draw_bounding_volume(scene, ob, ob->boundtype);
                                }
                        }
-                       else if (ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb ? ob->bb : cu->bb)) {
+                       else if (ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb)) {
                                empty_object = drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
                        }
 
@@ -6798,7 +6801,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
                                        draw_bounding_volume(scene, ob, ob->boundtype);
                                }
                        }
-                       else if (ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb ? ob->bb : cu->bb)) {
+                       else if (ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb)) {
                                empty_object = drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
 
 //XXX old animsys                              if (cu->path)