diff options
Diffstat (limited to 'source/blender/editors/mesh/editmesh_utils.c')
-rw-r--r-- | source/blender/editors/mesh/editmesh_utils.c | 55 |
1 files changed, 27 insertions, 28 deletions
diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index 6c9973dc209..46c63d2e057 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -187,20 +187,19 @@ bool EDBM_op_finish(BMEditMesh *em, BMOperator *bmop, wmOperator *op, const bool return false; } - else { - em->emcopyusers--; - if (em->emcopyusers < 0) { - printf("warning: em->emcopyusers was less than zero.\n"); - } - if (em->emcopyusers <= 0) { - BKE_editmesh_free(em->emcopy); - MEM_freeN(em->emcopy); - em->emcopy = NULL; - } + em->emcopyusers--; + if (em->emcopyusers < 0) { + printf("warning: em->emcopyusers was less than zero.\n"); + } - return true; + if (em->emcopyusers <= 0) { + BKE_editmesh_free(em->emcopy); + MEM_freeN(em->emcopy); + em->emcopy = NULL; } + + return true; } bool EDBM_op_callf(BMEditMesh *em, wmOperator *op, const char *fmt, ...) @@ -526,10 +525,7 @@ void EDBM_flag_enable_all(BMEditMesh *em, const char hflag) /** * Return a new UVVertMap from the editmesh */ -UvVertMap *BM_uv_vert_map_create(BMesh *bm, - const float limit[2], - const bool use_select, - const bool use_winding) +UvVertMap *BM_uv_vert_map_create(BMesh *bm, const bool use_select, const bool use_winding) { BMVert *ev; BMFace *efa; @@ -538,7 +534,7 @@ UvVertMap *BM_uv_vert_map_create(BMesh *bm, /* vars from original func */ UvVertMap *vmap; UvMapVert *buf; - MLoopUV *luv; + const MLoopUV *luv; uint a; int totverts, i, totuv, totfaces; const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV); @@ -610,7 +606,7 @@ UvVertMap *BM_uv_vert_map_create(BMesh *bm, BM_ITER_MESH_INDEX (ev, &iter, bm, BM_VERTS_OF_MESH, a) { UvMapVert *newvlist = NULL, *vlist = vmap->vert[a]; UvMapVert *iterv, *v, *lastv, *next; - float *uv, *uv2, uvdiff[2]; + const float *uv, *uv2; while (vlist) { v = vlist; @@ -634,9 +630,7 @@ UvVertMap *BM_uv_vert_map_create(BMesh *bm, luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); uv2 = luv->uv; - sub_v2_v2v2(uvdiff, uv2, uv); - - if (fabsf(uvdiff[0]) < limit[0] && fabsf(uvdiff[1]) < limit[1] && + if (compare_v2v2(uv2, uv, STD_UV_CONNECT_LIMIT) && (!use_winding || winding[iterv->poly_index] == winding[v->poly_index])) { if (lastv) { lastv->next = next; @@ -778,7 +772,8 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm, BM_ITER_MESH_INDEX (ev, &iter, bm, BM_VERTS_OF_MESH, i) { UvElement *newvlist = NULL, *vlist = element_map->vert[i]; UvElement *iterv, *v, *lastv, *next; - float *uv, *uv2, uvdiff[2]; + const float *uv, *uv2; + bool uv_vert_sel, uv2_vert_sel; while (vlist) { v = vlist; @@ -789,6 +784,7 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm, l = v->l; luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); uv = luv->uv; + uv_vert_sel = luv->flag & MLOOPUV_VERTSEL; lastv = NULL; iterv = vlist; @@ -799,12 +795,15 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm, l = iterv->l; luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); uv2 = luv->uv; + uv2_vert_sel = luv->flag & MLOOPUV_VERTSEL; - sub_v2_v2v2(uvdiff, uv2, uv); + /* Check if the uv loops share the same selection state (if not, they are not connected as + * they have been ripped or other edit commands have separated them). */ + const bool connected = (uv_vert_sel == uv2_vert_sel) && + compare_v2v2(uv2, uv, STD_UV_CONNECT_LIMIT); - if (fabsf(uvdiff[0]) < STD_UV_CONNECT_LIMIT && fabsf(uvdiff[1]) < STD_UV_CONNECT_LIMIT && - (!use_winding || - winding[BM_elem_index_get(iterv->l->f)] == winding[BM_elem_index_get(v->l->f)])) { + if (connected && (!use_winding || winding[BM_elem_index_get(iterv->l->f)] == + winding[BM_elem_index_get(v->l->f)])) { if (lastv) { lastv->next = next; } @@ -1030,7 +1029,7 @@ bool EDBM_vert_color_check(BMEditMesh *em) /** \name Mirror Cache API * \{ */ -static BMVert *cache_mirr_intptr_as_bmvert(intptr_t *index_lookup, int index) +static BMVert *cache_mirr_intptr_as_bmvert(const intptr_t *index_lookup, int index) { intptr_t eve_i = index_lookup[index]; return (eve_i == -1) ? NULL : (BMVert *)eve_i; @@ -1628,10 +1627,10 @@ bool BMBVH_EdgeVisible(struct BMBVHTree *tree, if (f && !edge_ray_cast(tree, co2, dir2, NULL, e)) { return true; } - else if (f && !edge_ray_cast(tree, co3, dir3, NULL, e)) { + if (f && !edge_ray_cast(tree, co3, dir3, NULL, e)) { return true; } - else if (!f) { + if (!f) { return true; } |