27 const bool use_toolflags,
33 size_t vert_size, edge_size, loop_size, face_size;
35 if (use_toolflags ==
true) {
38 loop_size =
sizeof(
BMLoop);
42 vert_size =
sizeof(
BMVert);
43 edge_size =
sizeof(
BMEdge);
44 loop_size =
sizeof(
BMLoop);
45 face_size =
sizeof(
BMFace);
70 #ifdef USE_BMESH_HOLES
171 if (is_ldata_free || is_pdata_free) {
223 #ifdef USE_BMESH_HOLES
279 #ifdef BMOP_UNTAN_MULTIRES_ENABLED
283 bmesh_mdisps_space_set(
bm, MULTIRES_SPACE_TANGENT, MULTIRES_SPACE_ABSOLUTE);
286 bmesh_rationalize_normals(
bm, 0);
297 #ifdef BMOP_UNTAN_MULTIRES_ENABLED
301 bmesh_rationalize_normals(
bm, 1);
302 bmesh_mdisps_space_set(
bm, MULTIRES_SPACE_ABSOLUTE, MULTIRES_SPACE_TANGENT);
304 else if (flag & BMO_OP_FLAG_RATIONALIZE_NORMALS) {
305 bmesh_rationalize_normals(
bm, 1);
342 if (htype_needed == 0) {
402 }
while ((l_iter = l_iter->
next) != l_first);
452 BMesh *
bm,
const char *location,
const char *func,
const char *msg_a,
const char *msg_b)
457 const char *type_names[3] = {
"vert",
"edge",
"face"};
462 bool is_any_error =
false;
464 for (i = 0; i < 3; i++) {
467 bool is_error =
false;
483 if ((is_error ==
true) && (is_dirty ==
false)) {
486 "Invalid Index: at %s, %s, %s[%d] invalid index %d, '%s', '%s'\n",
495 else if ((is_error ==
false) && (is_dirty ==
true)) {
501 "Invalid Dirty: at %s, %s (%s), dirty flag was set but all index values are "
502 "correct, '%s', '%s'\n",
514 if (is_any_error == 0) {
515 fprintf(stderr,
"Valid Index Success: at %s, %s, '%s', '%s'\n", location, func, msg_a, msg_b);
561 const char htype_needed =
572 if (htype_needed == 0) {
677 }
while ((l_iter = l_iter->
next) != l_first);
687 return (index < bm->totvert) ?
bm->
vtable[index] :
nullptr;
695 return (index < bm->totedge) ?
bm->
etable[index] :
nullptr;
703 return (index < bm->totface) ?
bm->
ftable[index] :
nullptr;
729 GHash *vptr_map =
nullptr, *eptr_map =
nullptr, *fptr_map =
nullptr;
736 if (!(vert_idx || edge_idx || face_idx)) {
745 BMVert **verts_pool, *verts_copy, **vep;
758 void **pyptrs = (cd_vert_pyptr != -1) ?
759 (
void **)
MEM_mallocN(
sizeof(
void *) * totvert, __func__) :
761 for (i = totvert, ve = verts_copy + totvert - 1, vep = verts_pool + totvert - 1; i--;
765 if (cd_vert_pyptr != -1) {
772 new_idx = vert_idx + totvert - 1;
773 ve = verts_copy + totvert - 1;
774 vep = verts_pool + totvert - 1;
775 for (i = totvert; i--; new_idx--, ve--, vep--) {
776 BMVert *new_vep = verts_pool[*new_idx];
780 "mapping vert from %d to %d (%p/%p to %p)\n", i, *new_idx, *vep, verts_pool[i], new_vep);
783 if (cd_vert_pyptr != -1) {
785 *pyptr = pyptrs[*new_idx];
799 BMEdge **edges_pool, *edges_copy, **edp;
812 void **pyptrs = (cd_edge_pyptr != -1) ?
813 (
void **)
MEM_mallocN(
sizeof(
void *) * totedge, __func__) :
815 for (i = totedge, ed = edges_copy + totedge - 1, edp = edges_pool + totedge - 1; i--;
818 if (cd_edge_pyptr != -1) {
825 new_idx = edge_idx + totedge - 1;
826 ed = edges_copy + totedge - 1;
827 edp = edges_pool + totedge - 1;
828 for (i = totedge; i--; new_idx--, ed--, edp--) {
829 BMEdge *new_edp = edges_pool[*new_idx];
834 "mapping edge from %d to %d (%p/%p to %p)\n", i, *new_idx, *edp, edges_pool[i], new_edp);
836 if (cd_edge_pyptr != -1) {
838 *pyptr = pyptrs[*new_idx];
852 BMFace **faces_pool, *faces_copy, **fap;
865 void **pyptrs = (cd_poly_pyptr != -1) ?
866 (
void **)
MEM_mallocN(
sizeof(
void *) * totface, __func__) :
868 for (i = totface, fa = faces_copy + totface - 1, fap = faces_pool + totface - 1; i--;
871 if (cd_poly_pyptr != -1) {
878 new_idx = face_idx + totface - 1;
879 fa = faces_copy + totface - 1;
880 fap = faces_pool + totface - 1;
881 for (i = totface; i--; new_idx--, fa--, fap--) {
882 BMFace *new_fap = faces_pool[*new_idx];
885 if (cd_poly_pyptr != -1) {
887 *pyptr = pyptrs[*new_idx];
915 if (vptr_map || eptr_map) {
929 printf(
"Edge v1_disk_link prev: %p -> %p\n",
932 printf(
"Edge v1_disk_link next: %p -> %p\n",
935 printf(
"Edge v2_disk_link prev: %p -> %p\n",
938 printf(
"Edge v2_disk_link next: %p -> %p\n",
979 switch (ese->
htype) {
1027 const char remap = (vpool_dst ?
BM_VERT : 0) | (epool_dst ?
BM_EDGE : 0) |
1043 const bool use_toolflags =
params->use_toolflags;
1051 memcpy(v_dst, v_src,
sizeof(
BMVert));
1052 if (use_toolflags) {
1058 vtable_dst[index] = v_dst;
1069 memcpy(e_dst, e_src,
sizeof(
BMEdge));
1070 if (use_toolflags) {
1076 etable_dst[index] = e_dst;
1083 int index, index_loop = 0;
1089 memcpy(f_dst, f_src,
sizeof(
BMFace));
1090 if (use_toolflags) {
1096 ftable_dst[index] = f_dst;
1102 BMLoop *l_iter_src, *l_first_src;
1106 memcpy(l_dst, l_iter_src,
sizeof(
BMLoop));
1107 ltable_dst[index_loop] = l_dst;
1109 }
while ((l_iter_src = l_iter_src->
next) != l_first_src);
1114 #define MAP_VERT(ele) vtable_dst[BM_elem_index_get(ele)]
1115 #define MAP_EDGE(ele) etable_dst[BM_elem_index_get(ele)]
1116 #define MAP_LOOP(ele) ltable_dst[BM_elem_index_get(ele)]
1117 #define MAP_FACE(ele) ftable_dst[BM_elem_index_get(ele)]
1119 #define REMAP_VERT(ele) \
1121 if (remap & BM_VERT) { \
1122 ele = MAP_VERT(ele); \
1126 #define REMAP_EDGE(ele) \
1128 if (remap & BM_EDGE) { \
1129 ele = MAP_EDGE(ele); \
1133 #define REMAP_LOOP(ele) \
1135 if (remap & BM_LOOP) { \
1136 ele = MAP_LOOP(ele); \
1140 #define REMAP_FACE(ele) \
1142 if (remap & BM_FACE) { \
1143 ele = MAP_FACE(ele); \
1177 BMFace *f = ftable_dst[i];
1181 BMLoop *l_iter, *l_first;
1192 }
while ((l_iter = l_iter->
next) != l_first);
1198 switch (ese->htype) {
1287 bm_mempool_init_ex(&allocsize, use_toolflags, &vpool_dst, &epool_dst,
nullptr, &fpool_dst);
1289 if (use_toolflags ==
false) {
1339 const float (*vert_coords)[3],
1340 const float mat[4][4])
typedef float(TangentPoint)[2]
CustomData interface, see also DNA_customdata_types.h.
void CustomData_free(struct CustomData *data, int totelem)
bool CustomData_has_layer(const struct CustomData *data, int type)
bool CustomData_bmesh_has_free(const struct CustomData *data)
int CustomData_get_offset(const struct CustomData *data, int type)
void CustomData_bmesh_free_block(struct CustomData *data, void **block)
void CustomData_reset(struct CustomData *data)
void BKE_lnor_spacearr_free(MLoopNorSpaceArray *lnors_spacearr)
void * BLI_ghash_lookup(const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
GHash * BLI_ghash_ptr_new_ex(const char *info, unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
void BLI_ghash_insert(GHash *gh, void *key, void *val)
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
#define LISTBASE_FOREACH(type, var, list)
BLI_INLINE void BLI_listbase_clear(struct ListBase *lb)
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
void mul_v3_m4v3(float r[3], const float M[4][4], const float v[3])
MINLINE void copy_v3_v3(float r[3], const float a[3])
BLI_mempool * BLI_mempool_create(unsigned int esize, unsigned int elem_num, unsigned int pchunk, unsigned int flag) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
void * BLI_mempool_alloc(BLI_mempool *pool) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(1)
void BLI_mempool_destroy(BLI_mempool *pool) ATTR_NONNULL(1)
void * BLI_mempool_calloc(BLI_mempool *pool) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(1)
void * BLI_mempool_findelem(BLI_mempool *pool, unsigned int index) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
These structs are the foundation for all linked lists in the library system.
Read Guarded memory(de)allocation.
struct BMFace_OFlag BMFace_OFlag
struct BMVert_OFlag BMVert_OFlag
#define BM_FACE_FIRST_LOOP(p)
struct BMEdge_OFlag BMEdge_OFlag
#define BM_ELEM_CD_GET_VOID_P(ele, offset)
void BMO_error_clear(BMesh *bm)
#define BM_ELEM_INDEX_VALIDATE(_bm, _msg_a, _msg_b)
#define BM_elem_index_get(ele)
#define BM_elem_index_set(ele, index)
int BM_iter_as_array(BMesh *bm, const char itype, void *data, void **array, const int len)
Iterator as Array.
#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_select_mode_flush(BMesh *bm)
void BM_mesh_elem_toolflags_clear(BMesh *bm)
void BM_mesh_vert_coords_apply_with_mat4(BMesh *bm, const float(*vert_coords)[3], const float mat[4][4])
const BMAllocTemplate bm_mesh_allocsize_default
BMFace * BM_face_at_index_find(BMesh *bm, const int index)
void BM_mesh_toolflags_set(BMesh *bm, bool use_toolflags)
void BM_mesh_data_free(BMesh *bm)
BMesh Free Mesh Data.
static void bm_mempool_init_ex(const BMAllocTemplate *allocsize, const bool use_toolflags, BLI_mempool **r_vpool, BLI_mempool **r_epool, BLI_mempool **r_lpool, BLI_mempool **r_fpool)
void BM_mesh_remap(BMesh *bm, const uint *vert_idx, const uint *edge_idx, const uint *face_idx)
void BM_mesh_vert_coords_apply(BMesh *bm, const float(*vert_coords)[3])
void BM_mesh_clear(BMesh *bm)
BMesh Clear Mesh.
const BMAllocTemplate bm_mesh_chunksize_default
BMEdge * BM_edge_at_index_find_or_table(BMesh *bm, const int index)
static void bm_mempool_init(BMesh *bm, const BMAllocTemplate *allocsize, const bool use_toolflags)
void BM_mesh_elem_toolflags_ensure(BMesh *bm)
BMEdge * BM_edge_at_index_find(BMesh *bm, const int index)
void BM_mesh_free(BMesh *bm)
BMesh Free Mesh.
void BM_mesh_rebuild(BMesh *bm, const struct BMeshCreateParams *params, BLI_mempool *vpool_dst, BLI_mempool *epool_dst, BLI_mempool *lpool_dst, BLI_mempool *fpool_dst)
BMFace * BM_face_at_index_find_or_table(BMesh *bm, const int index)
BMVert * BM_vert_at_index_find_or_table(BMesh *bm, const int index)
BMesh * BM_mesh_create(const BMAllocTemplate *allocsize, const struct BMeshCreateParams *params)
void bmesh_edit_begin(BMesh *UNUSED(bm), BMOpTypeFlag UNUSED(type_flag))
void BM_mesh_elem_table_free(BMesh *bm, const char htype)
BMVert * BM_vert_at_index_find(BMesh *bm, const int index)
int BM_mesh_elem_count(BMesh *bm, const char htype)
void BM_mesh_elem_table_ensure(BMesh *bm, const char htype)
void BM_mesh_elem_table_init(BMesh *bm, const char htype)
float(* BM_mesh_vert_coords_alloc(BMesh *bm, int *r_vert_len))[3]
void BM_mesh_elem_index_ensure(BMesh *bm, const char htype)
void BM_mesh_elem_index_validate(BMesh *bm, const char *location, const char *func, const char *msg_a, const char *msg_b)
BMLoop * BM_loop_at_index_find(BMesh *bm, const int index)
void bmesh_edit_end(BMesh *bm, BMOpTypeFlag type_flag)
BMesh End Edit.
bool BM_mesh_elem_table_check(BMesh *bm)
void BM_mesh_vert_coords_get(BMesh *bm, float(*vert_coords)[3])
void BM_mesh_elem_index_ensure_ex(BMesh *bm, const char htype, int elem_offset[4])
#define BMALLOC_TEMPLATE_FROM_BM(bm)
void BM_mesh_normals_update(BMesh *bm)
@ BMO_OPTYPE_FLAG_INVALIDATE_CLNOR_ALL
@ BMO_OPTYPE_FLAG_SELECT_VALIDATE
@ BMO_OPTYPE_FLAG_UNTAN_MULTIRES
@ BMO_OPTYPE_FLAG_NORMALS_CALC
@ BMO_OPTYPE_FLAG_SELECT_FLUSH
ATTR_WARN_UNUSED_RESULT const BMLoop * l
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
ATTR_WARN_UNUSED_RESULT const BMVert * v
void bpy_bm_generic_invalidate(struct BPy_BMGeneric *UNUSED(self))
SyclQueue void void size_t num_bytes void
static int elem_offset(const SDNA *sdna, const char *type, const char *name, const SDNA_Struct *old)
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_mallocN)(size_t len, const char *str)
struct BMFlagLayer * oflags
struct BMEditSelection * next
struct BMFlagLayer * oflags
struct BMLoop * radial_prev
struct BMLoop * radial_next
struct BMFlagLayer * oflags
struct BLI_mempool * epool
struct MLoopNorSpaceArray * lnor_spacearr
struct BLI_mempool * vtoolflagpool
struct BLI_mempool * etoolflagpool
struct BLI_mempool * ftoolflagpool
struct BLI_mempool * fpool
struct BLI_mempool * vpool
struct BLI_mempool * lpool
struct BLI_mempool * pool