diff options
Diffstat (limited to 'source/blender/editors/uvedit/uvedit_draw.c')
-rw-r--r-- | source/blender/editors/uvedit/uvedit_draw.c | 124 |
1 files changed, 62 insertions, 62 deletions
diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index 66ba28e70a6..6767d543c5e 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -112,10 +112,10 @@ static int draw_uvs_face_check(Scene *scene) ToolSettings *ts= scene->toolsettings; /* checks if we are selecting only faces */ - if(ts->uv_flag & UV_SYNC_SELECTION) { - if(ts->selectmode == SCE_SELECT_FACE) + if (ts->uv_flag & UV_SYNC_SELECTION) { + if (ts->selectmode == SCE_SELECT_FACE) return 2; - else if(ts->selectmode & SCE_SELECT_FACE) + else if (ts->selectmode & SCE_SELECT_FACE) return 1; else return 0; @@ -152,7 +152,7 @@ static int draw_uvs_dm_shadow(DerivedMesh *dm) { /* draw shadow mesh - this is the mesh with the modifier applied */ - if(dm && dm->drawUVEdges && CustomData_has_layer(&dm->loopData, CD_MLOOPUV)) { + if (dm && dm->drawUVEdges && CustomData_has_layer(&dm->loopData, CD_MLOOPUV)) { glColor3ub(112, 112, 112); dm->drawUVEdges(dm); return 1; @@ -204,22 +204,22 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe //totuvarea += tf_area(tf, efa->v4!=0); totuvarea += poly_uv_area(tf_uv, efa->len); - if(uvedit_face_visible(scene, ima, efa, tf)) { + if (uvedit_face_visible(scene, ima, efa, tf)) { BM_elem_flag_enable(efa, BM_ELEM_TAG); } else { - if(tf == activetf) + if (tf == activetf) activetf= NULL; BM_elem_flag_disable(efa, BM_ELEM_TAG); } } - if(totarea < FLT_EPSILON || totuvarea < FLT_EPSILON) { + if (totarea < FLT_EPSILON || totuvarea < FLT_EPSILON) { col[0] = 1.0; col[1] = col[2] = 0.0; glColor3fv(col); BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { - if(BM_elem_flag_test(efa, BM_ELEM_TAG)) { + if (BM_elem_flag_test(efa, BM_ELEM_TAG)) { glBegin(GL_POLYGON); BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); @@ -231,7 +231,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe } else { BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { - if(BM_elem_flag_test(efa, BM_ELEM_TAG)) { + if (BM_elem_flag_test(efa, BM_ELEM_TAG)) { area = BM_face_area_calc(em->bm, efa) / totarea; BLI_array_empty(tf_uv); @@ -253,9 +253,9 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe //uvarea = tf_area(tf, efa->v4!=0) / totuvarea; uvarea = poly_uv_area(tf_uv, efa->len) / totuvarea; - if(area < FLT_EPSILON || uvarea < FLT_EPSILON) + if (area < FLT_EPSILON || uvarea < FLT_EPSILON) areadiff = 1.0f; - else if(area>uvarea) + else if (area>uvarea) areadiff = 1.0f-(uvarea/area); else areadiff = 1.0f-(area/uvarea); @@ -286,13 +286,13 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe glShadeModel(GL_SMOOTH); - for(efa= em->faces.first; efa; efa= efa->next) { + for (efa= em->faces.first; efa; efa= efa->next) { tf= CustomData_em_get(&em->fdata, efa->head.data, CD_MTFACE); - if(uvedit_face_visible(scene, ima, efa, tf)) { + if (uvedit_face_visible(scene, ima, efa, tf)) { efa->tmp.p = tf; uv_copy_aspect(tf->uv, tf_uv, aspx, aspy); - if(efa->v4) { + if (efa->v4) { #if 0 /* Simple but slow, better reuse normalized vectors */ uvang1 = RAD2DEG(angle_v2v2v2(tf_uv[3], tf_uv[0], tf_uv[1])); @@ -410,7 +410,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe glEnd(); } else { - if(tf == activetf) + if (tf == activetf) activetf= NULL; efa->tmp.p = NULL; } @@ -430,24 +430,24 @@ static void draw_uvs_other(Scene *scene, Object *obedit, Image *curimage) glColor3ub(96, 96, 96); - for(base=scene->base.first; base; base=base->next) { + for (base=scene->base.first; base; base=base->next) { Object *ob= base->object; - if(!(base->flag & SELECT)) continue; - if(!(base->lay & scene->lay)) continue; - if(ob->restrictflag & OB_RESTRICT_VIEW) continue; + if (!(base->flag & SELECT)) continue; + if (!(base->lay & scene->lay)) continue; + if (ob->restrictflag & OB_RESTRICT_VIEW) continue; - if((ob->type==OB_MESH) && (ob!=obedit)) { + if ((ob->type==OB_MESH) && (ob!=obedit)) { Mesh *me= ob->data; - if(me->mtface) { + if (me->mtface) { MPoly *mface= me->mpoly; MTexPoly *tface= me->mtpoly; MLoopUV *mloopuv; int a, b; - for(a=me->totpoly; a>0; a--, tface++, mface++) { - if(tface->tpage == curimage) { + for (a=me->totpoly; a>0; a--, tface++, mface++) { + if (tface->tpage == curimage) { glBegin(GL_LINE_LOOP); mloopuv = me->mloopuv + mface->loopstart; @@ -467,19 +467,19 @@ static void draw_uvs_texpaint(SpaceImage *sima, Scene *scene, Object *ob) Mesh *me= ob->data; Image *curimage = ED_space_image(sima); - if(sima->flag & SI_DRAW_OTHER) + if (sima->flag & SI_DRAW_OTHER) draw_uvs_other(scene, ob, curimage); glColor3ub(112, 112, 112); - if(me->mtface) { + if (me->mtface) { MPoly *mface= me->mpoly; MTexPoly *tface= me->mtpoly; MLoopUV *mloopuv; int a, b; - for(a=me->totpoly; a>0; a--, tface++, mface++) { - if(tface->tpage == curimage) { + for (a=me->totpoly; a>0; a--, tface++, mface++) { + if (tface->tpage == curimage) { glBegin(GL_LINE_LOOP); mloopuv = me->mloopuv + mface->loopstart; @@ -517,13 +517,13 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) ts= scene->toolsettings; drawfaces= draw_uvs_face_check(scene); - if(ts->uv_flag & UV_SYNC_SELECTION) + if (ts->uv_flag & UV_SYNC_SELECTION) interpedges= (ts->selectmode & SCE_SELECT_VERTEX); else interpedges= (ts->uv_selectmode == UV_SELECT_VERTEX); /* draw other uvs */ - if(sima->flag & SI_DRAW_OTHER) { + if (sima->flag & SI_DRAW_OTHER) { Image *curimage= (activetf)? activetf->tpage: NULL; draw_uvs_other(scene, obedit, curimage); @@ -531,29 +531,29 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) /* 1. draw shadow mesh */ - if(sima->flag & SI_DRAWSHADOW) { + if (sima->flag & SI_DRAWSHADOW) { /* first try existing derivedmesh */ - if(!draw_uvs_dm_shadow(em->derivedFinal)) { + if (!draw_uvs_dm_shadow(em->derivedFinal)) { /* create one if it does not exist */ cagedm = editbmesh_get_derived_cage_and_final(scene, obedit, me->edit_btmesh, &finaldm, CD_MASK_BAREMESH|CD_MASK_MTFACE); /* 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 this */ - if(!((ts->uv_flag & UV_SYNC_SELECTION) && (cagedm == finaldm))) + if (!((ts->uv_flag & UV_SYNC_SELECTION) && (cagedm == finaldm))) draw_uvs_dm_shadow(finaldm); /* release derivedmesh again */ - if(cagedm != finaldm) cagedm->release(cagedm); + if (cagedm != finaldm) cagedm->release(cagedm); finaldm->release(finaldm); } } /* 2. draw colored faces */ - if(sima->flag & SI_DRAW_STRETCH) { + if (sima->flag & SI_DRAW_STRETCH) { draw_uvs_stretch(sima, scene, em, activetf); } - else if(!(sima->flag & SI_NO_DRAWFACES)) { + else if (!(sima->flag & SI_NO_DRAWFACES)) { /* draw transparent faces */ UI_GetThemeColor4ubv(TH_FACE, col1); UI_GetThemeColor4ubv(TH_FACE_SELECT, col2); @@ -563,11 +563,11 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); - if(uvedit_face_visible(scene, ima, efa, tf)) { + if (uvedit_face_visible(scene, ima, efa, tf)) { BM_elem_flag_enable(efa, BM_ELEM_TAG); - if(tf==activetf) continue; /* important the temp boolean is set above */ + if (tf==activetf) continue; /* important the temp boolean is set above */ - if(uvedit_face_selected(scene, em, efa)) + if (uvedit_face_selected(scene, em, efa)) glColor4ubv((GLubyte *)col2); else glColor4ubv((GLubyte *)col1); @@ -580,7 +580,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) glEnd(); } else { - if(tf == activetf) + if (tf == activetf) activetf= NULL; BM_elem_flag_disable(efa, BM_ELEM_TAG); } @@ -593,11 +593,11 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); - if(uvedit_face_visible(scene, ima, efa, tf)) { + if (uvedit_face_visible(scene, ima, efa, tf)) { BM_elem_flag_enable(efa, BM_ELEM_TAG); } else { - if(tf == activetf) + if (tf == activetf) activetf= NULL; BM_elem_flag_disable(efa, BM_ELEM_TAG); } @@ -607,7 +607,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) /* 3. draw active face stippled */ - if(activef) { + if (activef) { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); UI_ThemeColor4(TH_EDITMESH_ACTIVE); @@ -628,7 +628,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) /* 4. draw edges */ - if(sima->flag & SI_SMOOTH_UV) { + if (sima->flag & SI_SMOOTH_UV) { glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -641,7 +641,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) continue; tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); - if(tf) { + if (tf) { cpack(0x111111); glBegin(GL_LINE_LOOP); @@ -676,7 +676,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) break; case SI_UVDT_BLACK: /* black/white */ case SI_UVDT_WHITE: - if(sima->dt_uv==SI_UVDT_WHITE) glColor3f(1.0f, 1.0f, 1.0f); + if (sima->dt_uv==SI_UVDT_WHITE) glColor3f(1.0f, 1.0f, 1.0f); else glColor3f(0.0f, 0.0f, 0.0f); BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { @@ -711,11 +711,11 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) col2[0] = col2[1] = col2[2] = 192; col2[3] = 255; glColor4ubv((unsigned char *)col2); - if(me->drawflag & ME_DRAWEDGES) { + if (me->drawflag & ME_DRAWEDGES) { int sel, lastsel = -1; UI_GetThemeColor4ubv(TH_VERTEX_SELECT, col1); - if(interpedges) { + if (interpedges) { glShadeModel(GL_SMOOTH); BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { @@ -743,7 +743,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) glBegin(GL_LINES); BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { sel = (uvedit_edge_selected(em, scene, l)? 1 : 0); - if(sel != lastsel){ + if (sel != lastsel) { glColor4ubv(sel ? (GLubyte *)col1 : (GLubyte *)col2); lastsel = sel; } @@ -774,14 +774,14 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) break; } - if(sima->flag & SI_SMOOTH_UV) { + if (sima->flag & SI_SMOOTH_UV) { glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); } /* 5. draw face centers */ - if(drawfaces) { + if (drawfaces) { float cent[2]; pointsize = UI_GetThemeValuef(TH_FACEDOT_SIZE); @@ -795,7 +795,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) continue; - if(!uvedit_face_selected(scene, em, efa)) { + if (!uvedit_face_selected(scene, em, efa)) { poly_uv_center(em, efa, cent); bglVertex2fv(cent); } @@ -810,7 +810,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) continue; - if(uvedit_face_selected(scene, em, efa)) { + if (uvedit_face_selected(scene, em, efa)) { poly_uv_center(em, efa, cent); bglVertex2fv(cent); } @@ -820,7 +820,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) /* 6. draw uv vertices */ - if(drawfaces != 2) { /* 2 means Mesh Face Mode */ + if (drawfaces != 2) { /* 2 means Mesh Face Mode */ /* unselected uvs */ UI_ThemeColor(TH_VERTEX); pointsize = UI_GetThemeValuef(TH_VERTEX_SIZE); @@ -833,7 +833,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); - if(!uvedit_uv_selected(em, scene, l)) + if (!uvedit_uv_selected(em, scene, l)) bglVertex2fv(luv->uv); } } @@ -852,7 +852,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); - if(luv->flag & MLOOPUV_PINNED) + if (luv->flag & MLOOPUV_PINNED) bglVertex2fv(luv->uv); } } @@ -870,7 +870,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); - if(uvedit_uv_selected(em, scene, l)) + if (uvedit_uv_selected(em, scene, l)) bglVertex2fv(luv->uv); } } @@ -878,7 +878,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) } /* finally draw stitch preview */ - if(stitch_preview) { + if (stitch_preview) { int i, index = 0; glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT); glEnableClientState(GL_VERTEX_ARRAY); @@ -891,7 +891,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) glDrawArrays(GL_TRIANGLES, 0, stitch_preview->num_static_tris*3); glVertexPointer(2, GL_FLOAT, 0, stitch_preview->preview_polys); - for(i = 0; i < stitch_preview->num_polys; i++){ + for (i = 0; i < stitch_preview->num_polys; i++) { glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); UI_ThemeColor4(TH_STITCH_PREVIEW_FACE); glDrawArrays(GL_POLYGON, index, stitch_preview->uvs_per_polygon[i]); @@ -934,15 +934,15 @@ void draw_uvedit_main(SpaceImage *sima, ARegion *ar, Scene *scene, Object *obedi show_uvedit= ED_space_image_show_uvedit(sima, obedit); show_uvshadow= ED_space_image_show_uvshadow(sima, obedit); - if(show_uvedit || show_uvshadow || show_texpaint_uvshadow) { - if(show_uvshadow) + if (show_uvedit || show_uvshadow || show_texpaint_uvshadow) { + if (show_uvshadow) draw_uvs_shadow(obedit); - else if(show_uvedit) + else if (show_uvedit) draw_uvs(sima, scene, obedit); else draw_uvs_texpaint(sima, scene, obact); - if(show_uvedit && !(toolsettings->use_uv_sculpt)) + if (show_uvedit && !(toolsettings->use_uv_sculpt)) drawcursor_sima(sima, ar); } } |