From 925f21342709522afa334218e97e0b31f87f1516 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Wed, 7 Mar 2012 12:48:52 +0000 Subject: Code cleanup: simplify the DerivedMesh.drawMappedFaces interface. This function pointer's 'setDrawOptions' parameter took a slightly different type than the other drawing callbacks. In particular, it could set a 'drawSmooth' value to indicate that smoothing should always be enabled, overriding the face flag. However, all callbacks either did not set this value, or set it unconditionally to 1. Replaced this by adding a new 'flag' parameter to drawFacesMapped, which can be set to DM_DRAW_ALWAYS_SMOOTH where appropriate. Also removed the 'useColors' parameter and replaced it with another flag value, DM_DRAW_USE_COLORS. Removed the 'wpaint__setSolidDrawOptions' callback, was only being used to set the shading to smooth. --- source/blender/editors/space_view3d/drawobject.c | 32 +++++++++++------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'source/blender/editors/space_view3d/drawobject.c') diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 77a686e81b7..e56b4216583 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2482,7 +2482,7 @@ static void draw_dm_edges_sharp(BMEditMesh *em, DerivedMesh *dm) /* Draw faces with color set based on selection * return 2 for the active face so it renders with stipple enabled */ -static int draw_dm_faces_sel__setDrawOptions(void *userData, int index, int *UNUSED(drawSmooth_r)) +static int draw_dm_faces_sel__setDrawOptions(void *userData, int index) { drawDMFacesSel_userData * data = userData; BMFace *efa = EDBM_get_face_for_index(data->em, index); @@ -2965,7 +2965,7 @@ static void draw_em_indices(BMEditMesh *em) } } -static int draw_em_fancy__setFaceOpts(void *userData, int index, int *UNUSED(drawSmooth_r)) +static int draw_em_fancy__setFaceOpts(void *userData, int index) { BMFace *efa = EDBM_get_face_for_index(userData, index); @@ -3189,12 +3189,6 @@ static void draw_mesh_object_outline(View3D *v3d, Object *ob, DerivedMesh *dm) } } -static int wpaint__setSolidDrawOptions(void *UNUSED(userData), int UNUSED(index), int *drawSmooth_r) -{ - *drawSmooth_r = 1; - return 1; -} - static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, Base *base, int dt, int flag) { Object *ob= base->object; @@ -3283,7 +3277,8 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D /* 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, wpaint__setSolidDrawOptions, GPU_enable_material, NULL, me->mpoly, 1); + 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 @@ -3336,7 +3331,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D glEnable(GL_LIGHTING); glEnable(GL_COLOR_MATERIAL); - dm->drawMappedFaces(dm, NULL, GPU_enable_material, NULL, NULL, 1); + dm->drawMappedFaces(dm, NULL, GPU_enable_material, NULL, NULL, DM_DRAW_USE_COLORS); glDisable(GL_COLOR_MATERIAL); glDisable(GL_LIGHTING); @@ -3411,7 +3406,8 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D glEnable(GL_LIGHTING); glEnable(GL_COLOR_MATERIAL); - dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, GPU_enable_material, NULL, me->mpoly, 1); + dm->drawMappedFaces(dm, NULL, GPU_enable_material, NULL, me->mpoly, + DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH); glDisable(GL_COLOR_MATERIAL); glDisable(GL_LIGHTING); @@ -3419,10 +3415,12 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D } else if (ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_TEXTURE_PAINT)) { if (me->mloopcol) - dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, GPU_enable_material, NULL, NULL, 1); + dm->drawMappedFaces(dm, NULL, GPU_enable_material, NULL, NULL, + DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH); else { glColor3f(1.0f, 1.0f, 1.0f); - dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, GPU_enable_material, NULL, NULL, 0); + dm->drawMappedFaces(dm, NULL, GPU_enable_material, NULL, NULL, + DM_DRAW_ALWAYS_SMOOTH); } } } @@ -7147,7 +7145,7 @@ static void bbs_mesh_wire(BMEditMesh *em, DerivedMesh *dm, int offset) dm->drawMappedEdges(dm, bbs_mesh_wire__setDrawOptions, ptrs); } -static int bbs_mesh_solid__setSolidDrawOptions(void *userData, int index, int *UNUSED(drawSmooth_r)) +static int bbs_mesh_solid__setSolidDrawOptions(void *userData, int index) { BMFace *efa = EDBM_get_face_for_index(((void**)userData)[0], index); @@ -7198,13 +7196,13 @@ static void bbs_mesh_solid_EM(BMEditMesh *em, Scene *scene, View3D *v3d, } } -static int bbs_mesh_solid__setDrawOpts(void *UNUSED(userData), int index, int *UNUSED(drawSmooth_r)) +static int bbs_mesh_solid__setDrawOpts(void *UNUSED(userData), int index) { WM_set_framebuffer_index_color(index+1); return 1; } -static int bbs_mesh_solid_hide__setDrawOpts(void *userData, int index, int *UNUSED(drawSmooth_r)) +static int bbs_mesh_solid_hide__setDrawOpts(void *userData, int index) { Mesh *me = userData; @@ -7218,7 +7216,7 @@ static int bbs_mesh_solid_hide__setDrawOpts(void *userData, int index, int *UNUS } // must have called WM_set_framebuffer_index_color beforehand -static int bbs_mesh_solid_hide2__setDrawOpts(void *userData, int index, int *UNUSED(drawSmooth_r)) +static int bbs_mesh_solid_hide2__setDrawOpts(void *userData, int index) { Mesh *me = userData; -- cgit v1.2.3