diff options
author | Campbell Barton <ideasman42@gmail.com> | 2007-09-22 19:32:08 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2007-09-22 19:32:08 +0400 |
commit | d5b186ba6bac1e41a87aa4d9153a30a4091524f4 (patch) | |
tree | 411816e4991daac29aa98b5425a01ed144c5be1d /source | |
parent | 5d2bf66e794167be7004987bc95cdcf60f474ce9 (diff) |
made draw shadow work as it used to (I didnt understand at first that this was to draw the subsurfed UV faces)
this is really slow, its unuseable on suzanne subdivided twice on my computer with 2.45 and trunk, this could be sped up however it would need to be subsurf spesific.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/subsurf_ccg.c | 33 | ||||
-rw-r--r-- | source/blender/src/drawimage.c | 80 |
2 files changed, 80 insertions, 33 deletions
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index ea2021430f1..39674c9796f 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -1874,6 +1874,37 @@ static void ccgDM_drawMappedFacesTex(DerivedMesh *dm, int (*setDrawOptions)(void ccgDM_drawFacesTex_common(dm, NULL, setDrawOptions, userData); } +static void ccgDM_drawUVEdges(DerivedMesh *dm) +{ + + MFace *mf = dm->getFaceArray(dm); + MTFace *tf = DM_get_face_data_layer(dm, CD_MTFACE); + int i; + + glBegin(GL_LINES); + for(i = 0; i < dm->numFaceData; i++, mf++, tf++) { + if(!(mf->flag&ME_HIDE)) { + glVertex2fv(tf->uv[0]); + glVertex2fv(tf->uv[1]); + + glVertex2fv(tf->uv[1]); + glVertex2fv(tf->uv[2]); + + if(!mf->v4) { + glVertex2fv(tf->uv[2]); + glVertex2fv(tf->uv[0]); + } else { + glVertex2fv(tf->uv[2]); + glVertex2fv(tf->uv[3]); + + glVertex2fv(tf->uv[3]); + glVertex2fv(tf->uv[0]); + } + } + } + glEnd(); +} + static void ccgDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r), void *userData, int useColors) { CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; CCGSubSurf *ss = ccgdm->ss; @@ -2101,7 +2132,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, ccgdm->dm.drawFacesTex = ccgDM_drawFacesTex; ccgdm->dm.drawMappedFaces = ccgDM_drawMappedFaces; ccgdm->dm.drawMappedFacesTex = ccgDM_drawMappedFacesTex; - /* todo: drawUVEdges */ + ccgdm->dm.drawUVEdges = ccgDM_drawUVEdges; ccgdm->dm.drawMappedEdgesInterp = ccgDM_drawMappedEdgesInterp; ccgdm->dm.drawMappedEdges = ccgDM_drawMappedEdges; diff --git a/source/blender/src/drawimage.c b/source/blender/src/drawimage.c index 8db0eda752b..d69ec6d1b05 100644 --- a/source/blender/src/drawimage.c +++ b/source/blender/src/drawimage.c @@ -454,7 +454,7 @@ void draw_uvs_sima(void) EditFace *efa; char col1[4], col2[4]; - float pointsize= BIF_GetThemeValuef(TH_VERTEX_SIZE); + float pointsize; if (!G.obedit || !CustomData_has_layer(&em->fdata, CD_MTFACE)) return; @@ -464,36 +464,43 @@ void draw_uvs_sima(void) glLoadIdentity(); - if(G.sima->flag & SI_DRAWTOOL || G.sima->flag & SI_DRAWSHADOW) { + if(G.sima->flag & SI_DRAWTOOL) { + /* draws the grey mesh when painting */ glColor3ub(112, 112, 112); for (efa= em->faces.first; efa; efa= efa->next) { tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); - if (SIMA_FACEDRAW_CHECK(efa, tface)) { - efa->tmp.p = tface; - } else { - glBegin(GL_LINE_LOOP); - glVertex2fv(tface->uv[0]); - glVertex2fv(tface->uv[1]); - glVertex2fv(tface->uv[2]); - if(efa->v4) glVertex2fv(tface->uv[3]); - glEnd(); - - efa->tmp.p = NULL; - } + glBegin(GL_LINE_LOOP); + glVertex2fv(tface->uv[0]); + glVertex2fv(tface->uv[1]); + glVertex2fv(tface->uv[2]); + if(efa->v4) glVertex2fv(tface->uv[3]); + glEnd(); } - if(G.sima->flag & SI_DRAWTOOL) - return; /* only draw shadow mesh */ + return; /* only draw shadow mesh */ + } else if (G.sima->flag & SI_DRAWSHADOW) { + /* draw shadow mesh - this is the mesh with the modifier applied */ + DerivedMesh *finalDM, *cageDM; - } else { - /* would be nice to do this within a draw loop but most below are optional, so it would involve too many checks */ - for (efa= em->faces.first; efa; efa= efa->next) { - tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); - if (SIMA_FACEDRAW_CHECK(efa, tface)) { - efa->tmp.p = tface; - } else { - efa->tmp.p = NULL; - } + glColor3ub(112, 112, 112); + if (G.editMesh->derivedFinal && G.editMesh->derivedFinal->drawUVEdges) { + G.editMesh->derivedFinal->drawUVEdges(G.editMesh->derivedFinal); + } + + /* draw final mesh with modifiers applied */ + cageDM = editmesh_get_derived_cage_and_final(&finalDM, CD_MASK_BAREMESH | CD_MASK_MTFACE); + + if (finalDM->drawUVEdges && + /* When sync selection is enabled, all faces are drawn (except for hidden) + * so if cage is the same as the final, theres no point in drawing the shadowmesh. */ + !((G.sima->flag & SI_SYNC_UVSEL && cageDM==finalDM)) + ) { + glColor3ub(112, 112, 112); + finalDM->drawUVEdges(finalDM); } + + if (cageDM != finalDM) + cageDM->release(cageDM); + finalDM->release(finalDM); } /* draw transparent faces */ @@ -504,13 +511,8 @@ void draw_uvs_sima(void) glEnable(GL_BLEND); for (efa= em->faces.first; efa; efa= efa->next) { - -// tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); -// if (SIMA_FACEDRAW_CHECK(efa, tface)) { - - /*this is a shortcut to do the same as above but a faster for drawing */ - if ((tface=(MTFace *)efa->tmp.p)) { - + tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + if (SIMA_FACEDRAW_CHECK(efa, tface)) { if( SIMA_FACESEL_CHECK(efa, tface) ) glColor4ubv((GLubyte *)col2); else @@ -522,6 +524,19 @@ void draw_uvs_sima(void) glVertex2fv(tface->uv[2]); if(efa->v4) glVertex2fv(tface->uv[3]); glEnd(); + efa->tmp.p = tface; + } else { + efa->tmp.p = NULL; + } + } + } else { + /* would be nice to do this within a draw loop but most below are optional, so it would involve too many checks */ + for (efa= em->faces.first; efa; efa= efa->next) { + tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + if (SIMA_FACEDRAW_CHECK(efa, tface)) { + efa->tmp.p = tface; + } else { + efa->tmp.p = NULL; } } glDisable(GL_BLEND); @@ -677,6 +692,7 @@ void draw_uvs_sima(void) /* unselected uv's */ BIF_ThemeColor(TH_VERTEX); + pointsize = BIF_GetThemeValuef(TH_VERTEX_SIZE); glPointSize(pointsize); bglBegin(GL_POINTS); |