Fix T47891: Edges throw shadow in edit mode

This commit is contained in:
Campbell Barton 2016-04-20 12:39:15 +10:00
parent 4ee5ba41bb
commit 81a477f4dc

View File

@ -3678,29 +3678,10 @@ static void draw_em_fancy(Scene *scene, ARegion *ar, View3D *v3d,
{ {
RegionView3D *rv3d = ar->regiondata; RegionView3D *rv3d = ar->regiondata;
Mesh *me = ob->data; Mesh *me = ob->data;
BMFace *efa_act = BM_mesh_active_face_get(em->bm, false, true); /* annoying but active faces is stored differently */ const bool use_occlude_wire = (dt > OB_WIRE) && (v3d->flag2 & V3D_OCCLUDE_WIRE);
BMEdge *eed_act = NULL; bool use_depth_offset = false;
BMVert *eve_act = NULL;
bool use_occlude_wire = (v3d->flag2 & V3D_OCCLUDE_WIRE) && (dt > OB_WIRE);
glLineWidth(1); glLineWidth(1);
if (em->bm->selected.last) {
BMEditSelection *ese = em->bm->selected.last;
/* face is handled above */
#if 0
if (ese->type == BM_FACE) {
efa_act = (BMFace *)ese->data;
}
else
#endif
if (ese->htype == BM_EDGE) {
eed_act = (BMEdge *)ese->ele;
}
else if (ese->htype == BM_VERT) {
eve_act = (BMVert *)ese->ele;
}
}
BM_mesh_elem_table_ensure(em->bm, BM_VERT | BM_EDGE | BM_FACE); BM_mesh_elem_table_ensure(em->bm, BM_VERT | BM_EDGE | BM_FACE);
@ -3710,6 +3691,7 @@ static void draw_em_fancy(Scene *scene, ARegion *ar, View3D *v3d,
ED_view3d_polygon_offset(rv3d, 1.0); ED_view3d_polygon_offset(rv3d, 1.0);
glDepthMask(0); glDepthMask(0);
use_depth_offset = true;
} }
else { else {
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
@ -3756,6 +3738,7 @@ static void draw_em_fancy(Scene *scene, ARegion *ar, View3D *v3d,
ED_view3d_polygon_offset(rv3d, 1.0); ED_view3d_polygon_offset(rv3d, 1.0);
glDepthMask(0); glDepthMask(0);
use_depth_offset = true;
} }
else { else {
if (cageDM != finalDM) { if (cageDM != finalDM) {
@ -3764,145 +3747,172 @@ static void draw_em_fancy(Scene *scene, ARegion *ar, View3D *v3d,
} }
} }
if ((me->drawflag & ME_DRAWFACES) && (use_occlude_wire == false)) { /* transp faces */ if ((dt > OB_WIRE) && (v3d->flag2 & V3D_RENDER_SHADOW)) {
unsigned char col1[4], col2[4], col3[4]; /* pass */
#ifdef WITH_FREESTYLE
unsigned char col4[4];
#endif
UI_GetThemeColor4ubv(TH_FACE, col1);
UI_GetThemeColor4ubv(TH_FACE_SELECT, col2);
UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col3);
#ifdef WITH_FREESTYLE
UI_GetThemeColor4ubv(TH_FREESTYLE_FACE_MARK, col4);
#endif
glEnable(GL_BLEND);
glDepthMask(0); /* disable write in zbuffer, needed for nice transp */
/* don't draw unselected faces, only selected, this is MUCH nicer when texturing */
if (check_object_draw_texture(scene, v3d, dt))
col1[3] = 0;
#ifdef WITH_FREESTYLE
if (!(me->drawflag & ME_DRAW_FREESTYLE_FACE) || !CustomData_has_layer(&em->bm->pdata, CD_FREESTYLE_FACE))
col4[3] = 0;
draw_dm_faces_sel(em, cageDM, col1, col2, col3, col4, efa_act);
#else
draw_dm_faces_sel(em, cageDM, col1, col2, col3, efa_act);
#endif
glDisable(GL_BLEND);
glDepthMask(1); /* restore write in zbuffer */
}
else if (efa_act) {
/* even if draw faces is off it would be nice to draw the stipple face
* Make all other faces zero alpha except for the active */
unsigned char col1[4], col2[4], col3[4];
#ifdef WITH_FREESTYLE
unsigned char col4[4];
col4[3] = 0; /* don't draw */
#endif
col1[3] = col2[3] = 0; /* don't draw */
UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col3);
glEnable(GL_BLEND);
glDepthMask(0); /* disable write in zbuffer, needed for nice transp */
#ifdef WITH_FREESTYLE
draw_dm_faces_sel(em, cageDM, col1, col2, col3, col4, efa_act);
#else
draw_dm_faces_sel(em, cageDM, col1, col2, col3, efa_act);
#endif
glDisable(GL_BLEND);
glDepthMask(1); /* restore write in zbuffer */
}
/* here starts all fancy draw-extra over */
if ((me->drawflag & ME_DRAWEDGES) == 0 && check_object_draw_texture(scene, v3d, dt)) {
/* we are drawing textures and 'ME_DRAWEDGES' is disabled, don't draw any edges */
/* only draw selected edges otherwise there is no way of telling if a face is selected */
draw_em_fancy_edges(em, scene, v3d, me, cageDM, 1, eed_act);
} }
else { else {
if (me->drawflag & ME_DRAWSEAMS) { /* annoying but active faces is stored differently */
UI_ThemeColor(TH_EDGE_SEAM); BMFace *efa_act = BM_mesh_active_face_get(em->bm, false, true);
glLineWidth(2); BMEdge *eed_act = NULL;
BMVert *eve_act = NULL;
draw_dm_edges_seams(em, cageDM); if (em->bm->selected.last) {
BMEditSelection *ese = em->bm->selected.last;
glColor3ub(0, 0, 0); /* face is handled above */
#if 0
if (ese->type == BM_FACE) {
efa_act = (BMFace *)ese->data;
}
else
#endif
if (ese->htype == BM_EDGE) {
eed_act = (BMEdge *)ese->ele;
}
else if (ese->htype == BM_VERT) {
eve_act = (BMVert *)ese->ele;
}
} }
if (me->drawflag & ME_DRAWSHARP) {
UI_ThemeColor(TH_EDGE_SHARP);
glLineWidth(2);
draw_dm_edges_sharp(em, cageDM); if ((me->drawflag & ME_DRAWFACES) && (use_occlude_wire == false)) { /* transp faces */
unsigned char col1[4], col2[4], col3[4];
#ifdef WITH_FREESTYLE
unsigned char col4[4];
#endif
glColor3ub(0, 0, 0); UI_GetThemeColor4ubv(TH_FACE, col1);
} UI_GetThemeColor4ubv(TH_FACE_SELECT, col2);
UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col3);
#ifdef WITH_FREESTYLE
UI_GetThemeColor4ubv(TH_FREESTYLE_FACE_MARK, col4);
#endif
glEnable(GL_BLEND);
glDepthMask(0); /* disable write in zbuffer, needed for nice transp */
/* don't draw unselected faces, only selected, this is MUCH nicer when texturing */
if (check_object_draw_texture(scene, v3d, dt))
col1[3] = 0;
#ifdef WITH_FREESTYLE #ifdef WITH_FREESTYLE
if (me->drawflag & ME_DRAW_FREESTYLE_EDGE && CustomData_has_layer(&em->bm->edata, CD_FREESTYLE_EDGE)) { if (!(me->drawflag & ME_DRAW_FREESTYLE_FACE) || !CustomData_has_layer(&em->bm->pdata, CD_FREESTYLE_FACE))
UI_ThemeColor(TH_FREESTYLE_EDGE_MARK); col4[3] = 0;
glLineWidth(2);
draw_dm_faces_sel(em, cageDM, col1, col2, col3, col4, efa_act);
draw_dm_edges_freestyle(em, cageDM); #else
draw_dm_faces_sel(em, cageDM, col1, col2, col3, efa_act);
glColor3ub(0, 0, 0);
}
#endif #endif
if (me->drawflag & ME_DRAWCREASES) { glDisable(GL_BLEND);
draw_dm_creases(em, cageDM); glDepthMask(1); /* restore write in zbuffer */
} }
if (me->drawflag & ME_DRAWBWEIGHTS) { else if (efa_act) {
draw_dm_bweights(em, scene, cageDM); /* even if draw faces is off it would be nice to draw the stipple face
* Make all other faces zero alpha except for the active */
unsigned char col1[4], col2[4], col3[4];
#ifdef WITH_FREESTYLE
unsigned char col4[4];
col4[3] = 0; /* don't draw */
#endif
col1[3] = col2[3] = 0; /* don't draw */
UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col3);
glEnable(GL_BLEND);
glDepthMask(0); /* disable write in zbuffer, needed for nice transp */
#ifdef WITH_FREESTYLE
draw_dm_faces_sel(em, cageDM, col1, col2, col3, col4, efa_act);
#else
draw_dm_faces_sel(em, cageDM, col1, col2, col3, efa_act);
#endif
glDisable(GL_BLEND);
glDepthMask(1); /* restore write in zbuffer */
} }
glLineWidth(1); /* here starts all fancy draw-extra over */
draw_em_fancy_edges(em, scene, v3d, me, cageDM, 0, eed_act); if ((me->drawflag & ME_DRAWEDGES) == 0 && check_object_draw_texture(scene, v3d, dt)) {
} /* we are drawing textures and 'ME_DRAWEDGES' is disabled, don't draw any edges */
{ /* only draw selected edges otherwise there is no way of telling if a face is selected */
draw_em_fancy_verts(scene, v3d, ob, em, cageDM, eve_act, rv3d); draw_em_fancy_edges(em, scene, v3d, me, cageDM, 1, eed_act);
if (me->drawflag & ME_DRAWNORMALS) {
UI_ThemeColor(TH_NORMAL);
draw_dm_face_normals(em, scene, ob, cageDM);
} }
if (me->drawflag & ME_DRAW_VNORMALS) { else {
UI_ThemeColor(TH_VNORMAL); if (me->drawflag & ME_DRAWSEAMS) {
draw_dm_vert_normals(em, scene, ob, cageDM); UI_ThemeColor(TH_EDGE_SEAM);
} glLineWidth(2);
if (me->drawflag & ME_DRAW_LNORMALS) {
UI_ThemeColor(TH_LNORMAL); draw_dm_edges_seams(em, cageDM);
draw_dm_loop_normals(em, scene, ob, cageDM);
glColor3ub(0, 0, 0);
}
if (me->drawflag & ME_DRAWSHARP) {
UI_ThemeColor(TH_EDGE_SHARP);
glLineWidth(2);
draw_dm_edges_sharp(em, cageDM);
glColor3ub(0, 0, 0);
}
#ifdef WITH_FREESTYLE
if (me->drawflag & ME_DRAW_FREESTYLE_EDGE && CustomData_has_layer(&em->bm->edata, CD_FREESTYLE_EDGE)) {
UI_ThemeColor(TH_FREESTYLE_EDGE_MARK);
glLineWidth(2);
draw_dm_edges_freestyle(em, cageDM);
glColor3ub(0, 0, 0);
}
#endif
if (me->drawflag & ME_DRAWCREASES) {
draw_dm_creases(em, cageDM);
}
if (me->drawflag & ME_DRAWBWEIGHTS) {
draw_dm_bweights(em, scene, cageDM);
}
glLineWidth(1);
draw_em_fancy_edges(em, scene, v3d, me, cageDM, 0, eed_act);
} }
if ((me->drawflag & (ME_DRAWEXTRA_EDGELEN |
ME_DRAWEXTRA_FACEAREA |
ME_DRAWEXTRA_FACEANG |
ME_DRAWEXTRA_EDGEANG)) &&
!(v3d->flag2 & V3D_RENDER_OVERRIDE))
{ {
draw_em_measure_stats(ar, v3d, ob, em, &scene->unit); draw_em_fancy_verts(scene, v3d, ob, em, cageDM, eve_act, rv3d);
}
if ((G.debug & G_DEBUG) && (me->drawflag & ME_DRAWEXTRA_INDICES) && if (me->drawflag & ME_DRAWNORMALS) {
!(v3d->flag2 & V3D_RENDER_OVERRIDE)) UI_ThemeColor(TH_NORMAL);
{ draw_dm_face_normals(em, scene, ob, cageDM);
draw_em_indices(em); }
if (me->drawflag & ME_DRAW_VNORMALS) {
UI_ThemeColor(TH_VNORMAL);
draw_dm_vert_normals(em, scene, ob, cageDM);
}
if (me->drawflag & ME_DRAW_LNORMALS) {
UI_ThemeColor(TH_LNORMAL);
draw_dm_loop_normals(em, scene, ob, cageDM);
}
if ((me->drawflag & (ME_DRAWEXTRA_EDGELEN |
ME_DRAWEXTRA_FACEAREA |
ME_DRAWEXTRA_FACEANG |
ME_DRAWEXTRA_EDGEANG)) &&
!(v3d->flag2 & V3D_RENDER_OVERRIDE))
{
draw_em_measure_stats(ar, v3d, ob, em, &scene->unit);
}
if ((G.debug & G_DEBUG) && (me->drawflag & ME_DRAWEXTRA_INDICES) &&
!(v3d->flag2 & V3D_RENDER_OVERRIDE))
{
draw_em_indices(em);
}
} }
} }
if (dt > OB_WIRE) { if (use_depth_offset) {
glDepthMask(1); glDepthMask(1);
ED_view3d_polygon_offset(rv3d, 0.0); ED_view3d_polygon_offset(rv3d, 0.0);
GPU_object_material_unbind(); GPU_object_material_unbind();