diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_queries.c | 13 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_queries.h | 1 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_dissolve.c | 10 | ||||
-rw-r--r-- | source/blender/bmesh/tools/bmesh_decimate_dissolve.c | 4 |
4 files changed, 21 insertions, 7 deletions
diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c index d35625566c0..d478ac07474 100644 --- a/source/blender/bmesh/intern/bmesh_queries.c +++ b/source/blender/bmesh/intern/bmesh_queries.c @@ -659,6 +659,19 @@ bool BM_edge_loop_pair(BMEdge *e, BMLoop **r_la, BMLoop **r_lb) } /** + * Fast alternative to ``(BM_vert_edge_count(v) == 2)`` + */ +bool BM_vert_is_edge_pair(BMVert *v) +{ + BMEdge *e = v->e; + if (e) { + const BMDiskLink *dl = bmesh_disk_edge_link_from_vert(e, v); + return (dl->next == dl->prev); + } + return false; +} + +/** * Returns the number of edges around this vertex. */ int BM_vert_edge_count(BMVert *v) diff --git a/source/blender/bmesh/intern/bmesh_queries.h b/source/blender/bmesh/intern/bmesh_queries.h index 7db04a529eb..21d20976901 100644 --- a/source/blender/bmesh/intern/bmesh_queries.h +++ b/source/blender/bmesh/intern/bmesh_queries.h @@ -65,6 +65,7 @@ int BM_edge_face_count(BMEdge *e); int BM_vert_face_count(BMVert *v); BMEdge *BM_vert_other_disk_edge(BMVert *v, BMEdge *e); +bool BM_vert_is_edge_pair(BMVert *v); bool BM_vert_is_wire(const BMVert *v); BLI_INLINE bool BM_edge_is_wire(const BMEdge *e); diff --git a/source/blender/bmesh/operators/bmo_dissolve.c b/source/blender/bmesh/operators/bmo_dissolve.c index 93296c51f8e..bebfeaa5b06 100644 --- a/source/blender/bmesh/operators/bmo_dissolve.c +++ b/source/blender/bmesh/operators/bmo_dissolve.c @@ -92,7 +92,7 @@ static void bm_face_split(BMesh *bm, const short oflag) BMIter liter; BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { if (BMO_elem_flag_test(bm, v, oflag)) { - if (BM_vert_edge_count(v) > 2) { + if (BM_vert_is_edge_pair(v) == false) { BMLoop *l; BM_ITER_ELEM (l, &liter, v, BM_LOOPS_OF_VERT) { if (l->f->len > 3) { @@ -129,7 +129,7 @@ void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op) BMVert *v; BM_ITER_MESH (v, &viter, bm, BM_VERTS_OF_MESH) { - BMO_elem_flag_set(bm, v, VERT_MARK, (BM_vert_edge_count(v) != 2)); + BMO_elem_flag_set(bm, v, VERT_MARK, !BM_vert_is_edge_pair(v)); } } @@ -215,7 +215,7 @@ void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op) BM_ITER_MESH_MUTABLE (v, v_next, &viter, bm, BM_VERTS_OF_MESH) { if (BMO_elem_flag_test(bm, v, VERT_MARK)) { - if (BM_vert_edge_count(v) == 2) { + if (BM_vert_is_edge_pair(v)) { BM_vert_collapse_edge(bm, v->e, v, true, true); } } @@ -272,7 +272,7 @@ void bmo_dissolve_edges_exec(BMesh *bm, BMOperator *op) if (use_verts) { BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { - BMO_elem_flag_set(bm, v, VERT_MARK, (BM_vert_edge_count(v) != 2)); + BMO_elem_flag_set(bm, v, VERT_MARK, !BM_vert_is_edge_pair(v)); } } @@ -327,7 +327,7 @@ void bmo_dissolve_edges_exec(BMesh *bm, BMOperator *op) if (use_verts) { BM_ITER_MESH_MUTABLE (v, v_next, &iter, bm, BM_VERTS_OF_MESH) { if (BMO_elem_flag_test(bm, v, VERT_MARK)) { - if (BM_vert_edge_count(v) == 2) { + if (BM_vert_is_edge_pair(v)) { BM_vert_collapse_edge(bm, v->e, v, true, true); } } diff --git a/source/blender/bmesh/tools/bmesh_decimate_dissolve.c b/source/blender/bmesh/tools/bmesh_decimate_dissolve.c index 99cb68c025a..096349e8e9c 100644 --- a/source/blender/bmesh/tools/bmesh_decimate_dissolve.c +++ b/source/blender/bmesh/tools/bmesh_decimate_dissolve.c @@ -235,7 +235,7 @@ void BM_mesh_decimate_dissolve_ex(BMesh *bm, const float angle_limit, const bool for (i = 0; i < vinput_len; i++) { BMVert *v = vinput_arr[i]; if (LIKELY(v != NULL) && - BM_vert_edge_count(v) == 2) + BM_vert_is_edge_pair(v)) { BM_vert_collapse_edge(bm, v->e, v, true, true); /* join edges */ } @@ -274,7 +274,7 @@ void BM_mesh_decimate_dissolve_ex(BMesh *bm, const float angle_limit, const bool v = BLI_heap_node_ptr(vnode_top); i = BM_elem_index_get(v); - if (BM_vert_edge_count(v) == 2) { + if (BM_vert_is_edge_pair(v)) { e_new = BM_vert_collapse_edge(bm, v->e, v, true, true); /* join edges */ if (e_new) { |