Fix for bug #5606:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 8 Jan 2007 23:47:03 +0000 (23:47 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 8 Jan 2007 23:47:03 +0000 (23:47 +0000)
Subsurf modifier displays normals wrong with mixed smooth and solid faces.

source/blender/blenkernel/intern/cdderivedmesh.c

index d2b7eca..e17b6da 100644 (file)
@@ -280,7 +280,6 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm, int (*setMaterial)(int))
                        if(shademodel == GL_FLAT) {
                                if (nors) {
                                        glNormal3fv(nors);
-                                       nors += 3;
                                }
                                else {
                                        /* TODO make this better (cache facenormals as layer?) */
@@ -304,6 +303,8 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm, int (*setMaterial)(int))
                                PASSVERT(mface->v4);
                        }
                }
+
+               if(nors) nors += 3;
        }
        glEnd();
 
@@ -413,7 +414,6 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
                if(!(mf->flag&ME_SMOOTH)) {
                        if (nors) {
                                glNormal3fv(nors);
-                               nors += 3;
                        }
                        else {
                                /* TODO make this better (cache facenormals as layer?) */
@@ -457,6 +457,8 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
                        glVertex3fv(mvert->co);
                }
                glEnd();
+
+               if(nors) nors += 3;
        }
 }
 
@@ -496,7 +498,6 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us
                        if (!drawSmooth) {
                                if (nors) {
                                        glNormal3fv(nors);
-                                       nors += 3;
                                }
                                else {
                                        /* TODO make this better (cache facenormals as layer?) */
@@ -541,6 +542,8 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us
 
                        glEnd();
                }
+               
+               if (nors) nors += 3;
        }
 }