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/cdderivedmesh.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/cdderivedmesh.c')
-rw-r--r-- | source/blender/blenkernel/intern/cdderivedmesh.c | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index e6d37718cba..7ba9e6b9686 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -623,26 +623,26 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, DEBUG_VBO( "Using legacy code. cdDM_drawFacesTex_common\n" ); for(i = 0; i < dm->numTessFaceData; i++, mf++) { MVert *mvert; - int flag; + DMDrawOption draw_option; unsigned char *cp = NULL; if(drawParams) { - flag = drawParams(tf? &tf[i]: NULL, (mcol != NULL), mf->mat_nr); + draw_option = drawParams(tf? &tf[i]: NULL, (mcol != NULL), mf->mat_nr); } else { if(index) { orig = *index++; if(orig == ORIGINDEX_NONE) { if(nors) nors += 3; continue; } - if(drawParamsMapped) flag = drawParamsMapped(userData, orig); + if(drawParamsMapped) draw_option = drawParamsMapped(userData, orig); else { if(nors) nors += 3; continue; } } else - if(drawParamsMapped) flag = drawParamsMapped(userData, i); + if(drawParamsMapped) draw_option = drawParamsMapped(userData, i); else { if(nors) nors += 3; continue; } } - if(flag != 0) { - if (flag==1 && mcol) + if(draw_option != DM_DRAW_OPTION_SKIP) { + if (draw_option != DM_DRAW_OPTION_NO_MCOL && mcol) cp= (unsigned char*) &mcol[i*4]; if(!(mf->flag&ME_SMOOTH)) { @@ -734,29 +734,29 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, /* lastFlag = 0; */ /* UNUSED */ for(i = 0; i < tottri; i++) { int actualFace = next_actualFace; - int flag = 1; + DMDrawOption draw_option = DM_DRAW_OPTION_NORMAL; int flush = 0; if(i != tottri-1) next_actualFace= dm->drawObject->triangle_to_mface[i+1]; if(drawParams) { - flag = drawParams(tf? &tf[actualFace]: NULL, (mcol != NULL), mf[actualFace].mat_nr); + draw_option = drawParams(tf? &tf[actualFace]: NULL, (mcol != NULL), mf[actualFace].mat_nr); } else { if(index) { orig = index[actualFace]; if(orig == ORIGINDEX_NONE) continue; if(drawParamsMapped) - flag = drawParamsMapped(userData, orig); + draw_option = drawParamsMapped(userData, orig); } else if(drawParamsMapped) - flag = drawParamsMapped(userData, actualFace); + draw_option = drawParamsMapped(userData, actualFace); } /* flush buffer if current triangle isn't drawable or it's last triangle */ - flush= !flag || i == tottri - 1; + flush= (draw_option == DM_DRAW_OPTION_SKIP) || (i == tottri - 1); if(!flush && compareDrawOptions) { /* also compare draw options and flush buffer if they're different @@ -766,7 +766,8 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, if(flush) { int first= startFace*3; - int count= (i-startFace+(flag ? 1 : 0))*3; /* Add one to the length if we're drawing at the end of the array */ + /* Add one to the length if we're drawing at the end of the array */ + int count= (i-startFace+(draw_option != DM_DRAW_OPTION_SKIP ? 1 : 0))*3; if(count) { if (col) @@ -823,16 +824,16 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, DEBUG_VBO( "Using legacy code. cdDM_drawMappedFaces\n" ); for(i = 0; i < dm->numTessFaceData; i++, mf++) { int drawSmooth = (flag & DM_DRAW_ALWAYS_SMOOTH) ? 1 : (mf->flag & ME_SMOOTH); - int draw= 1; + DMDrawOption draw_option= DM_DRAW_OPTION_NORMAL; orig= (index==NULL) ? i : *index++; if(orig == ORIGINDEX_NONE) - draw= setMaterial(mf->mat_nr + 1, NULL); + draw_option= setMaterial(mf->mat_nr + 1, NULL); else if (setDrawOptions != NULL) - draw= setDrawOptions(userData, orig); + draw_option= setDrawOptions(userData, orig); - if(draw) { + if(draw_option != DM_DRAW_OPTION_SKIP) { unsigned char *cp = NULL; if(useColors && mc) @@ -916,7 +917,7 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, int actualFace = next_actualFace; MFace *mface= mf + actualFace; /*int drawSmooth= (flag & DM_DRAW_ALWAYS_SMOOTH) ? 1 : (mface->flag & ME_SMOOTH);*/ /* UNUSED */ - int draw = 1; + DMDrawOption draw_option = DM_DRAW_OPTION_NORMAL; int flush = 0; if(i != tottri-1) @@ -925,16 +926,16 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, orig= (index==NULL) ? actualFace : index[actualFace]; if(orig == ORIGINDEX_NONE) - draw= setMaterial(mface->mat_nr + 1, NULL); + draw_option= setMaterial(mface->mat_nr + 1, NULL); else if (setDrawOptions != NULL) - draw= setDrawOptions(userData, orig); + draw_option= setDrawOptions(userData, orig); /* Goal is to draw as long of a contiguous triangle array as possible, so draw when we hit either an invisible triangle or at the end of the array */ /* flush buffer if current triangle isn't drawable or it's last triangle... */ - flush= !draw || i == tottri - 1; + flush= (draw_option == DM_DRAW_OPTION_SKIP) || (i == tottri - 1); /* ... or when material setting is dissferent */ flush|= mf[actualFace].mat_nr != mf[next_actualFace].mat_nr; @@ -945,7 +946,8 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, if(flush) { int first= prevstart*3; - int count= (i-prevstart+(draw ? 1 : 0))*3; /* Add one to the length if we're drawing at the end of the array */ + /* Add one to the length if we're drawing at the end of the array */ + int count= (i-prevstart+(draw_option != DM_DRAW_OPTION_SKIP ? 1 : 0))*3; if(count) glDrawArrays(GL_TRIANGLES, first, count); @@ -1067,7 +1069,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, /* continue */ } - else if(!setDrawOptions(userData, orig)) + else if(setDrawOptions(userData, orig) == DM_DRAW_OPTION_SKIP) continue; } @@ -1403,7 +1405,7 @@ static void cdDM_drawMappedEdges(DerivedMesh *dm, DMSetDrawOptions setDrawOption else orig = i; - if(!setDrawOptions || setDrawOptions(userData, orig)) { + if(!setDrawOptions || (setDrawOptions(userData, orig) != DM_DRAW_OPTION_SKIP)) { glVertex3fv(vert[edge->v1].co); glVertex3fv(vert[edge->v2].co); } |