Fix part of #20468: material changes when switch to sculpt mode.
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Sat, 6 Feb 2010 17:04:13 +0000 (17:04 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Sat, 6 Feb 2010 17:04:13 +0000 (17:04 +0000)
source/blender/blenkernel/intern/cdderivedmesh.c
source/blender/blenkernel/intern/subsurf_ccg.c

index 61f8ac09fb7ea7ab928a83cde4964b37d5e9a631..6ebd28833c5078464d2df65a3704740c10b31b19 100644 (file)
@@ -414,15 +414,17 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm,
 }
 
        if(cddm->pbvh) {
-               float (*face_nors)[3] = CustomData_get_layer(&dm->faceData, CD_NORMAL);
+               if(dm->numFaceData) {
+                       float (*face_nors)[3] = CustomData_get_layer(&dm->faceData, CD_NORMAL);
 
-               /* should be per face */
-               if(dm->numFaceData && mface->flag & ME_SMOOTH)
-                       glShadeModel(GL_SMOOTH);
-
-               BLI_pbvh_draw(cddm->pbvh, partial_redraw_planes, face_nors);
+                       /* should be per face */
+                       if(!setMaterial(mface->mat_nr+1, NULL))
+                               return;
 
-               glShadeModel(GL_FLAT);
+                       glShadeModel((mface->flag & ME_SMOOTH)? GL_SMOOTH: GL_FLAT);
+                       BLI_pbvh_draw(cddm->pbvh, partial_redraw_planes, face_nors);
+                       glShadeModel(GL_FLAT);
+               }
 
                return;
        }
index 445fc23b069b9975668f070b476f4af8391e01d9..2ad17b7d0b98a57c225958680764c1025923d6e5 100644 (file)
@@ -1240,13 +1240,15 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)
                        MEM_freeN(faces);
                }
 
-               /* should be per face */
-               if(faceFlags && faceFlags[0] & ME_SMOOTH)
-                       glShadeModel(GL_SMOOTH);
+               if(dm->numFaceData) {
+                       /* should be per face */
+                       if(!setMaterial(faceFlags[1], NULL))
+                               return;
 
-               BLI_pbvh_draw(ccgdm->pbvh, partial_redraw_planes, NULL);
-
-               glShadeModel(GL_FLAT);
+                       glShadeModel((faceFlags[0] & ME_SMOOTH)? GL_SMOOTH: GL_FLAT);
+                       BLI_pbvh_draw(ccgdm->pbvh, partial_redraw_planes, NULL);
+                       glShadeModel(GL_FLAT);
+               }
 
                return;
        }