Revision: 41828
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41828
Author:   lukastoenne
Date:     2011-11-14 11:17:07 +0000 (Mon, 14 Nov 2011)
Log Message:
-----------
Better fix for crashes when rendering original edit mesh faces on empty edit 
mesh with constructive modifier (#29241). This avoids the additional test 
inside the loop.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_view3d/drawobject.c

Modified: trunk/blender/source/blender/editors/space_view3d/drawobject.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/drawobject.c      
2011-11-14 10:47:34 UTC (rev 41827)
+++ trunk/blender/source/blender/editors/space_view3d/drawobject.c      
2011-11-14 11:17:07 UTC (rev 41828)
@@ -2696,8 +2696,7 @@
 {
        EditFace *efa = EM_get_face_for_index(index);
 
-       /* efa=0 for constructive modifier on empty mesh */
-       if (efa && efa->h==0) {
+       if (efa->h==0) {
                GPU_enable_material(efa->mat_nr+1, NULL);
                return 1;
        }
@@ -2736,29 +2735,35 @@
        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

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to