diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/space_view3d/drawmesh.c | 63 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 34 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_intern.h | 6 |
3 files changed, 54 insertions, 49 deletions
diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 837b02ace64..b5c44fd1a8c 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -926,14 +926,14 @@ static int tex_mat_set_face_editmesh_cb(void *userData, int index) return !BM_elem_flag_test(efa, BM_ELEM_HIDDEN); } -void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, DerivedMesh *dm, int draw_flags) +void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, DerivedMesh *dm, const int draw_flags) { if ((!BKE_scene_use_new_shading_nodes(scene)) || (draw_flags & DRAW_MODIFIERS_PREVIEW)) { draw_mesh_textured_old(scene, v3d, rv3d, ob, dm, draw_flags); return; } else if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) { - draw_mesh_paint(rv3d, ob, dm, draw_flags); + draw_mesh_paint(v3d, rv3d, ob, dm, draw_flags); return; } @@ -1002,37 +1002,43 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *o /* Vertex Paint and Weight Paint */ -void draw_mesh_paint(RegionView3D *rv3d, Object *ob, DerivedMesh *dm, int draw_flags) +void draw_mesh_paint(View3D *v3d, RegionView3D *rv3d, Object *ob, DerivedMesh *dm, int draw_flags) { DMSetDrawOptions facemask = NULL; Mesh *me = ob->data; + const short do_light = (v3d->drawtype >= OB_SOLID); /* hide faces in face select mode */ if (draw_flags & DRAW_FACE_SELECT) facemask = wpaint__setSolidDrawOptions_facemask; if (ob && ob->mode & OB_MODE_WEIGHT_PAINT) { - /* enforce default material settings */ - GPU_enable_material(0, NULL); + + if (do_light) { + /* enforce default material settings */ + GPU_enable_material(0, NULL); - /* but set default spec */ - glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR); - glEnable(GL_COLOR_MATERIAL); /* according manpages needed */ - glColor3ub(120, 120, 120); - glDisable(GL_COLOR_MATERIAL); + /* but set default spec */ + glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR); + glEnable(GL_COLOR_MATERIAL); /* according manpages needed */ + glColor3ub(120, 120, 120); + glDisable(GL_COLOR_MATERIAL); - /* diffuse */ - glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); - glEnable(GL_LIGHTING); - glEnable(GL_COLOR_MATERIAL); + /* 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); - glDisable(GL_COLOR_MATERIAL); - glDisable(GL_LIGHTING); + if (do_light) { + glDisable(GL_COLOR_MATERIAL); + glDisable(GL_LIGHTING); - GPU_disable_material(); + GPU_disable_material(); + } } else if (ob->mode & OB_MODE_VERTEX_PAINT) { if (me->mloopcol) { @@ -1047,7 +1053,28 @@ void draw_mesh_paint(RegionView3D *rv3d, Object *ob, DerivedMesh *dm, int draw_f } /* draw face selection on top */ - if (draw_flags & DRAW_FACE_SELECT) + if (draw_flags & DRAW_FACE_SELECT) { draw_mesh_face_select(rv3d, me, dm); + } + else if ((do_light == FALSE) || (ob->dtx & OB_DRAWWIRE)) { + + /* weight paint in solid mode, special case. focus on making the weights clear + * rather than the shading, this is also forced in wire view */ + + bglPolygonOffset(rv3d->dist, 1.0); + glDepthMask(0); // disable write in zbuffer, selected edge wires show better + + glEnable(GL_BLEND); + glColor4ub(255, 255, 255, 96); + glEnable(GL_LINE_STIPPLE); + glLineStipple(1, 0xAAAA); + + dm->drawEdges(dm, 1, 1); + + bglPolygonOffset(rv3d->dist, 0.0); + glDepthMask(1); + glDisable(GL_LINE_STIPPLE); + glDisable(GL_BLEND); + } } diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 876f3e78062..5413aa88ab6 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -3367,34 +3367,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D } } else if (dt == OB_SOLID) { - if (is_obact && ob->mode & (OB_MODE_VERTEX_PAINT | 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 */ - GPU_enable_material(0, NULL); - dm->drawMappedFaces(dm, NULL, GPU_enable_material, NULL, me->mpoly, - DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH); - - bglPolygonOffset(rv3d->dist, 1.0); - glDepthMask(0); // disable write in zbuffer, selected edge wires show better - - glEnable(GL_BLEND); - glColor4ub(255, 255, 255, 96); - glEnable(GL_LINE_STIPPLE); - glLineStipple(1, 0xAAAA); - - dm->drawEdges(dm, 1, 1); - - bglPolygonOffset(rv3d->dist, 0.0); - glDepthMask(1); - glDisable(GL_LINE_STIPPLE); - glDisable(GL_BLEND); - - GPU_disable_material(); - - /* since we already draw wire as wp guide, don't draw over the top */ - draw_wire = OBDRAW_WIRE_OFF; - } - else if (draw_flags & DRAW_MODIFIERS_PREVIEW) { + if (draw_flags & DRAW_MODIFIERS_PREVIEW) { /* for object selection draws no shade */ if (flag & (DRAW_PICKING | DRAW_CONSTCOLOR)) { dm->drawFacesSolid(dm, NULL, 0, GPU_enable_material); @@ -3485,7 +3458,10 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D } } else if (dt == OB_PAINT) { - draw_mesh_paint(rv3d, ob, dm, draw_flags); + draw_mesh_paint(v3d, rv3d, ob, dm, draw_flags); + + /* since we already draw wire as wp guide, don't draw over the top */ + draw_wire = OBDRAW_WIRE_OFF; } /* set default draw color back for wire or for draw-extra later on */ diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index b7cb9161ef4..f387e1dd844 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -131,8 +131,10 @@ void view3d_cached_text_draw_end(View3D * v3d, ARegion * ar, int depth_write, fl int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, int dt, int flag, const short is_outline); /* drawmesh.c */ -void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, struct Object *ob, struct DerivedMesh *dm, int faceselect); -void draw_mesh_paint(RegionView3D *rv3d, struct Object *ob, struct DerivedMesh *dm, int faceselect); +void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, + struct Object *ob, struct DerivedMesh *dm, const int draw_flags); +void draw_mesh_paint(View3D *v3d, RegionView3D *rv3d, + struct Object *ob, struct DerivedMesh *dm, const int draw_flags); /* view3d_draw.c */ void view3d_main_area_draw(const struct bContext *C, struct ARegion *ar); |