Blender V5.3
bmesh_decimate_dissolve.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 <algorithm>
14
15#include "BLI_heap.hh"
16#include "BLI_math_geom_c.hh"
18#include "BLI_math_vector_c.hh"
19
20#include "BKE_customdata.hh"
21
22#include "bmesh.hh"
23#include "bmesh_decimate.hh" /* own include */
24
25namespace blender {
26
27/* check that collapsing a vertex between 2 edges doesn't cause a degenerate face. */
28#define USE_DEGENERATE_CHECK
29
30#define COST_INVALID FLT_MAX
31
32namespace {
33
34struct DelimitData {
35 int cd_loop_type;
36 int cd_loop_size;
37 int cd_loop_offset;
38 int cd_loop_offset_end;
39};
40
41} // namespace
42
43static bool bm_edge_is_delimiter(const BMEdge *e,
44 const BMO_Delimit delimit,
45 const DelimitData *delimit_data);
46static bool bm_vert_is_delimiter(const BMVert *v,
47 const BMO_Delimit delimit,
48 const DelimitData *delimit_data);
49
50/* multiply vertex edge angle by face angle
51 * this means we are not left with sharp corners between _almost_ planer faces
52 * convert angles [0-PI/2] -> [0-1], multiply together, then convert back to radians. */
54 const BMO_Delimit delimit,
55 const DelimitData *delimit_data)
56{
57#define UNIT_TO_ANGLE DEG2RADF(90.0f)
58#define ANGLE_TO_UNIT (1.0f / UNIT_TO_ANGLE)
59
60 const float angle = BM_vert_calc_edge_angle(v);
61 /* NOTE: could be either edge, it doesn't matter. */
62 if (v->e && BM_edge_is_manifold(v->e)) {
63 /* Checking delimited is important here,
64 * otherwise, for example, the boundary between two materials
65 * will collapse if the faces on either side of the edge have a small angle.
66 *
67 * This way, delimiting edges are treated like boundary edges,
68 * the detail between two delimiting regions won't over-collapse. */
69 if (!bm_vert_is_delimiter(v, delimit, delimit_data)) {
72 }
73 }
74 return angle;
75
76#undef UNIT_TO_ANGLE
77#undef ANGLE_TO_UNIT
78}
79
80static bool bm_edge_is_contiguous_loop_cd_all(const BMEdge *e, const DelimitData *delimit_data)
81{
82 int cd_loop_offset;
83 for (cd_loop_offset = delimit_data->cd_loop_offset;
84 cd_loop_offset < delimit_data->cd_loop_offset_end;
85 cd_loop_offset += delimit_data->cd_loop_size)
86 {
87 if (BM_edge_is_contiguous_loop_cd(e, delimit_data->cd_loop_type, cd_loop_offset) == false) {
88 return false;
89 }
90 }
91
92 return true;
93}
94
95static bool bm_edge_is_delimiter(const BMEdge *e,
96 const BMO_Delimit delimit,
97 const DelimitData *delimit_data)
98{
99 /* Caller must ensure. */
101
102 if (delimit != 0) {
103 if (delimit & BMO_DELIM_SEAM) {
105 return true;
106 }
107 }
108 if (delimit & BMO_DELIM_SHARP) {
110 return true;
111 }
112 }
113 if (delimit & BMO_DELIM_MATERIAL) {
114 if (e->l->f->mat_nr != e->l->radial_next->f->mat_nr) {
115 return true;
116 }
117 }
118 if (delimit & BMO_DELIM_NORMAL) {
119 if (!BM_edge_is_contiguous(e)) {
120 return true;
121 }
122 }
123 if (delimit & BMO_DELIM_UV) {
124 if (bm_edge_is_contiguous_loop_cd_all(e, delimit_data) == 0) {
125 return true;
126 }
127 }
128 }
129
130 return false;
131}
132
133static bool bm_vert_is_delimiter(const BMVert *v,
134 const BMO_Delimit delimit,
135 const DelimitData *delimit_data)
136{
137 BLI_assert(v->e != nullptr);
138
139 if (delimit != 0) {
140 const BMEdge *e, *e_first;
141 e = e_first = v->e;
142 do {
143 if (BM_edge_is_manifold(e)) {
144 if (bm_edge_is_delimiter(e, delimit, delimit_data)) {
145 return true;
146 }
147 }
148 } while ((e = BM_DISK_EDGE_NEXT(e, v)) != e_first);
149 }
150 return false;
151}
152
154 const BMO_Delimit delimit,
155 const DelimitData *delimit_data)
156{
157 if (BM_edge_is_manifold(e) && !bm_edge_is_delimiter(e, delimit, delimit_data)) {
158 float angle_cos_neg = dot_v3v3(e->l->f->no, e->l->radial_next->f->no);
160 angle_cos_neg *= -1;
161 }
162 return angle_cos_neg;
163 }
164
165 return COST_INVALID;
166}
167
168#ifdef USE_DEGENERATE_CHECK
169
170static void mul_v2_m3v3_center(float r[2],
171 const float m[3][3],
172 const float a[3],
173 const float center[3])
174{
175 BLI_assert(r != a);
176 BLI_assert(r != center);
177
178 float co[3];
179 sub_v3_v3v3(co, a, center);
180
181 r[0] = m[0][0] * co[0] + m[1][0] * co[1] + m[2][0] * co[2];
182 r[1] = m[0][1] * co[0] + m[1][1] * co[1] + m[2][1] * co[2];
183}
184
186{
187 /* Calculate relative to the central vertex for higher precision. */
188 const float *center = l_ear->v->co;
189
190 float tri_2d[3][2];
191 float axis_mat[3][3];
192
193 axis_dominant_v3_to_m3(axis_mat, l_ear->f->no);
194
195 {
196 mul_v2_m3v3_center(tri_2d[0], axis_mat, l_ear->prev->v->co, center);
197# if 0
198 mul_v2_m3v3_center(tri_2d[1], axis_mat, l_ear->v->co, center);
199# else
200 zero_v2(tri_2d[1]);
201# endif
202 mul_v2_m3v3_center(tri_2d[2], axis_mat, l_ear->next->v->co, center);
203 }
204
205 /* check we're not flipping face corners before or after the ear */
206 {
207 float adjacent_2d[2];
208
209 if (!BM_vert_is_edge_pair(l_ear->prev->v)) {
210 mul_v2_m3v3_center(adjacent_2d, axis_mat, l_ear->prev->prev->v->co, center);
211 if (signum_i(cross_tri_v2(adjacent_2d, tri_2d[0], tri_2d[1])) !=
212 signum_i(cross_tri_v2(adjacent_2d, tri_2d[0], tri_2d[2])))
213 {
214 return true;
215 }
216 }
217
218 if (!BM_vert_is_edge_pair(l_ear->next->v)) {
219 mul_v2_m3v3_center(adjacent_2d, axis_mat, l_ear->next->next->v->co, center);
220 if (signum_i(cross_tri_v2(adjacent_2d, tri_2d[2], tri_2d[1])) !=
221 signum_i(cross_tri_v2(adjacent_2d, tri_2d[2], tri_2d[0])))
222 {
223 return true;
224 }
225 }
226 }
227
228 /* check no existing verts are inside the triangle */
229 {
230 /* triangle may be concave, if so - flip so we can use clockwise check */
231 if (cross_tri_v2(UNPACK3(tri_2d)) < 0.0f) {
232 swap_v2_v2(tri_2d[1], tri_2d[2]);
233 }
234
235 /* skip l_ear and adjacent verts */
236 BMLoop *l_iter, *l_first;
237
238 l_iter = l_ear->next->next;
239 l_first = l_ear->prev;
240 do {
241 float co_2d[2];
242 mul_v2_m3v3_center(co_2d, axis_mat, l_iter->v->co, center);
243 if (isect_point_tri_v2_cw(co_2d, tri_2d[0], tri_2d[1], tri_2d[2])) {
244 return true;
245 }
246 } while ((l_iter = l_iter->next) != l_first);
247 }
248
249 return false;
250}
251
253{
254 BMEdge *e_pair[2];
255 BMVert *v_pair[2];
256
257 if (BM_vert_edge_pair(v, &e_pair[0], &e_pair[1])) {
258
259 /* allow wire edges */
260 if (BM_edge_is_wire(e_pair[0]) || BM_edge_is_wire(e_pair[1])) {
261 return false;
262 }
263
264 v_pair[0] = BM_edge_other_vert(e_pair[0], v);
265 v_pair[1] = BM_edge_other_vert(e_pair[1], v);
266
267 if (fabsf(cos_v3v3v3(v_pair[0]->co, v->co, v_pair[1]->co)) < (1.0f - FLT_EPSILON)) {
268 BMLoop *l_iter, *l_first;
269 l_iter = l_first = e_pair[1]->l;
270 do {
271 if (l_iter->f->len > 3) {
272 BMLoop *l_pivot = (l_iter->v == v ? l_iter : l_iter->next);
273 BLI_assert(v == l_pivot->v);
274 if (bm_loop_collapse_is_degenerate(l_pivot)) {
275 return true;
276 }
277 }
278 } while ((l_iter = l_iter->radial_next) != l_first);
279 }
280 return false;
281 }
282 return true;
283}
284#endif /* USE_DEGENERATE_CHECK */
285
287 const float angle_limit,
288 const bool do_dissolve_boundaries,
289 BMO_Delimit delimit,
290 BMVert **vinput_arr,
291 const int vinput_len,
292 BMEdge **einput_arr,
293 const int einput_len,
294 const short oflag_out)
295{
296 const float angle_limit_cos_neg = -cosf(angle_limit);
297 DelimitData delimit_data = {0};
298 const int eheap_table_len = do_dissolve_boundaries ? einput_len : max_ii(einput_len, vinput_len);
299 void *_heap_table = MEM_new_array_uninitialized<HeapNode *>(eheap_table_len, __func__);
300
301 int i;
302
303 if (delimit & BMO_DELIM_UV) {
304 const int layer_len = CustomData_number_of_layers(&bm->ldata, CD_PROP_FLOAT2);
305 if (layer_len == 0) {
306 delimit &= ~BMO_DELIM_UV;
307 }
308 else {
309 delimit_data.cd_loop_type = CD_PROP_FLOAT2;
310 delimit_data.cd_loop_size = CustomData_sizeof(eCustomDataType(delimit_data.cd_loop_type));
311 delimit_data.cd_loop_offset = CustomData_get_n_offset(&bm->ldata, CD_PROP_FLOAT2, 0);
312 delimit_data.cd_loop_offset_end = delimit_data.cd_loop_offset +
313 delimit_data.cd_loop_size * layer_len;
314 }
315 }
316
317 /* --- first edges --- */
318 if (true) {
319 BMEdge **earray;
320 Heap *eheap;
321 HeapNode **eheap_table = static_cast<HeapNode **>(_heap_table);
322 HeapNode *enode_top;
323 int *vert_reverse_lookup;
324 BMIter iter;
325 BMEdge *e_iter;
326
327 /* --- setup heap --- */
328 eheap = BLI_heap_new_ex(einput_len);
329
330 /* wire -> tag */
331 BM_ITER_MESH (e_iter, &iter, bm, BM_EDGES_OF_MESH) {
333 BM_elem_index_set(e_iter, -1); /* set dirty */
334 }
336
337 /* build heap */
338 for (i = 0; i < einput_len; i++) {
339 BMEdge *e = einput_arr[i];
340 const float cost = bm_edge_calc_dissolve_error(e, delimit, &delimit_data);
341 eheap_table[i] = BLI_heap_insert(eheap, cost, e);
342 BM_elem_index_set(e, i); /* set dirty */
343 }
344
345 while ((BLI_heap_is_empty(eheap) == false) &&
346 (BLI_heap_node_value(enode_top = BLI_heap_top(eheap)) < angle_limit_cos_neg))
347 {
348 BMFace *f_new = nullptr;
349 BMEdge *e;
350
351 e = static_cast<BMEdge *>(BLI_heap_node_ptr(enode_top));
352 i = BM_elem_index_get(e);
353
354 if (BM_edge_is_manifold(e)) {
355 /* The `f_new` may be an existing face, see #144383.
356 * In this case it's still flagged as output so the selection
357 * isn't "lost" when dissolving, see: !144653. */
358 f_new = BM_faces_join_pair(bm, e->l, e->l->radial_next, false, nullptr);
359
360 if (f_new) {
361 BMLoop *l_first, *l_iter;
362
363 BLI_heap_remove(eheap, enode_top);
364 eheap_table[i] = nullptr;
365
366 /* update normal */
368 if (oflag_out) {
369 BMO_face_flag_enable(bm, f_new, oflag_out);
370 }
371
372 /* re-calculate costs */
373 l_iter = l_first = BM_FACE_FIRST_LOOP(f_new);
374 do {
375 const int j = BM_elem_index_get(l_iter->e);
376 if (j != -1 && eheap_table[j]) {
377 const float cost = bm_edge_calc_dissolve_error(l_iter->e, delimit, &delimit_data);
378 BLI_heap_node_value_update(eheap, eheap_table[j], cost);
379 }
380 } while ((l_iter = l_iter->next) != l_first);
381 }
382 }
383
384 if (f_new == nullptr) [[unlikely]] {
385 BLI_heap_node_value_update(eheap, enode_top, COST_INVALID);
386 }
387 }
388
389 /* prepare for cleanup */
391 vert_reverse_lookup = MEM_new_array_uninitialized<int>(bm->totvert, __func__);
392 std::fill_n(vert_reverse_lookup, bm->totvert, -1);
393 for (i = 0; i < vinput_len; i++) {
394 BMVert *v = vinput_arr[i];
395 vert_reverse_lookup[BM_elem_index_get(v)] = i;
396 }
397
398 /* --- cleanup --- */
400 BM_ITER_MESH_INDEX (e_iter, &iter, bm, BM_EDGES_OF_MESH, i) {
401 earray[i] = e_iter;
402 }
403 /* Remove all edges/verts left behind from dissolving,
404 * nulling the vertex array so we don't re-use. */
405 for (i = bm->totedge - 1; i != -1; i--) {
406 e_iter = earray[i];
407
408 if (BM_edge_is_wire(e_iter) && (BM_elem_flag_test(e_iter, BM_ELEM_TAG) == false)) {
409 /* edge has become wire */
410 int vidx_reverse;
411 BMVert *v1 = e_iter->v1;
412 BMVert *v2 = e_iter->v2;
413 BM_edge_kill(bm, e_iter);
414 if (v1->e == nullptr) {
415 vidx_reverse = vert_reverse_lookup[BM_elem_index_get(v1)];
416 if (vidx_reverse != -1) {
417 vinput_arr[vidx_reverse] = nullptr;
418 }
419 BM_vert_kill(bm, v1);
420 }
421 if (v2->e == nullptr) {
422 vidx_reverse = vert_reverse_lookup[BM_elem_index_get(v2)];
423 if (vidx_reverse != -1) {
424 vinput_arr[vidx_reverse] = nullptr;
425 }
427 }
428 }
429 }
430 MEM_delete(vert_reverse_lookup);
431 MEM_delete(earray);
432
433 BLI_heap_free(eheap, nullptr);
434 }
435
436 /* --- second verts --- */
437 if (do_dissolve_boundaries) {
438 /* simple version of the branch below, since we will dissolve _all_ verts that use 2 edges */
439 for (i = 0; i < vinput_len; i++) {
440 BMVert *v = vinput_arr[i];
441 if (LIKELY(v != nullptr) && BM_vert_is_edge_pair(v)) {
442 BM_vert_collapse_edge(bm, v->e, v, true, true, true); /* join edges */
443 }
444 }
445 }
446 else {
447 Heap *vheap;
448 HeapNode **vheap_table = static_cast<HeapNode **>(_heap_table);
449 HeapNode *vnode_top;
450
451 BMVert *v_iter;
452 BMIter iter;
453
454 BM_ITER_MESH (v_iter, &iter, bm, BM_VERTS_OF_MESH) {
455 BM_elem_index_set(v_iter, -1); /* set dirty */
456 }
458
459 vheap = BLI_heap_new_ex(vinput_len);
460
461 for (i = 0; i < vinput_len; i++) {
462 BMVert *v = vinput_arr[i];
463 if (v != nullptr) [[likely]] {
464 const float cost = bm_vert_edge_face_angle(v, delimit, &delimit_data);
465 vheap_table[i] = BLI_heap_insert(vheap, cost, v);
466 BM_elem_index_set(v, i); /* set dirty */
467 }
468 }
469
470 while ((BLI_heap_is_empty(vheap) == false) &&
471 (BLI_heap_node_value(vnode_top = BLI_heap_top(vheap)) < angle_limit))
472 {
473 BMEdge *e_new = nullptr;
474 BMVert *v;
475
476 v = static_cast<BMVert *>(BLI_heap_node_ptr(vnode_top));
477 i = BM_elem_index_get(v);
478
479 if (
482#else
484#endif
485 )
486 {
487 e_new = BM_vert_collapse_edge(bm, v->e, v, true, true, true); /* join edges */
488
489 if (e_new) {
490
491 BLI_heap_remove(vheap, vnode_top);
492 vheap_table[i] = nullptr;
493
494 /* update normal */
495 if (e_new->l) {
496 BMLoop *l_first, *l_iter;
497 l_iter = l_first = e_new->l;
498 do {
499 BM_face_normal_update(l_iter->f);
500 } while ((l_iter = l_iter->radial_next) != l_first);
501 }
502
503 /* re-calculate costs */
504 BM_ITER_ELEM (v_iter, &iter, e_new, BM_VERTS_OF_EDGE) {
505 const int j = BM_elem_index_get(v_iter);
506 if (j != -1 && vheap_table[j]) {
507 const float cost = bm_vert_edge_face_angle(v_iter, delimit, &delimit_data);
508 BLI_heap_node_value_update(vheap, vheap_table[j], cost);
509 }
510 }
511
512#ifdef USE_DEGENERATE_CHECK
513 /* dissolving a vertex may mean vertices we previously weren't able to dissolve
514 * can now be re-evaluated. */
515 if (e_new->l) {
516 BMLoop *l_first, *l_iter;
517 l_iter = l_first = e_new->l;
518 do {
519 /* skip vertices part of this edge, evaluated above */
520 BMLoop *l_cycle_first, *l_cycle_iter;
521 l_cycle_iter = l_iter->next->next;
522 l_cycle_first = l_iter->prev;
523 do {
524 const int j = BM_elem_index_get(l_cycle_iter->v);
525 if (j != -1 && vheap_table[j] &&
526 (BLI_heap_node_value(vheap_table[j]) == COST_INVALID))
527 {
528 const float cost = bm_vert_edge_face_angle(
529 l_cycle_iter->v, delimit, &delimit_data);
530 BLI_heap_node_value_update(vheap, vheap_table[j], cost);
531 }
532 } while ((l_cycle_iter = l_cycle_iter->next) != l_cycle_first);
533
534 } while ((l_iter = l_iter->radial_next) != l_first);
535 }
536#endif /* USE_DEGENERATE_CHECK */
537 }
538 }
539
540 if (e_new == nullptr) [[unlikely]] {
541 BLI_heap_node_value_update(vheap, vnode_top, COST_INVALID);
542 }
543 }
544
545 BLI_heap_free(vheap, nullptr);
546 }
547
548 MEM_delete_void(_heap_table);
549}
550
552 const float angle_limit,
553 const bool do_dissolve_boundaries,
554 const BMO_Delimit delimit)
555{
556 int vinput_len;
557 int einput_len;
558
559 BMVert **vinput_arr = static_cast<BMVert **>(
560 BM_iter_as_arrayN(bm, BM_VERTS_OF_MESH, nullptr, &vinput_len, nullptr, 0));
561 BMEdge **einput_arr = static_cast<BMEdge **>(
562 BM_iter_as_arrayN(bm, BM_EDGES_OF_MESH, nullptr, &einput_len, nullptr, 0));
563
565 angle_limit,
566 do_dissolve_boundaries,
567 delimit,
568 vinput_arr,
569 vinput_len,
570 einput_arr,
571 einput_len,
572 0);
573
574 MEM_delete(vinput_arr);
575 MEM_delete(einput_arr);
576}
577
578} // namespace blender
CustomData interface, see also DNA_customdata_types.h.
A min-heap / priority queue ADT.
Read Blender memory allocation and freeing.
#define UNPACK3(a)
#define LIKELY(x)
#define BM_DISK_EDGE_NEXT(e, v)
#define BM_FACE_FIRST_LOOP(p)
#define COST_INVALID
#define ANGLE_TO_UNIT
#define UNIT_TO_ANGLE
#define USE_DEGENERATE_CHECK
#define BM_elem_index_get(ele)
#define BM_elem_flag_set(ele, hflag, val)
#define BM_elem_index_set(ele, index)
#define BM_elem_flag_test(ele, hflag)
#define BM_ITER_ELEM(ele, iter, data, itype)
#define BM_ITER_MESH(ele, iter, bm, itype)
#define BM_ITER_MESH_INDEX(ele, iter, bm, itype, indexvar)
#define BMO_face_flag_enable(bm, e, oflag)
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
Definition btVector3.h:356
#define FLT_EPSILON
BMesh Iterators.
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void void bool BLI_heap_is_empty(const Heap *heap) ATTR_NONNULL(1)
Definition BLI_heap.cc:271
void BM_mesh_elem_index_ensure(BMesh *bm, const char htype)
Heap * BLI_heap_new_ex(unsigned int reserve_num) ATTR_WARN_UNUSED_RESULT
Definition BLI_heap.cc:173
BLI_INLINE bool BM_edge_is_wire(const BMEdge *e) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
int CustomData_number_of_layers(const CustomData *data, eCustomDataType type)
float BM_edge_calc_face_angle(const BMEdge *e)
HeapNode * BLI_heap_top(const Heap *heap) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition BLI_heap.cc:281
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
void BM_vert_kill(BMesh *bm, BMVert *v)
void void BLI_heap_remove(Heap *heap, HeapNode *node) ATTR_NONNULL(1
Definition BLI_heap.cc:309
static bool bm_vert_collapse_is_degenerate(BMVert *v)
int CustomData_get_n_offset(const CustomData *data, eCustomDataType type, int n)
void BM_mesh_decimate_dissolve(BMesh *bm, float angle_limit, bool do_dissolve_boundaries, const BMO_Delimit delimit)
void BLI_heap_free(Heap *heap, HeapFreeFP ptrfreefp) ATTR_NONNULL(1)
Definition BLI_heap.cc:193
MINLINE void swap_v2_v2(float a[2], float b[2])
MINLINE int max_ii(int a, int b)
int CustomData_sizeof(eCustomDataType type)
ATTR_WARN_UNUSED_RESULT const BMVert * v
static bool bm_edge_is_contiguous_loop_cd_all(const BMEdge *e, const DelimitData_CD *delimit_data)
float BM_vert_calc_edge_angle(const BMVert *v)
BLI_INLINE bool BM_edge_is_manifold(const BMEdge *e) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
MINLINE float cross_tri_v2(const float v1[2], const float v2[2], const float v3[2])
void MEM_delete_void(void *vmemh)
BLI_INLINE BMVert * BM_edge_other_vert(BMEdge *e, const BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
static bool bm_edge_is_delimiter(const BMEdge *e, const BMO_Delimit delimit, const DelimitData *delimit_data)
void BM_mesh_decimate_dissolve_ex(BMesh *bm, float angle_limit, bool do_dissolve_boundaries, BMO_Delimit delimit, BMVert **vinput_arr, int vinput_len, BMEdge **einput_arr, int einput_len, short oflag_out)
void BM_face_normal_update(BMFace *f)
void BM_edge_kill(BMesh *bm, BMEdge *e)
MINLINE int signum_i(float a)
BLI_INLINE bool BM_edge_is_contiguous(const BMEdge *e) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
HeapNode * BLI_heap_insert(Heap *heap, float value, void *ptr) ATTR_NONNULL(1)
Definition BLI_heap.cc:236
static float bm_edge_calc_dissolve_error(const BMEdge *e, const BMO_Delimit delimit, const DelimitData *delimit_data)
static float bm_vert_edge_face_angle(BMVert *v, const BMO_Delimit delimit, const DelimitData *delimit_data)
void * BM_iter_as_arrayN(BMesh *bm, const char itype, void *data, int *r_len, void **stack_array, int stack_array_size)
Iterator as Array.
BMEdge * BM_vert_collapse_edge(BMesh *bm, BMEdge *e_kill, BMVert *v_kill, const bool do_del, const bool kill_degenerate_faces, const bool kill_duplicate_faces)
Vert Collapse Faces.
static bool bm_vert_is_delimiter(const BMVert *v, const BMO_Delimit delimit, const DelimitData *delimit_data)
bool isect_point_tri_v2_cw(const float pt[2], const float v1[2], const float v2[2], const float v3[2])
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
void BLI_heap_node_value_update(Heap *heap, HeapNode *node, float value) ATTR_NONNULL(1
Definition BLI_heap.cc:324
ATTR_WARN_UNUSED_RESULT const BMVert * v2
static bool bm_loop_collapse_is_degenerate(BMLoop *l_ear)
bool BM_vert_is_edge_pair(const BMVert *v)
bool BM_vert_edge_pair(const BMVert *v, BMEdge **r_e_a, BMEdge **r_e_b)
BMFace * BM_faces_join_pair(BMesh *bm, BMLoop *l_a, BMLoop *l_b, const bool do_del, BMFace **r_double)
Faces Join Pair.
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
float cos_v3v3v3(const float p1[3], const float p2[3], const float p3[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void zero_v2(float r[2])
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
static void mul_v2_m3v3_center(float r[2], const float m[3][3], const float a[3], const float center[3])
bool BM_edge_is_contiguous_loop_cd(const BMEdge *e, const int cd_loop_type, const int cd_loop_offset)
void axis_dominant_v3_to_m3(float r_mat[3][3], const float normal[3])
Normal to x,y matrix.
void * BLI_heap_node_ptr(const HeapNode *heap) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition BLI_heap.cc:354
void void float BLI_heap_node_value(const HeapNode *heap) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition BLI_heap.cc:349
#define fabsf
#define cosf
struct BMLoop * l
struct BMLoop * next
struct BMLoop * prev
struct BMEdge * e
struct BMVert * v
struct BMLoop * radial_next
struct BMFace * f
struct BMEdge * e