diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2012-10-22 11:29:38 +0400 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2012-10-22 11:29:38 +0400 |
commit | ffd98941b5d6ef1ba8523f5c3c50bd1cf046a57f (patch) | |
tree | 3d522da53f366ecf3c9a73028588a5ee113fda71 /source/blender/editors/transform | |
parent | 492518f5e4ccc29975b2f376fb87af723f62142f (diff) |
Support for connected style proportional editing in UV editor. Now when connected proportional editing is on, only UVs on the same island will be proportionally moved. The implementation simply rejects UVs whose island does not belong to islands of selected vertices and decrements the total count of transform elements appropriately. Memory usage could be better but it would require some more preprocessing.
Diffstat (limited to 'source/blender/editors/transform')
-rw-r--r-- | source/blender/editors/transform/transform_conversions.c | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 0c9a29ce666..a9a74d3d0a1 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -76,6 +76,7 @@ #include "BKE_gpencil.h" #include "BKE_key.h" #include "BKE_main.h" +#include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_movieclip.h" #include "BKE_nla.h" @@ -2359,6 +2360,7 @@ static void createTransUVs(bContext *C, TransInfo *t) SpaceImage *sima = CTX_wm_space_image(C); Image *ima = CTX_data_edit_image(C); Scene *scene = t->scene; + ToolSettings *ts = CTX_data_tool_settings(C); TransData *td = NULL; TransData2D *td2d = NULL; MTexPoly *tf; @@ -2367,12 +2369,25 @@ static void createTransUVs(bContext *C, TransInfo *t) BMFace *efa; BMLoop *l; BMIter iter, liter; - int count = 0, countsel = 0; + UvElementMap *elementmap; + char *island_enabled; + int count = 0, countsel = 0, count_rejected = 0; int propmode = t->flag & T_PROP_EDIT; + int propconnected = t->flag & T_PROP_CONNECTED; if (!ED_space_image_show_uvedit(sima, t->obedit)) return; /* count */ + if(propconnected) { + /* create element map with island information */ + if (ts->uv_flag & UV_SYNC_SELECTION) { + elementmap = EDBM_uv_element_map_create (em, FALSE, TRUE); + } else { + elementmap = EDBM_uv_element_map_create (em, TRUE, TRUE); + } + island_enabled = MEM_callocN(sizeof(*island_enabled) * elementmap->totalIslands, "TransIslandData(UV Editing)"); + } + BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); @@ -2380,14 +2395,22 @@ static void createTransUVs(bContext *C, TransInfo *t) BM_elem_flag_disable(efa, BM_ELEM_TAG); continue; } - + BM_elem_flag_enable(efa, BM_ELEM_TAG); BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { - if (uvedit_uv_select_test(em, scene, l)) + if (uvedit_uv_select_test(em, scene, l)) { countsel++; - if (propmode) + if(propconnected) { + UvElement *element = ED_uv_element_get(elementmap, efa, l); + island_enabled[element->island] = TRUE; + } + + } + + if (propmode) { count++; + } } } @@ -2413,12 +2436,26 @@ static void createTransUVs(bContext *C, TransInfo *t) BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { if (!propmode && !uvedit_uv_select_test(em, scene, l)) continue; + + if (propconnected) { + UvElement *element = ED_uv_element_get(elementmap, efa, l); + if (!island_enabled[element->island]) { + count_rejected++; + continue; + } + } luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); UVsToTransData(sima, td++, td2d++, luv->uv, uvedit_uv_select_test(em, scene, l)); } } + if (propconnected) { + t->total -= count_rejected; + EDBM_uv_element_map_free(elementmap); + MEM_freeN(island_enabled); + } + if (sima->flag & SI_LIVE_UNWRAP) ED_uvedit_live_unwrap_begin(t->scene, t->obedit); } |