41#define VERT_SHARED (1 << 0)
43#define EDGE_RING (1 << 0)
44#define EDGE_RIM (1 << 1)
45#define EDGE_IN_STACK (1 << 2)
47#define FACE_OUT (1 << 0)
48#define FACE_SHARED (1 << 1)
49#define FACE_IN_STACK (1 << 2)
77 float fac = 1.333333f;
82 const float t = 1.0f +
dot;
83 fac = (fac * t) + (0.75f * (1.0f - t));
104 return (
len * 0.5f) * fac;
134 }
while ((l_iter = l_iter->
next) != l_first);
162 bool has_overlap =
true;
203 ListBaseT<BMEdgeLoopStore> *eloops_rim)
225 for (el_store = eloops_rim->first(); el_store; el_store =
BM_EDGELOOP_NEXT(el_store)) {
228 vert_eloop_map.
add(
static_cast<BMVert *
>(
node->data), el_store);
233 for (el_store = eloops_rim->first(); el_store; el_store =
BM_EDGELOOP_NEXT(el_store)) {
247 if (el_store_other) {
248 pair_test.first = el_store;
249 pair_test.second = el_store_other;
251 if (pair_test.first > pair_test.second) {
252 std::swap(pair_test.first, pair_test.second);
255 eloop_pair_set.
add(pair_test);
261 return eloop_pair_set;
283 v_arr[cuts + 1] = v_b;
287 v_arr[cuts + 1] = v_a;
321 bool found_outer =
false, found_inner =
false, found_outer_tag =
false;
323 float no_outer[3] = {0.0f}, no_inner[3] = {0.0f};
348 found_outer_tag =
true;
358 if (found_inner && found_outer_tag) {
366 else if (found_outer) {
385 for (i = 0; i < e_arr_len; i++) {
389 l_iter = l_first =
e->l;
396 }
while ((l_iter = l_iter->
radial_next) != l_first);
407 for (i = 0; i < e_arr_len_iter; i++) {
411 l_iter = l_first =
e->l;
414 }
while ((l_iter = l_iter->
radial_next) != l_first);
439 const int interp_mode)
454 float (*nors_pair[2])[3];
463 nors_pair[0] = lpair->
nors_a;
464 nors_pair[1] = lpair->
nors_b;
466 lpair->
nors_gh_a = MEM_new<Map<BMVert *, uint>>(__func__);
467 lpair->
nors_gh_b = MEM_new<Map<BMVert *, uint>>(__func__);
483 for (side_index = 0; side_index < 2; side_index++) {
488 float (*nor)[3] = nors_pair[side_index];
492 for (v_iter = lb->first(), i = 0; v_iter; v_iter = v_iter->
next, i++) {
495 nors_gh_iter->
add(
v, i);
513 MEM_delete(lpair->
nors_a);
514 MEM_delete(lpair->
nors_b);
532 ListBaseT<BMEdgeLoopStore> *eloops_ring,
533 const int interp_mode,
536 const float *falloff_cache)
538 const int resolu = cuts + 2;
540 bool is_a_no_valid, is_b_no_valid;
543 float el_store_a_co[3], el_store_b_co[3];
544 float el_store_a_no[3], el_store_b_no[3];
548 float (*coord_array_main)[3] =
nullptr;
567 if (is_a_no_valid ==
false) {
570 if (is_b_no_valid ==
false) {
573 (void)is_a_no_valid, (
void)is_b_no_valid;
578 if (
dot_v3v3(el_store_a_no, el_dir) > 0.0f) {
581 if (
dot_v3v3(el_store_b_no, el_dir) < 0.0f) {
589 float handle_a[3], handle_b[3];
593 el_store_a_co, el_store_a_no, el_store_b_co, el_store_b_no) *
604 for (i = 0; i < dims; i++) {
609 (
reinterpret_cast<float *
>(coord_array_main)) + i,
611 sizeof(
float) * dims);
615 switch (interp_mode) {
619 for (i = 0; i < resolu; i++) {
621 coord_array[i], el_store_a_co, el_store_b_co,
float(i) /
float(resolu - 1));
624 for (el_store_ring = eloops_ring->first(); el_store_ring;
630 for (v_iter = lb_ring->first(), i = 0; v_iter; v_iter = v_iter->
next, i++) {
631 if (i > 0 && i < resolu - 1) {
643 MEM_delete(coord_array);
652 float (*tri_sta)[3], (*tri_end)[3], (*tri_tmp)[3];
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++) {
661 coord_array_main[i - 1],
663 coord_array_main[i + 1]);
666 vec_to_quat(quat_array[0], direction_array[0], 5, 1);
669 for (i = 1; i < resolu; i++) {
675 cross_v3_v3v3(cross_tmp, direction_array[i - 1], direction_array[i]);
686 for (i = 0; i < resolu; i++) {
689 const float shape_size = falloff_cache ? falloff_cache[i] : 1.0f;
691 tri_tmp = tri_array[i];
694 for (j = 0; j < 3; j++) {
697 tri_tmp[j][0] = shape_size;
700 tri_tmp[j][1] = shape_size;
703 add_v3_v3(tri_tmp[j], coord_array_main[i]);
707 tri_sta = tri_array[0];
708 tri_end = tri_array[resolu - 1];
710 for (el_store_ring = eloops_ring->first(); el_store_ring;
720 for (v_iter = (lb_ring->first())->
next, i = 1; v_iter != lb_ring->last();
721 v_iter = v_iter->
next, i++)
723 float co_a[3], co_b[3];
725 tri_tmp = tri_array[i];
731 (
static_cast<BMVert *
>(v_iter->
data))->co, co_a, co_b,
float(i) /
float(resolu - 1));
735 MEM_delete(direction_array);
736 MEM_delete(quat_array);
737 MEM_delete(tri_array);
744 for (el_store_ring = eloops_ring->first(); el_store_ring;
753 float co_a[3], no_a[3], handle_a[3], co_b[3], no_b[3], handle_b[3];
781 for (i = 0; i < dims; i++) {
786 (
reinterpret_cast<float *
>(coord_array)) + i,
788 sizeof(
float) * dims);
792 for (v_iter = lb_ring->first()->
next, i = 1; v_iter != lb_ring->last();
793 v_iter = v_iter->
next, i++)
795 if (i > 0 && i < resolu - 1) {
809 MEM_delete(coord_array);
815 if (coord_array_main) {
816 MEM_delete(coord_array_main);
829 for (i = 0; i < cuts; i++) {
832 if (l_new ==
nullptr) {
852 LinkData *v_iter_a_first = lb_a->first();
853 LinkData *v_iter_b_first = lb_b->first();
855 LinkData *v_iter_a_step = v_iter_a_first;
856 LinkData *v_iter_b_step = v_iter_b_first;
860 static_cast<BMVert *
>(v_iter_b_first->
data)));
864 v_iter_a_step = v_iter_a_step->
next;
866 static_cast<BMVert *
>(v_iter_b_first->
data)) ||
870 v_iter_b_step = v_iter_b_step->
next;
872 static_cast<BMVert *
>(v_iter_a_first->
data)) ||
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();
880 static_cast<BMVert *
>(v_iter_b_step->
data)) ||
882 static_cast<BMVert *
>(v_iter_b_step->
data)) ||
911 node = lb_a->first();
925 if (
node->data == v_other) {
946 (
static_cast<BMVert *
>(lb_b->first()->data)));
964 ListBaseT<BMEdgeLoopStore> *eloops_ring,
974 BMEdge **edges_ring_arr = edges_ring_arr_buf.
data();
975 BMFace **faces_ring_arr = faces_ring_arr_buf.
data();
1027 while ((f =
STACK_POP(faces_ring_arr))) {
1028 BMLoop *l_iter, *l_first;
1039 }
while ((l_iter = l_iter->
next) != l_first);
1043 for (el_store_ring = eloops_ring->first(); el_store_ring;
1057 const int interp_mode,
1060 const float *falloff_cache)
1062 ListBaseT<BMEdgeLoopStore> eloops_ring = {
nullptr};
1066 bm, lpair, el_store_a, el_store_b, &eloops_ring, interp_mode, cuts,
smooth, falloff_cache);
1074 ListBaseT<BMEdgeLoopStore> eloops_rim = {
nullptr};
1078 bool changed =
false;
1083 const int resolu = cuts + 2;
1089 (profile_shape_factor != 0.0f) ? cuts + 2 : 0);
1090 float *falloff_cache = (profile_shape_factor != 0.0f) ? falloff_cache_buf.
data() :
nullptr;
1134 if (falloff_cache) {
1136 for (i = 0; i < resolu; i++) {
1137 float shape_size = 1.0f;
1139 fac =
fabsf(1.0f - 2.0f *
fabsf(0.5f - fac));
1141 shape_size += fac * profile_shape_factor;
1143 falloff_cache[i] = shape_size;
1157 else if (count == 2) {
1173 bm, lpair, el_store_a, el_store_b, interp_mode, cuts,
smooth, falloff_cache);
1192 lpair_arr = lpair_arr_buf.
data();
1195 for (
const int i : eloop_pairs_gs.
index_range()) {
1207 lpair_arr[i] = lpair;
1212 for (
const int i : eloop_pairs_gs.
index_range()) {
1220 bm, lpair, el_store_a, el_store_b, interp_mode, cuts,
smooth, falloff_cache);
#define STACK_PUSH(stack, val)
#define STACK_DECLARE(stack)
#define STACK_INIT(stack, stack_num)
Read Blender memory allocation and freeing.
#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)
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
bool add(const Key &key, const Value &value)
Value lookup_default(const Key &key, const Value &default_value) const
IndexRange index_range() const
float dot(VecOp< float, D >, VecOp< float, D >) RET
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
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])
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
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)
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_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)
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)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
struct BMLoop * radial_next
struct BMOpSlot slots_in[BMO_OP_MAX_SLOTS]
struct BMOpSlot slots_out[BMO_OP_MAX_SLOTS]
Map< BMVert *, uint > * nors_gh_a
Map< BMVert *, uint > * nors_gh_b