diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-07-01 04:42:44 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-07-01 04:42:44 +0400 |
commit | c729c5ab4b5b44b2f3081b06143816cd5d8a4074 (patch) | |
tree | d67d267f71610795a40d63cc76ea75377c1ecbed /source/blender/editors/space_view3d/drawmesh.c | |
parent | b3ceab896aa6369cf4cd6c62ae3b0e2180ff8ae6 (diff) |
fix [#35911] Show weights not working with a weight edit modifier in edit mode
Diffstat (limited to 'source/blender/editors/space_view3d/drawmesh.c')
-rw-r--r-- | source/blender/editors/space_view3d/drawmesh.c | 118 |
1 files changed, 63 insertions, 55 deletions
diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 6a836c4af13..8a714c4d51e 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -1004,45 +1004,81 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, } /* Vertex Paint and Weight Paint */ +void draw_mesh_paint_weight_faces(Mesh *me, DerivedMesh *dm, void *facemask, const bool use_light) +{ + if (use_light) { + const float spec[4] = {0.47f, 0.47f, 0.47f, 0.47f}; + + /* but set default spec */ + glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR); + glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, spec); + + /* diffuse */ + glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); + glEnable(GL_LIGHTING); + glEnable(GL_COLOR_MATERIAL); + } + + dm->drawMappedFaces(dm, (DMSetDrawOptions)facemask, GPU_enable_material, NULL, me, + DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH); + + if (use_light) { + glDisable(GL_COLOR_MATERIAL); + glDisable(GL_LIGHTING); + + GPU_disable_material(); + } +} + +void draw_mesh_paint_weight_edges(RegionView3D *rv3d, DerivedMesh *dm, const bool use_depth) +{ + /* weight paint in solid mode, special case. focus on making the weights clear + * rather than the shading, this is also forced in wire view */ + + if (use_depth) { + bglPolygonOffset(rv3d->dist, 1.0); + glDepthMask(0); /* disable write in zbuffer, selected edge wires show better */ + } + else { + glDisable(GL_DEPTH_TEST); + } + + glEnable(GL_BLEND); + glColor4ub(255, 255, 255, 96); + glEnable(GL_LINE_STIPPLE); + glLineStipple(1, 0xAAAA); + + dm->drawEdges(dm, 1, 1); + + if (use_depth) { + bglPolygonOffset(rv3d->dist, 0.0); + glDepthMask(1); + } + else { + glEnable(GL_DEPTH_TEST); + } + + glDisable(GL_LINE_STIPPLE); + glDisable(GL_BLEND); +} void draw_mesh_paint(View3D *v3d, RegionView3D *rv3d, Object *ob, DerivedMesh *dm, const int draw_flags) { DMSetDrawOptions facemask = NULL; Mesh *me = ob->data; - const bool do_light = (v3d->drawtype >= OB_SOLID); + const bool use_light = (v3d->drawtype >= OB_SOLID); /* hide faces in face select mode */ if (me->editflag & (ME_EDIT_PAINT_VERT_SEL | ME_EDIT_PAINT_FACE_SEL)) facemask = wpaint__setSolidDrawOptions_facemask; if (ob->mode & OB_MODE_WEIGHT_PAINT) { - - if (do_light) { - const float spec[4] = {0.47f, 0.47f, 0.47f, 0.47f}; - - /* enforce default material settings */ + if (use_light) { GPU_enable_material(0, NULL); - - /* but set default spec */ - glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR); - glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, spec); - - /* diffuse */ - glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); - glEnable(GL_LIGHTING); - glEnable(GL_COLOR_MATERIAL); } - dm->drawMappedFaces(dm, facemask, GPU_enable_material, NULL, me, - DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH); - - if (do_light) { - glDisable(GL_COLOR_MATERIAL); - glDisable(GL_LIGHTING); - - GPU_disable_material(); - } + draw_mesh_paint_weight_faces(me, dm, facemask, use_light); } else if (ob->mode & OB_MODE_VERTEX_PAINT) { if (me->mloopcol) { @@ -1060,37 +1096,9 @@ void draw_mesh_paint(View3D *v3d, RegionView3D *rv3d, if (draw_flags & DRAW_FACE_SELECT) { draw_mesh_face_select(rv3d, me, dm); } - else if ((do_light == false) || (ob->dtx & OB_DRAWWIRE)) { - const int use_depth = (v3d->flag & V3D_ZBUF_SELECT) || !(ob->mode & OB_MODE_WEIGHT_PAINT); - - /* weight paint in solid mode, special case. focus on making the weights clear - * rather than the shading, this is also forced in wire view */ - - if (use_depth) { - bglPolygonOffset(rv3d->dist, 1.0); - glDepthMask(0); /* disable write in zbuffer, selected edge wires show better */ - } - else { - glDisable(GL_DEPTH_TEST); - } - - glEnable(GL_BLEND); - glColor4ub(255, 255, 255, 96); - glEnable(GL_LINE_STIPPLE); - glLineStipple(1, 0xAAAA); - - dm->drawEdges(dm, 1, 1); - - if (use_depth) { - bglPolygonOffset(rv3d->dist, 0.0); - glDepthMask(1); - } - else { - glEnable(GL_DEPTH_TEST); - } - - glDisable(GL_LINE_STIPPLE); - glDisable(GL_BLEND); + else if ((use_light == false) || (ob->dtx & OB_DRAWWIRE)) { + const bool use_depth = (v3d->flag & V3D_ZBUF_SELECT) || !(ob->mode & OB_MODE_WEIGHT_PAINT); + draw_mesh_paint_weight_edges(rv3d, dm, use_depth); } } |