Blender V5.3
bmesh_edgesplit.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10
11#include "MEM_guardedalloc.h"
12
13#include "BLI_listbase.hh"
14#include "BLI_utildefines.hh"
15
16#include "bmesh.hh"
17
18#include "bmesh_edgesplit.hh" /* own include */
19
20namespace blender {
21
23 const bool use_verts,
24 const bool tag_only,
25 const bool copy_select)
26{
27 BMIter iter;
28 BMEdge *e;
29
30 bool use_ese = false;
32
33 if (copy_select && bm->selected.first()) {
34 for (BMEditSelection &ese : bm->selected) {
35 if (ese.htype != BM_FACE) {
36 ese_gh.add(ese.ele, &ese);
37 }
38 }
39
40 use_ese = true;
41 }
42
43 if (tag_only == false) {
44 BM_mesh_elem_hflag_enable_all(bm, BM_EDGE | (use_verts ? BM_VERT : 0), BM_ELEM_TAG, false);
45 }
46
47 if (use_verts) {
48 /* prevent one edge having both verts unflagged
49 * we could alternately disable these edges, either way its a corner case.
50 *
51 * This is needed so we don't split off the edge but then none of its verts which
52 * would leave a duplicate edge.
53 */
56 if ((BM_elem_flag_test(e->v1, BM_ELEM_TAG) == false) &&
57 (BM_elem_flag_test(e->v2, BM_ELEM_TAG) == false)) [[unlikely]]
58 {
61 }
62 }
63 }
64 }
65 else {
70 }
71 }
72 }
73
76 uint i;
77 for (i = 0; i < 2; i++) {
78 BMVert *v = ((&e->v1)[i]);
81
82 if (use_ese) {
83 BMVert **vtar;
84 int vtar_len;
85
86 BM_vert_separate_hflag(bm, v, BM_ELEM_TAG, copy_select, &vtar, &vtar_len);
87
88 /* first value is always in 'v' */
89 if (vtar_len > 1) {
90 BMEditSelection *ese = ese_gh.lookup_default(reinterpret_cast<BMElem *>(v), nullptr);
91 BLI_assert(v == vtar[0]);
92 if (ese) [[unlikely]] {
93 int j;
94 for (j = 1; j < vtar_len; j++) {
95 BLI_assert(v != vtar[j]);
97 }
98 }
99 }
100 MEM_delete(vtar);
101 }
102 else {
103 BM_vert_separate_hflag(bm, v, BM_ELEM_TAG, copy_select, nullptr, nullptr);
104 }
105 }
106 }
107 }
108 }
109
110#ifndef NDEBUG
111 /* ensure we don't have any double edges! */
112 BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
114 BLI_assert(BM_edge_find_double(e) == nullptr);
115 }
116 }
117#endif
118}
119
120} // namespace blender
Read Blender memory allocation and freeing.
#define BM_elem_flag_disable(ele, hflag)
#define BM_elem_flag_test(ele, hflag)
#define BM_elem_flag_enable(ele, hflag)
#define BM_ITER_MESH(ele, iter, bm, itype)
#define BM_select_history_store_after_notest(bm, ese_ref, ele)
bool add(const Key &key, const Value &value)
Definition BLI_map.hh:295
Value lookup_default(const Key &key, const Value &default_value) const
Definition BLI_map.hh:570
BMesh Iterators.
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void BM_mesh_elem_hflag_enable_all(BMesh *bm, const char htype, const char hflag, const bool respecthide)
unsigned int uint
Definition BKE_text.h:55
void BM_vert_separate_hflag(BMesh *bm, BMVert *v, const char hflag, const bool copy_select, BMVert ***r_vout, int *r_vout_len)
ATTR_WARN_UNUSED_RESULT const BMVert * v
void BM_mesh_edgesplit(BMesh *bm, const bool use_verts, const bool tag_only, const bool copy_select)
BMEdge * BM_edge_find_double(BMEdge *e)
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
ListBaseT< BMEditSelection > selected