28#define USE_LOOP_CUSTOMDATA_MERGE
58 void **blocks_l = iface->
blocks_l =
static_cast<void **
>(
60 void **blocks_v = iface->
blocks_v =
static_cast<void **
>(
62 float(*cos_2d)[2] = iface->
cos_2d =
static_cast<float(*)[2]
>(
76 mul_v2_m3v3(cos_2d[i],
static_cast<const float(*)[3]
>(axis_mat), l_iter->
v->
co);
77 blocks_l[i] =
nullptr;
82 blocks_v[i] =
nullptr;
87 }
while ((
void)i++, (l_iter = l_iter->
next) != l_first);
96 for (i = 0; i < iface->
f->
len; i++) {
102#ifdef USE_LOOP_CUSTOMDATA_MERGE
136 const bool is_flip = (l_a_inner->
next == l_a_outer);
137 BMLoop *l_a_inner_inset, *l_b_inner_inset;
155 e_a = l_a_inner->
prev->
e;
160 e_b = l_b_inner->
prev->
e;
168 if (l_a_inner_inset->
f == l_b_inner_inset->
f) {
199 const void *data_src;
214 if (is_flip ? (l_b_inner_inset->
e == l_a_inner_inset->
prev->
e) :
215 (l_a_inner_inset->
e == l_b_inner_inset->
prev->
e))
227 if (!
ELEM(l_iter, l_a_inner, l_b_inner, l_a_inner_inset, l_b_inner_inset)) {
260 const float thickness,
262 const bool use_even_offset,
263 const bool use_relative_offset,
264 const bool use_interpolate)
287 if (v_sep == v_other) {
294 }
while ((
void)i++, ((l_iter = l_iter->
next) != l_first));
316 if (use_interpolate ==
false) {
320 }
while ((
void)i++, ((l_iter = l_iter->
next) != l_first));
323 if (use_interpolate) {
337 const float *eno_prev = edge_nors[(i ? i : f->
len) - 1];
338 const float *eno_next = edge_nors[i];
347 if (use_even_offset) {
352 if (use_relative_offset) {
364 const float fac = depth * (use_relative_offset ? ((e_length_prev + e_length) * 0.5f) : 1.0f);
365 e_length_prev = e_length;
371 }
while ((
void)i++, ((l_iter = l_iter->
next) != l_first));
378 }
while ((
void)i++, ((l_iter = l_iter->
next) != l_first));
380 if (use_interpolate) {
398 }
while ((l_iter = l_iter->
next) != l_first);
428 if (use_interpolate) {
442 if (use_interpolate) {
450 if (use_interpolate) {
502 return ((tot_tag == 1) && (tot_untag >= 1)) ? l_tag :
nullptr;
546 void **vert_lengths_p)
566 } *vert_lengths =
static_cast<VertLengths *
>(*vert_lengths_p);
569 if (
UNLIKELY(vert_lengths ==
nullptr)) {
575 vert_lengths =
static_cast<VertLengths *
>(
586 for (
int i = 0; i < 2; i++) {
590 if (vert_lengths[v_index].
count == 0) {
593 vert_lengths[v_index].count = 1;
596 BLI_assert(vert_lengths[v_index].length_accum != -1.0f);
607 while (stack_index--) {
608 BMVert *
v = vert_stack[stack_index];
613 vert_lengths[v_index].length_accum /=
float(vert_lengths[v_index].
count);
614 vert_lengths[v_index].count = -1;
627 if (vert_lengths[v_other_index].
count >= 0) {
628 if (vert_lengths[v_other_index].
count == 0) {
631 BLI_assert(vert_lengths[v_index].length_accum >= 0.0f);
632 vert_lengths[v_other_index].count += 1;
633 vert_lengths[v_other_index].length_accum += vert_lengths[v_index].length_accum;
639 *vert_lengths_p = vert_lengths;
652 void **vert_lengths_p)
656 if (length != -1.0f) {
676 (use_outset ==
false);
678 const bool use_even_boundary = use_even_offset;
684#ifdef USE_LOOP_CUSTOMDATA_MERGE
688 int edge_info_len = 0;
701 const bool use_vert_coords_orig = use_edge_rail;
702 MemArena *vert_coords_orig =
nullptr;
703 GHash *vert_coords =
nullptr;
710 if (use_interpolate) {
718 if (use_outset ==
false) {
772 if (use_vert_coords_orig) {
778#define VERT_ORIG_STORE(_v) \
780 float *_co = static_cast<float *>(BLI_memarena_alloc(vert_coords_orig, sizeof(float[3]))); \
781 copy_v3_v3(_co, (_v)->co); \
782 BLI_ghash_insert(vert_coords, _v, _co); \
785#define VERT_ORIG_GET(_v) (const float *)BLI_ghash_lookup_default(vert_coords, (_v), (_v)->co)
788#define VERT_ORIG_REMOVE(_v) BLI_ghash_remove(vert_coords, (_v), nullptr, nullptr)
790 for (i = 0, es = edge_info; i < edge_info_len; i++, es++) {
827 if (use_interpolate) {
833 if (iface_array[j] ==
nullptr) {
837 iface_array[j] = iface;
847 for (i = 0, es = edge_info; i < edge_info_len; i++, es++) {
864 for (i = 0, es = edge_info; i < edge_info_len; i++, es++) {
865 for (
int j = 0; j < 2; j++) {
885 if (r_vout_len == 1) {
886 if (use_vert_coords_orig) {
893 for (k = 0; k < r_vout_len; k++) {
894 BMVert *v_split = vout[k];
897 int vert_edge_tag_tot = 0;
900 if (use_vert_coords_orig) {
909 if (vert_edge_tag_tot < 2) {
918 if (vert_edge_tag_tot != 0) {
921 if (vert_edge_tag_tot >= 2) {
946 if (use_edge_rail ==
false) {
949 else if (f_a != f_b) {
954 if (l_other_a->
v == l_other_b->
v) {
957 const float *co_other;
961 if (use_vert_coords_orig) {
965 co_other = l_other_a->
v->
co;
993 if (use_even_offset) {
1010 if (use_relative_offset) {
1012 (edge_info[vecpair[0]].length + edge_info[vecpair[1]].length) / 2.0f);
1015 else if (vert_edge_tag_tot == 1) {
1016 const float *e_no_a = edge_info[vecpair[0]].
no;
1018 if (use_even_boundary) {
1049 if (
l->
prev->
v == v_split) {
1052 else if (
l->
next->
v == v_split) {
1055 else if (
l->
v == v_split) {
1079 if (use_even_offset) {
1090 if (use_relative_offset) {
1091 mul_v3_fl(tvec, edge_info[vecpair[0]].length);
1105 if (r_vout_len > 2) {
1116 if (v_glue ==
nullptr) {
1121 if (use_vert_coords_orig) {
1135 if (use_vert_coords_orig) {
1140 if (use_interpolate) {
1141 for (i = 0; i < iface_array_len; i++) {
1142 if (iface_array[i]) {
1157 for (i = 0, es = edge_info; i < edge_info_len; i++, es++) {
1158 BMVert *varr[4] = {
nullptr};
1163 if (varr[0] == es->
e_new->
v1) {
1175 if (varr[0] == es->
e_new->
v1) {
1256 if (use_interpolate) {
1265#ifdef USE_LOOP_CUSTOMDATA_MERGE
1266 if (has_math_ldata) {
1270 e_connect = l_a->
prev->
e;
1301 if (use_interpolate) {
1302 for (i = 0; i < iface_array_len; i++) {
1303 if (iface_array[i]) {
1316 if (depth != 0.0f) {
1322 for (i = 0, es = edge_info; i < edge_info_len; i++, es++) {
1326 for (i = 0, es = edge_info; i < edge_info_len; i++, es++) {
1327 const float *no = es->
l->
f->
no;
1331 for (i = 0, es = edge_info; i < edge_info_len; i++, es++) {
1347 BMLoop *l_iter, *l_first;
1352 }
while ((l_iter = l_iter->
next) != l_first);
1360 void *vert_lengths_p =
nullptr;
1366 (use_relative_offset ?
1379 if (vert_lengths_p !=
nullptr) {
CustomData interface, see also DNA_customdata_types.h.
void CustomData_bmesh_free_block(CustomData *data, void **block)
bool CustomData_layer_has_math(const CustomData *data, int layer_n)
void CustomData_data_copy_value(eCustomDataType type, const void *source, void *dest)
void CustomData_bmesh_copy_block(CustomData &data, void *src_block, void **dst_block)
bool CustomData_data_equals(eCustomDataType type, const void *data1, const void *data2)
bool CustomData_has_math(const CustomData *data)
void CustomData_data_mix_value(eCustomDataType type, const void *source, void *dest, int mixmode, float mixfactor)
void CustomData_bmesh_free_block_data(CustomData *data, void *block)
#define BLI_array_alloca(arr, realsize)
GHash * BLI_ghash_ptr_new(const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
MINLINE float shell_v3v3_normalized_to_dist(const float a[3], const float b[3])
MINLINE float shell_v3v3_mid_normalized_to_dist(const float a[3], const float b[3])
void axis_dominant_v3_to_m3(float r_mat[3][3], const float normal[3])
Normal to x,y matrix.
void mul_v2_m3v3(float r[2], const float M[3][3], const float a[3])
MINLINE float len_squared_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
MINLINE float len_squared_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void negate_v3(float r[3])
MINLINE bool compare_v3v3(const float v1[3], const float v2[3], float limit) ATTR_WARN_UNUSED_RESULT
void mid_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f)
MINLINE void zero_v3(float r[3])
MINLINE void add_v3_v3(float r[3], const float a[3])
MINLINE float normalize_v3(float n[3])
void * BLI_memarena_alloc(struct MemArena *ma, size_t size) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_ALLOC_SIZE(2)
void BLI_memarena_free(struct MemArena *ma) ATTR_NONNULL(1)
struct MemArena * BLI_memarena_new(size_t bufsize, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(2) ATTR_MALLOC
#define BLI_MEMARENA_STD_BUFSIZE
void void BLI_memarena_clear(MemArena *ma) ATTR_NONNULL(1)
#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 Guarded memory(de)allocation.
#define BM_FACE_FIRST_LOOP(p)
#define BM_ELEM_CD_GET_VOID_P(ele, offset)
void BM_face_copy_shared(BMesh *bm, BMFace *f, BMLoopFilterFunc filter_fn, void *user_data)
copies face loop data from shared adjacent faces.
void BM_elem_attrs_copy(BMesh *bm, const BMCustomDataCopyMap &map, const BMVert *src, BMVert *dst)
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 bmesh_kernel_edge_separate(BMesh *bm, BMEdge *e, BMLoop *l_sep, const bool copy_select)
Separate Edge.
bool BM_vert_splice(BMesh *bm, BMVert *v_dst, BMVert *v_src)
Splice Vert.
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)
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.
void bmesh_kernel_vert_separate(BMesh *bm, BMVert *v, BMVert ***r_vout, int *r_vout_len, const bool copy_select)
Separate Vert.
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.
#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)
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.
#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)
ATTR_WARN_UNUSED_RESULT BMesh * bm
void BM_mesh_elem_hflag_enable_all(BMesh *bm, const char htype, const char hflag, const bool respecthide)
void BM_mesh_elem_hflag_disable_all(BMesh *bm, const char htype, const char hflag, const bool respecthide)
void BM_mesh_elem_index_ensure(BMesh *bm, const char htype)
BMVert * BM_face_loop_separate(BMesh *bm, BMLoop *l_sep)
Rip a single face from a vertex fan.
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.
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.
float BMO_slot_float_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
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)
#define BMO_face_flag_enable(bm, e, oflag)
#define BMO_ITER(ele, iter, slot_args, slot_name, restrict_flag)
bool BMO_slot_bool_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
void BM_edge_ordered_verts_ex(const BMEdge *edge, BMVert **r_v1, BMVert **r_v2, const BMLoop *edge_loop)
bool BM_edge_in_face(const BMEdge *e, const BMFace *f)
float BM_vert_calc_shell_factor(const BMVert *v)
bool BM_face_is_normal_valid(const BMFace *f)
BMLoop * BM_edge_other_loop(BMEdge *e, BMLoop *l)
float BM_edge_calc_length(const BMEdge *e)
void BM_edge_calc_face_tangent(const BMEdge *e, const BMLoop *e_loop, float r_tangent[3])
BMESH EDGE/FACE TANGENT.
BMLoop * BM_loop_other_vert_loop(BMLoop *l, BMVert *v)
Other Loop in Face Sharing a Vert.
BLI_INLINE bool BM_edge_is_manifold(const BMEdge *e) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
BLI_INLINE bool BM_edge_is_boundary(const BMEdge *e) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
BLI_INLINE BMVert * BM_edge_other_vert(BMEdge *e, const BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMLoop * l
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
ATTR_WARN_UNUSED_RESULT const BMLoop * l_b
ATTR_WARN_UNUSED_RESULT const BMVert * v
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)
void bmo_inset_region_exec(BMesh *bm, BMOperator *op)
static void bm_interp_face_store(InterpFace *iface, BMesh *bm, BMFace *f, MemArena *interp_arena)
#define VERT_ORIG_REMOVE(_v)
static void bm_interp_face_free(InterpFace *iface, BMesh *bm)
static float bm_edge_info_average_length_with_fallback(BMVert *v, SplitEdgeInfo *edge_info, BMesh *bm, void **vert_lengths_p)
void bmo_inset_individual_exec(BMesh *bm, BMOperator *op)
static float bm_edge_info_average_length_fallback(BMVert *v_lookup, SplitEdgeInfo *edge_info, BMesh *bm, void **vert_lengths_p)
static BMLoop * bm_edge_is_mixed_face_tag(BMLoop *l)
static float bm_edge_info_average_length(BMVert *v, SplitEdgeInfo *edge_info)
#define VERT_ORIG_GET(_v)
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)
#define VERT_ORIG_STORE(_v)
SIMD_FORCE_INLINE btScalar length() const
Return the length of the vector.
draw_view in_light_buf[] float
void *(* MEM_mallocN)(size_t len, const char *str)
void MEM_freeN(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
struct BMLoop * radial_next
struct BMOpSlot slots_out[BMO_OP_MAX_SLOTS]
struct BMOpSlot slots_in[BMO_OP_MAX_SLOTS]