From 8703dd9f52beccca20858042ac185fc48c3a2460 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 7 Oct 2007 02:49:03 +0000 Subject: This did not work how brecht intended - shared location sticky mode first uses the vert then checks the locations match, not just the locations. updated lasso tool to support this. --- source/blender/src/editview.c | 100 +++++++++++++++++------------------------- 1 file changed, 41 insertions(+), 59 deletions(-) (limited to 'source/blender/src/editview.c') diff --git a/source/blender/src/editview.c b/source/blender/src/editview.c index a4fac8f866f..fcb54812843 100644 --- a/source/blender/src/editview.c +++ b/source/blender/src/editview.c @@ -533,80 +533,62 @@ static void do_lasso_select_mesh_uv(short mcords[][2], short moves, short select } } } else if ((G.sima->flag & SI_SYNC_UVSEL)==0 && G.sima->sticky == SI_STICKY_LOC) { - - /* This is not that nice! - * - * do a proximity based sticky selecion, - * need to do some odd stuff here - */ - int j, face_count=0, coord_end = 0; /* so we know what the last coord is */ - float *coords, limit[2]; - + EditVert *eve; + EditFace *efa_vlist; + MTFace *tf_vlist; + UvMapVert *vlist; + struct UvVertMap *vmap; + float limit[2]; + int a; get_connected_limit_tface_uv(limit); - /* count and index */ - /* 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) { - tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); - if (SIMA_FACEDRAW_CHECK(efa, tf)) { - efa->tmp.p = tf; - face_count++; - } else { - efa->tmp.p = NULL; - } - } - /* assumes worst case where all quads are selected */ - coords = MEM_mallocN(sizeof(float) * face_count * 8, "lasso sticky coords"); + for (a=0, eve= em->verts.first; eve; a++, eve= eve->next) + eve->tmp.l = a; + EM_init_index_arrays(0, 0, 1); + vmap= make_uv_vert_map_EM(0, 0, limit); + + if(vmap == NULL) + return; for (efa= em->faces.first; efa; efa= efa->next) { - if ((tf=(MTFace *)efa->tmp.p)) { - if ((select) != (SIMA_FACESEL_CHECK(efa, tf))) { - tface_center(tf, cent, (void *)efa->v4); - uvco_to_areaco_noclip(cent, screenUV); - if (BLI_in_rcti(&rect, screenUV[0], screenUV[1]) && lasso_inside(mcords, moves, screenUV[0], screenUV[1])) { - - /* select now so as to avoid a location lookup later on */ + tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + + if ((select) != (SIMA_FACESEL_CHECK(efa, tf))) { + tface_center(tf, cent, (void *)efa->v4); + uvco_to_areaco_noclip(cent, screenUV); + + if (BLI_in_rcti(&rect, screenUV[0], screenUV[1]) && lasso_inside(mcords, moves, screenUV[0], screenUV[1])) { + nverts= efa->v4? 4: 3; + for(i=0; iv4? 4: 3; - for(j=0; juv[j][0]; - coords[coord_end++] = tf->uv[j][1]; - - } - } - } - } - } - - /* now select verts based on proximity to existing coords */ - for (efa= em->faces.first; efa; efa= efa->next) { - if ((tf=(MTFace *)efa->tmp.p)) { - nverts= efa->v4? 4: 3; - for(i=0; iuv[i][0]) < limit[0] && - fabs(coords[j+1]-tf->uv[i][1]) < limit[1] ) { - if (select) - tf->flag |= TF_SEL_MASK(i); - else - tf->flag &= ~TF_SEL_MASK(i); - break; + vlist= get_uv_map_vert_EM(vmap, (*(&efa->v1 + i))->tmp.l); + while (vlist) { + if (!vlist->separate) { + efa_vlist = EM_get_face_for_index(vlist->f); + if (efa != efa_vlist) { + tf_vlist = CustomData_em_get(&em->fdata, efa_vlist->data, CD_MTFACE); + + if (select) { + SIMA_UVSEL_SET(efa_vlist, tf_vlist, vlist->tfindex); + } else { + SIMA_UVSEL_UNSET(efa_vlist, tf_vlist, vlist->tfindex); + } + } } + vlist = vlist->next; } } } } } - MEM_freeN(coords); + EM_free_index_arrays(); + free_uv_vert_map_EM(vmap); } else { /* SI_STICKY_DISABLE or G.sima->flag & SI_SYNC_UVSEL */ -- cgit v1.2.3