diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-06-04 10:39:04 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-06-04 10:39:04 +0300 |
commit | 95011f6d484b369db92ae13c674a6522d664ea8f (patch) | |
tree | 91ba2719c9f3096fad0f1f768aa7b1c4d79aa32a /source/blender/editors/uvedit | |
parent | 0911acb5cf49c5ba05b1df045b41697704aa288a (diff) | |
parent | 44505b38df557a5711703613685a1dec9fc2c3d9 (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/editors/uvedit')
-rw-r--r-- | source/blender/editors/uvedit/uvedit_buttons.c | 12 | ||||
-rw-r--r-- | source/blender/editors/uvedit/uvedit_draw.c | 36 | ||||
-rw-r--r-- | source/blender/editors/uvedit/uvedit_ops.c | 118 | ||||
-rw-r--r-- | source/blender/editors/uvedit/uvedit_parametrizer.c | 168 | ||||
-rw-r--r-- | source/blender/editors/uvedit/uvedit_parametrizer.h | 2 | ||||
-rw-r--r-- | source/blender/editors/uvedit/uvedit_smart_stitch.c | 2 | ||||
-rw-r--r-- | source/blender/editors/uvedit/uvedit_unwrap_ops.c | 58 |
7 files changed, 198 insertions, 198 deletions
diff --git a/source/blender/editors/uvedit/uvedit_buttons.c b/source/blender/editors/uvedit/uvedit_buttons.c index f037783bd5e..5e867afd58e 100644 --- a/source/blender/editors/uvedit/uvedit_buttons.c +++ b/source/blender/editors/uvedit/uvedit_buttons.c @@ -70,7 +70,7 @@ static int uvedit_center(Scene *scene, Object *obedit, BMEditMesh *em, Image *im int tot = 0; const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); - + zero_v2(center); BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) { if (!uvedit_face_visible_test(scene, obedit, ima, f)) @@ -101,7 +101,7 @@ static void uvedit_translate(Scene *scene, Object *obedit, BMEditMesh *em, Image MLoopUV *luv; const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); - + BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) { if (!uvedit_face_visible_test(scene, obedit, ima, f)) continue; @@ -131,7 +131,7 @@ static void uvedit_vertex_buttons(const bContext *C, uiBlock *block) float width = 8 * UI_UNIT_X; ED_space_image_get_size(sima, &imx, &imy); - + em = BKE_editmesh_from_object(obedit); if (uvedit_center(scene, obedit, em, ima, center)) { @@ -164,7 +164,7 @@ static void uvedit_vertex_buttons(const bContext *C, uiBlock *block) step = 100; digits = 2; } - + UI_block_align_begin(block); uiDefButF(block, UI_BTYPE_NUM, B_UVEDIT_VERTEX, IFACE_("X:"), 0, 0, width, UI_UNIT_Y, &uvedit_old_center[0], UNPACK2(range_xy[0]), step, digits, ""); @@ -217,12 +217,12 @@ static int image_panel_uv_poll(const bContext *C, PanelType *UNUSED(pt)) static void image_panel_uv(const bContext *C, Panel *pa) { uiBlock *block; - + block = uiLayoutAbsoluteBlock(pa->layout); UI_block_func_handle_set(block, do_uvedit_vertex, NULL); uvedit_vertex_buttons(C, block); -} +} void ED_uvedit_buttons_register(ARegionType *art) { diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index 6b8bc957b26..e467c61609d 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -194,12 +194,12 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, Object *obedit, BME BLI_buffer_declare_static(vec2f, tf_uvorig_buf, BLI_BUFFER_NOP, BM_DEFAULT_NGON_STACK_SIZE); ED_space_image_get_uv_aspect(sima, &aspx, &aspy); - + switch (sima->dt_uvstretch) { case SI_UVDT_STRETCH_AREA: { float totarea = 0.0f, totuvarea = 0.0f, areadiff, uvarea, area; - + BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { const int efa_len = efa->len; float (*tf_uv)[2] = (float (*)[2])BLI_buffer_reinit_data(&tf_uv_buf, vec2f, efa_len); @@ -214,7 +214,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, Object *obedit, BME totarea += BM_face_calc_area(efa); totuvarea += area_poly_v2(tf_uv, efa->len); - + if (uvedit_face_visible_test(scene, obedit, ima, efa)) { BM_elem_flag_enable(efa, BM_ELEM_TAG); } @@ -266,17 +266,17 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, Object *obedit, BME uv_poly_copy_aspect(tf_uvorig, tf_uv, aspx, aspy, efa->len); uvarea = area_poly_v2(tf_uv, efa->len) / totuvarea; - + if (area < FLT_EPSILON || uvarea < FLT_EPSILON) areadiff = 1.0f; else if (area > uvarea) areadiff = 1.0f - (uvarea / area); else areadiff = 1.0f - (area / uvarea); - + weight_to_rgb(col, areadiff); immUniformColor3fv(col); - + /* TODO: use editmesh tessface */ immBegin(GWN_PRIM_TRI_FAN, efa->len); @@ -455,7 +455,7 @@ static void draw_uvs_other_mesh(Object *ob, const Image *curimage, for (a = 0; a < totcol; a++) { Image *image; - + /* if no materials, assume a default material with no image */ if (ob->totcol) ED_object_get_active_image(ob, a + 1, &image, NULL, NULL, NULL); @@ -602,7 +602,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje interpedges = (ts->selectmode & SCE_SELECT_VERTEX); else interpedges = (ts->uv_selectmode == UV_SELECT_VERTEX); - + /* draw other uvs */ if (sima->flag & SI_DRAW_OTHER) { Image *curimage; @@ -618,7 +618,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje } /* 1. draw shadow mesh */ - + if (sima->flag & SI_DRAWSHADOW) { Object *ob_cage_eval = DEG_get_evaluated_object(depsgraph, obedit); /* XXX TODO: Need to check if shadow mesh is different than original mesh. */ @@ -632,7 +632,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje } /* 2. draw colored faces */ - + if (sima->flag & SI_DRAW_STRETCH) { draw_uvs_stretch(sima, scene, obedit, em, efa_act); } @@ -899,7 +899,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje pointsize = UI_GetThemeValuef(TH_FACEDOT_SIZE); glPointSize(pointsize); - + immBeginAtMost(GWN_PRIM_POINTS, bm->totface); /* unselected faces */ @@ -950,7 +950,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje } /* 6. draw uv vertices */ - + if (drawfaces != 2) { /* 2 means Mesh Face Mode */ pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -975,12 +975,12 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje } immEnd(); - + /* pinned uvs */ /* give odd pointsizes odd pin pointsizes */ glPointSize(pointsize * 2 + (((int)pointsize % 2) ? (-1) : 0)); imm_cpack(0xFF); - + immBeginAtMost(GWN_PRIM_POINTS, bm->totloop); BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { @@ -996,11 +996,11 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje } immEnd(); - + /* selected uvs */ immUniformThemeColor(TH_VERTEX_SELECT); glPointSize(pointsize); - + immBeginAtMost(GWN_PRIM_POINTS, bm->totloop); BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { @@ -1033,10 +1033,10 @@ static void draw_uv_shadows_get( if ((sima->mode == SI_MODE_PAINT) && obedit && obedit->type == OB_MESH) { struct BMEditMesh *em = BKE_editmesh_from_object(obedit); - + *show_shadow = EDBM_uv_check(em); } - + *show_texpaint = (ob && ob->type == OB_MESH && ob->mode == OB_MODE_TEXTURE_PAINT); } diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index fceb1532077..6d5a1925dd5 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -108,13 +108,13 @@ bool ED_uvedit_test(Object *obedit) if (!obedit) return 0; - + if (obedit->type != OB_MESH) return 0; em = BKE_editmesh_from_object(obedit); ret = EDBM_uv_check(em); - + return ret; } @@ -167,7 +167,7 @@ bool ED_object_get_active_image( if (r_ntree) *r_ntree = ntree; return true; } - + if (r_ima) *r_ima = NULL; if (r_iuser) *r_iuser = NULL; if (r_node) *r_node = node; @@ -364,7 +364,7 @@ bool uvedit_edge_select_test( return BM_elem_flag_test(l->e, BM_ELEM_SELECT); } else { - return BM_elem_flag_test(l->v, BM_ELEM_SELECT) && + return BM_elem_flag_test(l->v, BM_ELEM_SELECT) && BM_elem_flag_test(l->next->v, BM_ELEM_SELECT); } } @@ -417,7 +417,7 @@ void uvedit_edge_select_enable( luv1 = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); luv2 = BM_ELEM_CD_GET_VOID_P(l->next, cd_loop_uv_offset); - + luv1->flag |= MLOOPUV_VERTSEL; luv2->flag |= MLOOPUV_VERTSEL; } @@ -445,7 +445,7 @@ void uvedit_edge_select_disable( luv1 = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); luv2 = BM_ELEM_CD_GET_VOID_P(l->next, cd_loop_uv_offset); - + luv1->flag &= ~MLOOPUV_VERTSEL; luv2->flag &= ~MLOOPUV_VERTSEL; } @@ -667,7 +667,7 @@ static bool UNUSED_FUNCTION(ED_uvedit_median)(Scene *scene, Image *ima, Object * bool ED_uvedit_center_multi(Scene *scene, Image *ima, Object **objects_edit, uint objects_len, float cent[2], char mode) { bool changed = false; - + if (mode == V3D_AROUND_CENTER_BOUNDS) { /* bounding box */ float min[2], max[2]; if (ED_uvedit_minmax_multi(scene, ima, objects_edit, objects_len, min, max)) { @@ -920,11 +920,11 @@ bool ED_uvedit_nearest_uv(Scene *scene, Object *obedit, Image *ima, const float mindist = 1e10f; copy_v2_v2(r_uv, co); - + BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { if (!uvedit_face_visible_test(scene, obedit, ima, efa)) continue; - + BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); dist = len_manhattan_v2v2(co, luv->uv); @@ -958,7 +958,7 @@ static void uv_select_edgeloop_vertex_loop_flag(UvMapVert *first) count++; } - + if (count < 5) first->flag = 1; } @@ -974,7 +974,7 @@ static UvMapVert *uv_select_edgeloop_vertex_map_get(UvVertMap *vmap, BMFace *efa if (iterv->f == BM_elem_index_get(efa)) return first; } - + return NULL; } @@ -1113,7 +1113,7 @@ static int uv_select_edgeloop( else { select = true; } - + BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { iterv_curr = uv_select_edgeloop_vertex_map_get(vmap, efa, l); @@ -1724,7 +1724,7 @@ static void UV_OT_align(wmOperatorType *ot) ot->description = "Align selected UV vertices to an axis"; ot->idname = "UV_OT_align"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* api callbacks */ ot->exec = uv_align_exec; ot->poll = ED_operator_uvedit; @@ -1919,7 +1919,7 @@ static void UV_OT_weld(wmOperatorType *ot) ot->description = "Weld selected UV vertices together"; ot->idname = "UV_OT_weld"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* api callbacks */ ot->exec = uv_weld_exec; ot->poll = ED_operator_uvedit; @@ -2073,7 +2073,7 @@ static void UV_OT_select_all(wmOperatorType *ot) ot->description = "Change selection of all UV vertices"; ot->idname = "UV_OT_select_all"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* api callbacks */ ot->exec = uv_select_all_exec; ot->poll = ED_operator_uvedit; @@ -2225,7 +2225,7 @@ static int uv_mouse_select_multi( hituv[i] = luv->uv; hitv[i] = BM_elem_index_get(l->v); } - + hitlen = hit.efa->len; } else if (selectmode == UV_SELECT_ISLAND) { @@ -2330,7 +2330,7 @@ static int uv_mouse_select_multi( BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { if (!uvedit_face_visible_test(scene, obedit, ima, efa)) continue; - + BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { if (sticky == SI_STICKY_DISABLE) continue; luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); @@ -2416,7 +2416,7 @@ static void UV_OT_select(wmOperatorType *ot) ot->description = "Select UV vertices"; ot->idname = "UV_OT_select"; ot->flag = OPTYPE_UNDO; - + /* api callbacks */ ot->exec = uv_select_exec; ot->invoke = uv_select_invoke; @@ -2465,7 +2465,7 @@ static void UV_OT_select_loop(wmOperatorType *ot) ot->description = "Select a loop of connected UV vertices"; ot->idname = "UV_OT_select_loop"; ot->flag = OPTYPE_UNDO; - + /* api callbacks */ ot->exec = uv_select_loop_exec; ot->invoke = uv_select_loop_invoke; @@ -2568,7 +2568,7 @@ static void UV_OT_select_linked(wmOperatorType *ot) 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 = uv_select_linked_exec; ot->poll = ED_operator_uvedit; /* requires space image */ @@ -2775,19 +2775,19 @@ static void uv_select_flush_from_tag_sticky_loc_internal( */ static void uv_select_flush_from_tag_face(SpaceImage *sima, Scene *scene, Object *obedit, const bool select) { - /* Selecting UV Faces with some modes requires us to change + /* Selecting UV Faces with some modes requires us to change * the selection in other faces (depending on the sticky mode). - * + * * This only needs to be done when the Mesh is not used for * selection (so for sticky modes, vertex or location based). */ - + ToolSettings *ts = scene->toolsettings; BMEditMesh *em = BKE_editmesh_from_object(obedit); BMFace *efa; BMLoop *l; BMIter iter, liter; const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); - + 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. */ @@ -2816,19 +2816,19 @@ static void uv_select_flush_from_tag_face(SpaceImage *sima, Scene *scene, Object struct UvVertMap *vmap; float limit[2]; unsigned int efa_index; - + uvedit_pixel_to_float(sima, limit, 0.05); - + BM_mesh_elem_table_ensure(em->bm, BM_FACE); vmap = BM_uv_vert_map_create(em->bm, limit, false, false); if (vmap == NULL) { return; } - + BM_ITER_MESH_INDEX (efa, &iter, em->bm, BM_FACES_OF_MESH, efa_index) { if (BM_elem_flag_test(efa, BM_ELEM_TAG)) { /* tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset); */ /* UNUSED */ - + BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { uv_select_flush_from_tag_sticky_loc_internal( scene, em, vmap, efa_index, l, @@ -2837,7 +2837,7 @@ static void uv_select_flush_from_tag_face(SpaceImage *sima, Scene *scene, Object } } BM_uv_vert_map_free(vmap); - + } else { /* SI_STICKY_DISABLE or ts->uv_flag & UV_SYNC_SELECTION */ BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { @@ -3068,17 +3068,17 @@ static void UV_OT_select_border(wmOperatorType *ot) ot->name = "Border Select"; ot->description = "Select UV vertices using border selection"; ot->idname = "UV_OT_select_border"; - + /* api callbacks */ ot->invoke = WM_gesture_border_invoke; ot->exec = uv_border_select_exec; ot->modal = WM_gesture_border_modal; ot->poll = ED_operator_uvedit_space_image; /* requires space image */; ot->cancel = WM_gesture_border_cancel; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ RNA_def_boolean(ot->srna, "pinned", 0, "Pinned", "Border select pinned UVs only"); @@ -3137,7 +3137,7 @@ static int uv_circle_select_exec(bContext *C, wmOperator *op) ellipse[1] = height * zoomy / radius; UI_view2d_region_to_view(&ar->v2d, x, y, &offset[0], &offset[1]); - + /* do selection */ if (use_face_center) { changed = false; @@ -3193,14 +3193,14 @@ static void UV_OT_circle_select(wmOperatorType *ot) 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 = uv_circle_select_exec; ot->poll = ED_operator_uvedit_space_image; /* requires space image */; ot->cancel = WM_gesture_circle_cancel; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -3416,7 +3416,7 @@ static int uv_snap_cursor_exec(bContext *C, wmOperator *op) if (!changed) return OPERATOR_CANCELLED; - + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_IMAGE, sima); return OPERATOR_FINISHED; @@ -3434,7 +3434,7 @@ static void UV_OT_snap_cursor(wmOperatorType *ot) ot->description = "Snap cursor to target type"; ot->idname = "UV_OT_snap_cursor"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* api callbacks */ ot->exec = uv_snap_cursor_exec; ot->poll = ED_operator_uvedit_space_image; /* requires space image */; @@ -3513,7 +3513,7 @@ static bool uv_snap_uvs_to_adjacent_unselected(Scene *scene, Image *ima, Object MLoopUV *luv; bool changed = false; const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV); - + /* index every vert that has a selected UV using it, but only once so as to * get unique indices and to count how much to malloc */ BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) { @@ -3575,7 +3575,7 @@ static bool uv_snap_uvs_to_pixels(SpaceImage *sima, Scene *scene, Object *obedit ED_space_image_get_size(sima, &width, &height); w = (float)width; h = (float)height; - + BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { if (!uvedit_face_visible_test(scene, obedit, ima, efa)) continue; @@ -3647,7 +3647,7 @@ static void UV_OT_snap_selected(wmOperatorType *ot) 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 = uv_snap_selection_exec; ot->poll = ED_operator_uvedit_space_image; @@ -3673,7 +3673,7 @@ static int uv_pin_exec(bContext *C, wmOperator *op) BMIter iter, liter; MLoopUV *luv; const bool clear = RNA_boolean_get(op->ptr, "clear"); - + const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { @@ -3682,7 +3682,7 @@ static int uv_pin_exec(bContext *C, wmOperator *op) BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); - + if (!clear) { if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) luv->flag |= MLOOPUV_PINNED; @@ -3693,7 +3693,7 @@ static int uv_pin_exec(bContext *C, wmOperator *op) } } } - + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); return OPERATOR_FINISHED; @@ -3706,7 +3706,7 @@ static void UV_OT_pin(wmOperatorType *ot) 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 = uv_pin_exec; ot->poll = ED_operator_uvedit; @@ -3731,7 +3731,7 @@ static int uv_select_pinned_exec(bContext *C, wmOperator *UNUSED(op)) BMLoop *l; BMIter iter, liter; MLoopUV *luv; - + const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { @@ -3740,12 +3740,12 @@ static int uv_select_pinned_exec(bContext *C, wmOperator *UNUSED(op)) BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); - + if (luv->flag & MLOOPUV_PINNED) uvedit_uv_select_enable(em, scene, l, false, cd_loop_uv_offset); } } - + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; @@ -3758,7 +3758,7 @@ static void UV_OT_select_pinned(wmOperatorType *ot) ot->description = "Select all pinned UV vertices"; ot->idname = "UV_OT_select_pinned"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* api callbacks */ ot->exec = uv_select_pinned_exec; ot->poll = ED_operator_uvedit; @@ -3878,7 +3878,7 @@ static int uv_hide_exec(bContext *C, wmOperator *op) /* flush vertex selection changes */ if (em->selectmode != SCE_SELECT_FACE) EDBM_selectmode_flush_ex(em, SCE_SELECT_VERTEX | SCE_SELECT_EDGE); - + BM_select_history_validate(em->bm); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); @@ -3894,7 +3894,7 @@ static void UV_OT_hide(wmOperatorType *ot) ot->description = "Hide (un)selected UV vertices"; ot->idname = "UV_OT_hide"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* api callbacks */ ot->exec = uv_hide_exec; ot->poll = ED_operator_uvedit; @@ -3961,7 +3961,7 @@ static int uv_reveal_exec(bContext *C, wmOperator *op) BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { totsel += BM_elem_flag_test(l->v, BM_ELEM_SELECT); } - + if (!totsel) { BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); @@ -4018,7 +4018,7 @@ static int uv_reveal_exec(bContext *C, wmOperator *op) } } } - + /* re-select tagged faces */ BM_mesh_elem_hflag_enable_test(em->bm, BM_FACE, BM_ELEM_SELECT, true, false, BM_ELEM_TAG); @@ -4034,7 +4034,7 @@ static void UV_OT_reveal(wmOperatorType *ot) ot->description = "Reveal all hidden UV vertices"; ot->idname = "UV_OT_reveal"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* api callbacks */ ot->exec = uv_reveal_exec; ot->poll = ED_operator_uvedit; @@ -4063,9 +4063,9 @@ static int uv_set_2d_cursor_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; RNA_float_get_array(op->ptr, "location", sima->cursor); - + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_IMAGE, NULL); - + return OPERATOR_FINISHED; } @@ -4095,7 +4095,7 @@ static void UV_OT_cursor_set(wmOperatorType *ot) ot->name = "Set 2D Cursor"; ot->description = "Set 2D cursor location"; ot->idname = "UV_OT_cursor_set"; - + /* api callbacks */ ot->exec = uv_set_2d_cursor_exec; ot->invoke = uv_set_2d_cursor_invoke; @@ -4381,7 +4381,7 @@ 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; @@ -4391,7 +4391,7 @@ void ED_keymap_uvedit(wmKeyConfig *keyconf) /* Mark edge seam */ WM_keymap_add_item(keymap, "UV_OT_mark_seam", EKEY, KM_PRESS, KM_CTRL, 0); - + /* pick selection */ RNA_boolean_set(WM_keymap_add_item(keymap, "UV_OT_select", SELECTMOUSE, KM_PRESS, 0, 0)->ptr, "extend", false); RNA_boolean_set(WM_keymap_add_item(keymap, "UV_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "extend", true); @@ -4462,7 +4462,7 @@ void ED_keymap_uvedit(wmKeyConfig *keyconf) /* cursor */ WM_keymap_add_item(keymap, "UV_OT_cursor_set", ACTIONMOUSE, KM_PRESS, 0, 0); - + /* menus */ WM_keymap_add_menu(keymap, "IMAGE_MT_uvs_snap", SKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_menu(keymap, "IMAGE_MT_uvs_select_mode", TABKEY, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c index c510c12ae53..1d2583cf9d4 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.c +++ b/source/blender/editors/uvedit/uvedit_parametrizer.c @@ -113,7 +113,7 @@ typedef struct PVert { float uv[2]; unsigned char flag; -} PVert; +} PVert; typedef struct PEdge { struct PEdge *nextlink; @@ -242,8 +242,8 @@ typedef struct PHandle { */ static int PHashSizes[] = { - 1, 3, 5, 11, 17, 37, 67, 131, 257, 521, 1031, 2053, 4099, 8209, - 16411, 32771, 65537, 131101, 262147, 524309, 1048583, 2097169, + 1, 3, 5, 11, 17, 37, 67, 131, 257, 521, 1031, 2053, 4099, 8209, + 16411, 32771, 65537, 131101, 262147, 524309, 1048583, 2097169, 4194319, 8388617, 16777259, 33554467, 67108879, 134217757, 268435459 }; @@ -294,7 +294,7 @@ static void phash_insert(PHash *ph, PHashLink *link) link->next = lookup->next; lookup->next = link; } - + ph->size++; if (ph->size > (size * 3)) { @@ -323,7 +323,7 @@ static PHashLink *phash_lookup(PHash *ph, PHashKey key) return link; else if (PHASH_hash(ph, link->key) != hash) return NULL; - + return link; } @@ -336,7 +336,7 @@ static PHashLink *phash_next(PHash *ph, PHashKey key, PHashLink *link) return link; else if (PHASH_hash(ph, link->key) != hash) return NULL; - + return link; } @@ -562,7 +562,7 @@ static PEdge *p_wheel_edge_next(PEdge *e) } static PEdge *p_wheel_edge_prev(PEdge *e) -{ +{ return (e->pair) ? e->pair->next : NULL; } @@ -619,7 +619,7 @@ static void p_chart_topological_sanity_check(PChart *chart) for (v = chart->verts; v; v = v->nextlink) param_test_equals_ptr("v->edge->vert", v, v->edge->vert); - + for (e = chart->edges; e; e = e->nextlink) { if (e->pair) { param_test_equals_ptr("e->pair->pair", e, e->pair->pair); @@ -867,7 +867,7 @@ static PBool p_edge_implicit_seam(PEdge *e, PEdge *ep) ep->flag |= PEDGE_SEAM; return P_TRUE; } - + return P_FALSE; } @@ -881,7 +881,7 @@ static PBool p_edge_has_pair(PHandle *handle, PEdge *e, PEdge **pair, PBool impl if (e->flag & PEDGE_SEAM) return P_FALSE; - + key = PHASH_edge(key1, key2); pe = (PEdge *)phash_lookup(handle->hash_edges, key); *pair = NULL; @@ -999,7 +999,7 @@ static void p_split_vert(PChart *chart, PEdge *e) lastwe = e; for (we = p_wheel_edge_prev(e); we && (we != e); we = p_wheel_edge_prev(we)) lastwe = we; - + /* go over all edges in wheel */ for (we = lastwe; we; we = p_wheel_edge_next(we)) { if (we->flag & PEDGE_VERTEX_SPLIT) @@ -1202,7 +1202,7 @@ static PBool p_quad_split_direction(PHandle *handle, float **co, PHashKey *vkeys /* Construction: boundary filling */ static void p_chart_boundaries(PChart *chart, int *nboundaries, PEdge **outer) -{ +{ PEdge *e, *be; float len, maxlen = -1.0; @@ -1327,7 +1327,7 @@ static void p_chart_fill_boundary(PChart *chart, PEdge *be, int nedges) } else { ne2->vert->edge = ne2; - + ne2->u.heaplink = BLI_heap_insert(heap, p_edge_boundary_angle(ne2), ne2); e2->u.heaplink = BLI_heap_insert(heap, p_edge_boundary_angle(e2), e2); } @@ -1412,7 +1412,7 @@ static void p_polygon_kernel_clip(float (*oldpoints)[2], int noldpoints, float ( newpoints[*nnewpoints][1] = p2[1]; (*nnewpoints)++; } - + p1in = p2in; p1 = p2; } @@ -1422,7 +1422,7 @@ static void p_polygon_kernel_center(float (*points)[2], int npoints, float *cent { int i, size, nnewpoints = npoints; float (*oldpoints)[2], (*newpoints)[2], *p1, *p2; - + size = npoints * 3; oldpoints = MEM_mallocN(sizeof(float) * 2 * size, "PPolygonOldPoints"); newpoints = MEM_mallocN(sizeof(float) * 2 * size, "PPolygonNewPoints"); @@ -1486,7 +1486,7 @@ static void p_polygon_kernel_center(float (*points)[2], int npoints, float *cent int NCOLLAPSE = 1; int NCOLLAPSEX = 0; - + static float p_vert_cotan(float *v1, float *v2, float *v3) { float a[3], b[3], c[3], clen; @@ -1499,10 +1499,10 @@ static float p_vert_cotan(float *v1, float *v2, float *v3) if (clen == 0.0f) return 0.0f; - + return dot_v3v3(a, b) / clen; } - + static PBool p_vert_flipped_wheel_triangle(PVert *v) { PEdge *e = v->edge; @@ -1530,7 +1530,7 @@ static PBool p_vert_map_harmonic_weights(PVert *v) do { float t1, t2, weight; PVert *v1, *v2; - + v1 = e->next->vert; v2 = e->next->next->vert; t1 = p_vert_cotan(v2->co, e->vert->co, v1->co); @@ -1563,7 +1563,7 @@ static PBool p_vert_map_harmonic_weights(PVert *v) weightsum += t1 + t2; positionsum[0] += (v2->uv[1] - v1->uv[1]) + (t1 * v2->uv[0] + t2 * v1->uv[0]); positionsum[1] += (v1->uv[0] - v2->uv[0]) + (t1 * v2->uv[1] + t2 * v1->uv[1]); - + e = p_wheel_edge_next(e); } while (e && (e != v->edge)); } @@ -1617,20 +1617,20 @@ static void p_vert_harmonic_insert(PVert *v) do { PEdge *nexte = p_wheel_edge_next(e); - points[i][0] = e->next->vert->uv[0]; - points[i][1] = e->next->vert->uv[1]; + points[i][0] = e->next->vert->uv[0]; + points[i][1] = e->next->vert->uv[1]; if (nexte == NULL) { i++; - points[i][0] = e->next->next->vert->uv[0]; - points[i][1] = e->next->next->vert->uv[1]; + points[i][0] = e->next->next->vert->uv[0]; + points[i][1] = e->next->next->vert->uv[1]; break; } e = nexte; i++; } while (e != v->edge); - + p_polygon_kernel_center(points, npoints, v->uv); MEM_freeN(points); @@ -1653,7 +1653,7 @@ static void p_vert_fix_edge_pointer(PVert *v) /* set v->edge pointer to the edge with no pair, if there is one */ while (v->edge->pair) { v->edge = p_wheel_edge_prev(v->edge); - + if (v->edge == start) break; } @@ -1699,7 +1699,7 @@ static void p_collapse_edge(PEdge *edge, PEdge *pair) else keepv->edge = pair->next->pair->next; } - + /* update pairs and v->edge pointers */ if (edge) { PEdge *e1 = edge->next, *e2 = e1->next; @@ -1821,7 +1821,7 @@ static PBool p_collapse_allowed_topologic(PEdge *edge, PEdge *pair) * the chart) */ else if (!p_vert_interior(oldv) && !p_vert_interior(keepv)) return P_FALSE; - + return P_TRUE; } @@ -1868,7 +1868,7 @@ static PBool p_collapse_allowed_geometric(PEdge *edge, PEdge *pair) if (p_collapse_normal_flipped(v1->co, v2->co, oldv->co, keepv->co)) return P_FALSE; - + a[0] = angle; a[1] = p_vec_angle(v2->co, v1->co, oldv->co); a[2] = M_PI - a[0] - a[1]; @@ -1903,7 +1903,7 @@ static PBool p_collapse_allowed_geometric(PEdge *edge, PEdge *pair) /* abf++ criterion 2: avoid collapsing verts inwards */ if (p_vert_interior(keepv)) return P_FALSE; - + /* don't collapse significant boundary changes */ angle = p_vec_angle(v1->co, oldv->co, v2->co); if (angle < (M_PI * 160.0 / 180.0)) @@ -1921,7 +1921,7 @@ static PBool p_collapse_allowed(PEdge *edge, PEdge *pair) if (oldv->flag & PVERT_PIN) return P_FALSE; - + return (p_collapse_allowed_topologic(edge, pair) && p_collapse_allowed_geometric(edge, pair)); } @@ -2010,7 +2010,7 @@ static float p_collapse_cost(PEdge *edge, PEdge *pair) return cost; } - + static void p_collapse_cost_vertex(PVert *vert, float *mincost, PEdge **mine) { PEdge *e, *enext, *pair; @@ -2172,7 +2172,7 @@ static void p_chart_simplify_compute(PChart *chart) for (v = chart->verts; v; v = v->nextlink) { float cost; PEdge *e = NULL; - + p_collapse_cost_vertex(v, &cost, &e); if (e) @@ -2237,7 +2237,7 @@ static void p_chart_simplify_compute(PChart *chart) BLI_heap_remove(heap, v->u.heaplink); v->u.heaplink = NULL; } - + p_collapse_cost_vertex(v, &cost, &collapse); if (collapse) @@ -2331,7 +2331,7 @@ static void p_abf_setup_system(PAbfSystem *sys) for (i = 0; i < sys->ninterior; i++) sys->lambdaLength[i] = 1.0; - + sys->minangle = 1.0 * M_PI / 180.0; sys->maxangle = (float)M_PI - sys->minangle; } @@ -2649,7 +2649,7 @@ static PBool p_abf_matrix_invert(PAbfSystem *sys, PChart *chart) dlambda1 = pre[0] + pre[1] + pre[2]; dlambda1 = sys->dstar[f->u.id] * (sys->bstar[f->u.id] - dlambda1); - + sys->lambdaTriangle[f->u.id] += dlambda1; dalpha = (sys->bAlpha[e1->u.id] - dlambda1); @@ -2914,7 +2914,7 @@ static PBool p_chart_symmetry_pins(PChart *chart, PEdge *outer, PVert **pin1, PV if (!maxe1 || !maxe2 || (maxlen < 0.5f * totlen)) return P_FALSE; - + /* find pin1 in the split vertices */ be1 = maxe1; be2 = maxe2; @@ -3212,7 +3212,7 @@ static void p_chart_lscm_end(PChart *chart) { if (chart->u.lscm.context) EIG_linear_solver_delete(chart->u.lscm.context); - + if (chart->u.lscm.abf_alpha) { MEM_freeN(chart->u.lscm.abf_alpha); chart->u.lscm.abf_alpha = NULL; @@ -3250,7 +3250,7 @@ static float p_face_stretch(PFace *f) if (area <= 0.0f) /* flipped face -> infinite stretch */ return 1e10f; - + w = 1.0f / (2.0f * area); /* compute derivatives */ @@ -3682,7 +3682,7 @@ static SmoothNode *p_node_new(MemArena *arena, SmoothTriangle **tri, int ntri, f if (ntri <= 10 || depth >= 15) return node; - + t1 = MEM_mallocN(sizeof(*t1) * ntri, "PNodeTri1"); t2 = MEM_mallocN(sizeof(*t2) * ntri, "PNodeTri1"); @@ -3707,7 +3707,7 @@ static SmoothNode *p_node_new(MemArena *arena, SmoothTriangle **tri, int ntri, f MEM_freeN(t2); return node; } - + node->tri = NULL; node->ntri = 0; MEM_freeN(tri); @@ -3782,7 +3782,7 @@ static float p_smooth_median_edge_length(PChart *chart) /* ok, so i'm lazy */ for (i = 0, e = chart->edges; e; e = e->nextlink, i++) lengths[i] = p_edge_length(e); - + qsort(lengths, i, sizeof(float), p_compare_float); median = lengths[i / 2]; @@ -3876,7 +3876,7 @@ static void p_smooth(PChart *chart) if ((gridx <= 2) || (gridy <= 2)) return; - + edgesx = gridx - 1; edgesy = gridy - 1; nsize = gridx * gridy; @@ -3936,7 +3936,7 @@ static void p_smooth(PChart *chart) float p[2], b[3]; i = x + y * gridx; - + p[0] = nodesx[i]; p[1] = nodesy[i]; @@ -3979,7 +3979,7 @@ static void p_smooth(PChart *chart) for (it2 = 0; it2 < maxiter2; it2++) { d = 0.0f; totiter += 1; - + memcpy(oldnodesx, nodesx, sizeof(float) * nsize); memcpy(oldnodesy, nodesy, sizeof(float) * nsize); @@ -4011,7 +4011,7 @@ static void p_smooth(PChart *chart) sum1 += vedges[j] * oldnodesy[i + gridx]; nodesy[i] = sum1 / sum2; - + p[0] = nodesx[i]; p[1] = nodesy[i]; @@ -4089,8 +4089,8 @@ static void p_smooth(PChart *chart) t2->co3[0] = t->co3[0]; t2->co3[1] = t->co3[1]; t2->oco3[0] = t->oco3[0]; t2->oco3[1] = t->oco3[1]; - *trip = t; trip++; t++; - *trip = t; trip++; t++; + *trip = t; trip++; t++; + *trip = t; trip++; t++; } } @@ -4107,7 +4107,7 @@ static void p_smooth(PChart *chart) p_node_delete(root); BLI_memarena_free(arena); - + MEM_freeN(triangles); } @@ -4149,7 +4149,7 @@ void param_delete(ParamHandle *handle) for (i = 0; i < phandle->ncharts; i++) p_chart_delete(phandle->charts[i]); - + if (phandle->charts) MEM_freeN(phandle->charts); @@ -4496,24 +4496,24 @@ static void param_pack_rotate(ParamHandle *handle) } void param_pack(ParamHandle *handle, float margin, bool do_rotate) -{ +{ /* box packing variables */ BoxPack *boxarray, *box; float tot_width, tot_height, scale; - + PChart *chart; int i, unpacked = 0; float trans[2]; double area = 0.0; - + PHandle *phandle = (PHandle *)handle; - + if (phandle->ncharts == 0) return; - + if (phandle->aspx != phandle->aspy) param_scale(handle, 1.0f / phandle->aspx, 1.0f / phandle->aspy); - + /* this could be its own function */ if (do_rotate) { param_pack_rotate(handle); @@ -4521,33 +4521,33 @@ void param_pack(ParamHandle *handle, float margin, bool do_rotate) /* we may not use all these boxes */ boxarray = MEM_mallocN(phandle->ncharts * sizeof(BoxPack), "BoxPack box"); - - + + for (i = 0; i < phandle->ncharts; i++) { chart = phandle->charts[i]; - + if (chart->flag & PCHART_NOPACK) { unpacked++; continue; } - + box = boxarray + (i - unpacked); - + p_chart_uv_bbox(chart, trans, chart->u.pack.size); - + trans[0] = -trans[0]; trans[1] = -trans[1]; - + p_chart_uv_translate(chart, trans); - + box->w = chart->u.pack.size[0] + trans[0]; box->h = chart->u.pack.size[1] + trans[1]; box->index = i; /* warning this index skips PCHART_NOPACK boxes */ - + if (margin > 0.0f) area += (double)sqrtf(box->w * box->h); } - + if (margin > 0.0f) { /* multiply the margin by the area to give predictable results not dependent on UV scale, * ...Without using the area running pack multiple times also gives a bad feedback loop. @@ -4556,12 +4556,12 @@ void param_pack(ParamHandle *handle, float margin, bool do_rotate) unpacked = 0; for (i = 0; i < phandle->ncharts; i++) { chart = phandle->charts[i]; - + if (chart->flag & PCHART_NOPACK) { unpacked++; continue; } - + box = boxarray + (i - unpacked); trans[0] = margin; trans[1] = margin; @@ -4570,19 +4570,19 @@ void param_pack(ParamHandle *handle, float margin, bool do_rotate) box->h += margin * 2; } } - + BLI_box_pack_2d(boxarray, phandle->ncharts - unpacked, &tot_width, &tot_height); - + if (tot_height > tot_width) scale = 1.0f / tot_height; else scale = 1.0f / tot_width; - + for (i = 0; i < phandle->ncharts - unpacked; i++) { box = boxarray + i; trans[0] = box->x; trans[1] = box->y; - + chart = phandle->charts[box->index]; p_chart_uv_translate(chart, trans); p_chart_uv_scale(chart, scale); @@ -4601,54 +4601,54 @@ void param_average(ParamHandle *handle) float tot_fac, fac; float minv[2], maxv[2], trans[2]; PHandle *phandle = (PHandle *)handle; - + if (phandle->ncharts == 0) return; - + for (i = 0; i < phandle->ncharts; i++) { PFace *f; chart = phandle->charts[i]; if (chart->flag & PCHART_NOPACK) continue; - + chart->u.pack.area = 0.0f; /* 3d area */ chart->u.pack.rescale = 0.0f; /* UV area, abusing rescale for tmp storage, oh well :/ */ - + for (f = chart->faces; f; f = f->nextlink) { chart->u.pack.area += p_face_area(f); chart->u.pack.rescale += fabsf(p_face_uv_area_signed(f)); } - + tot_facearea += chart->u.pack.area; tot_uvarea += chart->u.pack.rescale; } - + if (tot_facearea == tot_uvarea || tot_facearea == 0.0f || tot_uvarea == 0.0f) { /* nothing to do */ return; } - + tot_fac = tot_facearea / tot_uvarea; - + for (i = 0; i < phandle->ncharts; i++) { chart = phandle->charts[i]; if (chart->flag & PCHART_NOPACK) continue; - + if (chart->u.pack.area != 0.0f && chart->u.pack.rescale != 0.0f) { fac = chart->u.pack.area / chart->u.pack.rescale; - + /* Get the island center */ p_chart_uv_bbox(chart, minv, maxv); trans[0] = (minv[0] + maxv[0]) / -2.0f; trans[1] = (minv[1] + maxv[1]) / -2.0f; - + /* Move center to 0,0 */ p_chart_uv_translate(chart, trans); p_chart_uv_scale(chart, sqrtf(fac / tot_fac)); - + /* Move to original center */ trans[0] = -trans[0]; trans[1] = -trans[1]; diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.h b/source/blender/editors/uvedit/uvedit_parametrizer.h index 4322a3f7dfc..50b4ee66644 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.h +++ b/source/blender/editors/uvedit/uvedit_parametrizer.h @@ -30,7 +30,7 @@ #ifdef __cplusplus extern "C" { #endif - + #include "BLI_sys_types.h" // for intptr_t support typedef void ParamHandle; /* handle to a set of charts */ diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c index 4c205818329..f39498b08f3 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.c +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c @@ -2334,7 +2334,7 @@ void UV_OT_stitch(wmOperatorType *ot) ot->description = "Stitch selected UV vertices by proximity"; ot->idname = "UV_OT_stitch"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* api callbacks */ ot->invoke = stitch_invoke; ot->modal = stitch_modal; diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 521470d4e5f..78b412579e6 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -147,7 +147,7 @@ static bool ED_uvedit_ensure_uvs(bContext *C, Scene *UNUSED(scene), Object *obed } } } - + /* select new UV's (ignore UV_SYNC_SELECTION in this case) */ BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { BMIter liter; @@ -170,7 +170,7 @@ static bool uvedit_have_selection(Scene *scene, BMEditMesh *em, bool implicit) BMLoop *l; BMIter iter, liter; const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); - + if (cd_loop_uv_offset == -1) { return (em->bm->totfacesel != 0); } @@ -184,15 +184,15 @@ static bool uvedit_have_selection(Scene *scene, BMEditMesh *em, bool implicit) } else if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) continue; - + BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) break; } - + if (implicit && !l) continue; - + return true; } @@ -277,7 +277,7 @@ static ParamHandle *construct_param_handle( BMEdge *eed; BMIter iter, liter; int i; - + const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV); handle = param_construct_begin(); @@ -290,10 +290,10 @@ static ParamHandle *construct_param_handle( if (aspx != aspy) param_aspect_ratio(handle, aspx, aspy); } - + /* we need the vert indices */ BM_mesh_elem_index_ensure(bm, BM_VERT); - + BM_ITER_MESH_INDEX (efa, &iter, bm, BM_FACES_OF_MESH, i) { if ((BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) || (sel && BM_elem_flag_test(efa, BM_ELEM_SELECT) == 0)) { @@ -494,7 +494,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, Object *ob, B smd.levels = smd_real->levels; smd.subdivType = smd_real->subdivType; - + initialDerived = CDDM_from_editbmesh(em, false, false); derivedMesh = subsurf_make_derived_from_derived(initialDerived, &smd, NULL, SUBSURF_IN_EDIT_MODE); @@ -563,7 +563,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, Object *ob, B co[1] = subsurfedVerts[mloop[1].v].co; co[2] = subsurfedVerts[mloop[2].v].co; co[3] = subsurfedVerts[mloop[3].v].co; - + /* This is where all the magic is done. If the vertex exists in the, we pass the original uv pointer to the solver, thus * flushing the solution to the edit mesh. */ texface_from_original_index(origFace, origVertIndices[mloop[0].v], &uv[0], &pin[0], &select[0], scene, cd_loop_uv_offset); @@ -791,7 +791,7 @@ void UV_OT_minimize_stretch(wmOperatorType *ot) ot->idname = "UV_OT_minimize_stretch"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_GRAB_CURSOR | OPTYPE_BLOCKING; ot->description = "Reduce UV stretching by relaxing angles"; - + /* api callbacks */ ot->exec = minimize_stretch_exec; ot->invoke = minimize_stretch_invoke; @@ -869,7 +869,7 @@ void UV_OT_pack_islands(wmOperatorType *ot) ot->description = "Transform all islands so that they fill up the UV space as much as possible"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* api callbacks */ ot->exec = pack_islands_exec; ot->poll = ED_operator_uvedit; @@ -897,7 +897,7 @@ static int average_islands_scale_exec(bContext *C, wmOperator *UNUSED(op)) param_average(handle); param_flush(handle); param_delete(handle); - + DEG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); @@ -912,7 +912,7 @@ void UV_OT_average_islands_scale(wmOperatorType *ot) ot->description = "Average the size of separate UV islands, based on their area in 3D space"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* api callbacks */ ot->exec = average_islands_scale_exec; ot->poll = ED_operator_uvedit; @@ -950,7 +950,7 @@ void ED_uvedit_live_unwrap_re_solve(void) param_flush(liveHandle); } } - + void ED_uvedit_live_unwrap_end(short cancel) { if (liveHandle) { @@ -1139,7 +1139,7 @@ static void uv_map_transform(bContext *C, wmOperator *op, float rotmat[4][4]) /* be compatible to the "old" sphere/cylinder mode */ if (direction == ALIGN_TO_OBJECT) unit_m4(rotmat); - else + else uv_map_rotation_matrix(rotmat, rv3d, obedit, upangledeg, sideangledeg, radius); } @@ -1174,21 +1174,21 @@ static void correct_uv_aspect(Scene *scene, Object *ob, BMEditMesh *em) MLoopUV *luv; BMFace *efa; float scale, aspx, aspy; - + const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); ED_uvedit_get_aspect(scene, ob, em->bm, &aspx, &aspy); - + if (aspx == aspy) return; - + if (aspx > aspy) { scale = aspy / aspx; BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) continue; - + BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); luv->uv[0] = ((luv->uv[0] - 0.5f) * scale) + 0.5f; @@ -1201,7 +1201,7 @@ static void correct_uv_aspect(Scene *scene, Object *ob, BMEditMesh *em) BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) continue; - + BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); luv->uv[1] = ((luv->uv[1] - 0.5f) * scale) + 0.5f; @@ -1436,7 +1436,7 @@ void UV_OT_unwrap(wmOperatorType *ot) ot->description = "Unwrap the mesh of the object being edited"; ot->idname = "UV_OT_unwrap"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* api callbacks */ ot->exec = unwrap_exec; ot->poll = ED_operator_uvmap; @@ -1596,7 +1596,7 @@ void UV_OT_project_from_view(wmOperatorType *ot) ot->description = "Project the UV vertices of the mesh as seen in current 3D view"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* api callbacks */ ot->invoke = uv_from_view_invoke; ot->exec = uv_from_view_exec; @@ -1651,7 +1651,7 @@ void UV_OT_reset(wmOperatorType *ot) ot->description = "Reset UV projection"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* api callbacks */ ot->exec = reset_exec; ot->poll = ED_operator_uvmap; @@ -1670,7 +1670,7 @@ static void uv_sphere_project(float target[2], float source[3], float center[3], /* split line is always zero */ if (target[0] >= 1.0f) - target[0] -= 1.0f; + target[0] -= 1.0f; } static void uv_map_mirror(BMEditMesh *em, BMFace *efa) @@ -1764,7 +1764,7 @@ void UV_OT_sphere_project(wmOperatorType *ot) ot->description = "Project the UV vertices of the mesh over the curved surface of a sphere"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* api callbacks */ ot->exec = sphere_project_exec; ot->poll = ED_operator_uvmap; @@ -1787,7 +1787,7 @@ static void uv_cylinder_project(float target[2], float source[3], float center[3 /* split line is always zero */ if (target[0] >= 1.0f) - target[0] -= 1.0f; + target[0] -= 1.0f; } static int cylinder_project_exec(bContext *C, wmOperator *op) @@ -1852,7 +1852,7 @@ void UV_OT_cylinder_project(wmOperatorType *ot) ot->description = "Project the UV vertices of the mesh over the curved wall of a cylinder"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* api callbacks */ ot->exec = cylinder_project_exec; ot->poll = ED_operator_uvmap; @@ -1969,7 +1969,7 @@ void UV_OT_cube_project(wmOperatorType *ot) ot->description = "Project the UV vertices of the mesh over the six faces of a cube"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* api callbacks */ ot->exec = cube_project_exec; ot->poll = ED_operator_uvmap; |