Blender V5.3
bmo_subdivide_edgering.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
21
22#include "MEM_guardedalloc.h"
23
24#include "BLI_array.hh"
25#include "BLI_listbase.hh"
26#include "BLI_math_geom_c.hh"
28#include "BLI_math_vector_c.hh"
29#include "BLI_utildefines.hh"
31#include "BLI_vector_set.hh"
32
33#include "BKE_curve.hh"
34
35#include "bmesh.hh"
36
37#include "intern/bmesh_operators_private.hh" /* own include */
38
39namespace blender {
40
41#define VERT_SHARED (1 << 0)
42
43#define EDGE_RING (1 << 0)
44#define EDGE_RIM (1 << 1)
45#define EDGE_IN_STACK (1 << 2)
46
47#define FACE_OUT (1 << 0)
48#define FACE_SHARED (1 << 1)
49#define FACE_IN_STACK (1 << 2)
50
51/* -------------------------------------------------------------------- */
54
55#ifndef NDEBUG
57{
58 int count = 0;
59 BMIter iter;
60 BMVert *v;
63 count++;
64 }
65 }
66 return count;
67}
68#endif
69
70static float bezier_handle_calc_length_v3(const float co_a[3],
71 const float no_a[3],
72 const float co_b[3],
73 const float no_b[3])
74{
75 const float dot = dot_v3v3(no_a, no_b);
76 /* gives closest approx at a circle with 2 parallel handles */
77 float fac = 1.333333f;
78 float len;
79 if (dot < 0.0f) {
80 /* Scale down to 0.666 if we point directly at each other rough but ok. */
81 /* TODO: current blend from dot may not be optimal but its also a detail. */
82 const float t = 1.0f + dot;
83 fac = (fac * t) + (0.75f * (1.0f - t));
84 }
85
86#if 0
87 len = len_v3v3(co_a, co_b);
88#else
89 /* 2d length projected on plane of normals */
90 {
91 float co_a_ofs[3];
92 cross_v3_v3v3(co_a_ofs, no_a, no_b);
93 if (len_squared_v3(co_a_ofs) > FLT_EPSILON) {
94 add_v3_v3(co_a_ofs, co_a);
95 closest_to_line_v3(co_a_ofs, co_b, co_a, co_a_ofs);
96 }
97 else {
98 copy_v3_v3(co_a_ofs, co_a);
99 }
100 len = len_v3v3(co_a_ofs, co_b);
101 }
102#endif
103
104 return (len * 0.5f) * fac;
105}
106
107static void bm_edgeloop_vert_tag(BMEdgeLoopStore *el_store, const bool tag)
108{
109 LinkData *node = BM_edgeloop_verts_get(el_store)->first();
110 do {
111 BM_elem_flag_set((BMVert *)node->data, BM_ELEM_TAG, tag);
112 } while ((node = node->next));
113}
114
116 BMEdgeLoopStore *el_store,
117 const short oflag,
118 const bool tag)
119{
120 LinkData *node = BM_edgeloop_verts_get(el_store)->first();
121 do {
122 BMO_vert_flag_set(bm, (BMVert *)node->data, oflag, tag);
123 } while ((node = node->next));
124}
125
127{
128 BMLoop *l_iter, *l_first;
129 l_iter = l_first = BM_FACE_FIRST_LOOP(f);
130 do {
131 if (!BMO_vert_flag_test(bm, l_iter->v, oflag)) {
132 return false;
133 }
134 } while ((l_iter = l_iter->next) != l_first);
135 return true;
136}
137
139{
140 BMIter eiter;
141 BMEdge *e;
142
143 BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) {
145 BMVert *v_other = BM_edge_other_vert(e, v);
146 if (BM_elem_flag_test(v_other, BM_ELEM_TAG)) {
147 return true;
148 }
149 }
150 }
151 return false;
152}
153
154/* for now we need full overlap,
155 * supporting partial overlap could be done but gets complicated
156 * when trimming endpoints is not enough to ensure consistency.
157 */
159 BMEdgeLoopStore *el_store_a,
160 BMEdgeLoopStore *el_store_b)
161{
162 bool has_overlap = true;
163 ListBaseT<LinkData> *lb_a = BM_edgeloop_verts_get(el_store_a);
164 ListBaseT<LinkData> *lb_b = BM_edgeloop_verts_get(el_store_b);
165
166 bm_edgeloop_vert_tag(el_store_a, false);
167 bm_edgeloop_vert_tag(el_store_b, true);
168
169 for (LinkData &node : *lb_a) {
170 if (bm_vert_is_tag_edge_connect(bm, static_cast<BMVert *>(node.data)) == false) {
171 has_overlap = false;
172 goto finally;
173 }
174 }
175
176 bm_edgeloop_vert_tag(el_store_a, true);
177 bm_edgeloop_vert_tag(el_store_b, false);
178
179 for (LinkData &node : *lb_b) {
180 if (bm_vert_is_tag_edge_connect(bm, static_cast<BMVert *>(node.data)) == false) {
181 has_overlap = false;
182 goto finally;
183 }
184 }
185
186finally:
187 bm_edgeloop_vert_tag(el_store_a, false);
188 bm_edgeloop_vert_tag(el_store_b, false);
189 return has_overlap;
190}
191
193
194/* -------------------------------------------------------------------- */
199
200using BMEdgeLoopStorePair = std::pair<BMEdgeLoopStore *, BMEdgeLoopStore *>;
201
203 ListBaseT<BMEdgeLoopStore> *eloops_rim)
204{
218
219 VectorSet<BMEdgeLoopStorePair> eloop_pair_set;
221
222 BMEdgeLoopStore *el_store;
223
224 /* create vert -> eloop map */
225 for (el_store = eloops_rim->first(); el_store; el_store = BM_EDGELOOP_NEXT(el_store)) {
226 LinkData *node = BM_edgeloop_verts_get(el_store)->first();
227 do {
228 vert_eloop_map.add(static_cast<BMVert *>(node->data), el_store);
229 } while ((node = node->next));
230 }
231
232 /* collect eloop pairs */
233 for (el_store = eloops_rim->first(); el_store; el_store = BM_EDGELOOP_NEXT(el_store)) {
234 BMIter eiter;
235 BMEdge *e;
236
237 BMVert *v = static_cast<BMVert *>((BM_edgeloop_verts_get(el_store)->first())->data);
238
239 BM_ITER_ELEM (e, &eiter, (BMVert *)v, BM_EDGES_OF_VERT) {
241 BMVert *v_other = BM_edge_other_vert(e, v);
242 BMEdgeLoopStorePair pair_test;
243
244 BMEdgeLoopStore *el_store_other = vert_eloop_map.lookup_default(v_other, nullptr);
245
246 /* in rare cases we can't find a match */
247 if (el_store_other) {
248 pair_test.first = el_store;
249 pair_test.second = el_store_other;
250
251 if (pair_test.first > pair_test.second) {
252 std::swap(pair_test.first, pair_test.second);
253 }
254 /* The pair may exist already. */
255 eloop_pair_set.add(pair_test);
256 }
257 }
258 }
259 }
260
261 return eloop_pair_set;
262}
263
265
266/* -------------------------------------------------------------------- */
269
271 BMesh *bm, ListBaseT<BMEdgeLoopStore> *eloops, BMEdge *e, BMVert *v_a, const int cuts)
272{
273 BMEdgeLoopStore *eloop;
275 BMVert *v_b;
277
278 v_b = BM_edge_other_vert(e, v_a);
279
280 BM_edge_split_n(bm, e, cuts, &v_arr[1]);
281 if (v_a == e->v1) {
282 v_arr[0] = v_a;
283 v_arr[cuts + 1] = v_b;
284 }
285 else {
286 v_arr[0] = v_b;
287 v_arr[cuts + 1] = v_a;
288 }
289
290 eloop = BM_edgeloop_from_verts(v_arr.data(), cuts + 2, false);
291
292 if (v_a == e->v1) {
293 BM_edgeloop_flip(bm, eloop);
294 }
295
296 BLI_addtail(eloops, eloop);
297}
298
300
301/* -------------------------------------------------------------------- */
304
315static void bm_vert_calc_surface_tangent(BMesh *bm, BMVert *v, float r_no[3])
316{
317 BMIter eiter;
318 BMEdge *e;
319
320 /* get outer normal, fall back to inner (if this vertex is on a boundary) */
321 bool found_outer = false, found_inner = false, found_outer_tag = false;
322
323 float no_outer[3] = {0.0f}, no_inner[3] = {0.0f};
324
325 /* first find rim edges, typically we will only add 2 normals */
326 BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) {
327 if (BM_edge_is_wire(e)) [[unlikely]] {
328 /* pass - this may confuse things */
329 }
330 else if (BMO_edge_flag_test(bm, e, EDGE_RIM)) {
331 BMIter liter;
332 BMLoop *l;
333 BM_ITER_ELEM (l, &liter, e, BM_LOOPS_OF_EDGE) {
334 /* use unmarked (surrounding) faces to create surface tangent */
335 float no[3];
336 // BM_face_normal_update(l->f);
339 add_v3_v3(no_inner, no);
340 found_inner = true;
341 }
342 else {
343 add_v3_v3(no_outer, no);
344 found_outer = true;
345
346 /* other side is used too, blend midway */
347 if (BMO_face_flag_test(bm, l->f, FACE_OUT)) {
348 found_outer_tag = true;
349 }
350 }
351 }
352 }
353 }
354
355 /* detect if this vertex is in-between 2 loops (when blending multiple),
356 * if so - take both inner and outer into account */
357
358 if (found_inner && found_outer_tag) {
359 /* blend between the 2 */
360 negate_v3(no_outer);
361 normalize_v3(no_outer);
362 normalize_v3(no_inner);
363 add_v3_v3v3(r_no, no_outer, no_inner);
364 normalize_v3(r_no);
365 }
366 else if (found_outer) {
367 negate_v3(no_outer);
368 normalize_v3_v3(r_no, no_outer);
369 }
370 else {
371 /* we always have inner geometry */
372 BLI_assert(found_inner == true);
373 normalize_v3_v3(r_no, no_inner);
374 }
375}
376
381static void bm_faces_share_tag_flush(BMesh *bm, BMEdge **e_arr, const uint e_arr_len)
382{
383 uint i;
384
385 for (i = 0; i < e_arr_len; i++) {
386 BMEdge *e = e_arr[i];
387 BMLoop *l_iter, *l_first;
388
389 l_iter = l_first = e->l;
390 do {
391 if (!BMO_face_flag_test(bm, l_iter->f, FACE_SHARED)) {
392 if (bmo_face_is_vert_tag_all(bm, l_iter->f, VERT_SHARED)) {
394 }
395 }
396 } while ((l_iter = l_iter->radial_next) != l_first);
397 }
398}
399
403static void bm_faces_share_tag_clear(BMesh *bm, BMEdge **e_arr_iter, const uint e_arr_len_iter)
404{
405 uint i;
406
407 for (i = 0; i < e_arr_len_iter; i++) {
408 BMEdge *e = e_arr_iter[i];
409 BMLoop *l_iter, *l_first;
410
411 l_iter = l_first = e->l;
412 do {
414 } while ((l_iter = l_iter->radial_next) != l_first);
415 }
416}
417
426 /* handle array for splines */
429
430 /* since we don't have reliable index values into the array,
431 * store a map (BMVert -> index) */
434};
435
437 BMEdgeLoopStore *el_store_a,
438 BMEdgeLoopStore *el_store_b,
439 const int interp_mode)
440{
442
443 if (interp_mode == SUBD_RING_INTERP_SURF) {
444 const uint len_a = BM_edgeloop_length_get(el_store_a);
445 const uint len_b = BM_edgeloop_length_get(el_store_b);
446 const uint e_arr_a_len = len_a - (BM_edgeloop_is_closed(el_store_a) ? 0 : 1);
447 const uint e_arr_b_len = len_b - (BM_edgeloop_is_closed(el_store_b) ? 0 : 1);
450 uint i;
451
452 BMEdgeLoopStore *el_store_pair[2] = {el_store_a, el_store_b};
453 uint side_index;
454 float (*nors_pair[2])[3];
455 Map<BMVert *, uint> *nors_gh_pair[2];
456
457 BM_edgeloop_edges_get(el_store_a, e_arr_a.data());
458 BM_edgeloop_edges_get(el_store_b, e_arr_b.data());
459
460 lpair->nors_a = MEM_new_array_uninitialized<float[3]>(len_a, __func__);
461 lpair->nors_b = MEM_new_array_uninitialized<float[3]>(len_b, __func__);
462
463 nors_pair[0] = lpair->nors_a;
464 nors_pair[1] = lpair->nors_b;
465
466 lpair->nors_gh_a = MEM_new<Map<BMVert *, uint>>(__func__);
467 lpair->nors_gh_b = MEM_new<Map<BMVert *, uint>>(__func__);
468
469 nors_gh_pair[0] = lpair->nors_gh_a;
470 nors_gh_pair[1] = lpair->nors_gh_b;
471
472 /* now calculate nor */
473
474 /* all other verts must _not_ be tagged */
475 bmo_edgeloop_vert_tag(bm, el_store_a, VERT_SHARED, true);
476 bmo_edgeloop_vert_tag(bm, el_store_b, VERT_SHARED, true);
477
478 /* tag all faces that are in-between both loops */
479 bm_faces_share_tag_flush(bm, e_arr_a.data(), e_arr_a_len);
480 bm_faces_share_tag_flush(bm, e_arr_b.data(), e_arr_b_len);
481
482 /* now we have all data we need, calculate vertex spline nor! */
483 for (side_index = 0; side_index < 2; side_index++) {
484 /* iter vars */
485 BMEdgeLoopStore *el_store = el_store_pair[side_index];
486 ListBaseT<LinkData> *lb = BM_edgeloop_verts_get(el_store);
487 Map<BMVert *, uint> *nors_gh_iter = nors_gh_pair[side_index];
488 float (*nor)[3] = nors_pair[side_index];
489
490 LinkData *v_iter;
491
492 for (v_iter = lb->first(), i = 0; v_iter; v_iter = v_iter->next, i++) {
493 BMVert *v = static_cast<BMVert *>(v_iter->data);
495 nors_gh_iter->add(v, i);
496 }
497 }
498
499 /* cleanup verts share */
500 bmo_edgeloop_vert_tag(bm, el_store_a, VERT_SHARED, false);
501 bmo_edgeloop_vert_tag(bm, el_store_b, VERT_SHARED, false);
502
503 /* cleanup faces share */
504 bm_faces_share_tag_clear(bm, e_arr_a.data(), e_arr_a_len);
505 bm_faces_share_tag_clear(bm, e_arr_b.data(), e_arr_b_len);
506 }
507 return lpair;
508}
509
510static void bm_edgering_pair_store_free(LoopPairStore *lpair, const int interp_mode)
511{
512 if (interp_mode == SUBD_RING_INTERP_SURF) {
513 MEM_delete(lpair->nors_a);
514 MEM_delete(lpair->nors_b);
515
516 MEM_delete(lpair->nors_gh_a);
517 MEM_delete(lpair->nors_gh_b);
518 }
519 MEM_delete(lpair);
520}
521
523
524/* -------------------------------------------------------------------- */
527
529 LoopPairStore *lpair,
530 BMEdgeLoopStore *el_store_a,
531 BMEdgeLoopStore *el_store_b,
532 ListBaseT<BMEdgeLoopStore> *eloops_ring,
533 const int interp_mode,
534 const int cuts,
535 const float smooth,
536 const float *falloff_cache)
537{
538 const int resolu = cuts + 2;
539 const int dims = 3;
540 bool is_a_no_valid, is_b_no_valid;
541 int i;
542
543 float el_store_a_co[3], el_store_b_co[3];
544 float el_store_a_no[3], el_store_b_no[3];
545
546 BMEdgeLoopStore *el_store_ring;
547
548 float (*coord_array_main)[3] = nullptr;
549
550 BM_edgeloop_calc_center(bm, el_store_a);
551 BM_edgeloop_calc_center(bm, el_store_b);
552
553 is_a_no_valid = BM_edgeloop_calc_normal(bm, el_store_a);
554 is_b_no_valid = BM_edgeloop_calc_normal(bm, el_store_b);
555
556 copy_v3_v3(el_store_a_co, BM_edgeloop_center_get(el_store_a));
557 copy_v3_v3(el_store_b_co, BM_edgeloop_center_get(el_store_b));
558
559 /* correct normals need to be flipped to face each other
560 * we know both normals point in the same direction so one will need flipping */
561 {
562 float el_dir[3];
563 float no[3];
564 sub_v3_v3v3(el_dir, el_store_a_co, el_store_b_co);
565 normalize_v3_v3(no, el_dir);
566
567 if (is_a_no_valid == false) {
568 is_a_no_valid = BM_edgeloop_calc_normal_aligned(bm, el_store_a, no);
569 }
570 if (is_b_no_valid == false) {
571 is_b_no_valid = BM_edgeloop_calc_normal_aligned(bm, el_store_b, no);
572 }
573 (void)is_a_no_valid, (void)is_b_no_valid;
574
575 copy_v3_v3(el_store_a_no, BM_edgeloop_normal_get(el_store_a));
576 copy_v3_v3(el_store_b_no, BM_edgeloop_normal_get(el_store_b));
577
578 if (dot_v3v3(el_store_a_no, el_dir) > 0.0f) {
579 negate_v3(el_store_a_no);
580 }
581 if (dot_v3v3(el_store_b_no, el_dir) < 0.0f) {
582 negate_v3(el_store_b_no);
583 }
584 }
585 /* now normals are correct, don't touch! */
586
587 /* Calculate the center spline, multiple. */
588 if ((interp_mode == SUBD_RING_INTERP_PATH) || falloff_cache) {
589 float handle_a[3], handle_b[3];
590 float handle_len;
591
592 handle_len = bezier_handle_calc_length_v3(
593 el_store_a_co, el_store_a_no, el_store_b_co, el_store_b_no) *
594 smooth;
595
596 mul_v3_v3fl(handle_a, el_store_a_no, handle_len);
597 mul_v3_v3fl(handle_b, el_store_b_no, handle_len);
598
599 add_v3_v3(handle_a, el_store_a_co);
600 add_v3_v3(handle_b, el_store_b_co);
601
602 coord_array_main = MEM_new_array_uninitialized<float[3]>(resolu, __func__);
603
604 for (i = 0; i < dims; i++) {
605 BKE_curve_forward_diff_bezier(el_store_a_co[i],
606 handle_a[i],
607 handle_b[i],
608 el_store_b_co[i],
609 (reinterpret_cast<float *>(coord_array_main)) + i,
610 resolu - 1,
611 sizeof(float) * dims);
612 }
613 }
614
615 switch (interp_mode) {
617 if (falloff_cache) {
618 float (*coord_array)[3] = MEM_new_array_uninitialized<float[3]>(resolu, __func__);
619 for (i = 0; i < resolu; i++) {
621 coord_array[i], el_store_a_co, el_store_b_co, float(i) / float(resolu - 1));
622 }
623
624 for (el_store_ring = eloops_ring->first(); el_store_ring;
625 el_store_ring = BM_EDGELOOP_NEXT(el_store_ring))
626 {
627 ListBaseT<LinkData> *lb_ring = BM_edgeloop_verts_get(el_store_ring);
628 LinkData *v_iter;
629
630 for (v_iter = lb_ring->first(), i = 0; v_iter; v_iter = v_iter->next, i++) {
631 if (i > 0 && i < resolu - 1) {
632 /* shape */
633 if (falloff_cache) {
634 interp_v3_v3v3((static_cast<BMVert *>(v_iter->data))->co,
635 coord_array[i],
636 (static_cast<BMVert *>(v_iter->data))->co,
637 falloff_cache[i]);
638 }
639 }
640 }
641 }
642
643 MEM_delete(coord_array);
644 }
645
646 break;
647 }
649 float (*direction_array)[3] = MEM_new_array_uninitialized<float[3]>(resolu, __func__);
650 float (*quat_array)[4] = MEM_new_array_uninitialized<float[4]>(resolu, __func__);
651 float (*tri_array)[3][3] = MEM_new_array_uninitialized<float[3][3]>(resolu, __func__);
652 float (*tri_sta)[3], (*tri_end)[3], (*tri_tmp)[3];
653
654 /* very similar to make_bevel_list_3D_minimum_twist */
655
656 /* calculate normals */
657 copy_v3_v3(direction_array[0], el_store_a_no);
658 negate_v3_v3(direction_array[resolu - 1], el_store_b_no);
659 for (i = 1; i < resolu - 1; i++) {
660 bisect_v3_v3v3v3(direction_array[i],
661 coord_array_main[i - 1],
662 coord_array_main[i],
663 coord_array_main[i + 1]);
664 }
665
666 vec_to_quat(quat_array[0], direction_array[0], 5, 1);
667 normalize_qt(quat_array[0]);
668
669 for (i = 1; i < resolu; i++) {
670 float angle = angle_normalized_v3v3(direction_array[i - 1], direction_array[i]);
671 // BLI_assert(angle < DEG2RADF(90.0f));
672 if (angle > 0.0f) { /* otherwise we can keep as is */
673 float cross_tmp[3];
674 float q[4];
675 cross_v3_v3v3(cross_tmp, direction_array[i - 1], direction_array[i]);
676 axis_angle_to_quat(q, cross_tmp, angle);
677 mul_qt_qtqt(quat_array[i], q, quat_array[i - 1]);
678 normalize_qt(quat_array[i]);
679 }
680 else {
681 copy_qt_qt(quat_array[i], quat_array[i - 1]);
682 }
683 }
684
685 /* init base tri */
686 for (i = 0; i < resolu; i++) {
687 int j;
688
689 const float shape_size = falloff_cache ? falloff_cache[i] : 1.0f;
690
691 tri_tmp = tri_array[i];
692
693 /* create the triangle and transform */
694 for (j = 0; j < 3; j++) {
695 zero_v3(tri_tmp[j]);
696 if (j == 1) {
697 tri_tmp[j][0] = shape_size;
698 }
699 else if (j == 2) {
700 tri_tmp[j][1] = shape_size;
701 }
702 mul_qt_v3(quat_array[i], tri_tmp[j]);
703 add_v3_v3(tri_tmp[j], coord_array_main[i]);
704 }
705 }
706
707 tri_sta = tri_array[0];
708 tri_end = tri_array[resolu - 1];
709
710 for (el_store_ring = eloops_ring->first(); el_store_ring;
711 el_store_ring = BM_EDGELOOP_NEXT(el_store_ring))
712 {
713 ListBaseT<LinkData> *lb_ring = BM_edgeloop_verts_get(el_store_ring);
714 LinkData *v_iter;
715
716 BMVert *v_a = static_cast<BMVert *>(lb_ring->first()->data);
717 BMVert *v_b = static_cast<BMVert *>(lb_ring->last()->data);
718
719 /* skip first and last */
720 for (v_iter = (lb_ring->first())->next, i = 1; v_iter != lb_ring->last();
721 v_iter = v_iter->next, i++)
722 {
723 float co_a[3], co_b[3];
724
725 tri_tmp = tri_array[i];
726
727 transform_point_by_tri_v3(co_a, v_a->co, UNPACK3(tri_tmp), UNPACK3(tri_sta));
728 transform_point_by_tri_v3(co_b, v_b->co, UNPACK3(tri_tmp), UNPACK3(tri_end));
729
731 (static_cast<BMVert *>(v_iter->data))->co, co_a, co_b, float(i) / float(resolu - 1));
732 }
733 }
734
735 MEM_delete(direction_array);
736 MEM_delete(quat_array);
737 MEM_delete(tri_array);
738 break;
739 }
741 float (*coord_array)[3] = MEM_new_array_uninitialized<float[3]>(resolu, __func__);
742
743 /* calculate a bezier handle per edge ring */
744 for (el_store_ring = eloops_ring->first(); el_store_ring;
745 el_store_ring = BM_EDGELOOP_NEXT(el_store_ring))
746 {
747 ListBaseT<LinkData> *lb_ring = BM_edgeloop_verts_get(el_store_ring);
748 LinkData *v_iter;
749
750 BMVert *v_a = static_cast<BMVert *>(lb_ring->first()->data);
751 BMVert *v_b = static_cast<BMVert *>(lb_ring->last()->data);
752
753 float co_a[3], no_a[3], handle_a[3], co_b[3], no_b[3], handle_b[3];
754 float handle_len;
755
756 copy_v3_v3(co_a, v_a->co);
757 copy_v3_v3(co_b, v_b->co);
758
759/* don't calculate normals here else we get into feedback loop
760 * when subdividing 2+ connected edge rings */
761#if 0
764#else
765 {
766 const uint index_a = lpair->nors_gh_a->lookup(v_a);
767 const uint index_b = lpair->nors_gh_b->lookup(v_b);
768
769 copy_v3_v3(no_a, lpair->nors_a[index_a]);
770 copy_v3_v3(no_b, lpair->nors_b[index_b]);
771 }
772#endif
773 handle_len = bezier_handle_calc_length_v3(co_a, no_a, co_b, no_b) * smooth;
774
775 mul_v3_v3fl(handle_a, no_a, handle_len);
776 mul_v3_v3fl(handle_b, no_b, handle_len);
777
778 add_v3_v3(handle_a, co_a);
779 add_v3_v3(handle_b, co_b);
780
781 for (i = 0; i < dims; i++) {
783 handle_a[i],
784 handle_b[i],
785 co_b[i],
786 (reinterpret_cast<float *>(coord_array)) + i,
787 resolu - 1,
788 sizeof(float) * dims);
789 }
790
791 /* skip first and last */
792 for (v_iter = lb_ring->first()->next, i = 1; v_iter != lb_ring->last();
793 v_iter = v_iter->next, i++)
794 {
795 if (i > 0 && i < resolu - 1) {
796 copy_v3_v3((static_cast<BMVert *>(v_iter->data))->co, coord_array[i]);
797
798 /* shape */
799 if (falloff_cache) {
800 interp_v3_v3v3((static_cast<BMVert *>(v_iter->data))->co,
801 coord_array_main[i],
802 (static_cast<BMVert *>(v_iter->data))->co,
803 falloff_cache[i]);
804 }
805 }
806 }
807 }
808
809 MEM_delete(coord_array);
810
811 break;
812 }
813 }
814
815 if (coord_array_main) {
816 MEM_delete(coord_array_main);
817 }
818}
819
823static void bm_face_slice(BMesh *bm, BMLoop *l, const int cuts)
824{
825 /* TODO: interpolate edge data. */
826 BMLoop *l_new = l;
827 int i;
828
829 for (i = 0; i < cuts; i++) {
830 /* no chance of double */
831 BM_face_split(bm, l_new->f, l_new->prev, l_new->next->next, &l_new, nullptr, false);
832 if (l_new == nullptr) {
833 /* This happens when l_new->prev and l_new->next->next are adjacent. Since
834 * this sets l_new to nullptr, we cannot continue this for-loop. */
835 break;
836 }
837 if (l_new->f->len < l_new->radial_next->f->len) {
838 l_new = l_new->radial_next;
839 }
842 }
843}
844
846 BMEdgeLoopStore *el_store_a,
847 BMEdgeLoopStore *el_store_b)
848{
849 ListBaseT<LinkData> *lb_a = BM_edgeloop_verts_get(el_store_a);
850 ListBaseT<LinkData> *lb_b = BM_edgeloop_verts_get(el_store_b);
851
852 LinkData *v_iter_a_first = lb_a->first();
853 LinkData *v_iter_b_first = lb_b->first();
854
855 LinkData *v_iter_a_step = v_iter_a_first;
856 LinkData *v_iter_b_step = v_iter_b_first;
857
858 /* we _must_ have same starting edge shared */
859 BLI_assert(BM_edge_exists(static_cast<BMVert *>(v_iter_a_first->data),
860 static_cast<BMVert *>(v_iter_b_first->data)));
861
862 /* step around any fan-faces on both sides */
863 do {
864 v_iter_a_step = v_iter_a_step->next;
865 } while (v_iter_a_step && (BM_edge_exists(static_cast<BMVert *>(v_iter_a_step->data),
866 static_cast<BMVert *>(v_iter_b_first->data)) ||
867 BM_edge_exists(static_cast<BMVert *>(v_iter_a_step->data),
868 static_cast<BMVert *>(v_iter_b_first->next->data))));
869 do {
870 v_iter_b_step = v_iter_b_step->next;
871 } while (v_iter_b_step && (BM_edge_exists(static_cast<BMVert *>(v_iter_b_step->data),
872 static_cast<BMVert *>(v_iter_a_first->data)) ||
873 BM_edge_exists(static_cast<BMVert *>(v_iter_b_step->data),
874 static_cast<BMVert *>(v_iter_a_first->next->data))));
875
876 v_iter_a_step = v_iter_a_step ? v_iter_a_step->prev : lb_a->last();
877 v_iter_b_step = v_iter_b_step ? v_iter_b_step->prev : lb_b->last();
878
879 return !(BM_edge_exists(static_cast<BMVert *>(v_iter_a_step->data),
880 static_cast<BMVert *>(v_iter_b_step->data)) ||
881 BM_edge_exists(static_cast<BMVert *>(v_iter_a_first->next->data),
882 static_cast<BMVert *>(v_iter_b_step->data)) ||
883 BM_edge_exists(static_cast<BMVert *>(v_iter_b_first->next->data),
884 static_cast<BMVert *>(v_iter_a_step->data)));
885}
886
892 BMEdgeLoopStore *el_store_a,
893 BMEdgeLoopStore *el_store_b)
894{
895 ListBaseT<LinkData> *lb_a = BM_edgeloop_verts_get(el_store_a);
896 ListBaseT<LinkData> *lb_b = BM_edgeloop_verts_get(el_store_b);
897
898 LinkData *node;
899
900 bm_edgeloop_vert_tag(el_store_a, false);
901 bm_edgeloop_vert_tag(el_store_b, true);
902
903 /* before going much further, get ourselves in order
904 * - align loops (not strictly necessary but handy)
905 * - ensure winding is set for both loops */
906 if (BM_edgeloop_is_closed(el_store_a) && BM_edgeloop_is_closed(el_store_b)) {
907 BMIter eiter;
908 BMEdge *e;
909 BMVert *v_other;
910
911 node = lb_a->first();
912
913 BM_ITER_ELEM (e, &eiter, (BMVert *)node->data, BM_EDGES_OF_VERT) {
915 v_other = BM_edge_other_vert(e, static_cast<BMVert *>(node->data));
916 if (BM_elem_flag_test(v_other, BM_ELEM_TAG)) {
917 break;
918 }
919 v_other = nullptr;
920 }
921 }
922 BLI_assert(v_other != nullptr);
923
924 for (node = lb_b->first(); node; node = node->next) {
925 if (node->data == v_other) {
926 break;
927 }
928 }
929 BLI_assert(node != nullptr);
930
932
933 /* now check we are winding the same way */
934 if (bm_edgering_pair_order_is_flipped(bm, el_store_a, el_store_b)) {
935 BM_edgeloop_flip(bm, el_store_b);
936 /* re-ensure the first node */
938 }
939
940 /* sanity checks that we are aligned & winding now */
941 BLI_assert(bm_edgering_pair_order_is_flipped(bm, el_store_a, el_store_b) == false);
942 }
943 else {
944 /* If we don't share and edge - flip. */
945 BMEdge *e = BM_edge_exists((static_cast<BMVert *>(lb_a->first()->data)),
946 (static_cast<BMVert *>(lb_b->first()->data)));
947 if (e == nullptr || !BMO_edge_flag_test(bm, e, EDGE_RING)) {
948 BM_edgeloop_flip(bm, el_store_b);
949 }
950 }
951
952 /* for cases with multiple loops */
953 bm_edgeloop_vert_tag(el_store_b, false);
954}
955
962 BMEdgeLoopStore *el_store_a,
963 BMEdgeLoopStore *el_store_b,
964 ListBaseT<BMEdgeLoopStore> *eloops_ring,
965 const int cuts)
966{
967 ListBaseT<LinkData> *lb_a = BM_edgeloop_verts_get(el_store_a);
968 // ListBaseT<LinkData> *lb_b = BM_edgeloop_verts_get(el_store_b);
969 const int stack_max = max_ii(BM_edgeloop_length_get(el_store_a),
970 BM_edgeloop_length_get(el_store_b)) *
971 2;
972 Array<BMEdge *, BM_DEFAULT_TOPOLOGY_STACK_SIZE> edges_ring_arr_buf(stack_max);
973 Array<BMFace *, BM_DEFAULT_TOPOLOGY_STACK_SIZE> faces_ring_arr_buf(stack_max);
974 BMEdge **edges_ring_arr = edges_ring_arr_buf.data();
975 BMFace **faces_ring_arr = faces_ring_arr_buf.data();
976 STACK_DECLARE(edges_ring_arr);
977 STACK_DECLARE(faces_ring_arr);
978 BMEdgeLoopStore *el_store_ring;
979 BMEdge *e;
980 BMFace *f;
981
982 STACK_INIT(edges_ring_arr, stack_max);
983 STACK_INIT(faces_ring_arr, stack_max);
984
985 bm_edgeloop_vert_tag(el_store_a, false);
986 bm_edgeloop_vert_tag(el_store_b, true);
987
988 for (LinkData &node : *lb_a) {
989 BMIter eiter;
990
991 BM_ITER_ELEM (e, &eiter, (BMVert *)node.data, BM_EDGES_OF_VERT) {
993 BMVert *v_other = BM_edge_other_vert(e, static_cast<BMVert *>(node.data));
994 if (BM_elem_flag_test(v_other, BM_ELEM_TAG)) {
995 BMIter fiter;
996
998 STACK_PUSH(edges_ring_arr, e);
999
1000 /* add faces to the stack */
1001 BM_ITER_ELEM (f, &fiter, e, BM_FACES_OF_EDGE) {
1002 if (BMO_face_flag_test(bm, f, FACE_OUT)) {
1005 STACK_PUSH(faces_ring_arr, f);
1006 }
1007 }
1008 }
1009 }
1010 }
1011 }
1012 }
1013
1014 while ((e = STACK_POP(edges_ring_arr))) {
1015 /* found opposite edge */
1016 BMVert *v_other;
1017
1019
1020 /* unrelated to subdiv, but if we _don't_ clear flag, multiple rings fail */
1022
1023 v_other = BM_elem_flag_test(e->v1, BM_ELEM_TAG) ? e->v1 : e->v2;
1024 bm_edge_subdiv_as_loop(bm, eloops_ring, e, v_other, cuts);
1025 }
1026
1027 while ((f = STACK_POP(faces_ring_arr))) {
1028 BMLoop *l_iter, *l_first;
1029
1031
1032 /* Check each edge of the face */
1033 l_iter = l_first = BM_FACE_FIRST_LOOP(f);
1034 do {
1035 if (BMO_edge_flag_test(bm, l_iter->e, EDGE_RIM)) {
1036 bm_face_slice(bm, l_iter, cuts);
1037 break;
1038 }
1039 } while ((l_iter = l_iter->next) != l_first);
1040 }
1041
1042 /* Clear tags so subdiv verts don't get tagged too. */
1043 for (el_store_ring = eloops_ring->first(); el_store_ring;
1044 el_store_ring = BM_EDGELOOP_NEXT(el_store_ring))
1045 {
1046 bm_edgeloop_vert_tag(el_store_ring, false);
1047 }
1048
1049 /* cleanup after */
1050 bm_edgeloop_vert_tag(el_store_b, false);
1051}
1052
1054 LoopPairStore *lpair,
1055 BMEdgeLoopStore *el_store_a,
1056 BMEdgeLoopStore *el_store_b,
1057 const int interp_mode,
1058 const int cuts,
1059 const float smooth,
1060 const float *falloff_cache)
1061{
1062 ListBaseT<BMEdgeLoopStore> eloops_ring = {nullptr};
1063 bm_edgering_pair_order(bm, el_store_a, el_store_b);
1064 bm_edgering_pair_subdiv(bm, el_store_a, el_store_b, &eloops_ring, cuts);
1066 bm, lpair, el_store_a, el_store_b, &eloops_ring, interp_mode, cuts, smooth, falloff_cache);
1067 BM_mesh_edgeloops_free(&eloops_ring);
1068}
1069
1071{
1072 /* NOTE: keep this operator fast, its used in a modifier. */
1073
1074 ListBaseT<BMEdgeLoopStore> eloops_rim = {nullptr};
1075 BMOIter siter;
1076 BMEdge *e;
1077 int count;
1078 bool changed = false;
1079
1080 const int cuts = BMO_slot_int_get(op->slots_in, "cuts");
1081 const int interp_mode = BMO_slot_int_get(op->slots_in, "interp_mode");
1082 const float smooth = BMO_slot_float_get(op->slots_in, "smooth");
1083 const int resolu = cuts + 2;
1084
1085 /* optional 'shape' */
1086 const int profile_shape = BMO_slot_int_get(op->slots_in, "profile_shape");
1087 const float profile_shape_factor = BMO_slot_float_get(op->slots_in, "profile_shape_factor");
1089 (profile_shape_factor != 0.0f) ? cuts + 2 : 0);
1090 float *falloff_cache = (profile_shape_factor != 0.0f) ? falloff_cache_buf.data() : nullptr;
1091
1093
1095
1096 /* -------------------------------------------------------------------- */
1097 /* flag outer edges (loops defined as edges on the bounds of the edge ring) */
1098
1099 BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) {
1100 BMIter fiter;
1101 BMFace *f;
1102
1103 BM_ITER_ELEM (f, &fiter, e, BM_FACES_OF_EDGE) {
1104 /* could support ngons, other areas would need updating too, see #48926. */
1105 if ((f->len <= 4) && !BMO_face_flag_test(bm, f, FACE_OUT)) {
1106 BMIter liter;
1107 BMLoop *l;
1108 bool ok = false;
1109
1110 /* check at least 2 edges in the face are rings */
1111 BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
1112 if (BMO_edge_flag_test(bm, l->e, EDGE_RING) && e != l->e) {
1113 ok = true;
1114 break;
1115 }
1116 }
1117
1118 if (ok) {
1120
1121 BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
1122 if (!BMO_edge_flag_test(bm, l->e, EDGE_RING)) {
1124 }
1125 }
1126 }
1127 }
1128 }
1129 }
1130
1131 /* -------------------------------------------------------------------- */
1132 /* Cache falloff for each step (symmetrical) */
1133
1134 if (falloff_cache) {
1135 int i;
1136 for (i = 0; i < resolu; i++) {
1137 float shape_size = 1.0f;
1138 float fac = float(i) / float(resolu - 1);
1139 fac = fabsf(1.0f - 2.0f * fabsf(0.5f - fac));
1140 fac = bmesh_subd_falloff_calc(profile_shape, fac);
1141 shape_size += fac * profile_shape_factor;
1142
1143 falloff_cache[i] = shape_size;
1144 }
1145 }
1146
1147 /* -------------------------------------------------------------------- */
1148 /* Execute subdivision on all ring pairs */
1149
1150 count = BM_mesh_edgeloops_find(
1151 bm, &eloops_rim, [&](BMEdge *e) { return BMO_edge_flag_test_bool(bm, e, EDGE_RIM); });
1152
1153 if (count < 2) {
1154 BMO_error_raise(bm, op, BMO_ERROR_CANCEL, "No edge rings found");
1155 goto cleanup;
1156 }
1157 else if (count == 2) {
1158 /* this case could be removed,
1159 * but simple to avoid 'bm_edgering_pair_calc' in this case since there's only one. */
1160 BMEdgeLoopStore *el_store_a = eloops_rim.first();
1161 BMEdgeLoopStore *el_store_b = eloops_rim.last();
1162 LoopPairStore *lpair;
1163
1164 if (bm_edgeloop_check_overlap_all(bm, el_store_a, el_store_b)) {
1165 lpair = bm_edgering_pair_store_create(bm, el_store_a, el_store_b, interp_mode);
1166 }
1167 else {
1168 lpair = nullptr;
1169 }
1170
1171 if (lpair) {
1173 bm, lpair, el_store_a, el_store_b, interp_mode, cuts, smooth, falloff_cache);
1174 bm_edgering_pair_store_free(lpair, interp_mode);
1175 changed = true;
1176 }
1177 else {
1178 BMO_error_raise(bm, op, BMO_ERROR_CANCEL, "Edge-ring pair isn't connected");
1179 goto cleanup;
1180 }
1181 }
1182 else {
1183 const VectorSet<BMEdgeLoopStorePair> eloop_pairs_gs = bm_edgering_pair_calc(bm, &eloops_rim);
1184 LoopPairStore **lpair_arr;
1185
1186 if (eloop_pairs_gs.is_empty()) {
1187 BMO_error_raise(bm, op, BMO_ERROR_CANCEL, "Edge-rings are not connected");
1188 goto cleanup;
1189 }
1190
1191 Array<LoopPairStore *, BM_DEFAULT_TOPOLOGY_STACK_SIZE> lpair_arr_buf(eloop_pairs_gs.size());
1192 lpair_arr = lpair_arr_buf.data();
1193
1194 /* first cache pairs */
1195 for (const int i : eloop_pairs_gs.index_range()) {
1196 const BMEdgeLoopStorePair &eloop_pair = eloop_pairs_gs[i];
1197 BMEdgeLoopStore *el_store_a = eloop_pair.first;
1198 BMEdgeLoopStore *el_store_b = eloop_pair.second;
1199
1200 LoopPairStore *lpair;
1201 if (bm_edgeloop_check_overlap_all(bm, el_store_a, el_store_b)) {
1202 lpair = bm_edgering_pair_store_create(bm, el_store_a, el_store_b, interp_mode);
1203 }
1204 else {
1205 lpair = nullptr;
1206 }
1207 lpair_arr[i] = lpair;
1208
1210 }
1211
1212 for (const int i : eloop_pairs_gs.index_range()) {
1213 const BMEdgeLoopStorePair &eloop_pair = eloop_pairs_gs[i];
1214 BMEdgeLoopStore *el_store_a = eloop_pair.first;
1215 BMEdgeLoopStore *el_store_b = eloop_pair.second;
1216 LoopPairStore *lpair = lpair_arr[i];
1217
1218 if (lpair) {
1220 bm, lpair, el_store_a, el_store_b, interp_mode, cuts, smooth, falloff_cache);
1221 bm_edgering_pair_store_free(lpair, interp_mode);
1222 changed = true;
1223 }
1224
1226 }
1227 }
1228
1229cleanup:
1230 BM_mesh_edgeloops_free(&eloops_rim);
1231
1232 /* flag output */
1233 if (changed) {
1235 }
1236}
1237
1239
1240} // namespace blender
#define STACK_POP(stack)
#define STACK_PUSH(stack, val)
#define STACK_DECLARE(stack)
#define STACK_INIT(stack, stack_num)
Read Blender memory allocation and freeing.
#define UNPACK3(a)
#define BM_FACE_FIRST_LOOP(p)
#define BM_EDGELOOP_NEXT(el_store)
#define BM_elem_flag_set(ele, hflag, val)
#define BM_elem_flag_test(ele, hflag)
#define BM_ITER_ELEM(ele, iter, data, itype)
#define BM_ITER_MESH(ele, iter, bm, itype)
#define BMO_edge_flag_test_bool(bm, e, oflag)
#define BMO_edge_flag_test(bm, e, oflag)
#define BMO_edge_flag_enable(bm, e, oflag)
#define BMO_vert_flag_set(bm, e, oflag, val)
#define BMO_face_flag_enable(bm, e, oflag)
#define BMO_ITER(ele, iter, slot_args, slot_name, restrict_flag)
#define BMO_vert_flag_test(bm, e, oflag)
#define BMO_face_flag_disable(bm, e, oflag)
#define BMO_edge_flag_disable(bm, e, oflag)
#define BMO_face_flag_test(bm, e, oflag)
#define FACE_OUT
Definition bmo_bridge.cc:30
#define FACE_IN_STACK
#define EDGE_RING
#define EDGE_IN_STACK
#define FACE_SHARED
#define VERT_SHARED
#define EDGE_RIM
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
Definition btVector3.h:356
const T * data() const
Definition BLI_array.hh:323
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
bool add(const Key &key)
int64_t size() const
IndexRange index_range() const
#define FLT_EPSILON
float dot(VecOp< float, D >, VecOp< float, D >) RET
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
Definition math_dual.h:263
BMesh Iterators.
bool BM_edgeloop_calc_normal_aligned(BMesh *, BMEdgeLoopStore *el_store, const float no_align[3])
BMEdgeLoopStore * BM_edgeloop_from_verts(BMVert **v_arr, const int v_arr_tot, bool is_closed)
void * MEM_new_uninitialized(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void BM_edge_calc_face_tangent(const BMEdge *e, const BMLoop *e_loop, float r_tangent[3])
BMESH EDGE/FACE TANGENT.
ListBaseT< LinkData > * BM_edgeloop_verts_get(BMEdgeLoopStore *el_store)
MINLINE void negate_v3_v3(float r[3], const float a[3])
int BM_mesh_edgeloops_find(BMesh *bm, ListBaseT< BMEdgeLoopStore > *r_eloops, FunctionRef< bool(BMEdge *)> test_fn, const BMEdgeLoopFind_Params *params)
float angle_normalized_v3v3(const float v1[3], const float v2[3]) ATTR_WARN_UNUSED_RESULT
int BMO_slot_int_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
BLI_INLINE bool BM_edge_is_wire(const BMEdge *e) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void BM_edgeloop_flip(BMesh *, BMEdgeLoopStore *el_store)
MINLINE void copy_v3_v3(float r[3], const float a[3])
unsigned int uint
Definition BKE_text.h:55
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
static bool bm_edgeloop_check_overlap_all(BMesh *bm, BMEdgeLoopStore *el_store_a, BMEdgeLoopStore *el_store_b)
ATTR_WARN_UNUSED_RESULT const BMLoop * l
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
void vec_to_quat(float q[4], const float vec[3], short axis, short upflag)
static LoopPairStore * bm_edgering_pair_store_create(BMesh *bm, BMEdgeLoopStore *el_store_a, BMEdgeLoopStore *el_store_b, const int interp_mode)
void BM_mesh_edgeloops_free(ListBaseT< BMEdgeLoopStore > *eloops)
float BMO_slot_float_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
void BMO_slot_buffer_flag_enable(BMesh *bm, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, char htype, short oflag)
BMO_FLAG_BUFFER.
static void bm_edgeloop_vert_tag(BMEdgeLoopStore *el_store, const bool tag)
float normalize_qt(float q[4])
static void bm_edge_subdiv_as_loop(BMesh *bm, ListBaseT< BMEdgeLoopStore > *eloops, BMEdge *e, BMVert *v_a, const int cuts)
const float * BM_edgeloop_normal_get(BMEdgeLoopStore *el_store)
void axis_angle_to_quat(float r[4], const float axis[3], float angle)
void transform_point_by_tri_v3(float pt_tar[3], float const pt_src[3], const float tri_tar_p1[3], const float tri_tar_p2[3], const float tri_tar_p3[3], const float tri_src_p1[3], const float tri_src_p2[3], const float tri_src_p3[3])
static bool bm_edgering_pair_order_is_flipped(BMesh *, BMEdgeLoopStore *el_store_a, BMEdgeLoopStore *el_store_b)
void BM_mesh_elem_hflag_disable_all(BMesh *bm, const char htype, const char hflag, const bool respecthide)
BMVert * BM_edge_split_n(BMesh *bm, BMEdge *e, int numcuts, BMVert **r_varr)
Split an edge multiple times evenly.
MINLINE int max_ii(int a, int b)
void mul_qt_qtqt(float q[4], const float a[4], const float b[4])
ATTR_WARN_UNUSED_RESULT const BMVert * v
BLI_INLINE bool BM_vert_in_edge(const BMEdge *e, const BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
BLI_INLINE BMVert * BM_edge_other_vert(BMEdge *e, const BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
bool BM_edgeloop_is_closed(BMEdgeLoopStore *el_store)
void mul_qt_v3(const float q[4], float r[3])
static void bm_edgering_pair_order(BMesh *bm, BMEdgeLoopStore *el_store_a, BMEdgeLoopStore *el_store_b)
int BM_edgeloop_length_get(BMEdgeLoopStore *el_store)
std::pair< BMEdgeLoopStore *, BMEdgeLoopStore * > BMEdgeLoopStorePair
const float * BM_edgeloop_center_get(BMEdgeLoopStore *el_store)
static void bm_faces_share_tag_flush(BMesh *bm, BMEdge **e_arr, const uint e_arr_len)
static VectorSet< BMEdgeLoopStorePair > bm_edgering_pair_calc(BMesh *bm, ListBaseT< BMEdgeLoopStore > *eloops_rim)
void BM_edgeloop_edges_get(BMEdgeLoopStore *el_store, BMEdge **e_arr)
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
void copy_qt_qt(float q[4], const float a[4])
BMesh const char void * data
static void bm_face_slice(BMesh *bm, BMLoop *l, const int cuts)
void BMO_slot_buffer_from_enabled_flag(BMesh *bm, BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, char htype, short oflag)
static void bm_vert_calc_surface_tangent(BMesh *bm, BMVert *v, float r_no[3])
static uint bm_verts_tag_count(BMesh *bm)
void BLI_listbase_rotate_first(ListBase *lb, void *vlink) ATTR_NONNULL(1
Definition listbase.cc:869
void BM_edgeloop_calc_center(BMesh *, BMEdgeLoopStore *el_store)
MINLINE void negate_v3(float r[3])
void bmo_subdivide_edgering_exec(BMesh *bm, BMOperator *op)
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], float t)
MINLINE void zero_v3(float r[3])
float bmesh_subd_falloff_calc(const int falloff, float val)
MINLINE float normalize_v3_v3(float r[3], const float a[3])
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
BMEdge * BM_edge_exists(BMVert *v_a, BMVert *v_b)
MINLINE float normalize_v3(float n[3])
MINLINE void add_v3_v3(float r[3], const float a[3])
static float bezier_handle_calc_length_v3(const float co_a[3], const float no_a[3], const float co_b[3], const float no_b[3])
static void bmo_edgeloop_vert_tag(BMesh *bm, BMEdgeLoopStore *el_store, const short oflag, const bool tag)
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
static bool bm_vert_is_tag_edge_connect(BMesh *bm, BMVert *v)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:118
static void bm_edgering_pair_ringsubd(BMesh *bm, LoopPairStore *lpair, BMEdgeLoopStore *el_store_a, BMEdgeLoopStore *el_store_b, const int interp_mode, const int cuts, const float smooth, const float *falloff_cache)
@ SUBD_RING_INTERP_SURF
@ SUBD_RING_INTERP_PATH
@ SUBD_RING_INTERP_LINEAR
BMFace * BM_face_split(BMesh *bm, BMFace *f, BMLoop *l_a, BMLoop *l_b, BMLoop **r_l, BMEdge *example, const bool no_double)
Face Split.
float closest_to_line_v3(float r_close[3], const float p[3], const float l1[3], const float l2[3])
void bisect_v3_v3v3v3(float r[3], const float a[3], const float b[3], const float c[3])
MINLINE float len_squared_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
void BMO_error_raise(BMesh *bm, BMOperator *owner, eBMOpErrorLevel level, const char *msg) ATTR_NONNULL(1
static void bm_edgering_pair_store_free(LoopPairStore *lpair, const int interp_mode)
static void bm_edgering_pair_subdiv(BMesh *bm, BMEdgeLoopStore *el_store_a, BMEdgeLoopStore *el_store_b, ListBaseT< BMEdgeLoopStore > *eloops_ring, const int cuts)
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
ATTR_WARN_UNUSED_RESULT const BMFlagLayer const short oflag
void BKE_curve_forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride)
Definition curve.cc:1696
@ BMO_ERROR_CANCEL
bool BM_edgeloop_calc_normal(BMesh *, BMEdgeLoopStore *el_store)
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
static void bm_edgering_pair_interpolate(BMesh *bm, LoopPairStore *lpair, BMEdgeLoopStore *el_store_a, BMEdgeLoopStore *el_store_b, ListBaseT< BMEdgeLoopStore > *eloops_ring, const int interp_mode, const int cuts, const float smooth, const float *falloff_cache)
static bool bmo_face_is_vert_tag_all(BMesh *bm, BMFace *f, short oflag)
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
static void bm_faces_share_tag_clear(BMesh *bm, BMEdge **e_arr_iter, const uint e_arr_len_iter)
#define fabsf
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
struct BMLoop * next
struct BMLoop * prev
struct BMEdge * e
struct BMVert * v
struct BMLoop * radial_next
struct BMFace * f
struct BMOpSlot slots_in[BMO_OP_MAX_SLOTS]
struct BMOpSlot slots_out[BMO_OP_MAX_SLOTS]
struct LinkData * prev
struct LinkData * next
Map< BMVert *, uint > * nors_gh_a
Map< BMVert *, uint > * nors_gh_b