Index: source/blender/editors/uvedit/uvedit_draw.c =================================================================== --- source/blender/editors/uvedit/uvedit_draw.c (revision 48272) +++ source/blender/editors/uvedit/uvedit_draw.c (working copy) @@ -120,8 +120,10 @@ static int draw_uvs_face_check(Scene *scene) else return 0; } - else - return (ts->uv_selectmode == UV_SELECT_FACE); + else { + /* also draw face centers for island select mode */ + return (ts->uv_selectmode == UV_SELECT_FACE || ts->uv_selectmode == UV_SELECT_ISLAND); + } } static void draw_uvs_shadow(Object *obedit) Index: source/blender/editors/uvedit/uvedit_intern.h =================================================================== --- source/blender/editors/uvedit/uvedit_intern.h (revision 48272) +++ source/blender/editors/uvedit/uvedit_intern.h (working copy) @@ -59,23 +59,26 @@ void uv_poly_copy_aspect(float uv_orig [][2], float uv[][2], float aspx, float void uv_poly_center(struct BMEditMesh *em, struct BMFace *f, float r_cent[2]); /* find nearest */ - typedef struct NearestHit { struct BMFace *efa; struct MTexPoly *tf; struct BMLoop *l, *nextl; struct MLoopUV *luv, *nextluv; - int lindex; //index of loop within face - int vert1, vert2; //index in mesh of edge vertices + int lindex; /* index of loop within face */ + int vert1, vert2; /* index in mesh of edge vertices */ + float dist; /* distance to hit, as in dx + dy */ } NearestHit; void uv_find_nearest_vert(struct Scene *scene, struct Image *ima, struct BMEditMesh *em, const float co[2], const float penalty[2], struct NearestHit *hit); void uv_find_nearest_edge(struct Scene *scene, struct Image *ima, struct BMEditMesh *em, const float co[2], struct NearestHit *hit); +void uv_find_nearest_face(struct Scene *scene, struct Image *ima, struct BMEditMesh *em, + const float co[2], NearestHit *hit); +void uv_find_nearest_island(struct Scene *scene, struct Image *ima, struct BMEditMesh *em, + const float co[2], NearestHit *hit); /* utility tool functions */ - struct UvElement *ED_uv_element_get(struct UvElementMap *map, struct BMFace *efa, struct BMLoop *l); void uvedit_live_unwrap_update(struct SpaceImage *sima, struct Scene *scene, struct Object *obedit); Index: source/blender/editors/uvedit/uvedit_ops.c =================================================================== --- source/blender/editors/uvedit/uvedit_ops.c (revision 48272) +++ source/blender/editors/uvedit/uvedit_ops.c (working copy) @@ -541,8 +541,7 @@ void uv_poly_center(BMEditMesh *em, BMFace *f, float r_cent[2]) float uv_poly_area(float uv[][2], int len) { - //BMESH_TODO: make this not suck - //maybe use scanfill? I dunno. + /* BMESH_TODO: make this not suck, maybe use scanfill? I dunno. */ if (len >= 4) return area_tri_v2(uv[0], uv[1], uv[2]) + area_tri_v2(uv[0], uv[2], uv[3]); @@ -681,6 +680,7 @@ void uv_find_nearest_edge(Scene *scene, Image *ima, BMEditMesh *em, const float hit->lindex = i; hit->vert1 = BM_elem_index_get(hit->l->v); hit->vert2 = BM_elem_index_get(hit->l->next->v); + hit->dist = dist; mindist = dist; } @@ -690,7 +690,7 @@ void uv_find_nearest_edge(Scene *scene, Image *ima, BMEditMesh *em, const float } } -static void find_nearest_uv_face(Scene *scene, Image *ima, BMEditMesh *em, const float co[2], NearestHit *hit) +static void uv_find_nearest_face(Scene *scene, Image *ima, BMEditMesh *em, const float co[2], NearestHit *hit) { MTexPoly *tf; BMFace *efa; @@ -717,6 +717,7 @@ static void find_nearest_uv_face(Scene *scene, Image *ima, BMEditMesh *em, const if (dist < mindist) { hit->tf = tf; hit->efa = efa; + hit->dist = dist; mindist = dist; } } @@ -820,6 +821,7 @@ void uv_find_nearest_vert(Scene *scene, Image *ima, BMEditMesh *em, hit->efa = efa; hit->lindex = i; hit->vert1 = BM_elem_index_get(hit->l->v); + hit->dist = dist; } i++; @@ -827,6 +829,40 @@ void uv_find_nearest_vert(Scene *scene, Image *ima, BMEditMesh *em, } } +/* find nearest vert, edge, or face */ +void uv_find_nearest_island(Scene *scene, Image *ima, BMEditMesh *em, const float co[2], NearestHit *hit) +{ + NearestHit temp_hit; + + memset(hit, 0, sizeof(*hit)); + + uv_find_nearest_vert(scene, ima, em, co, NULL, &temp_hit); + if(temp_hit.efa != NULL) + *hit = temp_hit; + + memset(&temp_hit, 0, sizeof(temp_hit)); + uv_find_nearest_edge(scene, ima, em, co, &temp_hit); + if (temp_hit.efa != NULL) { + if (hit) { + if (temp_hit.dist <= hit->dist) + *hit = temp_hit; + } + else + *hit = temp_hit; + } + + memset(&temp_hit, 0, sizeof(temp_hit)); + uv_find_nearest_face(scene, ima, em, co, &temp_hit); + if (temp_hit.efa != NULL) { + if (hit) { + if (temp_hit.dist <= hit->dist) + *hit = temp_hit; + } + else + *hit = temp_hit; + } +} + int ED_uvedit_nearest_uv(Scene *scene, Object *obedit, Image *ima, const float co[2], float r_uv[2]) { BMEditMesh *em = BMEdit_FromObject(obedit); @@ -1790,7 +1826,7 @@ static int mouse_select(bContext *C, const float co[2], int extend, int loop) } else if (selectmode == UV_SELECT_FACE) { /* find face */ - find_nearest_uv_face(scene, ima, em, co, &hit); + uv_find_nearest_face(scene, ima, em, co, &hit); if (hit.efa == NULL) { BLI_array_free(hitv); BLI_array_free(hituv); @@ -1815,7 +1851,7 @@ static int mouse_select(bContext *C, const float co[2], int extend, int loop) hitlen = hit.efa->len; } else if (selectmode == UV_SELECT_ISLAND) { - uv_find_nearest_vert(scene, ima, em, co, NULL, &hit); + uv_find_nearest_island(scene, ima, em, co, &hit); if (hit.efa == NULL) { BLI_array_free(hitv); @@ -2332,8 +2368,8 @@ static void uv_faces_do_sticky(SpaceImage *sima, Scene *scene, Object *obedit, s struct UvVertMap *vmap; float limit[2]; unsigned int efa_index; - //BMVert *eve; /* removed vert counting for now */ - //int a; + /* BMVert *eve; */ /* removed vert counting for now */ + /* int a; */ uvedit_pixel_to_float(sima, limit, 0.05);