Merged changes in the trunk up to revision 42021.
[blender.git] / source / blender / editors / space_view3d / drawobject.c
index 70cdefddc7265500c2f1d8a2165ef914766be8b7..0ce2e891b6ee6e25d33a53a1d50d463e0db21775 100644 (file)
@@ -1693,7 +1693,7 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base
                        if(cam->flag & CAM_SHOWLIMITS) {
                                draw_limit_line(cam->clipsta, cam->clipend, 0x77FFFF);
                                /* qdn: was yafray only, now also enabled for Blender to be used with defocus composit node */
-                               draw_focus_cross(dof_camera(ob), cam->drawsize);
+                               draw_focus_cross(object_camera_dof_distance(ob), cam->drawsize);
                        }
 
                        wrld= scene->world;
@@ -2747,29 +2747,35 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object
        if(dt>OB_WIRE) {
                if(CHECK_OB_DRAWTEXTURE(v3d, dt)) {
                        if(draw_glsl_material(scene, ob, v3d, dt)) {
-                               glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW);
+                               /* if em has no faces the drawMappedFaces callback will fail */
+                               if(em->faces.first) {
+                                       glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW);
 
-                               finalDM->drawMappedFacesGLSL(finalDM, GPU_enable_material,
-                                       draw_em_fancy__setGLSLFaceOpts, NULL);
-                               GPU_disable_material();
+                                       finalDM->drawMappedFacesGLSL(finalDM, GPU_enable_material,
+                                                                                                draw_em_fancy__setGLSLFaceOpts, NULL);
+                                       GPU_disable_material();
 
-                               glFrontFace(GL_CCW);
+                                       glFrontFace(GL_CCW);
+                               }
                        }
                        else {
                                draw_mesh_textured(scene, v3d, rv3d, ob, finalDM, 0);
                        }
                }
                else {
-                       /* 3 floats for position, 3 for normal and times two because the faces may actually be quads instead of triangles */
-                       glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, me->flag & ME_TWOSIDED);
+                       /* if em has no faces the drawMappedFaces callback will fail */
+                       if(em->faces.first) {
+                               /* 3 floats for position, 3 for normal and times two because the faces may actually be quads instead of triangles */
+                               glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, me->flag & ME_TWOSIDED);
 
-                       glEnable(GL_LIGHTING);
-                       glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW);
+                               glEnable(GL_LIGHTING);
+                               glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW);
 
-                       finalDM->drawMappedFaces(finalDM, draw_em_fancy__setFaceOpts, NULL, 0, GPU_enable_material, NULL);
+                               finalDM->drawMappedFaces(finalDM, draw_em_fancy__setFaceOpts, NULL, 0, GPU_enable_material, NULL);
 
-                       glFrontFace(GL_CCW);
-                       glDisable(GL_LIGHTING);
+                               glFrontFace(GL_CCW);
+                               glDisable(GL_LIGHTING);
+                       }
                }
                        
                // Setup for drawing wire over, disable zbuffer