diff options
author | Nicholas Bishop <nicholasbishop@gmail.com> | 2012-03-07 16:48:52 +0400 |
---|---|---|
committer | Nicholas Bishop <nicholasbishop@gmail.com> | 2012-03-07 16:48:52 +0400 |
commit | 925f21342709522afa334218e97e0b31f87f1516 (patch) | |
tree | 5fd06cc9a34227079fa47d8c9a7554c6441a7d32 /source/blender/editors/space_view3d | |
parent | 43711d856891c46c1dc898554f40534d9b5f529f (diff) |
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.
Diffstat (limited to 'source/blender/editors/space_view3d')
-rw-r--r-- | source/blender/editors/space_view3d/drawmesh.c | 13 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 32 |
2 files changed, 20 insertions, 25 deletions
diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 9ad7a196113..fabd3f92573 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -576,7 +576,7 @@ static int draw_em_tf_mapped__set_draw(void *userData, int index) } } -static int wpaint__setSolidDrawOptions_material(void *userData, int index, int *drawSmooth_r) +static int wpaint__setSolidDrawOptions_material(void *userData, int index) { Mesh *me = (Mesh*)userData; @@ -587,17 +587,15 @@ static int wpaint__setSolidDrawOptions_material(void *userData, int index, int * } } - *drawSmooth_r = 1; return 1; } /* when face select is on, use face hidden flag */ -static int wpaint__setSolidDrawOptions_facemask(void *userData, int index, int *drawSmooth_r) +static int wpaint__setSolidDrawOptions_facemask(void *userData, int index) { Mesh *me = (Mesh*)userData; MPoly *mp = &me->mpoly[index]; if (mp->flag & ME_HIDE) return 0; - *drawSmooth_r = 1; return 1; } @@ -783,7 +781,8 @@ void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec } else if (draw_flags & DRAW_FACE_SELECT) { if (ob->mode & OB_MODE_WEIGHT_PAINT) - dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions_facemask, GPU_enable_material, NULL, me, 1); + dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions_facemask, GPU_enable_material, NULL, me, + DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH); else dm->drawMappedFacesTex(dm, me->mpoly ? draw_tface_mapped__set_draw : NULL, NULL, me); } @@ -940,10 +939,8 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *o if (ob->mode & OB_MODE_WEIGHT_PAINT) { /* weight paint mode exception */ - int useColors= 1; - dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions_material, - GPU_enable_material, NULL, ob->data, useColors); + GPU_enable_material, NULL, ob->data, DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH); } else { Mesh *me= ob->data; 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; |