From 44505b38df557a5711703613685a1dec9fc2c3d9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 4 Jun 2018 09:31:30 +0200 Subject: Cleanup: strip trailing space in editors --- source/blender/editors/uvedit/uvedit_buttons.c | 12 +- source/blender/editors/uvedit/uvedit_draw.c | 72 ++++----- source/blender/editors/uvedit/uvedit_ops.c | 150 +++++++++--------- .../blender/editors/uvedit/uvedit_parametrizer.c | 168 ++++++++++----------- .../blender/editors/uvedit/uvedit_parametrizer.h | 2 +- .../blender/editors/uvedit/uvedit_smart_stitch.c | 2 +- source/blender/editors/uvedit/uvedit_unwrap_ops.c | 70 ++++----- 7 files changed, 238 insertions(+), 238 deletions(-) (limited to 'source/blender/editors/uvedit') diff --git a/source/blender/editors/uvedit/uvedit_buttons.c b/source/blender/editors/uvedit/uvedit_buttons.c index ab415c0cb83..92e0920da6b 100644 --- a/source/blender/editors/uvedit/uvedit_buttons.c +++ b/source/blender/editors/uvedit/uvedit_buttons.c @@ -72,7 +72,7 @@ static int uvedit_center(Scene *scene, BMEditMesh *em, Image *ima, float center[ const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); const int cd_poly_tex_offset = CustomData_get_offset(&em->bm->pdata, CD_MTEXPOLY); - + zero_v2(center); BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) { tf = BM_ELEM_CD_GET_VOID_P(f, cd_poly_tex_offset); @@ -106,7 +106,7 @@ static void uvedit_translate(Scene *scene, BMEditMesh *em, Image *ima, float del const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); const int cd_poly_tex_offset = CustomData_get_offset(&em->bm->pdata, CD_MTEXPOLY); - + BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) { tf = BM_ELEM_CD_GET_VOID_P(f, cd_poly_tex_offset); if (!uvedit_face_visible_test(scene, ima, f, tf)) @@ -137,7 +137,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, em, ima, center)) { @@ -170,7 +170,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, ""); @@ -223,12 +223,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 7b793697077..79dcfb3299f 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -81,7 +81,7 @@ void ED_image_draw_cursor(ARegion *ar, const float cursor[2]) mul_v2_fl(zoom, 256.0f * UI_DPI_FAC); x_fac = zoom[0]; y_fac = zoom[1]; - + cpack(0xFFFFFF); glTranslate2fv(cursor); fdrawline(-0.05f * x_fac, 0, 0, 0.05f * y_fac); @@ -181,12 +181,12 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe 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); @@ -202,7 +202,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe totarea += BM_face_calc_area(efa); totuvarea += area_poly_v2(tf_uv, efa->len); - + if (uvedit_face_visible_test(scene, ima, efa, tf)) { BM_elem_flag_enable(efa, BM_ELEM_TAG); } @@ -212,7 +212,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe BM_elem_flag_disable(efa, BM_ELEM_TAG); } } - + if (totarea < FLT_EPSILON || totuvarea < FLT_EPSILON) { col[0] = 1.0; col[1] = col[2] = 0.0; @@ -245,17 +245,17 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe 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); glColor3fv(col); - + /* TODO: USE_EDBM_LOOPTRIS */ glBegin(GL_POLYGON); BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { @@ -278,10 +278,10 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe BLI_buffer_declare_static(vec2f, auv_buf, BLI_BUFFER_NOP, BM_DEFAULT_NGON_STACK_SIZE); col[3] = 0.5f; /* hard coded alpha, not that nice */ - + BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset); - + if (uvedit_face_visible_test(scene, ima, efa, tf)) { const int efa_len = efa->len; float (*tf_uv)[2] = (float (*)[2])BLI_buffer_reinit_data(&tf_uv_buf, vec2f, efa_len); @@ -423,7 +423,7 @@ static void draw_uvs_other_mesh_new_shading(Object *ob, const Image *curimage, c 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); @@ -581,7 +581,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) 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; @@ -602,7 +602,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) } /* 1. draw shadow mesh */ - + if (sima->flag & SI_DRAWSHADOW) { DM_update_materials(em->derivedFinal, obedit); /* first try existing derivedmesh */ @@ -616,15 +616,15 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) * so if cage is the same as the final, theres no point in drawing this */ if (!((ts->uv_flag & UV_SYNC_SELECTION) && (cagedm == finaldm))) draw_uvs_dm_shadow(finaldm); - + /* release derivedmesh again */ if (cagedm != finaldm) cagedm->release(cagedm); finaldm->release(finaldm); } } - + /* 2. draw colored faces */ - + if (sima->flag & SI_DRAW_STRETCH) { draw_uvs_stretch(sima, scene, em, activetf); } @@ -634,7 +634,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) UI_GetThemeColor4ubv(TH_FACE_SELECT, col2); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); - + #ifdef USE_EDBM_LOOPTRIS { unsigned int i; @@ -679,7 +679,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) glColor4ubv((GLubyte *)col2); else glColor4ubv((GLubyte *)col1); - + glBegin(GL_POLYGON); BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); @@ -698,7 +698,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) } else { /* would be nice to do this within a draw loop but most below are optional, so it would involve too many checks */ - + BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset); @@ -711,7 +711,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) BM_elem_flag_disable(efa, BM_ELEM_TAG); } } - + } /* 3. draw active face stippled */ @@ -738,7 +738,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) } } #endif - + /* 4. draw edges */ if (sima->flag & SI_SMOOTH_UV) { @@ -771,7 +771,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) } break; case SI_UVDT_BLACK: /* black/white */ - case SI_UVDT_WHITE: + case SI_UVDT_WHITE: if (sima->dt_uv == SI_UVDT_WHITE) glColor3f(1.0f, 1.0f, 1.0f); else glColor3f(0.0f, 0.0f, 0.0f); @@ -785,14 +785,14 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) case SI_UVDT_OUTLINE: glLineWidth(3); cpack(0x0); - + BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) continue; draw_uvs_lineloop_bmface(efa, cd_loop_uv_offset); } - + glLineWidth(1); UI_GetThemeColor4ubv(TH_WIRE_EDIT, col2); glColor4ubv((unsigned char *)col2); @@ -844,11 +844,11 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) continue; - + draw_uvs_lineloop_bmface(efa, cd_loop_uv_offset); } } - + break; } @@ -861,10 +861,10 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) if (drawfaces) { float cent[2]; - + pointsize = UI_GetThemeValuef(TH_FACEDOT_SIZE); glPointSize(pointsize); - + glBegin(GL_POINTS); /* unselected faces */ @@ -897,13 +897,13 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) } /* 6. draw uv vertices */ - + if (drawfaces != 2) { /* 2 means Mesh Face Mode */ /* unselected uvs */ UI_ThemeColor(TH_VERTEX); pointsize = UI_GetThemeValuef(TH_VERTEX_SIZE); glPointSize(pointsize); - + glBegin(GL_POINTS); BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) @@ -916,12 +916,12 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) } } glEnd(); - + /* pinned uvs */ /* give odd pointsizes odd pin pointsizes */ glPointSize(pointsize * 2 + (((int)pointsize % 2) ? (-1) : 0)); cpack(0xFF); - + glBegin(GL_POINTS); BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) @@ -935,11 +935,11 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) } } glEnd(); - + /* selected uvs */ UI_ThemeColor(TH_VERTEX_SELECT); glPointSize(pointsize); - + glBegin(GL_POINTS); BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) @@ -966,10 +966,10 @@ static void draw_uv_shadows_get(SpaceImage *sima, Object *ob, Object *obedit, bo 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 9c6f468532f..0fa5fb9a48d 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -102,13 +102,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; } @@ -161,7 +161,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; @@ -196,7 +196,7 @@ void ED_uvedit_assign_image(Main *UNUSED(bmain), Scene *scene, Object *obedit, I MTexPoly *tf; bool update = false; const bool selected = !(scene->toolsettings->uv_flag & UV_SYNC_SELECTION); - + /* skip assigning these procedural images... */ if (ima && (ima->type == IMA_TYPE_R_RESULT || ima->type == IMA_TYPE_COMPOSITE)) return; @@ -252,7 +252,7 @@ void ED_uvedit_assign_image(Main *UNUSED(bmain), Scene *scene, Object *obedit, I { if (ima) { tf->tpage = ima; - + if (ima->id.us == 0) id_us_plus(&ima->id); else id_lib_extern(&ima->id); @@ -299,7 +299,7 @@ static bool uvedit_set_tile(Object *obedit, Image *ima, int curtile) BMIter iter; MTexPoly *tf; int cd_poly_tex_offset; - + /* verify if we have something to do */ if (!ima || !ED_uvedit_test(obedit)) return false; @@ -310,7 +310,7 @@ static bool uvedit_set_tile(Object *obedit, Image *ima, int curtile) /* skip assigning these procedural images... */ if (ima->type == IMA_TYPE_R_RESULT || ima->type == IMA_TYPE_COMPOSITE) return false; - + em = BKE_editmesh_from_object(obedit); cd_poly_tex_offset = CustomData_get_offset(&em->bm->pdata, CD_MTEXPOLY); @@ -492,7 +492,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); } } @@ -545,7 +545,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; } @@ -573,7 +573,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; } @@ -714,7 +714,7 @@ bool ED_uvedit_minmax(Scene *scene, Image *ima, Object *obedit, float r_min[2], tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset); if (!uvedit_face_visible_test(scene, ima, efa, tf)) continue; - + BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) { luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); @@ -763,7 +763,7 @@ static bool ED_uvedit_median(Scene *scene, Image *ima, Object *obedit, float co[ tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset); if (!uvedit_face_visible_test(scene, ima, efa, tf)) continue; - + BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) { @@ -781,7 +781,7 @@ static bool ED_uvedit_median(Scene *scene, Image *ima, Object *obedit, float co[ static bool uvedit_center(Scene *scene, Image *ima, Object *obedit, 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(scene, ima, obedit, min, max)) { @@ -991,12 +991,12 @@ 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) { tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset); if (!uvedit_face_visible_test(scene, ima, efa, tf)) 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); @@ -1030,7 +1030,7 @@ static void uv_select_edgeloop_vertex_loop_flag(UvMapVert *first) count++; } - + if (count < 5) first->flag = 1; } @@ -1046,7 +1046,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; } @@ -1188,7 +1188,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); @@ -1295,7 +1295,7 @@ static void uv_select_linked( /* make_uv_vert_map_EM sets verts tmp.l to the indices */ vlist = BM_uv_vert_map_at_index(vmap, BM_elem_index_get(l->v)); - + startv = vlist; for (iterv = vlist; iterv; iterv = iterv->next) { @@ -1809,7 +1809,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; @@ -2008,7 +2008,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; @@ -2055,7 +2055,7 @@ static void uv_select_all_perform(Scene *scene, Image *ima, BMEditMesh *em, int action = SEL_SELECT; BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset); - + if (!uvedit_face_visible_test(scene, ima, efa, tf)) continue; @@ -2069,8 +2069,8 @@ static void uv_select_all_perform(Scene *scene, Image *ima, BMEditMesh *em, int } } } - - + + BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset); @@ -2119,7 +2119,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; @@ -2272,7 +2272,7 @@ static int uv_mouse_select(bContext *C, const float co[2], bool extend, bool loo hituv[i] = luv->uv; hitv[i] = BM_elem_index_get(l->v); } - + hitlen = hit.efa->len; } else if (selectmode == UV_SELECT_ISLAND) { @@ -2367,7 +2367,7 @@ static int uv_mouse_select(bContext *C, const float co[2], bool extend, bool loo tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset); if (!uvedit_face_visible_test(scene, ima, efa, tf)) 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); @@ -2444,7 +2444,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; @@ -2493,7 +2493,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; @@ -2575,7 +2575,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 */ @@ -2785,12 +2785,12 @@ 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; @@ -2798,7 +2798,7 @@ static void uv_select_flush_from_tag_face(SpaceImage *sima, Scene *scene, Object BMIter iter, liter; /* MTexPoly *tf; */ 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. */ @@ -2827,19 +2827,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, @@ -2848,7 +2848,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) { @@ -3057,12 +3057,12 @@ static int uv_border_select_exec(bContext *C, wmOperator *op) if (ts->uv_flag & UV_SYNC_SELECTION) { WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); } - + return OPERATOR_FINISHED; } return OPERATOR_CANCELLED; -} +} static void UV_OT_select_border(wmOperatorType *ot) { @@ -3070,17 +3070,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"); @@ -3139,7 +3139,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; @@ -3195,14 +3195,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; @@ -3399,7 +3399,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; @@ -3417,7 +3417,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 */; @@ -3504,7 +3504,7 @@ static bool uv_snap_uvs_to_adjacent_unselected(Scene *scene, Image *ima, Object bool changed = false; const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV); const int cd_poly_tex_offset = CustomData_get_offset(&bm->pdata, CD_MTEXPOLY); - + /* 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) { @@ -3569,7 +3569,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) { tface = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset); if (!uvedit_face_visible_test(scene, ima, efa, tface)) @@ -3642,7 +3642,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; @@ -3669,7 +3669,7 @@ static int uv_pin_exec(bContext *C, wmOperator *op) MTexPoly *tface; 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); const int cd_poly_tex_offset = CustomData_get_offset(&em->bm->pdata, CD_MTEXPOLY); @@ -3680,7 +3680,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; @@ -3691,7 +3691,7 @@ static int uv_pin_exec(bContext *C, wmOperator *op) } } } - + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); return OPERATOR_FINISHED; @@ -3704,7 +3704,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; @@ -3730,7 +3730,7 @@ static int uv_select_pinned_exec(bContext *C, wmOperator *UNUSED(op)) BMIter iter, liter; MTexPoly *tface; MLoopUV *luv; - + const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); const int cd_poly_tex_offset = CustomData_get_offset(&em->bm->pdata, CD_MTEXPOLY); @@ -3741,12 +3741,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; @@ -3759,7 +3759,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; @@ -3883,7 +3883,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); @@ -3899,7 +3899,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; @@ -3966,7 +3966,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); @@ -4023,7 +4023,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); @@ -4039,7 +4039,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; @@ -4068,9 +4068,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; } @@ -4100,7 +4100,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; @@ -4134,7 +4134,7 @@ static int set_tile_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } - + return OPERATOR_CANCELLED; } @@ -4154,10 +4154,10 @@ static int set_tile_invoke(bContext *C, wmOperator *op, const wmEvent *event) if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) { fx = fx * ima->xrep; fy = fy * ima->yrep; - + tile[0] = fx; tile[1] = fy; - + sima->curtile = tile[1] * ima->xrep + tile[0]; RNA_int_set_array(op->ptr, "tile", tile); } @@ -4171,7 +4171,7 @@ static void UV_OT_tile_set(wmOperatorType *ot) 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; @@ -4457,7 +4457,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; @@ -4467,7 +4467,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); @@ -4539,7 +4539,7 @@ void ED_keymap_uvedit(wmKeyConfig *keyconf) /* cursor */ WM_keymap_add_item(keymap, "UV_OT_cursor_set", ACTIONMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "UV_OT_tile_set", ACTIONMOUSE, KM_PRESS, KM_SHIFT, 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 057417b898f..e4452af4790 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.c +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c @@ -2265,7 +2265,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 bc38a1cd3bb..dbe8796ba8b 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -145,10 +145,10 @@ static bool ED_uvedit_ensure_uvs(bContext *C, Scene *scene, Object *obedit) } } } - + if (ima) ED_uvedit_assign_image(bmain, scene, obedit, ima, NULL); - + /* select new UV's (ignore UV_SYNC_SELECTION in this case) */ BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { BMIter liter; @@ -171,7 +171,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); } @@ -185,15 +185,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; } @@ -267,7 +267,7 @@ static ParamHandle *construct_param_handle(Scene *scene, Object *ob, BMesh *bm, BMEdge *eed; BMIter iter, liter; int i; - + const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV); handle = param_construct_begin(); @@ -280,10 +280,10 @@ static ParamHandle *construct_param_handle(Scene *scene, Object *ob, BMesh *bm, 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)) { @@ -401,7 +401,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); @@ -470,7 +470,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); @@ -698,7 +698,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; @@ -740,7 +740,7 @@ static int pack_islands_exec(bContext *C, wmOperator *op) RNA_float_set(op->ptr, "margin", scene->toolsettings->uvcalc_margin); ED_uvedit_pack_islands(scene, obedit, em->bm, true, true, do_rotate); - + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); @@ -755,7 +755,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; @@ -783,7 +783,7 @@ static int average_islands_scale_exec(bContext *C, wmOperator *UNUSED(op)) param_average(handle); param_flush(handle); param_delete(handle); - + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); @@ -798,7 +798,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; @@ -836,7 +836,7 @@ void ED_uvedit_live_unwrap_re_solve(void) param_flush(liveHandle); } } - + void ED_uvedit_live_unwrap_end(short cancel) { if (liveHandle) { @@ -1025,7 +1025,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); } @@ -1060,21 +1060,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; @@ -1087,7 +1087,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; @@ -1221,7 +1221,7 @@ static int unwrap_exec(bContext *C, wmOperator *op) if (!uvedit_have_selection(scene, em, implicit)) { return OPERATOR_CANCELLED; } - + /* add uvs if they don't exist yet */ if (!ED_uvedit_ensure_uvs(C, scene, obedit)) { return OPERATOR_CANCELLED; @@ -1284,7 +1284,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; @@ -1345,7 +1345,7 @@ static int uv_from_view_exec(bContext *C, wmOperator *op) if (RNA_boolean_get(op->ptr, "orthographic")) { uv_map_rotation_matrix(rotmat, rv3d, obedit, 90.0f, 0.0f, 1.0f); - + BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) continue; @@ -1372,7 +1372,7 @@ static int uv_from_view_exec(bContext *C, wmOperator *op) BLI_uvproject_from_camera(luv->uv, l->v->co, uci); } } - + MEM_freeN(uci); } } @@ -1416,7 +1416,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; @@ -1447,7 +1447,7 @@ static int reset_exec(bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); - + return OPERATOR_FINISHED; } @@ -1459,7 +1459,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; @@ -1478,7 +1478,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, MTexPoly *UNUSED(tf)) @@ -1565,7 +1565,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; @@ -1588,7 +1588,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) @@ -1646,7 +1646,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; @@ -1747,7 +1747,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; -- cgit v1.2.3