Partial Fix T47221: Sculpt Hide fails w/ texture drawing
authorCampbell Barton <ideasman42@gmail.com>
Tue, 2 Feb 2016 05:06:45 +0000 (16:06 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 2 Feb 2016 05:48:44 +0000 (16:48 +1100)
Support for skipping hidden faces in sculpt mode w/ texture drawing.

source/blender/blenkernel/intern/cdderivedmesh.c
source/blender/editors/space_view3d/drawmesh.c

index 90269724db6f207da8de00c5a9c6a22a3b7f5fe2..0d3848f978767477b9069a928b0991d2580460e1 100644 (file)
@@ -498,7 +498,8 @@ static void cdDM_drawFacesTex_common(
        const  MLoopCol *mloopcol;
        int i;
        int colType, start_element, tot_drawn;
-       bool use_tface = (uvflag & DM_DRAW_USE_ACTIVE_UV) != 0;
+       const bool use_hide = (uvflag & DM_DRAW_SKIP_HIDDEN) != 0;
+       const bool use_tface = (uvflag & DM_DRAW_USE_ACTIVE_UV) != 0;
        int totpoly;
        int next_actualFace;
        int mat_index;
@@ -570,7 +571,10 @@ static void cdDM_drawFacesTex_common(
                        if (i != totpoly - 1)
                                next_actualFace = bufmat->polys[i + 1];
 
-                       if (drawParams) {
+                       if (use_hide && (mpoly[actualFace].flag & ME_HIDE)) {
+                               draw_option = DM_DRAW_OPTION_SKIP;
+                       }
+                       else if (drawParams) {
                                MTexPoly *tp = use_tface && mtexpoly ? &mtexpoly[actualFace] : NULL;
                                draw_option = drawParams(tp, (mloopcol != NULL), mpoly[actualFace].mat_nr);
                        }
index 11ba6fb709b93a5297315d18f26f0cea584ee89f..5ded3a9518d7497976b7bf48d4e6c3ca4a22e042 100644 (file)
@@ -942,7 +942,6 @@ static void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d
                                    Object *ob, DerivedMesh *dm, const int draw_flags)
 {
        Mesh *me = ob->data;
-       DMDrawFlag uvflag = DM_DRAW_USE_ACTIVE_UV;
 
        /* correct for negative scale */
        if (ob->transflag & OB_NEG_SCALE) glFrontFace(GL_CW);
@@ -953,10 +952,6 @@ static void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d
 
        glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
 
-       if (ob->mode & OB_MODE_TEXTURE_PAINT) {
-               uvflag = DM_DRAW_USE_TEXPAINT_UV;
-       }
-
        if (ob->mode & OB_MODE_EDIT) {
                drawEMTFMapped_userData data;
 
@@ -969,34 +964,54 @@ static void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d
 
                dm->drawMappedFacesTex(dm, draw_em_tf_mapped__set_draw, compareDrawOptionsEm, &data, 0);
        }
-       else if (draw_flags & DRAW_FACE_SELECT) {
-               if (ob->mode & OB_MODE_WEIGHT_PAINT)
-                       dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions_facemask, GPU_object_material_bind, NULL, me,
-                                           DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH | DM_DRAW_SKIP_HIDDEN);
+       else if ((draw_flags & DRAW_FACE_SELECT) &&
+                (ob->mode & OB_MODE_WEIGHT_PAINT))
+       {
+               dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions_facemask, GPU_object_material_bind, NULL, me,
+                                   DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH | DM_DRAW_SKIP_HIDDEN);
+       }
+       else {
+               DMDrawFlag uvflag;
+               drawTFace_userData userData;
+
+               if (ob->mode & OB_MODE_TEXTURE_PAINT) {
+                       uvflag = DM_DRAW_USE_TEXPAINT_UV;
+               }
                else {
-                       drawTFace_userData userData;
+                       uvflag = DM_DRAW_USE_ACTIVE_UV;
+               }
 
-                       userData.mpoly = DM_get_poly_data_layer(dm, CD_MPOLY);
-                       userData.mtexpoly = DM_get_poly_data_layer(dm, CD_MTEXPOLY);
-                       userData.me = me;
-                       dm->drawMappedFacesTex(dm, me->mpoly ? draw_tface_mapped__set_draw : NULL, compareDrawOptions, &userData, uvflag);
+               if ((ob->mode & OB_MODE_SCULPT) && (ob == OBACT)) {
+                       uvflag |= DM_DRAW_SKIP_HIDDEN;
                }
-       }
-       else {          
-               drawTFace_userData userData;
-               
-               update_tface_color_layer(dm, !(ob->mode & OB_MODE_TEXTURE_PAINT));
-               
+
+
                userData.mpoly = DM_get_poly_data_layer(dm, CD_MPOLY);
                userData.mtexpoly = DM_get_poly_data_layer(dm, CD_MTEXPOLY);
-               userData.me = NULL;
-               
-               dm->drawFacesTex(dm, draw_tface__set_draw, compareDrawOptions, &userData, uvflag);
+
+               if (draw_flags & DRAW_FACE_SELECT) {
+                       userData.me = me;
+
+                       dm->drawMappedFacesTex(
+                               dm, me->mpoly ? draw_tface_mapped__set_draw : NULL, compareDrawOptions,
+                               &userData, uvflag);
+               }
+               else {
+                       userData.me = NULL;
+
+                       update_tface_color_layer(dm, !(ob->mode & OB_MODE_TEXTURE_PAINT));
+                       dm->drawFacesTex(
+                               dm, draw_tface__set_draw, compareDrawOptions,
+                               &userData, uvflag);
+               }
        }
 
        /* draw game engine text hack */
-       if (BKE_bproperty_object_get(ob, "Text"))
-               draw_mesh_text(scene, ob, 0);
+       if (rv3d->rflag & RV3D_IS_GAME_ENGINE) {
+               if (BKE_bproperty_object_get(ob, "Text")) {
+                       draw_mesh_text(scene, ob, 0);
+               }
+       }
 
        draw_textured_end();