Change texface draw to always use glShadeModel(GL_SMOOTH), with texface draw.
[blender-staging.git] / source / blender / blenkernel / intern / editderivedmesh.c
index 8eccfd4d3f0a62d6a3aba8c463a6906eb47be460..62f11eb263110d9a144c290bad4bf7a29a7326d0 100644 (file)
@@ -273,7 +273,7 @@ static void emDM_drawMappedFaces(
 {
        EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
        EditFace *efa;
 {
        EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
        EditFace *efa;
-       int i, draw;
+       int i, draw, flush;
        const int skip_normals= !glIsEnabled(GL_LIGHTING); /* could be passed as an arg */
 
        /* GL_ZERO is used to detect if drawing has started or not */
        const int skip_normals= !glIsEnabled(GL_LIGHTING); /* could be passed as an arg */
 
        /* GL_ZERO is used to detect if drawing has started or not */
@@ -352,7 +352,11 @@ static void emDM_drawMappedFaces(
                                        }
                                }
 
                                        }
                                }
 
-                               if (draw==2) {
+                               flush= (draw==2);
+                               if (!skip_normals && !flush && efa->next)
+                                       flush|= efa->mat_nr != efa->next->mat_nr;
+
+                               if (flush) {
                                        glEnd();
                                        poly_prev= GL_ZERO; /* force glBegin */
 
                                        glEnd();
                                        poly_prev= GL_ZERO; /* force glBegin */
 
@@ -419,8 +423,11 @@ static void emDM_drawMappedFaces(
                                        }
                                }
 
                                        }
                                }
 
+                               flush= (draw==2);
+                               if (!skip_normals && !flush && efa->next)
+                                       flush|= efa->mat_nr != efa->next->mat_nr;
 
 
-                               if (draw==2) {
+                               if (flush) {
                                        glEnd();
                                        poly_prev= GL_ZERO; /* force glBegin */
 
                                        glEnd();
                                        poly_prev= GL_ZERO; /* force glBegin */
 
@@ -481,9 +488,6 @@ static void emDM_drawFacesTex_common(
                                                cp= (unsigned char*)mcol;
                                        }
                                }
                                                cp= (unsigned char*)mcol;
                                        }
                                }
-                               else {
-                                       glShadeModel(drawSmooth?GL_SMOOTH:GL_FLAT);
-                               }
 
                                glBegin(efa->v4?GL_QUADS:GL_TRIANGLES);
                                if (!drawSmooth) {
 
                                glBegin(efa->v4?GL_QUADS:GL_TRIANGLES);
                                if (!drawSmooth) {
@@ -557,9 +561,6 @@ static void emDM_drawFacesTex_common(
                                                cp= (unsigned char*)mcol;
                                        }
                                }
                                                cp= (unsigned char*)mcol;
                                        }
                                }
-                               else {
-                                       glShadeModel(drawSmooth?GL_SMOOTH:GL_FLAT);
-                               }
 
                                glBegin(efa->v4?GL_QUADS:GL_TRIANGLES);
                                if (!drawSmooth) {
 
                                glBegin(efa->v4?GL_QUADS:GL_TRIANGLES);
                                if (!drawSmooth) {
@@ -610,6 +611,8 @@ static void emDM_drawFacesTex_common(
                        }
                }
        }
                        }
                }
        }
+
+       glShadeModel(GL_FLAT);
 }
 
 static void emDM_drawFacesTex(
 }
 
 static void emDM_drawFacesTex(