diff options
author | Nicholas Bishop <nicholasbishop@gmail.com> | 2012-03-08 10:47:05 +0400 |
---|---|---|
committer | Nicholas Bishop <nicholasbishop@gmail.com> | 2012-03-08 10:47:05 +0400 |
commit | 640b0adb9844f506ed68f99f8761a1f4daa288b0 (patch) | |
tree | 957737baac66b88d79f1f24b6d7a262dcbfc4b7e /source/blender/blenkernel/intern/editderivedmesh.c | |
parent | ee84084f990da866c15a7b24e7c5945050c4a720 (diff) |
Code cleanup: use named values for options in DerivedMesh drawing.
The DMSetDrawOptions[Tex] callbacks return 0 (skip), 1 (draw), or 2
(either stipple or skip mcols.) In the CDDM, EDDM, and CCGDM draw
functions, as well as the callbacks in drawmesh/drawobject, replace
these numbers with values from an enum, DMDrawOptions.
Diffstat (limited to 'source/blender/blenkernel/intern/editderivedmesh.c')
-rw-r--r-- | source/blender/blenkernel/intern/editderivedmesh.c | 53 |
1 files changed, 29 insertions, 24 deletions
diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c index 943f499ed1b..6912eb8dbe8 100644 --- a/source/blender/blenkernel/intern/editderivedmesh.c +++ b/source/blender/blenkernel/intern/editderivedmesh.c @@ -414,7 +414,7 @@ static void emDM_drawMappedEdges( glBegin(GL_LINES); eed = BM_iter_new(&iter, bmdm->tc->bm, BM_EDGES_OF_MESH, NULL); for (i=0; eed; i++,eed=BM_iter_step(&iter)) { - if (!setDrawOptions || setDrawOptions(userData, i)) { + if (!setDrawOptions || (setDrawOptions(userData, i) != DM_DRAW_OPTION_SKIP)) { glVertex3fv(bmdm->vertexCos[BM_elem_index_get(eed->v1)]); glVertex3fv(bmdm->vertexCos[BM_elem_index_get(eed->v2)]); } @@ -425,7 +425,7 @@ static void emDM_drawMappedEdges( glBegin(GL_LINES); eed = BM_iter_new(&iter, bmdm->tc->bm, BM_EDGES_OF_MESH, NULL); for (i=0; eed; i++,eed=BM_iter_step(&iter)) { - if (!setDrawOptions || setDrawOptions(userData, i)) { + if (!setDrawOptions || (setDrawOptions(userData, i) != DM_DRAW_OPTION_SKIP)) { glVertex3fv(eed->v1->co); glVertex3fv(eed->v2->co); } @@ -459,7 +459,7 @@ static void emDM_drawMappedEdgesInterp( glBegin(GL_LINES); eed = BM_iter_new(&iter, bmdm->tc->bm, BM_EDGES_OF_MESH, NULL); for (i=0; eed; i++,eed=BM_iter_step(&iter)) { - if (!setDrawOptions || setDrawOptions(userData, i)) { + if (!setDrawOptions || (setDrawOptions(userData, i) != DM_DRAW_OPTION_SKIP)) { setDrawInterpOptions(userData, i, 0.0); glVertex3fv(bmdm->vertexCos[BM_elem_index_get(eed->v1)]); setDrawInterpOptions(userData, i, 1.0); @@ -472,7 +472,7 @@ static void emDM_drawMappedEdgesInterp( glBegin(GL_LINES); eed = BM_iter_new(&iter, bmdm->tc->bm, BM_EDGES_OF_MESH, NULL); for (i=0; eed; i++,eed=BM_iter_step(&iter)) { - if (!setDrawOptions || setDrawOptions(userData, i)) { + if (!setDrawOptions || (setDrawOptions(userData, i) != DM_DRAW_OPTION_SKIP)) { setDrawInterpOptions(userData, i, 0.0); glVertex3fv(eed->v1->co); setDrawInterpOptions(userData, i, 1.0); @@ -590,7 +590,8 @@ static void emDM_drawMappedFaces( struct BMLoop *(*looptris)[3]= bmdm->tc->looptris; const int tottri= bmdm->tc->tottri; const int lasttri= tottri - 1; /* compare agasint this a lot */ - int i, draw, flush; + DMDrawOption draw_option; + int i, flush; const int skip_normals= !glIsEnabled(GL_LIGHTING); /* could be passed as an arg */ /* GL_ZERO is used to detect if drawing has started or not */ @@ -618,10 +619,12 @@ static void emDM_drawMappedFaces( efa = l[0]->f; drawSmooth= (flag & DM_DRAW_ALWAYS_SMOOTH) ? 1 : BM_elem_flag_test(efa, BM_ELEM_SMOOTH); - draw = setDrawOptions==NULL ? 1 : setDrawOptions(userData, BM_elem_index_get(efa)); - if (draw) { + draw_option = (!setDrawOptions ? + DM_DRAW_OPTION_NORMAL : + setDrawOptions(userData, BM_elem_index_get(efa))); + if (draw_option != DM_DRAW_OPTION_SKIP) { const GLenum poly_type= GL_TRIANGLES; /* BMESH NOTE, this is odd but keep it for now to match trunk */ - if (draw==2) { /* enabled with stipple */ + if (draw_option == DM_DRAW_OPTION_STIPPLE) { /* enabled with stipple */ if (poly_prev != GL_ZERO) glEnd(); poly_prev= GL_ZERO; /* force glBegin */ @@ -667,7 +670,7 @@ static void emDM_drawMappedFaces( } } - flush= (draw==2); + flush= (draw_option == DM_DRAW_OPTION_STIPPLE); if (!skip_normals && !flush && (i != lasttri)) flush|= efa->mat_nr != looptris[i + 1][0]->f->mat_nr; /* TODO, make this neater */ @@ -690,10 +693,12 @@ static void emDM_drawMappedFaces( efa = l[0]->f; drawSmooth= (flag & DM_DRAW_ALWAYS_SMOOTH) ? 1 : BM_elem_flag_test(efa, BM_ELEM_SMOOTH); - draw = setDrawOptions==NULL ? 1 : setDrawOptions(userData, BM_elem_index_get(efa)); - if (draw) { + draw_option = (!setDrawOptions ? + DM_DRAW_OPTION_NORMAL : + setDrawOptions(userData, BM_elem_index_get(efa))); + if (draw_option != DM_DRAW_OPTION_SKIP) { const GLenum poly_type= GL_TRIANGLES; /* BMESH NOTE, this is odd but keep it for now to match trunk */ - if (draw==2) { /* enabled with stipple */ + if (draw_option == DM_DRAW_OPTION_STIPPLE) { /* enabled with stipple */ if (poly_prev != GL_ZERO) glEnd(); poly_prev= GL_ZERO; /* force glBegin */ @@ -739,7 +744,7 @@ static void emDM_drawMappedFaces( } } - flush= (draw==2); + flush= (draw_option == DM_DRAW_OPTION_STIPPLE); if (!skip_normals && !flush && (i != lasttri)) { flush|= efa->mat_nr != looptris[i + 1][0]->f->mat_nr; /* TODO, make this neater */ } @@ -815,7 +820,7 @@ static void emDM_drawFacesTex_common( MTFace mtf = {{{0}}}; /*unsigned char *cp= NULL;*/ /*UNUSED*/ int drawSmooth= BM_elem_flag_test(ls[0]->f, BM_ELEM_SMOOTH); - int flag; + DMDrawOption draw_option; efa = ls[0]->f; @@ -824,13 +829,13 @@ static void emDM_drawFacesTex_common( } if (drawParams) - flag= drawParams(&mtf, has_vcol, efa->mat_nr); + draw_option= drawParams(&mtf, has_vcol, efa->mat_nr); else if (drawParamsMapped) - flag= drawParamsMapped(userData, BM_elem_index_get(efa)); + draw_option= drawParamsMapped(userData, BM_elem_index_get(efa)); else - flag= 1; + draw_option= DM_DRAW_OPTION_NORMAL; - if (flag != 0) { /* flag 0 == the face is hidden or invisible */ + if (draw_option != DM_DRAW_OPTION_SKIP) { if (!drawSmooth) { glNormal3fv(bmdm->polyNos[BM_elem_index_get(efa)]); @@ -886,7 +891,7 @@ static void emDM_drawFacesTex_common( MTFace mtf = {{{0}}}; /*unsigned char *cp= NULL;*/ /*UNUSED*/ int drawSmooth= BM_elem_flag_test(ls[0]->f, BM_ELEM_SMOOTH); - int flag; + DMDrawOption draw_option; efa = ls[0]->f; @@ -895,13 +900,13 @@ static void emDM_drawFacesTex_common( } if (drawParams) - flag= drawParams(&mtf, has_vcol, efa->mat_nr); + draw_option= drawParams(&mtf, has_vcol, efa->mat_nr); else if (drawParamsMapped) - flag= drawParamsMapped(userData, BM_elem_index_get(efa)); + draw_option= drawParamsMapped(userData, BM_elem_index_get(efa)); else - flag= 1; + draw_option= DM_DRAW_OPTION_NORMAL; - if (flag != 0) { /* flag 0 == the face is hidden or invisible */ + if (draw_option != DM_DRAW_OPTION_SKIP) { glBegin(GL_TRIANGLES); if (!drawSmooth) { @@ -1032,7 +1037,7 @@ static void emDM_drawMappedFacesGLSL( efa = ltri[0]->f; drawSmooth= BM_elem_flag_test(efa, BM_ELEM_SMOOTH); - if (setDrawOptions && !setDrawOptions(userData, BM_elem_index_get(efa))) + if (setDrawOptions && (setDrawOptions(userData, BM_elem_index_get(efa)) == DM_DRAW_OPTION_SKIP)) continue; new_matnr = efa->mat_nr + 1; |