Blender V5.3
bmo_inset.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
11
12#include "MEM_guardedalloc.h"
13
14#include "BLI_array.hh"
15#include "BLI_math_geom_c.hh"
16#include "BLI_math_matrix_c.hh"
17#include "BLI_math_vector_c.hh"
18#include "BLI_memarena.hh"
20
21#include "DNA_modifier_enums.h"
22
23#include "BKE_customdata.hh"
24
25#include "bmesh.hh"
26
27#include "intern/bmesh_operators_private.hh" /* own include */
28
29namespace blender {
30
31/* Merge loop-data that diverges, see: #41445 */
32#define USE_LOOP_CUSTOMDATA_MERGE
33
34#define ELE_NEW 1
35
36/* -------------------------------------------------------------------- */
48
49/* just enough of a face to store interpolation data we can use once the inset is done */
50struct InterpFace {
52 void **blocks_l;
53 void **blocks_v;
55 float axis_mat[3][3];
56};
57
58/* basically a clone of #BM_vert_interp_from_face */
59static void bm_interp_face_store(InterpFace *iface, BMesh *bm, BMFace *f, MemArena *interp_arena)
60{
61 BMLoop *l_iter, *l_first;
62 void **blocks_l = iface->blocks_l = static_cast<void **>(
63 BLI_memarena_alloc(interp_arena, sizeof(*iface->blocks_l) * f->len));
64 void **blocks_v = iface->blocks_v = static_cast<void **>(
65 BLI_memarena_alloc(interp_arena, sizeof(*iface->blocks_v) * f->len));
66 float (*cos_2d)[2] = iface->cos_2d = static_cast<float (*)[2]>(
67 BLI_memarena_alloc(interp_arena, sizeof(*iface->cos_2d) * f->len));
68 void *axis_mat = iface->axis_mat;
69 int i;
70
72
73 axis_dominant_v3_to_m3(static_cast<float (*)[3]>(axis_mat), f->no);
74
75 iface->f = f;
76
77 i = 0;
78 l_iter = l_first = BM_FACE_FIRST_LOOP(f);
79 do {
80 mul_v2_m3v3(cos_2d[i], static_cast<const float (*)[3]>(axis_mat), l_iter->v->co);
81 blocks_l[i] = nullptr;
82 CustomData_bmesh_copy_block(bm->ldata, l_iter->head.data, &blocks_l[i]);
83 /* if we were not modifying the loops later we would do... */
84 // blocks[i] = l_iter->head.data;
85
86 blocks_v[i] = nullptr;
87 CustomData_bmesh_copy_block(bm->vdata, l_iter->v->head.data, &blocks_v[i]);
88
89 /* use later for index lookups */
90 BM_elem_index_set(l_iter, i); /* set_dirty */
91 } while ((void)i++, (l_iter = l_iter->next) != l_first);
93}
95{
96 void **blocks_l = iface->blocks_l;
97 void **blocks_v = iface->blocks_v;
98 int i;
99
100 for (i = 0; i < iface->f->len; i++) {
101 CustomData_bmesh_free_block(&bm->ldata, &blocks_l[i]);
102 CustomData_bmesh_free_block(&bm->vdata, &blocks_v[i]);
103 }
104}
105
106#ifdef USE_LOOP_CUSTOMDATA_MERGE
112 BMEdge *e_connect,
113 BMLoop *l_a_outer,
114 BMLoop *l_b_outer,
115 BMLoop *l_a_inner,
116 BMLoop *l_b_inner)
117{
139
140 const bool is_flip = (l_a_inner->next == l_a_outer);
141 BMLoop *l_a_inner_inset, *l_b_inner_inset;
142 BMEdge *e_a, *e_b;
143 int layer_n;
144
145 /* paranoid sanity checks */
146 BLI_assert(l_a_outer->v == l_b_outer->v);
147 BLI_assert(l_a_inner->v == l_b_inner->v);
148
149 BLI_assert(l_b_inner->f != l_a_inner->f);
150
151 BLI_assert(l_a_outer->f == l_a_inner->f);
152 BLI_assert(l_b_outer->f == l_b_inner->f);
153
154 (void)e_connect;
155 BLI_assert(BM_edge_in_face(e_connect, l_a_inner->f));
156 BLI_assert(BM_edge_in_face(e_connect, l_b_inner->f));
157
158 if (is_flip) {
159 e_a = l_a_inner->prev->e;
160 e_b = l_b_inner->e;
161 }
162 else {
163 e_a = l_a_inner->e;
164 e_b = l_b_inner->prev->e;
165 }
166
167 /* The edges must be manifold for the "other" loop to make sense. */
168 if (!BM_edge_is_manifold(e_a) || !BM_edge_is_manifold(e_b)) {
169 return;
170 }
171
172 l_a_inner_inset = BM_edge_other_loop(e_a, l_a_inner);
173 l_b_inner_inset = BM_edge_other_loop(e_b, l_b_inner);
174 BLI_assert(l_a_inner_inset->v == l_b_inner_inset->v);
175
176 /* check if there is no chance of diversion */
177 if (l_a_inner_inset->f == l_b_inner_inset->f) {
178 return;
179 }
180
181 for (layer_n = 0; layer_n < bm->ldata.totlayer; layer_n++) {
182 const int type = bm->ldata.layers[layer_n].type;
183 const int offset = bm->ldata.layers[layer_n].offset;
184 if (!CustomData_layer_has_math(&bm->ldata, layer_n)) {
185 continue;
186 }
187
188 /* check we begin with merged data */
190 BM_ELEM_CD_GET_VOID_P(l_a_outer, offset),
191 BM_ELEM_CD_GET_VOID_P(l_b_outer, offset)) == true)
192
193/* Epsilon for comparing UVs is too big, gives noticeable problems. */
194# if 0
195 &&
196 /* check if the data ends up diverged */
198 BM_ELEM_CD_GET_VOID_P(l_a_inner, offset),
199 BM_ELEM_CD_GET_VOID_P(l_b_inner, offset)) == false)
200# endif
201 )
202 {
203 /* no need to allocate a temp block:
204 * a = (a + b);
205 * a *= 0.5f;
206 * b = a;
207 */
208 const void *data_src;
209
211 BM_ELEM_CD_GET_VOID_P(l_a_inner_inset, offset),
212 BM_ELEM_CD_GET_VOID_P(l_b_inner_inset, offset),
214 0.5f);
216 BM_ELEM_CD_GET_VOID_P(l_a_inner_inset, offset),
217 BM_ELEM_CD_GET_VOID_P(l_b_inner_inset, offset));
218
219 /* use this as a reference (could be 'l_b_inner_inset' too) */
220 data_src = BM_ELEM_CD_GET_VOID_P(l_a_inner_inset, offset);
221
222 /* check if the 2 faces share an edge */
223 if (is_flip ? (l_b_inner_inset->e == l_a_inner_inset->prev->e) :
224 (l_a_inner_inset->e == l_b_inner_inset->prev->e))
225 {
226 /* simple case, we have all loops already */
227 }
228 else {
229 /* compare with (l_a_inner / l_b_inner) and assign the blended value if they match */
230 BMIter iter;
231 BMLoop *l_iter;
232 const void *data_cmp_a = BM_ELEM_CD_GET_VOID_P(l_b_inner, offset);
233 const void *data_cmp_b = BM_ELEM_CD_GET_VOID_P(l_a_inner, offset);
234 BM_ITER_ELEM (l_iter, &iter, l_a_inner_inset->v, BM_LOOPS_OF_VERT) {
235 if (BM_elem_flag_test(l_iter->f, BM_ELEM_TAG)) {
236 if (!ELEM(l_iter, l_a_inner, l_b_inner, l_a_inner_inset, l_b_inner_inset)) {
237 void *data_dst = BM_ELEM_CD_GET_VOID_P(l_iter, offset);
238
239 if (CustomData_data_equals(eCustomDataType(type), data_dst, data_cmp_a) ||
240 CustomData_data_equals(eCustomDataType(type), data_dst, data_cmp_b))
241 {
242 CustomData_data_copy_value(eCustomDataType(type), data_src, data_dst);
243 }
244 }
245 }
246 }
247 }
248
250 eCustomDataType(type), data_src, BM_ELEM_CD_GET_VOID_P(l_b_inner, offset));
252 eCustomDataType(type), data_src, BM_ELEM_CD_GET_VOID_P(l_a_inner, offset));
253 }
254 }
255}
256#endif /* USE_LOOP_CUSTOMDATA_MERGE */
257
259
260/* -------------------------------------------------------------------- */
265
267 BMFace *f,
268 MemArena *interp_arena,
269 const float thickness,
270 const float depth,
271 const bool use_even_offset,
272 const bool use_relative_offset,
273 const bool use_interpolate)
274{
275 InterpFace *iface = nullptr;
276
277 /* stores verts split away from the face (aligned with face verts) */
279 /* store edge normals (aligned with face-loop-edges) */
282
283 BMLoop *l_iter, *l_first;
284 BMLoop *l_other;
285 uint i;
286 float e_length_prev;
287
288 l_first = BM_FACE_FIRST_LOOP(f);
289
290 /* split off all loops */
291 l_iter = l_first;
292 i = 0;
293 do {
294 BMVert *v_other = l_iter->v;
295 BMVert *v_sep = BM_face_loop_separate(bm, l_iter);
296 if (v_sep == v_other) {
297 v_other = BM_vert_create(bm, l_iter->v->co, l_iter->v, BM_CREATE_NOP);
298 }
299 verts[i] = v_other;
300
301 /* unrelated to splitting, but calc here */
302 BM_edge_calc_face_tangent(l_iter->e, l_iter, edge_nors[i]);
303 } while ((void)i++, ((l_iter = l_iter->next) != l_first));
304
305 /* build rim faces */
306 l_iter = l_first;
307 i = 0;
308 do {
309 BMFace *f_new_outer;
310 BMVert *v_other = verts[i];
311 BMVert *v_other_next = verts[(i + 1) % f->len];
312
313 BMEdge *e_other = BM_edge_create(bm, v_other, v_other_next, l_iter->e, BM_CREATE_NO_DOUBLE);
314 (void)e_other;
315
316 f_new_outer = BM_face_create_quad_tri(
317 bm, v_other, v_other_next, l_iter->next->v, l_iter->v, f, BM_CREATE_NOP);
318 BMO_face_flag_enable(bm, f_new_outer, ELE_NEW);
319
320 /* copy loop data */
321 l_other = l_iter->radial_next;
322 BM_elem_attrs_copy(bm, l_iter->next, l_other->prev);
323 BM_elem_attrs_copy(bm, l_iter, l_other->next->next);
324
325 if (use_interpolate == false) {
326 BM_elem_attrs_copy(bm, l_iter->next, l_other);
327 BM_elem_attrs_copy(bm, l_iter, l_other->next);
328 }
329 } while ((void)i++, ((l_iter = l_iter->next) != l_first));
330
331 /* hold interpolation values */
332 if (use_interpolate) {
333 iface = static_cast<InterpFace *>(BLI_memarena_alloc(interp_arena, sizeof(*iface)));
334 bm_interp_face_store(iface, bm, f, interp_arena);
335 }
336
337 /* Calculate translation vector for new */
338 l_iter = l_first;
339 i = 0;
340
341 if (depth != 0.0f) {
342 e_length_prev = BM_edge_calc_length(l_iter->prev->e);
343 }
344
345 do {
346 const float *eno_prev = edge_nors[(i ? i : f->len) - 1];
347 const float *eno_next = edge_nors[i];
348 float tvec[3];
349 float v_new_co[3];
350
351 add_v3_v3v3(tvec, eno_prev, eno_next);
352 normalize_v3(tvec);
353
354 copy_v3_v3(v_new_co, l_iter->v->co);
355
356 if (use_even_offset) {
357 mul_v3_fl(tvec, shell_v3v3_mid_normalized_to_dist(eno_prev, eno_next));
358 }
359
360 /* Modify vertices and their normals */
361 if (use_relative_offset) {
362 mul_v3_fl(tvec,
363 (BM_edge_calc_length(l_iter->e) + BM_edge_calc_length(l_iter->prev->e)) / 2.0f);
364 }
365
366 madd_v3_v3fl(v_new_co, tvec, thickness);
367
368 /* Set normal, add depth and write new vertex position. */
369 copy_v3_v3(l_iter->v->no, f->no);
370
371 if (depth != 0.0f) {
372 const float e_length = BM_edge_calc_length(l_iter->e);
373 const float fac = depth * (use_relative_offset ? ((e_length_prev + e_length) * 0.5f) : 1.0f);
374 e_length_prev = e_length;
375
376 madd_v3_v3fl(v_new_co, f->no, fac);
377 }
378
379 copy_v3_v3(coords[i], v_new_co);
380 } while ((void)i++, ((l_iter = l_iter->next) != l_first));
381
382 /* update the coords */
383 l_iter = l_first;
384 i = 0;
385 do {
386 copy_v3_v3(l_iter->v->co, coords[i]);
387 } while ((void)i++, ((l_iter = l_iter->next) != l_first));
388
389 if (use_interpolate) {
391 iface->f,
392 iface->f,
393 true,
394 (const void **)iface->blocks_l,
395 (const void **)iface->blocks_v,
396 iface->cos_2d,
397 iface->axis_mat);
398
399 /* build rim faces */
400 l_iter = l_first;
401 do {
402 /* copy loop data */
403 l_other = l_iter->radial_next;
404
405 BM_elem_attrs_copy(bm, l_iter->next, l_other);
406 BM_elem_attrs_copy(bm, l_iter, l_other->next);
407 } while ((l_iter = l_iter->next) != l_first);
408
409 bm_interp_face_free(iface, bm);
410 }
411}
412
420{
421 BMFace *f;
422
423 BMOIter oiter;
424 MemArena *interp_arena = nullptr;
425
426 const float thickness = BMO_slot_float_get(op->slots_in, "thickness");
427 const float depth = BMO_slot_float_get(op->slots_in, "depth");
428 const bool use_even_offset = BMO_slot_bool_get(op->slots_in, "use_even_offset");
429 const bool use_relative_offset = BMO_slot_bool_get(op->slots_in, "use_relative_offset");
430 const bool use_interpolate = BMO_slot_bool_get(op->slots_in, "use_interpolate");
431
432 /* Only tag faces in slot */
434
436
437 if (use_interpolate) {
438 interp_arena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__);
439 }
440
441 BMO_ITER (f, &oiter, op->slots_in, "faces", BM_FACE) {
443 f,
444 interp_arena,
445 thickness,
446 depth,
447 use_even_offset,
448 use_relative_offset,
449 use_interpolate);
450
451 if (use_interpolate) {
452 BLI_memarena_clear(interp_arena);
453 }
454 }
455
456 /* we could flag new edges/verts too, is it useful? */
458
459 if (use_interpolate) {
460 BLI_memarena_free(interp_arena);
461 }
462}
463
465
466/* -------------------------------------------------------------------- */
471
479
489{
490 if (l != nullptr) [[likely]] {
491 int tot_tag = 0;
492 int tot_untag = 0;
493 BMLoop *l_iter;
494 BMLoop *l_tag = nullptr;
495 l_iter = l;
496 do {
497 if (BM_elem_flag_test(l_iter->f, BM_ELEM_TAG)) {
498 /* more than one tagged face - bail out early! */
499 if (tot_tag == 1) {
500 return nullptr;
501 }
502 l_tag = l_iter;
503 tot_tag++;
504 }
505 else {
506 tot_untag++;
507 }
508
509 } while ((l_iter = l_iter->radial_next) != l);
510
511 return ((tot_tag == 1) && (tot_untag >= 1)) ? l_tag : nullptr;
512 }
513 return nullptr;
514}
515
517{
518 BMIter iter;
519 BMEdge *e;
520
521 float len = 0.0f;
522 int tot = 0;
523
524 BM_ITER_ELEM (e, &iter, v, BM_EDGES_OF_VERT) {
525 const int i = BM_elem_index_get(e);
526 if (i != -1) {
527 len += edge_info[i].length;
528 tot++;
529 }
530 }
531
532 if (tot != 0) {
533 return len / float(tot);
534 }
535 return -1.0f;
536}
537
553 SplitEdgeInfo *edge_info,
554 BMesh *bm,
555 void **vert_lengths_p)
556{
557 struct VertLengths {
565 float length_accum;
574 int count;
575 } *vert_lengths = static_cast<VertLengths *>(*vert_lengths_p);
576
577 /* Only run this once, if needed. */
578 if (vert_lengths == nullptr) [[unlikely]] {
579 BMVert **vert_stack = MEM_new_array_uninitialized<BMVert *>(bm->totvert, __func__);
580 STACK_DECLARE(vert_stack);
581 STACK_INIT(vert_stack, bm->totvert);
582
583 vert_lengths = MEM_new_array_zeroed<VertLengths>(bm->totvert, __func__);
584
585 /* Needed for 'vert_lengths' lookup from connected vertices. */
587
588 {
589 BMIter iter;
590 BMEdge *e;
591 BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
592 if (BM_elem_index_get(e) != -1) {
593 for (int i = 0; i < 2; i++) {
594 BMVert *v = *((&e->v1) + i);
596 const int v_index = BM_elem_index_get(v);
597 if (vert_lengths[v_index].count == 0) {
598 STACK_PUSH(vert_stack, v);
599 /* Needed for the first pass, avoid a separate loop to handle the first pass. */
600 vert_lengths[v_index].count = 1;
601 /* We know the edge lengths exist in this case, should never be -1. */
602 vert_lengths[v_index].length_accum = bm_edge_info_average_length(v, edge_info);
603 BLI_assert(vert_lengths[v_index].length_accum != -1.0f);
604 }
605 }
606 }
607 }
608 }
609 }
610
611 /* While there are vertices without their accumulated lengths divided by the count. */
612 while (STACK_SIZE(vert_stack) != 0) {
613 int stack_index = STACK_SIZE(vert_stack);
614 while (stack_index--) {
615 BMVert *v = vert_stack[stack_index];
616 STACK_REMOVE(vert_stack, stack_index);
617 const int v_index = BM_elem_index_get(v);
618
619 BLI_assert(vert_lengths[v_index].count > 0);
620 vert_lengths[v_index].length_accum /= float(vert_lengths[v_index].count);
621 vert_lengths[v_index].count = -1; /* Ignore in future passes. */
622
623 BMIter iter;
624 BMEdge *e;
625 BM_ITER_ELEM (e, &iter, v, BM_EDGES_OF_VERT) {
627 continue;
628 }
629 BMVert *v_other = BM_edge_other_vert(e, v);
630 if (!BM_elem_flag_test(v_other, BM_ELEM_TAG)) {
631 continue;
632 }
633 int v_other_index = BM_elem_index_get(v_other);
634 if (vert_lengths[v_other_index].count >= 0) {
635 if (vert_lengths[v_other_index].count == 0) {
636 STACK_PUSH(vert_stack, v_other);
637 }
638 BLI_assert(vert_lengths[v_index].length_accum >= 0.0f);
639 vert_lengths[v_other_index].count += 1;
640 vert_lengths[v_other_index].length_accum += vert_lengths[v_index].length_accum;
641 }
642 }
643 }
644 }
645 MEM_delete(vert_stack);
646 *vert_lengths_p = vert_lengths;
647 }
648
649 BLI_assert(vert_lengths[BM_elem_index_get(v_lookup)].length_accum >= 0.0f);
650 return vert_lengths[BM_elem_index_get(v_lookup)].length_accum;
651}
652
654 BMVert *v,
655 SplitEdgeInfo *edge_info,
656
657 /* Needed for 'bm_edge_info_average_length_fallback' */
658 BMesh *bm,
659 void **vert_lengths_p)
660{
661
662 const float length = bm_edge_info_average_length(v, edge_info);
663 if (length != -1.0f) {
664 return length;
665 }
666 return bm_edge_info_average_length_fallback(v, edge_info, bm, vert_lengths_p);
667}
668
670{
671 /*
672 * Implementation:
673 *
674 * - Set all faces as tagged/untagged based on selection.
675 * - Find all edges that have 1 tagged, 1 untagged face.
676 * - Separate these edges and tag vertices, set their index to point to the original edge.
677 * - Build faces between old/new edges.
678 * - Inset the new edges into their faces.
679 */
680
681 const bool use_outset = BMO_slot_bool_get(op->slots_in, "use_outset");
682 const bool use_boundary = BMO_slot_bool_get(op->slots_in, "use_boundary") &&
683 (use_outset == false);
684 const bool use_even_offset = BMO_slot_bool_get(op->slots_in, "use_even_offset");
685 const bool use_even_boundary = use_even_offset; /* could make own option */
686 const bool use_relative_offset = BMO_slot_bool_get(op->slots_in, "use_relative_offset");
687 const bool use_edge_rail = BMO_slot_bool_get(op->slots_in, "use_edge_rail");
688 const bool use_interpolate = BMO_slot_bool_get(op->slots_in, "use_interpolate");
689 const float thickness = BMO_slot_float_get(op->slots_in, "thickness");
690 const float depth = BMO_slot_float_get(op->slots_in, "depth");
691#ifdef USE_LOOP_CUSTOMDATA_MERGE
692 const bool has_math_ldata = (use_interpolate && CustomData_has_math(&bm->ldata));
693#endif
694
695 int edge_info_len = 0;
696
697 BMIter iter;
698 SplitEdgeInfo *edge_info;
699 SplitEdgeInfo *es;
700
701 /* Interpolation Vars */
702 /* an array aligned with faces but only fill items which are used. */
703 InterpFace **iface_array = nullptr;
704 int iface_array_len;
705 MemArena *interp_arena = nullptr;
706
707 /* BMVert original location storage */
708 const bool use_vert_coords_orig = use_edge_rail;
709 Map<BMVert *, float3> vert_coords;
710
711 BMVert *v;
712 BMEdge *e;
713 BMFace *f;
714 int i, k;
715
716 if (use_interpolate) {
717 interp_arena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__);
718 /* warning, we could be more clever here and not over alloc */
719 iface_array = MEM_new_array_zeroed<InterpFace *>(bm->totface, __func__);
720 iface_array_len = bm->totface;
721 }
722
723 if (use_outset == false) {
726 }
727 else {
730 BMO_slot_buffer_hflag_disable(bm, op->slots_in, "faces_exclude", BM_FACE, BM_ELEM_TAG, false);
731 }
732
733 /* first count all inset edges we will split */
734 /* fill in array and initialize tagging */
735 BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
736 if (
737 /* tag if boundary is enabled */
738 (use_boundary && BM_edge_is_boundary(e) && BM_elem_flag_test(e->l->f, BM_ELEM_TAG)) ||
739
740 /* tag if edge is an interior edge in between a tagged and untagged face */
742 {
743 /* tag */
747
748 BM_elem_index_set(e, edge_info_len); /* set_dirty! */
749 edge_info_len++;
750 }
751 else {
755
756 BM_elem_index_set(e, -1); /* set_dirty! */
757 }
758 }
760
761 edge_info = MEM_new_array_uninitialized<SplitEdgeInfo>(edge_info_len, __func__);
762
763 /* fill in array and initialize tagging */
764 es = edge_info;
765 BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
766 i = BM_elem_index_get(e);
767 if (i != -1) {
768 /* calc edge-split info */
770 es->e_old = e;
771 es++;
772 /* initialize no and e_new after */
773 }
774 }
775
776 for (i = 0, es = edge_info; i < edge_info_len; i++, es++) {
777 if ((es->l = bm_edge_is_mixed_face_tag(es->e_old->l))) {
778 /* do nothing */
779 }
780 else {
781 es->l = es->e_old->l; /* must be a boundary */
782 }
783
784 /* run the separate arg */
785 if (!BM_edge_is_boundary(es->e_old)) {
786 bmesh_kernel_edge_separate(bm, es->e_old, es->l, false);
787 }
788
789 /* calc edge-split info */
790 es->e_new = es->l->e;
791 BM_edge_calc_face_tangent(es->e_new, es->l, es->no);
792
793 if (es->e_new == es->e_old) { /* happens on boundary edges */
794 /* Take care here, we're creating this double edge which _must_
795 * have its verts replaced later on. */
796 es->e_old = BM_edge_create(bm, es->e_new->v1, es->e_new->v2, es->e_new, BM_CREATE_NOP);
797 }
798
799 /* store index back to original in 'edge_info' */
800 BM_elem_index_set(es->e_new, i);
802
803 /* important to tag again here */
806
807 /* initialize interpolation vars */
808 /* this could go in its own loop,
809 * only use the 'es->l->f' so we don't store loops for faces which have no mixed selection
810 *
811 * NOTE: faces on the other side of the inset will be interpolated too since this is hard to
812 * detect, just allow it even though it will cause some redundant interpolation */
813 if (use_interpolate) {
814 BMIter viter;
815 BM_ITER_ELEM (v, &viter, es->l->e, BM_VERTS_OF_EDGE) {
816 BMIter fiter;
817 BM_ITER_ELEM (f, &fiter, v, BM_FACES_OF_VERT) {
818 const int j = BM_elem_index_get(f);
819 if (iface_array[j] == nullptr) {
820 InterpFace *iface = static_cast<InterpFace *>(
821 BLI_memarena_alloc(interp_arena, sizeof(*iface)));
822 bm_interp_face_store(iface, bm, f, interp_arena);
823 iface_array[j] = iface;
824 }
825 }
826 }
827 }
828 /* done interpolation */
829 }
830
831/* show edge normals for debugging */
832#if 0
833 for (i = 0, es = edge_info; i < edge_info_len; i++, es++) {
834 float tvec[3];
835 BMVert *v1, *v2;
836
837 mid_v3_v3v3(tvec, es->e_new->v1->co, es->e_new->v2->co);
838
839 v1 = BM_vert_create(bm, tvec, nullptr, BM_CREATE_NOP);
840 v2 = BM_vert_create(bm, tvec, nullptr, BM_CREATE_NOP);
841 madd_v3_v3fl(v2->co, es->no, 0.1f);
842 BM_edge_create(bm, v1, v2, nullptr, 0);
843 }
844#endif
845
846 /* Execute the split and position verts, it would be most obvious to loop
847 * over verts here but don't do this since we will be splitting them off
848 * (iterating stuff you modify is bad juju)
849 * instead loop over edges then their verts. */
850 for (i = 0, es = edge_info; i < edge_info_len; i++, es++) {
851 for (int j = 0; j < 2; j++) {
852 v = (j == 0) ? es->e_new->v1 : es->e_new->v2;
853
854 /* end confusing part - just pretend this is a typical loop on verts */
855
856 /* only split of tagged verts - used by separated edges */
857
858 /* comment the first part because we know this verts in a tagged face */
859 if (/* v->e && */ BM_elem_flag_test(v, BM_ELEM_TAG)) {
860 BMVert **vout;
861 int vout_len;
862 BMVert *v_glue = nullptr;
863
864 /* disable touching twice, this _will_ happen if the flags not disabled */
866
867 bmesh_kernel_vert_separate(bm, v, &vout, &vout_len, false);
868 v = nullptr; /* don't use again */
869
870 /* in some cases the edge doesn't split off */
871 if (vout_len == 1) {
872 if (use_vert_coords_orig) {
873 vert_coords.add(vout[0], vout[0]->co);
874 }
875 MEM_delete(vout);
876 continue;
877 }
878
879 for (k = 0; k < vout_len; k++) {
880 BMVert *v_split = vout[k]; /* only to avoid vout[k] all over */
881
882 /* need to check if this vertex is from a */
883 int vert_edge_tag_tot = 0;
884 int vecpair[2];
885
886 if (use_vert_coords_orig) {
887 vert_coords.add(v_split, v_split->co);
888 }
889
890 /* find adjacent */
891 BM_ITER_ELEM (e, &iter, v_split, BM_EDGES_OF_VERT) {
892 if (BM_elem_flag_test(e, BM_ELEM_TAG) && e->l &&
894 {
895 if (vert_edge_tag_tot < 2) {
896 vecpair[vert_edge_tag_tot] = BM_elem_index_get(e);
897 BLI_assert(vecpair[vert_edge_tag_tot] != -1);
898 }
899
900 vert_edge_tag_tot++;
901 }
902 }
903
904 if (vert_edge_tag_tot != 0) {
905 float tvec[3];
906
907 if (vert_edge_tag_tot >= 2) { /* 2 edge users - common case */
908 /* now there are 2 cases to check for,
909 *
910 * if both edges use the same face OR both faces have the same normal,
911 * ...then we can calculate an edge that fits nicely between the 2 edge normals.
912 *
913 * Otherwise use the shared edge OR the corner defined by these 2 face normals,
914 * when both edges faces are adjacent this works best but even when this vertex
915 * fans out faces it should work ok.
916 */
917
918 SplitEdgeInfo *e_info_a = &edge_info[vecpair[0]];
919 SplitEdgeInfo *e_info_b = &edge_info[vecpair[1]];
920
921 BMFace *f_a = e_info_a->l->f;
922 BMFace *f_b = e_info_b->l->f;
923
924 /* set to true when we're not in-between (e_info_a->no, e_info_b->no) exactly
925 * in this case use a check the angle of the tvec when calculating shell thickness */
926 bool is_mid = true;
927
928 /* we use this as either the normal OR to find the right direction for the
929 * cross product between both face normals */
930 add_v3_v3v3(tvec, e_info_a->no, e_info_b->no);
931
932 if (use_edge_rail == false) {
933 /* pass */
934 }
935 else if (f_a != f_b) {
936 /* these lookups are very quick */
937 BMLoop *l_other_a = BM_loop_other_vert_loop(e_info_a->l, v_split);
938 BMLoop *l_other_b = BM_loop_other_vert_loop(e_info_b->l, v_split);
939
940 if (l_other_a->v == l_other_b->v) {
941 /* both edges faces are adjacent, but we don't need to know the shared edge
942 * having both verts is enough. */
943 float3 co_other;
944
945 /* note that we can't use 'l_other_a->v' directly since it
946 * may be inset and give a feedback loop. */
947 if (use_vert_coords_orig) {
948 co_other = vert_coords.lookup_default(l_other_a->v, l_other_a->v->co);
949 }
950 else {
951 co_other = l_other_a->v->co;
952 }
953
954 sub_v3_v3v3(tvec, co_other, v_split->co);
955 is_mid = false;
956 }
957
958/* Disable since this gives odd results at times, see #39288. */
959#if 0
960 else if (compare_v3v3(f_a->no, f_b->no, 0.001f) == false) {
961 /* epsilon increased to fix #32329. */
962
963 /* faces don't touch,
964 * just get cross product of their normals, its *good enough*
965 */
966 float tno[3];
967 cross_v3_v3v3(tno, f_a->no, f_b->no);
968 if (dot_v3v3(tvec, tno) < 0.0f) {
969 negate_v3(tno);
970 }
971 copy_v3_v3(tvec, tno);
972 is_mid = false;
973 }
974#endif
975 }
976 normalize_v3(tvec);
977
978 /* scale by edge angle */
979 if (use_even_offset) {
980 if (is_mid) {
981 mul_v3_fl(tvec, shell_v3v3_mid_normalized_to_dist(e_info_a->no, e_info_b->no));
982 }
983 else {
984 /* use the largest angle */
985 mul_v3_fl(
986 tvec,
988 len_squared_v3v3(tvec, e_info_a->no) >
989 len_squared_v3v3(tvec, e_info_b->no) ?
990 e_info_a->no :
991 e_info_b->no));
992 }
993 }
994
995 /* scale relative to edge lengths */
996 if (use_relative_offset) {
997 mul_v3_fl(tvec,
998 (edge_info[vecpair[0]].length + edge_info[vecpair[1]].length) / 2.0f);
999 }
1000 }
1001 else if (vert_edge_tag_tot == 1) { /* 1 edge user - boundary vert, not so common */
1002 const float *e_no_a = edge_info[vecpair[0]].no;
1003
1004 if (use_even_boundary) {
1005
1030
1031 BMEdge *e_other;
1032 BMVert *v_other;
1033 /* loop will always be either next of prev */
1034 BMLoop *l = v_split->e->l;
1035 if (l->prev->v == v_split) {
1036 l = l->prev;
1037 }
1038 else if (l->next->v == v_split) {
1039 l = l->next;
1040 }
1041 else if (l->v == v_split) {
1042 /* pass */
1043 }
1044 else {
1045 /* should never happen */
1046 BLI_assert(0);
1047 }
1048
1049 /* find the edge which is _not_ being split here */
1050 if (!BM_elem_flag_test(l->e, BM_ELEM_TAG)) {
1051 e_other = l->e;
1052 }
1053 else if (!BM_elem_flag_test(l->prev->e, BM_ELEM_TAG)) {
1054 e_other = l->prev->e;
1055 }
1056 else {
1057 BLI_assert(0);
1058 e_other = nullptr;
1059 }
1060
1061 v_other = BM_edge_other_vert(e_other, v_split);
1062 sub_v3_v3v3(tvec, v_other->co, v_split->co);
1063 normalize_v3(tvec);
1064
1065 if (use_even_offset) {
1066 mul_v3_fl(tvec, shell_v3v3_normalized_to_dist(e_no_a, tvec));
1067 }
1068 }
1069 else {
1070 copy_v3_v3(tvec, e_no_a);
1071 }
1072
1073 /* use_even_offset - doesn't apply here */
1074
1075 /* scale relative to edge length */
1076 if (use_relative_offset) {
1077 mul_v3_fl(tvec, edge_info[vecpair[0]].length);
1078 }
1079 }
1080 else {
1081 /* should never happen */
1082 BLI_assert(0);
1083 zero_v3(tvec);
1084 }
1085
1086 /* apply the offset */
1087 madd_v3_v3fl(v_split->co, tvec, thickness);
1088 }
1089
1090 /* this saves expensive/slow glue check for common cases */
1091 if (vout_len > 2) {
1092 bool ok = true;
1093 /* last step, nullptr this vertex if has a tagged face */
1094 BM_ITER_ELEM (f, &iter, v_split, BM_FACES_OF_VERT) {
1096 ok = false;
1097 break;
1098 }
1099 }
1100
1101 if (ok) {
1102 if (v_glue == nullptr) {
1103 v_glue = v_split;
1104 }
1105 else {
1106 if (BM_vert_splice(bm, v_glue, v_split)) {
1107 if (use_vert_coords_orig) {
1108 vert_coords.remove(v_split);
1109 }
1110 }
1111 }
1112 }
1113 }
1114 /* end glue */
1115 }
1116 MEM_delete(vout);
1117 }
1118 }
1119 }
1120
1121 if (use_interpolate) {
1122 for (i = 0; i < iface_array_len; i++) {
1123 if (iface_array[i]) {
1124 InterpFace *iface = iface_array[i];
1126 iface->f,
1127 iface->f,
1128 true,
1129 (const void **)iface->blocks_l,
1130 (const void **)iface->blocks_v,
1131 iface->cos_2d,
1132 iface->axis_mat);
1133 }
1134 }
1135 }
1136
1137 /* create faces */
1138 for (i = 0, es = edge_info; i < edge_info_len; i++, es++) {
1139 BMVert *varr[4] = {nullptr};
1140 int j;
1141 /* get the verts in the correct order */
1142 BM_edge_ordered_verts_ex(es->e_new, &varr[1], &varr[0], es->l);
1143#if 0
1144 if (varr[0] == es->e_new->v1) {
1145 varr[2] = es->e_old->v2;
1146 varr[3] = es->e_old->v1;
1147 }
1148 else {
1149 varr[2] = es->e_old->v1;
1150 varr[3] = es->e_old->v2;
1151 }
1152 j = 4;
1153#else
1154 /* slightly trickier check - since we can't assume the verts are split */
1155 j = 2; /* 2 edges are set */
1156 if (varr[0] == es->e_new->v1) {
1157 if (es->e_old->v2 != es->e_new->v2) {
1158 varr[j++] = es->e_old->v2;
1159 }
1160 if (es->e_old->v1 != es->e_new->v1) {
1161 varr[j++] = es->e_old->v1;
1162 }
1163 }
1164 else {
1165 if (es->e_old->v1 != es->e_new->v1) {
1166 varr[j++] = es->e_old->v1;
1167 }
1168 if (es->e_old->v2 != es->e_new->v2) {
1169 varr[j++] = es->e_old->v2;
1170 }
1171 }
1172
1173 if (j == 2) {
1174 /* can't make face! */
1175 continue;
1176 }
1177#endif
1178 /* no need to check doubles, we KNOW there won't be any */
1179 /* yes - reverse face is correct in this case */
1180 f = BM_face_create_verts(bm, varr, j, es->l->f, BM_CREATE_NOP, true);
1182
1183 /* Copy for loop data, otherwise UVs and vertex-colors are no good.
1184 * tiny speedup here we could be more clever and copy from known adjacent data
1185 * also - we could attempt to interpolate the loop data,
1186 * this would be much slower but more useful too. */
1187 if (false) {
1188 /* Don't use this because face boundaries have no adjacent loops and won't be filled in.
1189 * instead copy from the opposite side with the code below */
1190 BM_face_copy_shared(bm, f, nullptr, nullptr);
1191 }
1192 else {
1193 /* 2 inner loops on the edge between the new face and the original */
1194 BMLoop *l_a;
1195 BMLoop *l_b;
1196 BMLoop *l_a_other;
1197 BMLoop *l_b_other;
1198
1199 l_a = BM_FACE_FIRST_LOOP(f);
1200 l_b = l_a->next;
1201
1202 /* we know this side has a radial_next because of the order of created verts in the quad */
1203 l_a_other = BM_edge_other_loop(l_a->e, l_a);
1204 l_b_other = BM_edge_other_loop(l_a->e, l_b);
1205 BM_elem_attrs_copy(bm, l_a_other, l_a);
1206 BM_elem_attrs_copy(bm, l_b_other, l_b);
1207
1208 BLI_assert(l_a->f != l_a_other->f);
1209 BLI_assert(l_b->f != l_b_other->f);
1210
1211 /* step around to the opposite side of the quad - warning, this may have no other edges! */
1212 l_a = l_a->next->next;
1213 l_b = l_a->next;
1214
1235
1236 /* swap a<->b intentionally */
1237 if (use_interpolate) {
1238 InterpFace *iface = iface_array[BM_elem_index_get(es->l->f)];
1239 const int i_a = BM_elem_index_get(l_a_other);
1240 const int i_b = BM_elem_index_get(l_b_other);
1244 CustomData_bmesh_copy_block(bm->ldata, iface->blocks_l[i_b], &l_a->head.data);
1245
1246#ifdef USE_LOOP_CUSTOMDATA_MERGE
1247 if (has_math_ldata) {
1248 BMEdge *e_connect;
1249
1250 /* connecting edge 'a' */
1251 e_connect = l_a->prev->e;
1252 if (BM_edge_is_manifold(e_connect)) {
1254 e_connect,
1255 l_a,
1256 BM_edge_other_loop(e_connect, l_a),
1257 l_a->prev,
1258 BM_edge_other_loop(e_connect, l_a->prev));
1259 }
1260
1261 /* connecting edge 'b' */
1262 e_connect = l_b->e;
1263 if (BM_edge_is_manifold(e_connect)) {
1264 /* swap arg order to maintain winding */
1266 e_connect,
1267 l_b,
1268 BM_edge_other_loop(e_connect, l_b),
1269 l_b->next,
1270 BM_edge_other_loop(e_connect, l_b->next));
1271 }
1272 }
1273#endif /* USE_LOOP_CUSTOMDATA_MERGE */
1274 }
1275 else {
1276 BM_elem_attrs_copy(bm, l_a_other, l_b);
1277 BM_elem_attrs_copy(bm, l_b_other, l_a);
1278 }
1279 }
1280 }
1281
1282 if (use_interpolate) {
1283 for (i = 0; i < iface_array_len; i++) {
1284 if (iface_array[i]) {
1285 bm_interp_face_free(iface_array[i], bm);
1286 }
1287 }
1288
1289 BLI_memarena_free(interp_arena);
1290 MEM_delete(iface_array);
1291 }
1292
1293 /* we could flag new edges/verts too, is it useful? */
1295
1296 /* cheap feature to add depth to the inset */
1297 if (depth != 0.0f) {
1298 float (*varr_co)[3];
1299 BMOIter oiter;
1300
1301 /* We need to re-calculate tagged normals,
1302 * but for this purpose we can copy tagged verts from the faces they inset from. */
1303 for (i = 0, es = edge_info; i < edge_info_len; i++, es++) {
1304 zero_v3(es->e_new->v1->no);
1305 zero_v3(es->e_new->v2->no);
1306 }
1307 for (i = 0, es = edge_info; i < edge_info_len; i++, es++) {
1308 const float *no = es->l->f->no;
1309 add_v3_v3(es->e_new->v1->no, no);
1310 add_v3_v3(es->e_new->v2->no, no);
1311 }
1312 for (i = 0, es = edge_info; i < edge_info_len; i++, es++) {
1313 /* annoying, avoid normalizing twice */
1314 if (len_squared_v3(es->e_new->v1->no) != 1.0f) {
1315 normalize_v3(es->e_new->v1->no);
1316 }
1317 if (len_squared_v3(es->e_new->v2->no) != 1.0f) {
1318 normalize_v3(es->e_new->v2->no);
1319 }
1320 }
1321 /* done correcting edge verts normals */
1322
1323 /* untag verts */
1325
1326 /* tag face verts */
1327 BMO_ITER (f, &oiter, op->slots_in, "faces", BM_FACE) {
1328 BMLoop *l_iter, *l_first;
1329 l_iter = l_first = BM_FACE_FIRST_LOOP(f);
1330 do {
1333 } while ((l_iter = l_iter->next) != l_first);
1334 }
1335
1336 /* do in 2 passes so moving the verts doesn't feed back into face angle checks
1337 * which BM_vert_calc_shell_factor uses. */
1338
1339 /* over allocate */
1340 varr_co = MEM_new_array_zeroed<float[3]>(bm->totvert, __func__);
1341 void *vert_lengths_p = nullptr;
1342
1343 BM_ITER_MESH_INDEX (v, &iter, bm, BM_VERTS_OF_MESH, i) {
1345 const float fac =
1346 depth *
1347 (use_relative_offset ?
1349 v,
1350 edge_info,
1351 /* Variables needed for filling interior values for vertex lengths. */
1352 bm,
1353 &vert_lengths_p) :
1354 1.0f) *
1355 (use_even_boundary ? BM_vert_calc_shell_factor(v) : 1.0f);
1356 madd_v3_v3v3fl(varr_co[i], v->co, v->no, fac);
1357 }
1358 }
1359
1360 if (vert_lengths_p != nullptr) {
1361 MEM_delete_void(vert_lengths_p);
1362 }
1363
1364 BM_ITER_MESH_INDEX (v, &iter, bm, BM_VERTS_OF_MESH, i) {
1366 copy_v3_v3(v->co, varr_co[i]);
1367 }
1368 }
1369 MEM_delete(varr_co);
1370 }
1371
1372 MEM_delete(edge_info);
1373}
1374
1376
1377} // namespace blender
CustomData interface, see also DNA_customdata_types.h.
#define BLI_MEMARENA_STD_BUFSIZE
#define STACK_PUSH(stack, val)
#define STACK_DECLARE(stack)
#define STACK_SIZE(stack)
#define STACK_INIT(stack, stack_num)
#define STACK_REMOVE(stack, i)
Read Blender memory allocation and freeing.
#define ELEM(...)
#define BM_FACE_FIRST_LOOP(p)
#define BM_ELEM_CD_GET_VOID_P(ele, offset)
#define BM_elem_index_get(ele)
#define BM_elem_flag_disable(ele, hflag)
#define BM_elem_index_set(ele, index)
#define BM_elem_flag_test(ele, hflag)
#define BM_elem_flag_enable(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)
#define BMO_ITER(ele, iter, slot_args, slot_name, restrict_flag)
#define ELE_NEW
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 remove(const Key &key)
Definition BLI_map.hh:368
float length(VecOp< float, D >) RET
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
Definition math_dual.h:263
BMesh Iterators.
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f)
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.
MINLINE float len_squared_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
BMFace * BM_face_create_verts(BMesh *bm, BMVert **vert_arr, const int len, const BMFace *f_example, const eBMCreateFlag create_flag, const bool create_edges)
MINLINE float shell_v3v3_normalized_to_dist(const float a[3], const float b[3])
void BM_mesh_elem_index_ensure(BMesh *bm, const char htype)
void BM_mesh_elem_hflag_enable_all(BMesh *bm, const char htype, const char hflag, const bool respecthide)
void bmo_inset_region_exec(BMesh *bm, BMOperator *op)
Definition bmo_inset.cc:669
bool BM_edge_in_face(const BMEdge *e, const BMFace *f)
static float bm_edge_info_average_length_with_fallback(BMVert *v, SplitEdgeInfo *edge_info, BMesh *bm, void **vert_lengths_p)
Definition bmo_inset.cc:653
MemArena * BLI_memarena_new(size_t bufsize, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(2) ATTR_MALLOC
void CustomData_data_mix_value(eCustomDataType type, const void *source, void *dest, int mixmode, float mixfactor)
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
void BMO_slot_buffer_hflag_enable(BMesh *bm, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, char htype, char hflag, bool do_flush)
BMO_FLAG_BUFFER.
ATTR_WARN_UNUSED_RESULT const BMLoop * l
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
static void bmo_face_inset_individual(BMesh *bm, BMFace *f, MemArena *interp_arena, const float thickness, const float depth, const bool use_even_offset, const bool use_relative_offset, const bool use_interpolate)
Definition bmo_inset.cc:266
float BMO_slot_float_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
void mul_v2_m3v3(float r[2], const float M[3][3], const float a[3])
bool CustomData_data_equals(eCustomDataType type, const void *data1, const void *data2)
void BM_mesh_elem_hflag_disable_all(BMesh *bm, const char htype, const char hflag, const bool respecthide)
float BM_vert_calc_shell_factor(const BMVert *v)
ATTR_WARN_UNUSED_RESULT const BMVert * v
void CustomData_bmesh_copy_block(CustomData &data, void *src_block, void **dst_block)
BMVert * BM_vert_create(BMesh *bm, const float co[3], const BMVert *v_example, const eBMCreateFlag create_flag)
Main function for creating a new vertex.
BLI_INLINE bool BM_edge_is_manifold(const BMEdge *e) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
float BM_edge_calc_length(const BMEdge *e)
void MEM_delete_void(void *vmemh)
void bmesh_kernel_edge_separate(BMesh *bm, BMEdge *e, BMLoop *l_sep, const bool copy_select)
Separate Edge.
BLI_INLINE BMVert * BM_edge_other_vert(BMEdge *e, const BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void BM_edge_ordered_verts_ex(const BMEdge *edge, BMVert **r_v1, BMVert **r_v2, const BMLoop *edge_loop)
static void bm_interp_face_store(InterpFace *iface, BMesh *bm, BMFace *f, MemArena *interp_arena)
Definition bmo_inset.cc:59
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
BMFace * BM_face_create_quad_tri(BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v3, BMVert *v4, const BMFace *f_example, const eBMCreateFlag create_flag)
Make Quad/Triangle.
void CustomData_bmesh_free_block(CustomData *data, void **block)
@ BM_CREATE_NO_DOUBLE
Definition bmesh_core.hh:36
@ BM_CREATE_NOP
Definition bmesh_core.hh:34
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
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)
void CustomData_data_copy_value(eCustomDataType type, const void *source, void *dest)
void BLI_memarena_clear(MemArena *ma) ATTR_NONNULL(1)
void BM_face_copy_shared(BMesh *bm, BMFace *f, BMLoopFilterFunc filter_fn, void *user_data)
copies face loop data from shared adjacent faces.
static float bm_edge_info_average_length(BMVert *v, SplitEdgeInfo *edge_info)
Definition bmo_inset.cc:516
void bmesh_kernel_vert_separate(BMesh *bm, BMVert *v, BMVert ***r_vout, int *r_vout_len, const bool copy_select)
Separate Vert.
ATTR_WARN_UNUSED_RESULT const BMLoop * l_b
MINLINE void negate_v3(float r[3])
static void bm_loop_customdata_merge(BMesh *bm, BMEdge *e_connect, BMLoop *l_a_outer, BMLoop *l_b_outer, BMLoop *l_a_inner, BMLoop *l_b_inner)
Definition bmo_inset.cc:111
bool BM_vert_splice(BMesh *bm, BMVert *v_dst, BMVert *v_src)
Splice Vert.
BLI_INLINE bool BM_edge_is_boundary(const BMEdge *e) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
BMVert * BM_face_loop_separate(BMesh *bm, BMLoop *l_sep)
Rip a single face from a vertex fan.
MINLINE void zero_v3(float r[3])
BMLoop * BM_edge_other_loop(BMEdge *e, BMLoop *l)
BMLoop * BM_loop_other_vert_loop(BMLoop *l, BMVert *v)
Other Loop in Face Sharing a Vert.
void bmo_inset_individual_exec(BMesh *bm, BMOperator *op)
Definition bmo_inset.cc:419
void * BLI_memarena_alloc(MemArena *ma, size_t size) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_ALLOC_SIZE(2)
MINLINE float normalize_v3(float n[3])
MINLINE void add_v3_v3(float r[3], const float a[3])
bool BMO_slot_bool_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
void mid_v3_v3v3(float r[3], const float a[3], const float b[3])
static BMLoop * bm_edge_is_mixed_face_tag(BMLoop *l)
Definition bmo_inset.cc:488
MINLINE bool compare_v3v3(const float v1[3], const float v2[3], float limit) ATTR_WARN_UNUSED_RESULT
MINLINE float shell_v3v3_mid_normalized_to_dist(const float a[3], const float b[3])
ATTR_WARN_UNUSED_RESULT const BMVert * v2
MINLINE float len_squared_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
void CustomData_bmesh_free_block_data(CustomData *data, void *block)
void BM_face_interp_from_face_ex(BMesh *bm, BMFace *f_dst, const BMFace *f_src, const bool do_vertex, const void **blocks_l, const void **blocks_v, float(*cos_2d)[2], float axis_mat[3][3])
Data Interpolate From Face.
void BM_elem_attrs_copy(BMesh *bm, const BMCustomDataCopyMap &map, const BMVert *src, BMVert *dst)
bool CustomData_has_math(const CustomData *data)
VecBase< float, 3 > float3
static void bm_interp_face_free(InterpFace *iface, BMesh *bm)
Definition bmo_inset.cc:94
bool BM_face_is_normal_valid(const BMFace *f)
void BMO_slot_buffer_hflag_disable(BMesh *bm, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, char htype, char hflag, bool do_flush)
BMO_FLAG_BUFFER.
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
BMEdge * BM_edge_create(BMesh *bm, BMVert *v1, BMVert *v2, const BMEdge *e_example, const eBMCreateFlag create_flag)
Main function for creating a new edge.
bool CustomData_layer_has_math(const CustomData *data, int layer_n)
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
void axis_dominant_v3_to_m3(float r_mat[3][3], const float normal[3])
Normal to x,y matrix.
void BLI_memarena_free(MemArena *ma) ATTR_NONNULL(1)
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
static float bm_edge_info_average_length_fallback(BMVert *v_lookup, SplitEdgeInfo *edge_info, BMesh *bm, void **vert_lengths_p)
Definition bmo_inset.cc:552
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 BMEdge * e
float(* cos_2d)[2]
Definition bmo_inset.cc:54
float axis_mat[3][3]
Definition bmo_inset.cc:55