diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-03-25 12:20:19 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-03-25 12:20:19 +0400 |
commit | 3b711a6ed009b35bb69cd0ca878eeb8d55fa0e77 (patch) | |
tree | b3fdb366cb49bdea5b57dfa6ba4a82635c68d0ee /source/blender/editors/uvedit/uvedit_ops.c | |
parent | a2ebfc82dbe954acc432ae017ac62a30a11b6a16 (diff) | |
parent | e99a23fc6b33b5097eab44aac19c2a089ddebce6 (diff) |
Merged changes in the trunk up to revision 45133.
Conflicts resolved:
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/bmesh/intern/bmesh_construct.c
source/blender/bmesh/intern/bmesh_mesh_conv.c
source/blender/bmesh/intern/bmesh_mesh_conv.h
source/blender/editors/interface/interface_templates.c
source/blender/editors/interface/resources.c
source/blender/editors/mesh/bmesh_select.c
source/blender/editors/mesh/bmesh_tools.c
source/blender/editors/space_view3d/drawobject.c
source/blender/render/intern/source/shadeoutput.c
Diffstat (limited to 'source/blender/editors/uvedit/uvedit_ops.c')
-rw-r--r-- | source/blender/editors/uvedit/uvedit_ops.c | 806 |
1 files changed, 406 insertions, 400 deletions
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 28981d55793..3e6be67f233 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -94,7 +94,7 @@ int ED_uvedit_test(Object *obedit) if (!obedit) return 0; - if(obedit->type != OB_MESH) + if (obedit->type != OB_MESH) return 0; em = BMEdit_FromObject(obedit); @@ -116,10 +116,10 @@ static int UNUSED_FUNCTION(ED_operator_uvmap_mesh)(bContext *C) { Object *ob= CTX_data_active_object(C); - if(ob && ob->type==OB_MESH) { + if (ob && ob->type==OB_MESH) { Mesh *me = ob->data; - if(CustomData_get_layer(&me->fdata, CD_MTFACE) != NULL) + if (CustomData_get_layer(&me->fdata, CD_MTFACE) != NULL) return 1; } @@ -137,16 +137,16 @@ int ED_object_get_active_image(Object *ob, int mat_nr, Image **ima, ImageUser ** Material *ma= give_current_material(ob, mat_nr); bNode *node= (ma && ma->use_nodes)? nodeGetActiveTexture(ma->nodetree): NULL; - if(node && is_image_texture_node(node)) { - if(ima) *ima= (Image*)node->id; - if(iuser) *iuser= NULL; - if(node_r) *node_r= node; + if (node && is_image_texture_node(node)) { + if (ima) *ima= (Image*)node->id; + if (iuser) *iuser= NULL; + if (node_r) *node_r= node; return TRUE; } - if(ima) *ima= NULL; - if(iuser) *iuser= NULL; - if(node_r) *node_r= node; + if (ima) *ima= NULL; + if (iuser) *iuser= NULL; + if (node_r) *node_r= node; return FALSE; } @@ -156,7 +156,7 @@ void ED_object_assign_active_image(Main *bmain, Object *ob, int mat_nr, Image *i Material *ma= give_current_material(ob, mat_nr); bNode *node= (ma && ma->use_nodes)? nodeGetActiveTexture(ma->nodetree): NULL; - if(node && is_image_texture_node(node)) { + if (node && is_image_texture_node(node)) { node->id= &ima->id; ED_node_generic_update(bmain, ma->nodetree, node); } @@ -173,31 +173,31 @@ void ED_uvedit_assign_image(Main *bmain, Scene *scene, Object *obedit, Image *im int update= 0; /* skip assigning these procedural images... */ - if(ima && (ima->type==IMA_TYPE_R_RESULT || ima->type==IMA_TYPE_COMPOSITE)) + if (ima && (ima->type==IMA_TYPE_R_RESULT || ima->type==IMA_TYPE_COMPOSITE)) return; /* verify we have a mesh we can work with */ - if(!obedit || (obedit->type != OB_MESH)) + if (!obedit || (obedit->type != OB_MESH)) return; em = BMEdit_FromObject(obedit); - if(!em || !em->bm->totface) { + if (!em || !em->bm->totface) { return; } - if(scene_use_new_shading_nodes(scene)) { + if (scene_use_new_shading_nodes(scene)) { /* new shading system, assign image in material */ int sloppy= 1; BMFace *efa= BM_active_face_get(em->bm, sloppy); - if(efa) + if (efa) ED_object_assign_active_image(bmain, obedit, efa->mat_nr, ima); } else { /* old shading system, assign image to selected faces */ /* ensure we have a uv map */ - if(!CustomData_has_layer(&em->bm->pdata, CD_MTEXPOLY)) { + if (!CustomData_has_layer(&em->bm->pdata, CD_MTEXPOLY)) { BM_data_layer_add(em->bm, &em->bm->pdata, CD_MTEXPOLY); BM_data_layer_add(em->bm, &em->bm->ldata, CD_MLOOPUV); update= 1; @@ -207,11 +207,11 @@ void ED_uvedit_assign_image(Main *bmain, Scene *scene, Object *obedit, Image *im 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, previma, efa, tf)) { - if(ima) { + if (uvedit_face_visible(scene, previma, efa, tf)) { + if (ima) { tf->tpage= ima; - if(ima->id.us==0) id_us_plus(&ima->id); + if (ima->id.us==0) id_us_plus(&ima->id); else id_lib_extern(&ima->id); } else { @@ -223,7 +223,7 @@ void ED_uvedit_assign_image(Main *bmain, Scene *scene, Object *obedit, Image *im } /* and update depdency graph */ - if(update) + if (update) DAG_id_tag_update(obedit->data, 0); } @@ -239,14 +239,14 @@ static int uvedit_set_tile(Object *obedit, Image *ima, int curtile) MTexPoly *tf; /* verify if we have something to do */ - if(!ima || !ED_uvedit_test(obedit)) + if (!ima || !ED_uvedit_test(obedit)) return 0; - if((ima->tpageflag & IMA_TILES) == 0) + if ((ima->tpageflag & IMA_TILES) == 0) return 0; /* skip assigning these procedural images... */ - if(ima->type==IMA_TYPE_R_RESULT || ima->type==IMA_TYPE_COMPOSITE) + if (ima->type==IMA_TYPE_R_RESULT || ima->type==IMA_TYPE_COMPOSITE) return 0; em = BMEdit_FromObject(obedit); @@ -254,7 +254,7 @@ static int uvedit_set_tile(Object *obedit, Image *ima, int curtile) BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); - if(!BM_elem_flag_test(efa, BM_ELEM_HIDDEN) && BM_elem_flag_test(efa, BM_ELEM_SELECT)) + if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN) && BM_elem_flag_test(efa, BM_ELEM_SELECT)) tf->tile= curtile; /* set tile index */ } @@ -269,7 +269,7 @@ static void uvedit_pixel_to_float(SpaceImage *sima, float *dist, float pixeldist { int width, height; - if(sima) { + if (sima) { ED_space_image_size(sima, &width, &height); } else { @@ -287,7 +287,7 @@ int uvedit_face_visible_nolocal(Scene *scene, BMFace *efa) { ToolSettings *ts= scene->toolsettings; - if(ts->uv_flag & UV_SYNC_SELECTION) + if (ts->uv_flag & UV_SYNC_SELECTION) return (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)==0); else return (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)==0 && BM_elem_flag_test(efa, BM_ELEM_SELECT)); @@ -297,7 +297,7 @@ int uvedit_face_visible(Scene *scene, Image *ima, BMFace *efa, MTexPoly *tf) { ToolSettings *ts= scene->toolsettings; - if(ts->uv_flag & UV_SHOW_SAME_IMAGE) + if (ts->uv_flag & UV_SHOW_SAME_IMAGE) return (tf->tpage==ima)? uvedit_face_visible_nolocal(scene, efa): 0; else return uvedit_face_visible_nolocal(scene, efa); @@ -307,7 +307,7 @@ int uvedit_face_selected(Scene *scene, BMEditMesh *em, BMFace *efa) { ToolSettings *ts= scene->toolsettings; - if(ts->uv_flag & UV_SYNC_SELECTION) + if (ts->uv_flag & UV_SYNC_SELECTION) return (BM_elem_flag_test(efa, BM_ELEM_SELECT)); else { BMLoop *l; @@ -328,7 +328,7 @@ int uvedit_face_select(Scene *scene, BMEditMesh *em, BMFace *efa) { ToolSettings *ts= scene->toolsettings; - if(ts->uv_flag & UV_SYNC_SELECTION) + if (ts->uv_flag & UV_SYNC_SELECTION) BM_elem_select_set(em->bm, efa, TRUE); else { BMLoop *l; @@ -350,7 +350,7 @@ int uvedit_face_deselect(Scene *scene, BMEditMesh *em, BMFace *efa) { ToolSettings *ts= scene->toolsettings; - if(ts->uv_flag & UV_SYNC_SELECTION) { + if (ts->uv_flag & UV_SYNC_SELECTION) { BM_elem_select_set(em->bm, efa, FALSE); } else { @@ -373,7 +373,7 @@ int uvedit_edge_selected(BMEditMesh *em, Scene *scene, BMLoop *l) { ToolSettings *ts= scene->toolsettings; - if(ts->uv_flag & UV_SYNC_SELECTION) { + if (ts->uv_flag & UV_SYNC_SELECTION) { if (ts->selectmode & SCE_SELECT_FACE) { return BM_elem_flag_test(l->f, BM_ELEM_SELECT); } @@ -400,10 +400,10 @@ void uvedit_edge_select(BMEditMesh *em, Scene *scene, BMLoop *l) { ToolSettings *ts= scene->toolsettings; - 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) BM_elem_select_set(em->bm, l->f, TRUE); - else if(ts->selectmode & SCE_SELECT_EDGE) + else if (ts->selectmode & SCE_SELECT_EDGE) BM_elem_select_set(em->bm, l->e, TRUE); else { BM_elem_select_set(em->bm, l->e->v1, TRUE); @@ -426,10 +426,10 @@ void uvedit_edge_deselect(BMEditMesh *em, Scene *scene, BMLoop *l) { ToolSettings *ts= scene->toolsettings; - 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) BM_elem_select_set(em->bm, l->f, FALSE); - else if(ts->selectmode & SCE_SELECT_EDGE) + else if (ts->selectmode & SCE_SELECT_EDGE) BM_elem_select_set(em->bm, l->e, FALSE); else { BM_elem_select_set(em->bm, l->e->v1, FALSE); @@ -451,8 +451,8 @@ int uvedit_uv_selected(BMEditMesh *em, Scene *scene, BMLoop *l) { ToolSettings *ts= scene->toolsettings; - 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 BM_elem_flag_test(l->f, BM_ELEM_SELECT); else return BM_elem_flag_test(l->v, BM_ELEM_SELECT); @@ -468,8 +468,8 @@ void uvedit_uv_select(BMEditMesh *em, Scene *scene, BMLoop *l) { ToolSettings *ts= scene->toolsettings; - 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) BM_elem_select_set(em->bm, l->f, TRUE); else BM_elem_select_set(em->bm, l->v, TRUE); @@ -485,8 +485,8 @@ void uvedit_uv_deselect(BMEditMesh *em, Scene *scene, BMLoop *l) { ToolSettings *ts= scene->toolsettings; - 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) BM_elem_select_set(em->bm, l->f, FALSE); else BM_elem_select_set(em->bm, l->v, FALSE); @@ -502,7 +502,7 @@ void uvedit_uv_deselect(BMEditMesh *em, Scene *scene, BMLoop *l) void uvedit_live_unwrap_update(SpaceImage *sima, Scene *scene, Object *obedit) { - if(sima && (sima->flag & SI_LIVE_UNWRAP)) { + if (sima && (sima->flag & SI_LIVE_UNWRAP)) { ED_uvedit_live_unwrap_begin(scene, obedit); ED_uvedit_live_unwrap_re_solve(); ED_uvedit_live_unwrap_end(0); @@ -529,7 +529,7 @@ void poly_uv_center(BMEditMesh *em, BMFace *f, float cent[2]) void uv_center(float uv[][2], float cent[2], int quad) { - if(quad) { + if (quad) { cent[0] = (uv[0][0] + uv[1][0] + uv[2][0] + uv[3][0]) / 4.0f; cent[1] = (uv[0][1] + uv[1][1] + uv[2][1] + uv[3][1]) / 4.0f; } @@ -541,7 +541,7 @@ void uv_center(float uv[][2], float cent[2], int quad) float uv_area(float uv[][2], int quad) { - if(quad) + if (quad) return area_tri_v2(uv[0], uv[1], uv[2]) + area_tri_v2(uv[0], uv[2], uv[3]); else return area_tri_v2(uv[0], uv[1], uv[2]); @@ -552,7 +552,7 @@ float poly_uv_area(float uv[][2], int len) //BMESH_TODO: make this not suck //maybe use scanfill? I dunno. - if(len >= 4) + if (len >= 4) return area_tri_v2(uv[0], uv[1], uv[2]) + area_tri_v2(uv[0], uv[2], uv[3]); else return area_tri_v2(uv[0], uv[1], uv[2]); @@ -599,7 +599,7 @@ int ED_uvedit_minmax(Scene *scene, Image *ima, Object *obedit, float *min, float sel= 0; 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)) continue; BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { @@ -627,7 +627,7 @@ static int ED_uvedit_median(Scene *scene, Image *ima, Object *obedit, float co[3 zero_v3(co); 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)) continue; BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { @@ -649,8 +649,8 @@ static int uvedit_center(Scene *scene, Image *ima, Object *obedit, float *cent, float min[2], max[2]; int change= 0; - if(mode==V3D_CENTER) { /* bounding box */ - if(ED_uvedit_minmax(scene, ima, obedit, min, max)) { + if (mode==V3D_CENTER) { /* bounding box */ + if (ED_uvedit_minmax(scene, ima, obedit, min, max)) { change = 1; cent[0]= (min[0]+max[0])/2.0f; @@ -658,13 +658,13 @@ static int uvedit_center(Scene *scene, Image *ima, Object *obedit, float *cent, } } else { - if(ED_uvedit_median(scene, ima, obedit, cent)) { + if (ED_uvedit_median(scene, ima, obedit, cent)) { change = 1; } } - if(change) { + if (change) { return 1; } @@ -690,7 +690,7 @@ void uv_find_nearest_edge(Scene *scene, Image *ima, BMEditMesh *em, float co[2], 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)) continue; i = 0; @@ -700,7 +700,7 @@ void uv_find_nearest_edge(Scene *scene, Image *ima, BMEditMesh *em, float co[2], dist= dist_to_line_segment_v2(co, luv->uv, nextluv->uv); - if(dist < mindist) { + if (dist < mindist) { hit->tf= tf; hit->efa= efa; @@ -739,7 +739,7 @@ static void find_nearest_uv_face(Scene *scene, Image *ima, BMEditMesh *em, float 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)) continue; cent[0]= cent[1]= 0.0f; @@ -753,7 +753,7 @@ static void find_nearest_uv_face(Scene *scene, Image *ima, BMEditMesh *em, float cent[1] /= efa->len; dist= fabs(co[0]- cent[0]) + fabs(co[1]- cent[1]); - if(dist < mindist) { + if (dist < mindist) { hit->tf= tf; hit->efa= efa; mindist= dist; @@ -767,7 +767,7 @@ static int nearest_uv_between(BMEditMesh *em, BMFace *efa, int UNUSED(nverts), i BMLoop *l; MLoopUV *luv; BMIter iter; - float m[3], v1[3], v2[3], c1, c2, *uv1, *uv2, *uv3; + float m[3], v1[3], v2[3], c1, c2, *uv1, /* *uv2, */ /* UNUSED */ *uv3; int id1, id2, i; id1= (id+efa->len-1)%efa->len; @@ -783,7 +783,7 @@ static int nearest_uv_between(BMEditMesh *em, BMFace *efa, int UNUSED(nverts), i if (i == id1) uv1 = luv->uv; else if (i == id) - uv2 = luv->uv; + ; /* uv2 = luv->uv; */ /* UNUSED */ else if (i == id2) uv3 = luv->uv; @@ -797,7 +797,7 @@ static int nearest_uv_between(BMEditMesh *em, BMFace *efa, int UNUSED(nverts), i c1= v1[0]*m[1] - v1[1]*m[0]; c2= v1[0]*v2[1] - v1[1]*v2[0]; - if(c1*c2 < 0.0f) + if (c1*c2 < 0.0f) return 0; /* m and v1 on same side of v-v2? */ @@ -830,21 +830,21 @@ void uv_find_nearest_vert(Scene *scene, Image *ima, BMEditMesh *em, 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)) continue; i = 0; BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); - if(penalty && uvedit_uv_selected(em, scene, l)) + if (penalty && uvedit_uv_selected(em, scene, l)) dist= fabs(co[0]-luv->uv[0])+penalty[0] + fabs(co[1]-luv->uv[1])+penalty[1]; else dist= fabs(co[0]-luv->uv[0]) + fabs(co[1]-luv->uv[1]); - if(dist<=mindist) { - if(dist==mindist) - if(!nearest_uv_between(em, efa, efa->len, i, co, luv->uv)) { + if (dist<=mindist) { + if (dist==mindist) + if (!nearest_uv_between(em, efa, efa->len, i, co, luv->uv)) { i++; continue; } @@ -883,14 +883,14 @@ int ED_uvedit_nearest_uv(Scene *scene, Object *obedit, Image *ima, float co[2], 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)) continue; BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); dist= fabs(co[0]-luv->uv[0]) + fabs(co[1]-luv->uv[1]); - if(dist<=mindist) { + if (dist<=mindist) { mindist= dist; uv[0]= luv->uv[0]; @@ -910,14 +910,14 @@ static void uv_vertex_loop_flag(UvMapVert *first) UvMapVert *iterv; int count= 0; - for(iterv=first; iterv; iterv=iterv->next) { - if(iterv->separate && iterv!=first) + for (iterv=first; iterv; iterv=iterv->next) { + if (iterv->separate && iterv!=first) break; count++; } - if(count < 5) + if (count < 5) first->flag= 1; } @@ -929,10 +929,10 @@ static UvMapVert *uv_vertex_map_get(UvVertMap *vmap, BMFace *efa, int a) l = BM_iter_at_index(NULL, BM_LOOPS_OF_FACE, efa, a); first= EDBM_get_uv_map_vert(vmap, BM_elem_index_get(l->v)); - for(iterv=first; iterv; iterv=iterv->next) { - if(iterv->separate) + for (iterv=first; iterv; iterv=iterv->next) { + if (iterv->separate) first= iterv; - if(iterv->f == BM_elem_index_get(efa)) + if (iterv->f == BM_elem_index_get(efa)) return first; } @@ -945,8 +945,8 @@ UvElement *ED_get_uv_element(UvElementMap *map, BMFace *efa, BMLoop *l) element = map->vert[BM_elem_index_get(l->v)]; - for(; element; element = element->next) - if(element->face == efa) + for (; element; element = element->next) + if (element->face == efa) return element; return NULL; @@ -959,18 +959,18 @@ static int uv_edge_tag_faces(BMEditMesh *em, UvMapVert *first1, UvMapVert *first int tot = 0; /* count number of faces this edge has */ - for(iterv1=first1; iterv1; iterv1=iterv1->next) { - if(iterv1->separate && iterv1 != first1) + for (iterv1=first1; iterv1; iterv1=iterv1->next) { + if (iterv1->separate && iterv1 != first1) break; - for(iterv2=first2; iterv2; iterv2=iterv2->next) { - if(iterv2->separate && iterv2 != first2) + for (iterv2=first2; iterv2; iterv2=iterv2->next) { + if (iterv2->separate && iterv2 != first2) break; - if(iterv1->f == iterv2->f) { + if (iterv1->f == iterv2->f) { /* if face already tagged, don't do this edge */ efa= EDBM_get_face_for_index(em, iterv1->f); - if(BMO_elem_flag_test(em->bm, efa, EFA_F1_FLAG)) + if (BMO_elem_flag_test(em->bm, efa, EFA_F1_FLAG)) return 0; tot++; @@ -979,21 +979,21 @@ static int uv_edge_tag_faces(BMEditMesh *em, UvMapVert *first1, UvMapVert *first } } - if(*totface == 0) /* start edge */ + if (*totface == 0) /* start edge */ *totface= tot; - else if(tot != *totface) /* check for same number of faces as start edge */ + else if (tot != *totface) /* check for same number of faces as start edge */ return 0; /* tag the faces */ - for(iterv1=first1; iterv1; iterv1=iterv1->next) { - if(iterv1->separate && iterv1 != first1) + for (iterv1=first1; iterv1; iterv1=iterv1->next) { + if (iterv1->separate && iterv1 != first1) break; - for(iterv2=first2; iterv2; iterv2=iterv2->next) { - if(iterv2->separate && iterv2 != first2) + for (iterv2=first2; iterv2; iterv2=iterv2->next) { + if (iterv2->separate && iterv2 != first2) break; - if(iterv1->f == iterv2->f) { + if (iterv1->f == iterv2->f) { efa= EDBM_get_face_for_index(em, iterv1->f); BMO_elem_flag_enable(em->bm, efa, EFA_F1_FLAG); break; @@ -1022,7 +1022,7 @@ static int select_edgeloop(Scene *scene, Image *ima, BMEditMesh *em, NearestHit count = 0; BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { - if(!extend) { + if (!extend) { uvedit_face_deselect(scene, em, efa); } @@ -1044,12 +1044,12 @@ static int select_edgeloop(Scene *scene, Image *ima, BMEditMesh *em, NearestHit starttotf= 0; uv_edge_tag_faces(em, iterv1, iterv2, &starttotf); - /* sorry, first edge isnt even ok */ - if(iterv1->flag==0 && iterv2->flag==0) looking= 0; + /* sorry, first edge isn't even ok */ + if (iterv1->flag==0 && iterv2->flag==0) looking= 0; else looking= 1; /* iterate */ - while(looking) { + while (looking) { looking= 0; /* find correct valence edges which are not tagged yet, but connect to tagged one */ @@ -1057,9 +1057,9 @@ static int select_edgeloop(Scene *scene, Image *ima, BMEditMesh *em, NearestHit BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); - if(!BMO_elem_flag_test(em->bm, efa, EFA_F1_FLAG) && uvedit_face_visible(scene, ima, efa, tf)) { + if (!BMO_elem_flag_test(em->bm, efa, EFA_F1_FLAG) && uvedit_face_visible(scene, ima, efa, tf)) { nverts= efa->len; - for(a=0; a<nverts; a++) { + for (a=0; a<nverts; a++) { /* check face not hidden and not tagged */ iterv1= uv_vertex_map_get(vmap, efa, a); iterv2= uv_vertex_map_get(vmap, efa, (a+1)%nverts); @@ -1068,8 +1068,8 @@ static int select_edgeloop(Scene *scene, Image *ima, BMEditMesh *em, NearestHit continue; /* check if vertex is tagged and has right valence */ - if(iterv1->flag || iterv2->flag) { - if(uv_edge_tag_faces(em, iterv1, iterv2, &starttotf)) { + if (iterv1->flag || iterv2->flag) { + if (uv_edge_tag_faces(em, iterv1, iterv2, &starttotf)) { looking= 1; BMO_elem_flag_enable(em->bm, efa, EFA_F1_FLAG); @@ -1090,8 +1090,8 @@ static int select_edgeloop(Scene *scene, Image *ima, BMEditMesh *em, NearestHit iterv1->flag= 1; iterv2->flag= 1; - if(extend) { - if(uvedit_uv_selected(em, scene, hit->l)) + if (extend) { + if (uvedit_uv_selected(em, scene, hit->l)) select= 0; else select= 1; @@ -1104,8 +1104,8 @@ static int select_edgeloop(Scene *scene, Image *ima, BMEditMesh *em, NearestHit BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { iterv1= uv_vertex_map_get(vmap, efa, a); - if(iterv1->flag) { - if(select) uvedit_uv_select(em, scene, l); + if (iterv1->flag) { + if (select) uvedit_uv_select(em, scene, l); else uvedit_uv_deselect(em, scene, l); } @@ -1131,25 +1131,24 @@ static void select_linked(Scene *scene, Image *ima, BMEditMesh *em, float limit[ MLoopUV *luv; UvVertMap *vmap; UvMapVert *vlist, *iterv, *startv; - int i, nverts, stacksize= 0, *stack; + int i, stacksize= 0, *stack; unsigned int a; char *flag; EDBM_init_index_arrays(em, 0, 0, 1); /* we can use this too */ vmap= EDBM_make_uv_vert_map(em, 1, 1, limit); - if(vmap == NULL) + if (vmap == NULL) return; stack= MEM_mallocN(sizeof(*stack)*(em->bm->totface+1), "UvLinkStack"); flag= MEM_callocN(sizeof(*flag)*em->bm->totface, "UvLinkFlag"); - if(!hit) { - a = 0; - BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { + if (!hit) { + BM_ITER_INDEX(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL, a) { 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_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); @@ -1163,12 +1162,11 @@ static void select_linked(Scene *scene, Image *ima, BMEditMesh *em, float limit[ } } } - a++; } else { a = 0; BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { - if(efa == hit->efa) { + if (efa == hit->efa) { stack[stacksize]= a; stacksize++; flag[a]= 1; @@ -1179,7 +1177,7 @@ static void select_linked(Scene *scene, Image *ima, BMEditMesh *em, float limit[ } } - while(stacksize > 0) { + while (stacksize > 0) { int j; stacksize--; @@ -1187,14 +1185,12 @@ static void select_linked(Scene *scene, Image *ima, BMEditMesh *em, float limit[ j = 0; BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { - if(j==a) + if (j==a) break; j++; } - nverts= efa->len; - i = 0; BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { @@ -1203,17 +1199,17 @@ static void select_linked(Scene *scene, Image *ima, BMEditMesh *em, float limit[ startv= vlist; - for(iterv=vlist; iterv; iterv=iterv->next) { - if(iterv->separate) + for (iterv=vlist; iterv; iterv=iterv->next) { + if (iterv->separate) startv= iterv; - if(iterv->f == a) + if (iterv->f == a) break; } - for(iterv=startv; iterv; iterv=iterv->next) { - if((startv != iterv) && (iterv->separate)) + for (iterv=startv; iterv; iterv=iterv->next) { + if ((startv != iterv) && (iterv->separate)) break; - else if(!flag[iterv->f]) { + else if (!flag[iterv->f]) { flag[iterv->f]= 1; stack[stacksize]= iterv->f; stacksize++; @@ -1224,7 +1220,7 @@ static void select_linked(Scene *scene, Image *ima, BMEditMesh *em, float limit[ } } - if(!extend) { + if (!extend) { a = 0; BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { @@ -1259,7 +1255,7 @@ static void select_linked(Scene *scene, Image *ima, BMEditMesh *em, float limit[ a++; } - if(efa) { + if (efa) { a = 0; BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { if (!flag[a]) { @@ -1345,20 +1341,20 @@ static void weld_align_uv(bContext *C, int tool) INIT_MINMAX2(min, max); - if(tool == 'a') { + if (tool == 'a') { BMFace *efa; BMLoop *l; 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)) continue; BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { if (uvedit_uv_selected(em, scene, l)) { luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); - DO_MINMAX2(luv->uv, min, max) + DO_MINMAX2(luv->uv, min, max); } } } @@ -1368,13 +1364,13 @@ static void weld_align_uv(bContext *C, int tool) uvedit_center(scene, ima, obedit, cent, 0); - if(tool == 'x' || tool == 'w') { + if (tool == 'x' || tool == 'w') { BMFace *efa; BMLoop *l; 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)) continue; BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { @@ -1387,13 +1383,13 @@ static void weld_align_uv(bContext *C, int tool) } } - if(tool == 'y' || tool == 'w') { + if (tool == 'y' || tool == 'w') { BMFace *efa; BMLoop *l; 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)) continue; BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { @@ -1406,7 +1402,7 @@ static void weld_align_uv(bContext *C, int tool) } } - if(tool == 's' || tool == 't' || tool == 'u') { + if (tool == 's' || tool == 't' || tool == 'u') { BMEdge *eed; BMLoop *l; BMVert *eve; @@ -1466,7 +1462,7 @@ static void weld_align_uv(bContext *C, int tool) /* walk over edges, building an array of verts in a line */ while (eve) { BLI_array_append(eve_line, eve); - /* dont touch again */ + /* don't touch again */ BM_elem_flag_disable(eve, BM_ELEM_TAG); eve_next = NULL; @@ -1553,14 +1549,14 @@ static void UV_OT_align(wmOperatorType *ot) {0, NULL, 0, NULL, NULL}}; /* identifiers */ - ot->name= "Align"; - ot->description= "Align selected UV vertices to an axis"; - ot->idname= "UV_OT_align"; - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->name = "Align"; + ot->description = "Align selected UV vertices to an axis"; + ot->idname = "UV_OT_align"; + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; /* api callbacks */ - ot->exec= align_exec; - ot->poll= ED_operator_image_active; /* requires space image */; + ot->exec = align_exec; + ot->poll = ED_operator_image_active; /* requires space image */; /* properties */ RNA_def_enum(ot->srna, "axis", axis_items, 'a', "Axis", "Axis to align UV locations on"); @@ -1578,14 +1574,14 @@ static int weld_exec(bContext *C, wmOperator *UNUSED(op)) static void UV_OT_weld(wmOperatorType *ot) { /* identifiers */ - ot->name= "Weld"; - ot->description= "Weld selected UV vertices together"; - ot->idname= "UV_OT_weld"; - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->name = "Weld"; + ot->description = "Weld selected UV vertices together"; + ot->idname = "UV_OT_weld"; + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; /* api callbacks */ - ot->exec= weld_exec; - ot->poll= ED_operator_uvedit; + ot->exec = weld_exec; + ot->poll = ED_operator_uvedit; } @@ -1610,11 +1606,11 @@ static void select_all_perform(bContext *C, int action) em = BMEdit_FromObject(obedit); ima = CTX_data_edit_image(C); - if(ts->uv_flag & UV_SYNC_SELECTION) { + if (ts->uv_flag & UV_SYNC_SELECTION) { switch (action) { case SEL_TOGGLE: - EDBM_toggle_select_all(BMEdit_FromObject(obedit)); + EDBM_select_toggle_all(BMEdit_FromObject(obedit)); break; case SEL_SELECT: EDBM_flag_enable_all(em, BM_ELEM_SELECT); @@ -1633,7 +1629,7 @@ static void select_all_perform(bContext *C, int action) 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)) continue; BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { @@ -1651,7 +1647,7 @@ static void select_all_perform(bContext *C, int action) 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)) continue; BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { @@ -1688,14 +1684,14 @@ static int select_all_exec(bContext *C, wmOperator *op) static void UV_OT_select_all(wmOperatorType *ot) { /* identifiers */ - ot->name= "Select or Deselect All"; - ot->description= "Change selection of all UV vertices"; - ot->idname= "UV_OT_select_all"; - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->name = "(De)select All"; + ot->description = "Change selection of all UV vertices"; + ot->idname = "UV_OT_select_all"; + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; /* api callbacks */ - ot->exec= select_all_exec; - ot->poll= ED_operator_uvedit; + ot->exec = select_all_exec; + ot->poll = ED_operator_uvedit; WM_operator_properties_select_all(ot); } @@ -1708,16 +1704,16 @@ static int sticky_select(float *limit, int hitv[4], int v, float *hituv[4], floa /* this function test if some vertex needs to selected * in addition to the existing ones due to sticky select */ - if(sticky == SI_STICKY_DISABLE) + if (sticky == SI_STICKY_DISABLE) return 0; - for(i=0; i<hitlen; i++) { - if(hitv[i] == v) { - if(sticky == SI_STICKY_LOC) { - if(fabsf(hituv[i][0]-uv[0]) < limit[0] && fabsf(hituv[i][1]-uv[1]) < limit[1]) + for (i=0; i<hitlen; i++) { + if (hitv[i] == v) { + if (sticky == SI_STICKY_LOC) { + if (fabsf(hituv[i][0]-uv[0]) < limit[0] && fabsf(hituv[i][1]-uv[1]) < limit[1]) return 1; } - else if(sticky == SI_STICKY_VERTEX) + else if (sticky == SI_STICKY_VERTEX) return 1; } } @@ -1741,7 +1737,7 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop) NearestHit hit; int i, select = 1, selectmode, sticky, sync, *hitv=NULL, nvert; BLI_array_declare(hitv); - int flush = 0, hitlen=0; /* 0 == dont flush, 1 == sel, -1 == desel; only use when selection sync is enabled */ + int flush = 0, hitlen=0; /* 0 == don't flush, 1 == sel, -1 == desel; only use when selection sync is enabled */ float limit[2], **hituv = NULL; BLI_array_declare(hituv); float penalty[2]; @@ -1756,12 +1752,12 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop) uvedit_pixel_to_float(sima, penalty, 5.0f / sima->zoom); /* retrieve operation mode */ - if(ts->uv_flag & UV_SYNC_SELECTION) { + if (ts->uv_flag & UV_SYNC_SELECTION) { sync= 1; - if(ts->selectmode & SCE_SELECT_FACE) + if (ts->selectmode & SCE_SELECT_FACE) selectmode= UV_SELECT_FACE; - else if(ts->selectmode & SCE_SELECT_EDGE) + else if (ts->selectmode & SCE_SELECT_EDGE) selectmode= UV_SELECT_EDGE; else selectmode= UV_SELECT_VERTEX; @@ -1775,10 +1771,10 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop) } /* find nearest element */ - if(loop) { + if (loop) { /* find edge */ uv_find_nearest_edge(scene, ima, em, co, &hit); - if(hit.efa == NULL) { + if (hit.efa == NULL) { BLI_array_free(hitv); BLI_array_free(hituv); return OPERATOR_CANCELLED; @@ -1786,10 +1782,10 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop) hitlen = 0; } - else if(selectmode == UV_SELECT_VERTEX) { + else if (selectmode == UV_SELECT_VERTEX) { /* find vertex */ uv_find_nearest_vert(scene, ima, em, co, penalty, &hit); - if(hit.efa == NULL) { + if (hit.efa == NULL) { BLI_array_free(hitv); BLI_array_free(hituv); return OPERATOR_CANCELLED; @@ -1798,7 +1794,7 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop) /* mark 1 vertex as being hit */ BLI_array_growitems(hitv, hit.efa->len); BLI_array_growitems(hituv, hit.efa->len); - for(i=0; i<hit.efa->len; i++) { + for (i=0; i<hit.efa->len; i++) { hitv[i]= 0xFFFFFFFF; } @@ -1807,10 +1803,10 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop) hitlen = hit.efa->len; } - else if(selectmode == UV_SELECT_EDGE) { + else if (selectmode == UV_SELECT_EDGE) { /* find edge */ uv_find_nearest_edge(scene, ima, em, co, &hit); - if(hit.efa == NULL) { + if (hit.efa == NULL) { BLI_array_free(hitv); BLI_array_free(hituv); return OPERATOR_CANCELLED; @@ -1832,10 +1828,10 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop) hitlen = hit.efa->len; } - else if(selectmode == UV_SELECT_FACE) { + else if (selectmode == UV_SELECT_FACE) { /* find face */ find_nearest_uv_face(scene, ima, em, co, &hit); - if(hit.efa == NULL) { + if (hit.efa == NULL) { BLI_array_free(hitv); BLI_array_free(hituv); return OPERATOR_CANCELLED; @@ -1858,10 +1854,10 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop) hitlen = hit.efa->len; } - else if(selectmode == UV_SELECT_ISLAND) { + else if (selectmode == UV_SELECT_ISLAND) { uv_find_nearest_vert(scene, ima, em, co, NULL, &hit); - if(hit.efa==NULL) { + if (hit.efa==NULL) { BLI_array_free(hitv); BLI_array_free(hituv); return OPERATOR_CANCELLED; @@ -1877,16 +1873,16 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop) } /* do selection */ - if(loop) { + if (loop) { flush= select_edgeloop(scene, ima, em, &hit, limit, extend); } - else if(selectmode == UV_SELECT_ISLAND) { + else if (selectmode == UV_SELECT_ISLAND) { select_linked(scene, ima, em, limit, &hit, extend); } - else if(extend) { - if(selectmode == UV_SELECT_VERTEX) { + else if (extend) { + if (selectmode == UV_SELECT_VERTEX) { /* (de)select uv vertex */ - if(uvedit_uv_selected(em, scene, hit.l)) { + if (uvedit_uv_selected(em, scene, hit.l)) { uvedit_uv_deselect(em, scene, hit.l); select= 0; } @@ -1896,9 +1892,9 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop) } flush = 1; } - else if(selectmode == UV_SELECT_EDGE) { + else if (selectmode == UV_SELECT_EDGE) { /* (de)select edge */ - if(uvedit_edge_selected(em, scene, hit.l)) { + if (uvedit_edge_selected(em, scene, hit.l)) { uvedit_edge_deselect(em, scene, hit.l); select= 0; } @@ -1908,9 +1904,9 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop) } flush = 1; } - else if(selectmode == UV_SELECT_FACE) { + else if (selectmode == UV_SELECT_FACE) { /* (de)select face */ - if(uvedit_face_selected(scene, em, hit.efa)) { + if (uvedit_face_selected(scene, em, hit.efa)) { uvedit_face_deselect(scene, em, hit.efa); select= 0; } @@ -1922,20 +1918,20 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop) } /* (de)select sticky uv nodes */ - if(sticky != SI_STICKY_DISABLE) { + if (sticky != SI_STICKY_DISABLE) { BM_mesh_elem_index_ensure(em->bm, BM_VERT); /* deselect */ - if(select==0) { + if (select==0) { 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)) continue; BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); - if(sticky_select(limit, hitv, BM_elem_index_get(l->v), hituv, luv->uv, sticky, hitlen)) + if (sticky_select(limit, hitv, BM_elem_index_get(l->v), hituv, luv->uv, sticky, hitlen)) uvedit_uv_deselect(em, scene, l); } } @@ -1945,12 +1941,12 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop) else { 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)) continue; BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); - if(sticky_select(limit, hitv, BM_elem_index_get(l->v), hituv, luv->uv, sticky, hitlen)) + if (sticky_select(limit, hitv, BM_elem_index_get(l->v), hituv, luv->uv, sticky, hitlen)) uvedit_uv_select(em, scene, l); } } @@ -1965,33 +1961,33 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop) uvedit_face_deselect(scene, em, efa); } - if(selectmode == UV_SELECT_VERTEX) { + if (selectmode == UV_SELECT_VERTEX) { /* select vertex */ uvedit_uv_select(em, scene, hit.l); flush= 1; } - else if(selectmode == UV_SELECT_EDGE) { + else if (selectmode == UV_SELECT_EDGE) { /* select edge */ uvedit_edge_select(em, scene, hit.l); flush= 1; } - else if(selectmode == UV_SELECT_FACE) { + else if (selectmode == UV_SELECT_FACE) { /* select face */ uvedit_face_select(scene, em, hit.efa); } /* select sticky uvs */ - if(sticky != SI_STICKY_DISABLE) { + if (sticky != SI_STICKY_DISABLE) { 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)) continue; BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { - if(sticky == SI_STICKY_DISABLE) continue; + if (sticky == SI_STICKY_DISABLE) continue; luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); - if(sticky_select(limit, hitv, BM_elem_index_get(l->v), hituv, luv->uv, sticky, hitlen)) + if (sticky_select(limit, hitv, BM_elem_index_get(l->v), hituv, luv->uv, sticky, hitlen)) uvedit_uv_select(em, scene, l); flush= 1; @@ -2002,14 +1998,16 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop) #if 0 /* BM_elem_select_set API handles all of this? */ - if(sync) { + if (sync) { /* flush for mesh selection */ - if(ts->selectmode != SCE_SELECT_FACE) { - if(flush==1) EDBM_select_flush(em); - else if(flush==-1) EDBM_deselect_flush(em); + if (ts->selectmode != SCE_SELECT_FACE) { + if (flush==1) EDBM_select_flush(em); + else if (flush==-1) EDBM_deselect_flush(em); } } - +#else + (void)flush; /* flush is otherwise UNUSED */ + (void)sync; /* sync is otherwise UNUSED */ #endif DAG_id_tag_update(obedit->data, 0); @@ -2047,15 +2045,15 @@ static int select_invoke(bContext *C, wmOperator *op, wmEvent *event) static void UV_OT_select(wmOperatorType *ot) { /* identifiers */ - ot->name= "Select"; - ot->description= "Select UV vertices"; - ot->idname= "UV_OT_select"; - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->name = "Select"; + ot->description = "Select UV vertices"; + ot->idname = "UV_OT_select"; + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; /* api callbacks */ - ot->exec= select_exec; - ot->invoke= select_invoke; - ot->poll= ED_operator_image_active; /* requires space image */; + ot->exec = select_exec; + ot->invoke = select_invoke; + ot->poll = ED_operator_image_active; /* requires space image */; /* properties */ RNA_def_boolean(ot->srna, "extend", 0, @@ -2092,15 +2090,15 @@ static int select_loop_invoke(bContext *C, wmOperator *op, wmEvent *event) static void UV_OT_select_loop(wmOperatorType *ot) { /* identifiers */ - ot->name= "Loop Select"; - ot->description= "Select a loop of connected UV vertices"; - ot->idname= "UV_OT_select_loop"; - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->name = "Loop Select"; + ot->description = "Select a loop of connected UV vertices"; + ot->idname = "UV_OT_select_loop"; + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; /* api callbacks */ - ot->exec= select_loop_exec; - ot->invoke= select_loop_invoke; - ot->poll= ED_operator_image_active; /* requires space image */; + ot->exec = select_loop_exec; + ot->invoke = select_loop_invoke; + ot->poll = ED_operator_image_active; /* requires space image */; /* properties */ RNA_def_boolean(ot->srna, "extend", 0, @@ -2124,7 +2122,7 @@ static int select_linked_internal(bContext *C, wmOperator *op, wmEvent *event, i NearestHit hit, *hit_p= NULL; - if(ts->uv_flag & UV_SYNC_SELECTION) { + if (ts->uv_flag & UV_SYNC_SELECTION) { BKE_report(op->reports, RPT_ERROR, "Can't select linked when sync selection is enabled"); return OPERATOR_CANCELLED; } @@ -2132,10 +2130,10 @@ static int select_linked_internal(bContext *C, wmOperator *op, wmEvent *event, i extend= RNA_boolean_get(op->ptr, "extend"); uvedit_pixel_to_float(sima, limit, 0.05f); - if(pick) { + if (pick) { float co[2]; - if(event) { + if (event) { /* invoke */ ARegion *ar= CTX_wm_region(C); @@ -2167,14 +2165,14 @@ static int select_linked_exec(bContext *C, wmOperator *op) static void UV_OT_select_linked(wmOperatorType *ot) { /* identifiers */ - ot->name= "Select Linked"; - ot->description= "Select all UV vertices linked to the active UV map"; - ot->idname= "UV_OT_select_linked"; - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->name = "Select Linked"; + ot->description = "Select all UV vertices linked to the active UV map"; + ot->idname = "UV_OT_select_linked"; + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; /* api callbacks */ - ot->exec= select_linked_exec; - ot->poll= ED_operator_image_active; /* requires space image */ + ot->exec = select_linked_exec; + ot->poll = ED_operator_image_active; /* requires space image */ /* properties */ RNA_def_boolean(ot->srna, "extend", 0, @@ -2194,15 +2192,15 @@ static int select_linked_pick_exec(bContext *C, wmOperator *op) static void UV_OT_select_linked_pick(wmOperatorType *ot) { /* identifiers */ - ot->name= "Select Linked Pick"; - ot->description= "Select all UV vertices linked under the mouse"; - ot->idname= "UV_OT_select_linked_pick"; - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->name = "Select Linked Pick"; + ot->description = "Select all UV vertices linked under the mouse"; + ot->idname = "UV_OT_select_linked_pick"; + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; /* api callbacks */ - ot->invoke= select_linked_pick_invoke; - ot->exec= select_linked_pick_exec; - ot->poll= ED_operator_image_active; /* requires space image */; + ot->invoke = select_linked_pick_invoke; + ot->exec = select_linked_pick_exec; + ot->poll = ED_operator_image_active; /* requires space image */; /* properties */ RNA_def_boolean(ot->srna, "extend", 0, @@ -2227,7 +2225,7 @@ static int unlink_selection_exec(bContext *C, wmOperator *op) MTexPoly *tf; MLoopUV *luv; - if(ts->uv_flag & UV_SYNC_SELECTION) { + if (ts->uv_flag & UV_SYNC_SELECTION) { BKE_report(op->reports, RPT_ERROR, "Can't unlink selection when sync selection is enabled"); return OPERATOR_CANCELLED; } @@ -2236,7 +2234,7 @@ static int unlink_selection_exec(bContext *C, wmOperator *op) int desel = 0; 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)) continue; BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { @@ -2265,14 +2263,14 @@ static int unlink_selection_exec(bContext *C, wmOperator *op) static void UV_OT_unlink_selected(wmOperatorType *ot) { /* identifiers */ - ot->name= "Unlink Selection"; - ot->description= "Unlink selected UV vertices from active UV map"; - ot->idname= "UV_OT_unlink_selected"; - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->name = "Unlink Selection"; + ot->description = "Unlink selected UV vertices from active UV map"; + ot->idname = "UV_OT_unlink_selected"; + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; /* api callbacks */ - ot->exec= unlink_selection_exec; - ot->poll= ED_operator_uvedit; + ot->exec = unlink_selection_exec; + ot->poll = ED_operator_uvedit; } /* ******************** border select operator **************** */ @@ -2299,7 +2297,7 @@ static void uv_faces_do_sticky(bContext *C, SpaceImage *sima, Scene *scene, Obje BMIter iter, liter; /* MTexPoly *tf; */ - if((ts->uv_flag & UV_SYNC_SELECTION)==0 && sima->sticky == SI_STICKY_VERTEX) { + if ((ts->uv_flag & UV_SYNC_SELECTION)==0 && sima->sticky == SI_STICKY_VERTEX) { /* Tag all verts as untouched, then touch the ones that have a face center * in the loop and select all MLoopUV's that use a touched vert. */ BMVert *eve; @@ -2330,7 +2328,7 @@ static void uv_faces_do_sticky(bContext *C, SpaceImage *sima, Scene *scene, Obje } } } - else if((ts->uv_flag & UV_SYNC_SELECTION)==0 && sima->sticky == SI_STICKY_LOC) { + else if ((ts->uv_flag & UV_SYNC_SELECTION)==0 && sima->sticky == SI_STICKY_LOC) { BMFace *efa_vlist; /* MTexPoly *tf_vlist; */ /* UNUSED */ UvMapVert *start_vlist=NULL, *vlist_iter; @@ -2348,10 +2346,10 @@ static void uv_faces_do_sticky(bContext *C, SpaceImage *sima, Scene *scene, Obje /* verts are numbered above in make_uv_vert_map_EM, make sure this stays true! */ /* BMESH_TODO - why keep this commented? - campbell */ #if 0 - for(a=0, eve= em->verts.first; eve; a++, eve= eve->next) + for (a=0, eve= em->verts.first; eve; a++, eve= eve->next) eve->tmp.l = a; #endif - if(vmap == NULL) { + if (vmap == NULL) { return; } @@ -2361,7 +2359,7 @@ static void uv_faces_do_sticky(bContext *C, SpaceImage *sima, Scene *scene, Obje /* tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); */ /* UNUSED */ BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { - if(select) + if (select) uvedit_uv_select(em, scene, l); else uvedit_uv_deselect(em, scene, l); @@ -2369,10 +2367,10 @@ static void uv_faces_do_sticky(bContext *C, SpaceImage *sima, Scene *scene, Obje vlist_iter= EDBM_get_uv_map_vert(vmap, BM_elem_index_get(l->v)); while (vlist_iter) { - if(vlist_iter->separate) + if (vlist_iter->separate) start_vlist = vlist_iter; - if(efa_index == vlist_iter->f) + if (efa_index == vlist_iter->f) break; vlist_iter = vlist_iter->next; @@ -2381,14 +2379,14 @@ static void uv_faces_do_sticky(bContext *C, SpaceImage *sima, Scene *scene, Obje vlist_iter = start_vlist; while (vlist_iter) { - if(vlist_iter != start_vlist && vlist_iter->separate) + if (vlist_iter != start_vlist && vlist_iter->separate) break; - if(efa_index != vlist_iter->f) { + if (efa_index != vlist_iter->f) { efa_vlist = EDBM_get_face_for_index(em, vlist_iter->f); /* tf_vlist = CustomData_bmesh_get(&em->bm->pdata, efa_vlist->head.data, CD_MTEXPOLY); */ /* UNUSED */ - if(select) + if (select) uvedit_uv_select(em, scene, BM_iter_at_index(em->bm, BM_LOOPS_OF_FACE, efa_vlist, vlist_iter->tfindex)); else uvedit_uv_deselect(em, scene, BM_iter_at_index(em->bm, BM_LOOPS_OF_FACE, efa_vlist, vlist_iter->tfindex)); @@ -2405,7 +2403,7 @@ static void uv_faces_do_sticky(bContext *C, SpaceImage *sima, Scene *scene, Obje else { /* SI_STICKY_DISABLE or ts->uv_flag & UV_SYNC_SELECTION */ BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { if (BM_elem_flag_test(efa, BM_ELEM_TAG)) { - if(select) + if (select) uvedit_face_select(scene, em, efa); else uvedit_face_deselect(scene, em, efa); @@ -2433,10 +2431,10 @@ static int border_select_exec(bContext *C, wmOperator *op) int change, pinned, select, faces, extend; /* get rectangle from operator */ - rect.xmin= RNA_int_get(op->ptr, "xmin"); - rect.ymin= RNA_int_get(op->ptr, "ymin"); - rect.xmax= RNA_int_get(op->ptr, "xmax"); - rect.ymax= RNA_int_get(op->ptr, "ymax"); + rect.xmin = RNA_int_get(op->ptr, "xmin"); + rect.ymin = RNA_int_get(op->ptr, "ymin"); + rect.xmax = RNA_int_get(op->ptr, "xmax"); + rect.ymax = RNA_int_get(op->ptr, "ymax"); UI_view2d_region_to_view(&ar->v2d, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin); UI_view2d_region_to_view(&ar->v2d, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax); @@ -2446,16 +2444,16 @@ static int border_select_exec(bContext *C, wmOperator *op) pinned= RNA_boolean_get(op->ptr, "pinned"); extend= RNA_boolean_get(op->ptr, "extend"); - if(!extend) + if (!extend) select_all_perform(C, SEL_DESELECT); - if(ts->uv_flag & UV_SYNC_SELECTION) + if (ts->uv_flag & UV_SYNC_SELECTION) faces= (ts->selectmode == SCE_SELECT_FACE); else faces= (ts->uv_selectmode == UV_SELECT_FACE); /* do actual selection */ - if(faces && !pinned) { + if (faces && !pinned) { /* handle face selection mode */ float cent[2]; @@ -2466,9 +2464,9 @@ static int border_select_exec(bContext *C, wmOperator *op) BM_elem_flag_disable(efa, BM_ELEM_TAG); 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)) { poly_uv_center(em, efa, cent); - if(BLI_in_rctf(&rectf, cent[0], cent[1])) { + if (BLI_in_rctf(&rectf, cent[0], cent[1])) { BM_elem_flag_enable(efa, BM_ELEM_TAG); change = 1; } @@ -2476,7 +2474,7 @@ static int border_select_exec(bContext *C, wmOperator *op) } /* (de)selects all tagged faces and deals with sticky modes */ - if(change) + if (change) uv_faces_do_sticky(C, sima, scene, obedit, select); } else { @@ -2485,22 +2483,23 @@ static int border_select_exec(bContext *C, wmOperator *op) 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)) continue; BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); - if(!pinned || (ts->uv_flag & UV_SYNC_SELECTION) ) { + if (!pinned || (ts->uv_flag & UV_SYNC_SELECTION) ) { /* UV_SYNC_SELECTION - can't do pinned selection */ - if(BLI_in_rctf(&rectf, luv->uv[0], luv->uv[1])) { - if(select) uvedit_uv_select(em, scene, l); + if (BLI_in_rctf(&rectf, luv->uv[0], luv->uv[1])) { + if (select) uvedit_uv_select(em, scene, l); else uvedit_uv_deselect(em, scene, l); } - } else if(pinned) { + } + else if (pinned) { if ((luv->flag & MLOOPUV_PINNED) && BLI_in_rctf(&rectf, luv->uv[0], luv->uv[1])) { - if(select) uvedit_uv_select(em, scene, l); + if (select) uvedit_uv_select(em, scene, l); else uvedit_uv_deselect(em, scene, l); } } @@ -2508,12 +2507,12 @@ static int border_select_exec(bContext *C, wmOperator *op) } } - if(change) { + if (change) { /* make sure newly selected vert selection is updated*/ #if 0 /* BM_elem_select_set API handles all of this? */ - if(ts->uv_flag & UV_SYNC_SELECTION) { - if(ts->selectmode != SCE_SELECT_FACE) { - if(select) EDBM_select_flush(em); + if (ts->uv_flag & UV_SYNC_SELECTION) { + if (ts->selectmode != SCE_SELECT_FACE) { + if (select) EDBM_select_flush(em); else EDBM_deselect_flush(em); } } @@ -2530,19 +2529,19 @@ static int border_select_exec(bContext *C, wmOperator *op) static void UV_OT_select_border(wmOperatorType *ot) { /* identifiers */ - ot->name= "Border Select"; - ot->description= "Select UV vertices using border selection"; - ot->idname= "UV_OT_select_border"; + ot->name = "Border Select"; + ot->description = "Select UV vertices using border selection"; + ot->idname = "UV_OT_select_border"; /* api callbacks */ - ot->invoke= WM_border_select_invoke; - ot->exec= border_select_exec; - ot->modal= WM_border_select_modal; - ot->poll= ED_operator_image_active; /* requires space image */; - ot->cancel= WM_border_select_cancel; + ot->invoke = WM_border_select_invoke; + ot->exec = border_select_exec; + ot->modal = WM_border_select_modal; + ot->poll = ED_operator_image_active; /* requires space image */; + ot->cancel = WM_border_select_cancel; /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "pinned", 0, "Pinned", "Border select pinned UVs only"); @@ -2565,8 +2564,8 @@ static void select_uv_inside_ellipse(BMEditMesh *em, SpaceImage *UNUSED(sima), S y= (uv[1] - offset[1])*ell[1]; r2 = x*x + y*y; - if(r2 < 1.0f) { - if(select) uvedit_uv_select(em, scene, l); + if (r2 < 1.0f) { + if (select) uvedit_uv_select(em, scene, l); else uvedit_uv_deselect(em, scene, l); } } @@ -2611,7 +2610,7 @@ static int circle_select_exec(bContext *C, wmOperator *op) } #if 0 //I think the BM_elem_select_set api stuff handles all this as necessary? - if(select) EM_select_flush(em); + if (select) EM_select_flush(em); else EM_deselect_flush(em); #endif WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); @@ -2622,19 +2621,19 @@ static int circle_select_exec(bContext *C, wmOperator *op) static void UV_OT_circle_select(wmOperatorType *ot) { /* identifiers */ - ot->name= "Circle Select"; - ot->description= "Select UV vertices using circle selection"; - ot->idname= "UV_OT_circle_select"; + ot->name = "Circle Select"; + ot->description = "Select UV vertices using circle selection"; + ot->idname = "UV_OT_circle_select"; /* api callbacks */ - ot->invoke= WM_gesture_circle_invoke; - ot->modal= WM_gesture_circle_modal; - ot->exec= circle_select_exec; - ot->poll= ED_operator_image_active; /* requires space image */; - ot->cancel= WM_gesture_circle_cancel; + ot->invoke = WM_gesture_circle_invoke; + ot->modal = WM_gesture_circle_modal; + ot->exec = circle_select_exec; + ot->poll = ED_operator_image_active; /* requires space image */; + ot->cancel = WM_gesture_circle_cancel; /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ RNA_def_int(ot->srna, "x", 0, INT_MIN, INT_MAX, "X", "", INT_MIN, INT_MAX); @@ -2682,7 +2681,7 @@ static int snap_cursor_exec(bContext *C, wmOperator *op) break; } - if(!change) + if (!change) return OPERATOR_CANCELLED; WM_event_add_notifier(C, NC_SPACE|ND_SPACE_IMAGE, sima); @@ -2698,14 +2697,14 @@ static void UV_OT_snap_cursor(wmOperatorType *ot) {0, NULL, 0, NULL, NULL}}; /* identifiers */ - ot->name= "Snap Cursor"; - ot->description= "Snap cursor to target type"; - ot->idname= "UV_OT_snap_cursor"; - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->name = "Snap Cursor"; + ot->description = "Snap cursor to target type"; + ot->idname = "UV_OT_snap_cursor"; + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; /* api callbacks */ - ot->exec= snap_cursor_exec; - ot->poll= ED_operator_image_active; /* requires space image */; + ot->exec = snap_cursor_exec; + ot->poll = ED_operator_image_active; /* requires space image */; /* properties */ RNA_def_enum(ot->srna, "target", target_items, 0, "Target", "Target to snap the selected UVs to"); @@ -2725,11 +2724,11 @@ static int snap_uvs_to_cursor(Scene *scene, Image *ima, Object *obedit, SpaceIma BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { tface= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); - if(!uvedit_face_visible(scene, ima, efa, tface)) + if (!uvedit_face_visible(scene, ima, efa, tface)) continue; BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { - if(uvedit_uv_selected(em, scene, l)) { + if (uvedit_uv_selected(em, scene, l)) { luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); copy_v2_v2(luv->uv, sima->cursor); change= 1; @@ -2767,10 +2766,11 @@ static int snap_uvs_to_adjacent_unselected(Scene *scene, Image *ima, Object *obe * get unique indices and to count how much to malloc */ BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { tface= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); - if(!uvedit_face_visible(scene, ima, efa, tface)) { + if (!uvedit_face_visible(scene, ima, efa, tface)) { BM_elem_flag_disable(efa, BM_ELEM_TAG); continue; - } else { + } + else { BM_elem_flag_enable(efa, BM_ELEM_TAG); } @@ -2793,7 +2793,7 @@ static int snap_uvs_to_adjacent_unselected(Scene *scene, Image *ima, Object *obe continue; tface= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); - if(!uvedit_face_visible(scene, ima, efa, tface)) + if (!uvedit_face_visible(scene, ima, efa, tface)) continue; BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { @@ -2807,7 +2807,7 @@ static int snap_uvs_to_adjacent_unselected(Scene *scene, Image *ima, Object *obe } /* no other verts selected, bail out */ - if(!change) { + if (!change) { MEM_freeN(coords); MEM_freeN(usercount); return change; @@ -2819,7 +2819,7 @@ static int snap_uvs_to_adjacent_unselected(Scene *scene, Image *ima, Object *obe continue; tface= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); - if(!uvedit_face_visible(scene, ima, efa, tface)) + if (!uvedit_face_visible(scene, ima, efa, tface)) continue; BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { @@ -2856,7 +2856,7 @@ static int snap_uvs_to_pixels(SpaceImage *sima, Scene *scene, Object *obedit) BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { tface= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); - if(!uvedit_face_visible(scene, ima, efa, tface)) + if (!uvedit_face_visible(scene, ima, efa, tface)) continue; BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { @@ -2892,7 +2892,7 @@ static int snap_selection_exec(bContext *C, wmOperator *op) break; } - if(!change) + if (!change) return OPERATOR_CANCELLED; uvedit_live_unwrap_update(sima, scene, obedit); @@ -2911,14 +2911,14 @@ static void UV_OT_snap_selected(wmOperatorType *ot) {0, NULL, 0, NULL, NULL}}; /* identifiers */ - ot->name= "Snap Selection"; - ot->description= "Snap selected UV vertices to target type"; - ot->idname= "UV_OT_snap_selected"; - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->name = "Snap Selection"; + ot->description = "Snap selected UV vertices to target type"; + ot->idname = "UV_OT_snap_selected"; + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; /* api callbacks */ - ot->exec= snap_selection_exec; - ot->poll= ED_operator_image_active; /* requires space image */; + ot->exec = snap_selection_exec; + ot->poll = ED_operator_image_active; /* requires space image */; /* properties */ RNA_def_enum(ot->srna, "target", target_items, 0, "Target", "Target to snap the selected UVs to"); @@ -2941,16 +2941,17 @@ static int pin_exec(bContext *C, wmOperator *op) BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { tface= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); - if(!uvedit_face_visible(scene, ima, efa, tface)) + if (!uvedit_face_visible(scene, ima, efa, tface)) continue; BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); - if(!clear) { + if (!clear) { if (uvedit_uv_selected(em, scene, l)) luv->flag |= MLOOPUV_PINNED; - } else { + } + else { if (uvedit_uv_selected(em, scene, l)) luv->flag &= ~MLOOPUV_PINNED; } @@ -2965,14 +2966,14 @@ static int pin_exec(bContext *C, wmOperator *op) static void UV_OT_pin(wmOperatorType *ot) { /* identifiers */ - ot->name= "Pin"; - ot->description= "Set/clear selected UV vertices as anchored between multiple unwrap operations"; - ot->idname= "UV_OT_pin"; - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->name = "Pin"; + ot->description = "Set/clear selected UV vertices as anchored between multiple unwrap operations"; + ot->idname = "UV_OT_pin"; + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; /* api callbacks */ - ot->exec= pin_exec; - ot->poll= ED_operator_uvedit; + ot->exec = pin_exec; + ot->poll = ED_operator_uvedit; /* properties */ RNA_def_boolean(ot->srna, "clear", 0, "Clear", "Clear pinning for the selection instead of setting it"); @@ -2994,7 +2995,7 @@ static int select_pinned_exec(bContext *C, wmOperator *UNUSED(op)) BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { tface= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); - if(!uvedit_face_visible(scene, ima, efa, tface)) + if (!uvedit_face_visible(scene, ima, efa, tface)) continue; BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { @@ -3013,14 +3014,14 @@ static int select_pinned_exec(bContext *C, wmOperator *UNUSED(op)) static void UV_OT_select_pinned(wmOperatorType *ot) { /* identifiers */ - ot->name= "Selected Pinned"; - ot->description= "Select all pinned UV vertices"; - ot->idname= "UV_OT_select_pinned"; - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->name = "Selected Pinned"; + ot->description = "Select all pinned UV vertices"; + ot->idname = "UV_OT_select_pinned"; + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; /* api callbacks */ - ot->exec= select_pinned_exec; - ot->poll= ED_operator_uvedit; + ot->exec = select_pinned_exec; + ot->poll = ED_operator_uvedit; } /********************** hide operator *********************/ @@ -3039,7 +3040,7 @@ static int hide_exec(bContext *C, wmOperator *op) int swap = RNA_boolean_get(op->ptr, "unselected"); int facemode= sima ? sima->flag & SI_SELACTFACE : 0; - if(ts->uv_flag & UV_SYNC_SELECTION) { + if (ts->uv_flag & UV_SYNC_SELECTION) { EDBM_hide_mesh(em, swap); WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); @@ -3075,7 +3076,8 @@ static int hide_exec(bContext *C, wmOperator *op) BM_elem_select_set(em->bm, efa, FALSE); uvedit_face_deselect(scene, em, efa); } - } else if(em->selectmode == SCE_SELECT_FACE) { + } + else if (em->selectmode == SCE_SELECT_FACE) { /*check if a UV is selected*/ BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); @@ -3084,7 +3086,8 @@ static int hide_exec(bContext *C, wmOperator *op) } luv->flag &= ~MLOOPUV_VERTSEL; } - } else { + } + else { 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_VERTSEL) { @@ -3106,14 +3109,14 @@ static int hide_exec(bContext *C, wmOperator *op) static void UV_OT_hide(wmOperatorType *ot) { /* identifiers */ - ot->name= "Hide Selected"; - ot->description= "Hide (un)selected UV vertices"; - ot->idname= "UV_OT_hide"; - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->name = "Hide Selected"; + ot->description = "Hide (un)selected UV vertices"; + ot->idname = "UV_OT_hide"; + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; /* api callbacks */ - ot->exec= hide_exec; - ot->poll= ED_operator_uvedit; + ot->exec = hide_exec; + ot->poll = ED_operator_uvedit; /* props */ RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected"); @@ -3136,14 +3139,14 @@ static int reveal_exec(bContext *C, wmOperator *UNUSED(op)) int stickymode= sima ? (sima->sticky != SI_STICKY_DISABLE) : 1; /* call the mesh function if we are in mesh sync sel */ - if(ts->uv_flag & UV_SYNC_SELECTION) { + if (ts->uv_flag & UV_SYNC_SELECTION) { EDBM_reveal_mesh(em); WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); return OPERATOR_FINISHED; } - if(facemode) { - if(em->selectmode == SCE_SELECT_FACE) { + if (facemode) { + if (em->selectmode == SCE_SELECT_FACE) { BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN) && !BM_elem_flag_test(efa, BM_ELEM_SELECT)) { BM_elem_select_set(em->bm, efa, TRUE); @@ -3156,7 +3159,7 @@ static int reveal_exec(bContext *C, wmOperator *UNUSED(op)) } else { /* enable adjacent faces to have disconnected UV selections if sticky is disabled */ - if(!stickymode) { + if (!stickymode) { BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN) && !BM_elem_flag_test(efa, BM_ELEM_SELECT)) { int totsel=0; @@ -3174,7 +3177,8 @@ static int reveal_exec(bContext *C, wmOperator *UNUSED(op)) } } } - } else { + } + else { BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN) && !BM_elem_flag_test(efa, BM_ELEM_SELECT)) { BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { @@ -3189,7 +3193,8 @@ static int reveal_exec(bContext *C, wmOperator *UNUSED(op)) } } } - } else if(em->selectmode == SCE_SELECT_FACE) { + } + else if (em->selectmode == SCE_SELECT_FACE) { BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN) && !BM_elem_flag_test(efa, BM_ELEM_SELECT)) { BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { @@ -3200,7 +3205,8 @@ static int reveal_exec(bContext *C, wmOperator *UNUSED(op)) BM_elem_select_set(em->bm, efa, TRUE); } } - } else { + } + else { BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN) && !BM_elem_flag_test(efa, BM_ELEM_SELECT)) { BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { @@ -3223,14 +3229,14 @@ static int reveal_exec(bContext *C, wmOperator *UNUSED(op)) static void UV_OT_reveal(wmOperatorType *ot) { /* identifiers */ - ot->name= "Reveal Hidden"; - ot->description= "Reveal all hidden UV vertices"; - ot->idname= "UV_OT_reveal"; - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->name = "Reveal Hidden"; + ot->description = "Reveal all hidden UV vertices"; + ot->idname = "UV_OT_reveal"; + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; /* api callbacks */ - ot->exec= reveal_exec; - ot->poll= ED_operator_uvedit; + ot->exec = reveal_exec; + ot->poll = ED_operator_uvedit; } /******************** set 3d cursor operator ********************/ @@ -3240,7 +3246,7 @@ static int set_2d_cursor_exec(bContext *C, wmOperator *op) SpaceImage *sima = CTX_wm_space_image(C); float location[2]; - if(!sima) + if (!sima) return OPERATOR_CANCELLED; RNA_float_get_array(op->ptr, "location", location); @@ -3266,17 +3272,17 @@ static int set_2d_cursor_invoke(bContext *C, wmOperator *op, wmEvent *event) static void UV_OT_cursor_set(wmOperatorType *ot) { /* identifiers */ - ot->name= "Set 2D Cursor"; - ot->description= "Set 2D cursor location"; - ot->idname= "UV_OT_cursor_set"; + ot->name = "Set 2D Cursor"; + ot->description = "Set 2D cursor location"; + ot->idname = "UV_OT_cursor_set"; /* api callbacks */ - ot->exec= set_2d_cursor_exec; - ot->invoke= set_2d_cursor_invoke; - ot->poll= ED_operator_image_active; /* requires space image */; + ot->exec = set_2d_cursor_exec; + ot->invoke = set_2d_cursor_invoke; + ot->poll = ED_operator_image_active; /* requires space image */; /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MAX, FLT_MAX, "Location", "Cursor location in normalised (0.0-1.0) coordinates", -10.0f, 10.0f); @@ -3292,7 +3298,7 @@ static int set_tile_exec(bContext *C, wmOperator *op) RNA_int_get_array(op->ptr, "tile", tile); - if(uvedit_set_tile(obedit, ima, tile[0] + ima->xrep*tile[1])) { + if (uvedit_set_tile(obedit, ima, tile[0] + ima->xrep*tile[1])) { WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); WM_event_add_notifier(C, NC_SPACE|ND_SPACE_IMAGE, NULL); @@ -3310,12 +3316,12 @@ static int set_tile_invoke(bContext *C, wmOperator *op, wmEvent *event) float fx, fy; int tile[2]; - if(!ima || !(ima->tpageflag & IMA_TILES)) + if (!ima || !(ima->tpageflag & IMA_TILES)) return OPERATOR_CANCELLED; UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fx, &fy); - if(fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) { + if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) { fx= fx*ima->xrep; fy= fy*ima->yrep; @@ -3332,17 +3338,17 @@ static int set_tile_invoke(bContext *C, wmOperator *op, wmEvent *event) static void UV_OT_tile_set(wmOperatorType *ot) { /* identifiers */ - ot->name= "Set Tile"; - ot->description= "Set UV image tile coordinates"; - ot->idname= "UV_OT_tile_set"; + ot->name = "Set Tile"; + ot->description = "Set UV image tile coordinates"; + ot->idname = "UV_OT_tile_set"; /* api callbacks */ - ot->exec= set_tile_exec; - ot->invoke= set_tile_invoke; - ot->poll= ED_operator_image_active; /* requires space image */; + ot->exec = set_tile_exec; + ot->invoke = set_tile_invoke; + ot->poll = ED_operator_image_active; /* requires space image */; /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ RNA_def_int_vector(ot->srna, "tile", 2, NULL, 0, INT_MAX, "Tile", "Tile coordinate", 0, 10); @@ -3366,7 +3372,7 @@ static int seams_from_islands_exec(bContext *C, wmOperator *op) em = me->edit_btmesh; bm = em->bm; - if(!EDBM_texFaceCheck(em)) { + if (!EDBM_texFaceCheck(em)) { return OPERATOR_CANCELLED; } @@ -3392,34 +3398,34 @@ static int seams_from_islands_exec(bContext *C, wmOperator *op) UvMapVert *mv2cache = NULL, *mv2sep = NULL; mvinit1 = vmap->vert[BM_elem_index_get(editedge->v1)]; - if(mark_seams) + if (mark_seams) BM_elem_flag_disable(editedge, BM_ELEM_SEAM); - for(mv1 = mvinit1; mv1 && !faces_separated; mv1 = mv1->next) { - if(mv1->separate && commonFaces) + for (mv1 = mvinit1; mv1 && !faces_separated; mv1 = mv1->next) { + if (mv1->separate && commonFaces) v1coincident = 0; separated2 = 0; efa1 = EDBM_get_face_for_index(em, mv1->f); mvinit2 = vmap->vert[BM_elem_index_get(editedge->v2)]; - for(mv2 = mvinit2; mv2; mv2 = mv2->next) { - if(mv2->separate) + for (mv2 = mvinit2; mv2; mv2 = mv2->next) { + if (mv2->separate) mv2sep = mv2; efa2 = EDBM_get_face_for_index(em, mv2->f); - if(efa1 == efa2) { + if (efa1 == efa2) { /* if v1 is not coincident no point in comparing */ - if(v1coincident) { + if (v1coincident) { /* have we found previously anything? */ - if(mv2cache) { + if (mv2cache) { /* flag seam unless proved to be coincident with previous hit */ separated2 = 1; - for(mviter = mv2cache; mviter; mviter = mviter->next) { - if(mviter->separate && mviter != mv2cache) + for (mviter = mv2cache; mviter; mviter = mviter->next) { + if (mviter->separate && mviter != mv2cache) break; /* coincident with previous hit, do not flag seam */ - if(mviter == mv2) + if (mviter == mv2) separated2 = 0; } } @@ -3432,7 +3438,7 @@ static int seams_from_islands_exec(bContext *C, wmOperator *op) else separated1 = 1; - if(separated1 || separated2) { + if (separated1 || separated2) { faces_separated = 1; break; } @@ -3440,10 +3446,10 @@ static int seams_from_islands_exec(bContext *C, wmOperator *op) } } - if(faces_separated) { - if(mark_seams) + if (faces_separated) { + if (mark_seams) BM_elem_flag_enable(editedge, BM_ELEM_SEAM); - if(mark_sharp) + if (mark_sharp) BM_elem_flag_disable(editedge, BM_ELEM_SMOOTH); } } @@ -3463,16 +3469,16 @@ static int seams_from_islands_exec(bContext *C, wmOperator *op) static void UV_OT_seams_from_islands(wmOperatorType *ot) { /* identifiers */ - ot->name= "Seams From Islands"; - ot->description= "Set mesh seams according to island setup in the UV editor"; - ot->idname= "UV_OT_seams_from_islands"; + ot->name = "Seams From Islands"; + ot->description = "Set mesh seams according to island setup in the UV editor"; + ot->idname = "UV_OT_seams_from_islands"; /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; /* api callbacks */ - ot->exec= seams_from_islands_exec; - ot->poll= ED_operator_uvedit; + ot->exec = seams_from_islands_exec; + ot->poll = ED_operator_uvedit; RNA_def_boolean(ot->srna, "mark_seams", 1, "Mark Seams", "Mark boundary edges as seams"); RNA_def_boolean(ot->srna, "mark_sharp", 0, "Mark Sharp", "Mark boundary edges as sharp"); @@ -3492,7 +3498,7 @@ static int mark_seam_exec(bContext *C, wmOperator *UNUSED(op)) BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { BM_ITER(loop, &liter, bm, BM_LOOPS_OF_FACE, efa) { - if(uvedit_edge_selected(em, scene, loop)) { + if (uvedit_edge_selected(em, scene, loop)) { BM_elem_flag_enable(loop, BM_ELEM_SEAM); } } @@ -3500,7 +3506,7 @@ static int mark_seam_exec(bContext *C, wmOperator *UNUSED(op)) me->drawflag |= ME_DRAWSEAMS; - if(scene->toolsettings->edge_mode_live_unwrap) + if (scene->toolsettings->edge_mode_live_unwrap) ED_unwrap_lscm(scene, ob, FALSE); DAG_id_tag_update(&me->id, 0); @@ -3512,16 +3518,16 @@ static int mark_seam_exec(bContext *C, wmOperator *UNUSED(op)) static void UV_OT_mark_seam(wmOperatorType *ot) { /* identifiers */ - ot->name= "Mark Seams"; - ot->description= "Mark selected UV edges as seams"; - ot->idname= "UV_OT_mark_seam"; + ot->name = "Mark Seams"; + ot->description = "Mark selected UV edges as seams"; + ot->idname = "UV_OT_mark_seam"; /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; /* api callbacks */ - ot->exec= mark_seam_exec; - ot->poll= ED_operator_uvedit; + ot->exec = mark_seam_exec; + ot->poll = ED_operator_uvedit; } @@ -3573,8 +3579,8 @@ void ED_keymap_uvedit(wmKeyConfig *keyconf) wmKeyMap *keymap; wmKeyMapItem *kmi; - keymap= WM_keymap_find(keyconf, "UV Editor", 0, 0); - keymap->poll= ED_operator_uvedit_can_uv_sculpt; + keymap = WM_keymap_find(keyconf, "UV Editor", 0, 0); + keymap->poll = ED_operator_uvedit_can_uv_sculpt; /* Uv sculpt toggle */ kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", QKEY, KM_PRESS, 0, 0); |