Revision: 33649
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=33649
Author:   nicholasbishop
Date:     2010-12-14 04:30:30 +0100 (Tue, 14 Dec 2010)

Log Message:
-----------
Fixed bug #23922, Sculpting - Textured display draws incorrectly

Root cause is that some drawing modes don't work with PBVH
drawing. Worked around by adding a call to update mesh normals from
the PBVH so that sculpted changes appear correctly in those
"unsupported" modes. (They'll still draw much more slowly than solid,
but should at least appear correct now.)

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/cdderivedmesh.c
    trunk/blender/source/blender/blenkernel/intern/subsurf_ccg.c

Modified: trunk/blender/source/blender/blenkernel/intern/cdderivedmesh.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/cdderivedmesh.c      
2010-12-14 02:38:29 UTC (rev 33648)
+++ trunk/blender/source/blender/blenkernel/intern/cdderivedmesh.c      
2010-12-14 03:30:30 UTC (rev 33649)
@@ -226,6 +226,21 @@
        return cddm->pbvh;
 }
 
+/* update vertex normals so that drawing smooth faces works during sculpt
+   TODO: proper fix is to support the pbvh in all drawing modes */
+static void cdDM_update_normals_from_pbvh(DerivedMesh *dm)
+{
+       CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
+       float (*face_nors)[3];
+
+       if(!cddm->pbvh || !cddm->pbvh_draw || !dm->numFaceData)
+               return;
+
+       face_nors = CustomData_get_layer(&dm->faceData, CD_NORMAL);
+
+       BLI_pbvh_update(cddm->pbvh, PBVH_UpdateNormals, face_nors);
+}
+
 static void cdDM_drawVerts(DerivedMesh *dm)
 {
        CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
@@ -538,6 +553,8 @@
        if(col1 && col2)
                glEnable(GL_CULL_FACE);
 
+       cdDM_update_normals_from_pbvh(dm);
+
        if( GPU_buffer_legacy(dm) ) {
                DEBUG_VBO( "Using legacy code. cdDM_drawFacesColored\n" );
                glShadeModel(GL_SMOOTH);
@@ -617,6 +634,8 @@
        if(!mcol)
                mcol = dm->getFaceDataArray(dm, CD_MCOL);
 
+       cdDM_update_normals_from_pbvh(dm);
+
        if( GPU_buffer_legacy(dm) ) {
                DEBUG_VBO( "Using legacy code. cdDM_drawFacesTex_common\n" );
                for(i = 0; i < dm->numFaceData; i++, mf++) {
@@ -792,6 +811,8 @@
        if(!mc)
                mc = DM_get_face_data_layer(dm, CD_MCOL);
 
+       cdDM_update_normals_from_pbvh(dm);
+
        /* back-buffer always uses legacy since VBO's would need the
         * color array temporarily overwritten for drawing, then reset. */
        if( GPU_buffer_legacy(dm) || G.f & G_BACKBUFSEL) {
@@ -938,6 +959,8 @@
        int transp, new_transp, orig_transp;
        int orig, *index = dm->getFaceDataArray(dm, CD_ORIGINDEX);
 
+       cdDM_update_normals_from_pbvh(dm);
+
        matnr = -1;
        smoothnormal = 0;
        dodraw = 0;

Modified: trunk/blender/source/blender/blenkernel/intern/subsurf_ccg.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/subsurf_ccg.c        
2010-12-14 02:38:29 UTC (rev 33648)
+++ trunk/blender/source/blender/blenkernel/intern/subsurf_ccg.c        
2010-12-14 03:30:30 UTC (rev 33649)
@@ -1245,7 +1245,7 @@
        no[1] = b_dZ*a_cX - b_dX*a_cZ;
        no[2] = b_dX*a_cY - b_dY*a_cX;
 
-       /* don't normalize, GL_NORMALIZE is be enabled */
+       /* don't normalize, GL_NORMALIZE is enabled */
        glNormal3fv(no);
 }
 


_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to