Changeset View
Changeset View
Standalone View
Standalone View
source/blender/bmesh/intern/bmesh_mods.c
| Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | bool BM_vert_dissolve(BMesh *bm, BMVert *v) | ||||
| } | } | ||||
| if (!BM_vert_is_manifold(v)) { | if (!BM_vert_is_manifold(v)) { | ||||
| if (!v->e) { | if (!v->e) { | ||||
| BM_vert_kill(bm, v); | BM_vert_kill(bm, v); | ||||
| return true; | return true; | ||||
| } | } | ||||
| if (!v->e->l) { | if (!v->e->l) { | ||||
| if (len == 2) { | if (len == 2) { | ||||
| return (BM_vert_collapse_edge(bm, v->e, v, true, true) != NULL); | return (BM_vert_collapse_edge(bm, v->e, v, true, true, true) != NULL); | ||||
| } | } | ||||
| /* used to kill the vertex here, but it may be connected to faces. | /* used to kill the vertex here, but it may be connected to faces. | ||||
| * so better do nothing */ | * so better do nothing */ | ||||
| return false; | return false; | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| if (len == 2 && BM_vert_face_count_is_equal(v, 1)) { | if (len == 2 && BM_vert_face_count_is_equal(v, 1)) { | ||||
| /* boundary vertex on a face */ | /* boundary vertex on a face */ | ||||
| return (BM_vert_collapse_edge(bm, v->e, v, true, true) != NULL); | return (BM_vert_collapse_edge(bm, v->e, v, true, true, true) != NULL); | ||||
| } | } | ||||
| return BM_disk_dissolve(bm, v); | return BM_disk_dissolve(bm, v); | ||||
| } | } | ||||
| /** | /** | ||||
| * dissolves all faces around a vert, and removes it. | * dissolves all faces around a vert, and removes it. | ||||
| */ | */ | ||||
| bool BM_disk_dissolve(BMesh *bm, BMVert *v) | bool BM_disk_dissolve(BMesh *bm, BMVert *v) | ||||
| Show All 34 Lines | #if 0 | ||||
| if (!BM_disk_dissolve(bm, v)) { | if (!BM_disk_dissolve(bm, v)) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| #else | #else | ||||
| if (UNLIKELY(!BM_faces_join_pair(bm, e->l, e->l->radial_next, true))) { | if (UNLIKELY(!BM_faces_join_pair(bm, e->l, e->l->radial_next, true))) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| if (UNLIKELY(!BM_vert_collapse_faces(bm, v->e, v, 1.0, true, false, true))) { | if (UNLIKELY(!BM_vert_collapse_faces(bm, v->e, v, 1.0, true, false, true, true))) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| #endif | #endif | ||||
| return true; | return true; | ||||
| } | } | ||||
| if (keepedge == NULL && len == 2) { | if (keepedge == NULL && len == 2) { | ||||
| /* collapse the vertex */ | /* collapse the vertex */ | ||||
| e = BM_vert_collapse_faces(bm, v->e, v, 1.0, true, true, true); | e = BM_vert_collapse_faces(bm, v->e, v, 1.0, true, true, true, true); | ||||
| if (!e) { | if (!e) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| /* handle two-valence */ | /* handle two-valence */ | ||||
| if (e->l != e->l->radial_next) { | if (e->l != e->l->radial_next) { | ||||
| if (!BM_faces_join_pair(bm, e->l, e->l->radial_next, true)) { | if (!BM_faces_join_pair(bm, e->l, e->l->radial_next, true)) { | ||||
| Show All 26 Lines | while (!done) { | ||||
| done = false; | done = false; | ||||
| break; | break; | ||||
| } | } | ||||
| } while ((e = bmesh_disk_edge_next(e, v)) != v->e); | } while ((e = bmesh_disk_edge_next(e, v)) != v->e); | ||||
| } | } | ||||
| /* collapse the vertex */ | /* collapse the vertex */ | ||||
| /* note, the baseedge can be a boundary of manifold, use this as join_faces arg */ | /* note, the baseedge can be a boundary of manifold, use this as join_faces arg */ | ||||
| e = BM_vert_collapse_faces(bm, baseedge, v, 1.0, true, !BM_edge_is_boundary(baseedge), true); | e = BM_vert_collapse_faces( | ||||
| bm, baseedge, v, 1.0, true, !BM_edge_is_boundary(baseedge), true, true); | |||||
| if (!e) { | if (!e) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| if (e->l) { | if (e->l) { | ||||
| /* get remaining two faces */ | /* get remaining two faces */ | ||||
| if (e->l != e->l->radial_next) { | if (e->l != e->l->radial_next) { | ||||
| ▲ Show 20 Lines • Show All 231 Lines • ▼ Show 20 Lines | |||||
| * \returns The New Edge | * \returns The New Edge | ||||
| */ | */ | ||||
| BMEdge *BM_vert_collapse_faces(BMesh *bm, | BMEdge *BM_vert_collapse_faces(BMesh *bm, | ||||
| BMEdge *e_kill, | BMEdge *e_kill, | ||||
| BMVert *v_kill, | BMVert *v_kill, | ||||
| float fac, | float fac, | ||||
| const bool do_del, | const bool do_del, | ||||
| const bool join_faces, | const bool join_faces, | ||||
| const bool kill_degenerate_faces) | const bool kill_degenerate_faces, | ||||
| const bool kill_duplicate_faces) | |||||
| { | { | ||||
| BMEdge *e_new = NULL; | BMEdge *e_new = NULL; | ||||
| BMVert *tv = BM_edge_other_vert(e_kill, v_kill); | BMVert *tv = BM_edge_other_vert(e_kill, v_kill); | ||||
| BMEdge *e2; | BMEdge *e2; | ||||
| BMVert *tv2; | BMVert *tv2; | ||||
| /* Only intended to be called for 2-valence vertices */ | /* Only intended to be called for 2-valence vertices */ | ||||
| ▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | if (join_faces) { | ||||
| BLI_array_free(faces); | BLI_array_free(faces); | ||||
| } | } | ||||
| else { | else { | ||||
| /* single face or no faces */ | /* single face or no faces */ | ||||
| /* same as BM_vert_collapse_edge() however we already | /* same as BM_vert_collapse_edge() however we already | ||||
| * have vars to perform this operation so don't call. */ | * have vars to perform this operation so don't call. */ | ||||
| e_new = bmesh_kernel_join_edge_kill_vert( | e_new = bmesh_kernel_join_edge_kill_vert( | ||||
| bm, e_kill, v_kill, do_del, true, kill_degenerate_faces); | bm, e_kill, v_kill, do_del, true, kill_degenerate_faces, kill_duplicate_faces); | ||||
| /* e_new = BM_edge_exists(tv, tv2); */ /* same as return above */ | /* e_new = BM_edge_exists(tv, tv2); */ /* same as return above */ | ||||
| } | } | ||||
| return e_new; | return e_new; | ||||
| } | } | ||||
| /** | /** | ||||
| * \brief Vert Collapse Faces | * \brief Vert Collapse Faces | ||||
| * | * | ||||
| * Collapses a vertex onto another vertex it shares an edge with. | * Collapses a vertex onto another vertex it shares an edge with. | ||||
| * | * | ||||
| * \return The New Edge | * \return The New Edge | ||||
| */ | */ | ||||
| BMEdge *BM_vert_collapse_edge( | BMEdge *BM_vert_collapse_edge(BMesh *bm, | ||||
| BMesh *bm, BMEdge *e_kill, BMVert *v_kill, const bool do_del, const bool kill_degenerate_faces) | BMEdge *e_kill, | ||||
| BMVert *v_kill, | |||||
| const bool do_del, | |||||
| const bool kill_degenerate_faces, | |||||
| const bool kill_duplicate_faces) | |||||
| { | { | ||||
| /* nice example implementation but we want loops to have their customdata | /* nice example implementation but we want loops to have their customdata | ||||
| * accounted for */ | * accounted for */ | ||||
| #if 0 | #if 0 | ||||
| BMEdge *e_new = NULL; | BMEdge *e_new = NULL; | ||||
| /* Collapse between 2 edges */ | /* Collapse between 2 edges */ | ||||
| Show All 11 Lines | if (e2) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return e_new; | return e_new; | ||||
| #else | #else | ||||
| /* with these args faces are never joined, same as above | /* with these args faces are never joined, same as above | ||||
| * but account for loop customdata */ | * but account for loop customdata */ | ||||
| return BM_vert_collapse_faces(bm, e_kill, v_kill, 1.0f, do_del, false, kill_degenerate_faces); | return BM_vert_collapse_faces( | ||||
| bm, e_kill, v_kill, 1.0f, do_del, false, kill_degenerate_faces, kill_duplicate_faces); | |||||
| #endif | #endif | ||||
| } | } | ||||
| #undef DO_V_INTERP | #undef DO_V_INTERP | ||||
| /** | /** | ||||
| * Collapse and edge into a single vertex. | * Collapse and edge into a single vertex. | ||||
| */ | */ | ||||
| ▲ Show 20 Lines • Show All 545 Lines • Show Last 20 Lines | |||||