diff options
Diffstat (limited to 'source/blender/editors/uvedit/uvedit_buttons.c')
-rw-r--r-- | source/blender/editors/uvedit/uvedit_buttons.c | 77 |
1 files changed, 29 insertions, 48 deletions
diff --git a/source/blender/editors/uvedit/uvedit_buttons.c b/source/blender/editors/uvedit/uvedit_buttons.c index 5380f514a73..2a69a7d6abc 100644 --- a/source/blender/editors/uvedit/uvedit_buttons.c +++ b/source/blender/editors/uvedit/uvedit_buttons.c @@ -49,6 +49,7 @@ #include "BKE_customdata.h" #include "BKE_mesh.h" #include "BKE_screen.h" +#include "BKE_tessmesh.h" #include "ED_image.h" #include "ED_uvedit.h" @@ -63,32 +64,20 @@ /* UV Utilities */ -static int uvedit_center(Scene *scene, EditMesh *em, Image *ima, float center[2]) +static int uvedit_center(Scene *scene, BMEditMesh *em, Image *UNUSED(ima), float center[2]) { - EditFace *efa; - MTFace *tf; - int tot= 0; - + BMFace *f; + BMLoop *l; + BMIter iter, liter; + MLoopUV *luv; + int tot = 0.0; + zero_v2(center); - - for(efa= em->faces.first; efa; efa= efa->next) { - tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); - - if(uvedit_face_visible(scene, ima, efa, tf)) { - if(uvedit_uv_selected(scene, efa, tf, 0)) { - add_v2_v2(center, tf->uv[0]); - tot++; - } - if(uvedit_uv_selected(scene, efa, tf, 1)) { - add_v2_v2(center, tf->uv[1]); - tot++; - } - if(uvedit_uv_selected(scene, efa, tf, 2)) { - add_v2_v2(center, tf->uv[2]); - tot++; - } - if(efa->v4 && uvedit_uv_selected(scene, efa, tf, 3)) { - add_v2_v2(center, tf->uv[3]); + BM_ITER(f, &iter, em->bm, BM_FACES_OF_MESH, NULL) { + BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, f) { + luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); + if (uvedit_uv_selected(em, scene, l)) { + add_v2_v2(center, luv->uv); tot++; } } @@ -102,23 +91,19 @@ static int uvedit_center(Scene *scene, EditMesh *em, Image *ima, float center[2] return tot; } -static void uvedit_translate(Scene *scene, EditMesh *em, Image *ima, float delta[2]) +static void uvedit_translate(Scene *scene, BMEditMesh *em, Image *UNUSED(ima), float delta[2]) { - EditFace *efa; - MTFace *tf; - - for(efa= em->faces.first; efa; efa= efa->next) { - tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); - - if(uvedit_face_visible(scene, ima, efa, tf)) { - if(uvedit_uv_selected(scene, efa, tf, 0)) - add_v2_v2(tf->uv[0], delta); - if(uvedit_uv_selected(scene, efa, tf, 1)) - add_v2_v2(tf->uv[1], delta); - if(uvedit_uv_selected(scene, efa, tf, 2)) - add_v2_v2(tf->uv[2], delta); - if(efa->v4 && uvedit_uv_selected(scene, efa, tf, 3)) - add_v2_v2(tf->uv[3], delta); + BMFace *f; + BMLoop *l; + BMIter iter, liter; + MLoopUV *luv; + + BM_ITER(f, &iter, em->bm, BM_FACES_OF_MESH, NULL) { + BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, f) { + luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); + if (uvedit_uv_selected(em, scene, l)) { + add_v2_v2(luv->uv, delta); + } } } } @@ -133,13 +118,13 @@ static void uvedit_vertex_buttons(const bContext *C, uiBlock *block) Scene *scene= CTX_data_scene(C); Object *obedit= CTX_data_edit_object(C); Image *ima= sima->image; + BMEditMesh *em; float center[2]; int imx, imy, step, digits; - EditMesh *em; ED_space_image_size(sima, &imx, &imy); - em= BKE_mesh_get_editmesh((Mesh *)obedit->data); + em= ((Mesh *)obedit->data)->edit_btmesh; if(uvedit_center(scene, em, ima, center)) { copy_v2_v2(uvedit_old_center, center); @@ -163,8 +148,6 @@ static void uvedit_vertex_buttons(const bContext *C, uiBlock *block) uiDefButF(block, NUM, B_UVEDIT_VERTEX, "Y:", 165, 10, 145, 19, &uvedit_old_center[1], -10*imy, 10.0*imy, step, digits, ""); uiBlockEndAlign(block); } - - BKE_mesh_end_editmesh(obedit->data, em); } static void do_uvedit_vertex(bContext *C, void *UNUSED(arg), int event) @@ -173,14 +156,14 @@ static void do_uvedit_vertex(bContext *C, void *UNUSED(arg), int event) Scene *scene= CTX_data_scene(C); Object *obedit= CTX_data_edit_object(C); Image *ima= sima->image; - EditMesh *em; + BMEditMesh *em; float center[2], delta[2]; int imx, imy; if(event != B_UVEDIT_VERTEX) return; - em= BKE_mesh_get_editmesh((Mesh *)obedit->data); + em= ((Mesh *)obedit->data)->edit_btmesh; ED_space_image_size(sima, &imx, &imy); uvedit_center(scene, em, ima, center); @@ -196,8 +179,6 @@ static void do_uvedit_vertex(bContext *C, void *UNUSED(arg), int event) uvedit_translate(scene, em, ima, delta); - BKE_mesh_end_editmesh(obedit->data, em); - WM_event_add_notifier(C, NC_IMAGE, sima->image); } |