Blender  V3.3
bmesh_mesh.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #pragma once
4 
9 #include "bmesh_class.h"
10 
11 struct BMAllocTemplate;
13 struct BMPartialUpdate;
14 struct MLoopNorSpaceArray;
15 
18 
20  bool use_toolflags : true;
21 };
22 
32 BMesh *BM_mesh_create(const struct BMAllocTemplate *allocsize,
33  const struct BMeshCreateParams *params);
34 
40 void BM_mesh_free(BMesh *bm);
54 void BM_mesh_clear(BMesh *bm);
55 
67 void bmesh_edit_end(BMesh *bm, BMOpTypeFlag type_flag);
68 
69 void BM_mesh_elem_index_ensure_ex(BMesh *bm, char htype, int elem_offset[4]);
70 void BM_mesh_elem_index_ensure(BMesh *bm, char htype);
84  BMesh *bm, const char *location, const char *func, const char *msg_a, const char *msg_b);
85 
86 #ifndef NDEBUG
91 #endif
92 
96 void BM_mesh_toolflags_set(BMesh *bm, bool use_toolflags);
97 
98 void BM_mesh_elem_table_ensure(BMesh *bm, char htype);
99 /* use BM_mesh_elem_table_ensure where possible to avoid full rebuild */
100 void BM_mesh_elem_table_init(BMesh *bm, char htype);
101 void BM_mesh_elem_table_free(BMesh *bm, char htype);
102 
104 {
105  BLI_assert((index >= 0) && (index < bm->totvert));
107  return bm->vtable[index];
108 }
110 {
111  BLI_assert((index >= 0) && (index < bm->totedge));
113  return bm->etable[index];
114 }
116 {
117  BLI_assert((index >= 0) && (index < bm->totface));
119  return bm->ftable[index];
120 }
121 
122 BMVert *BM_vert_at_index_find(BMesh *bm, int index);
123 BMEdge *BM_edge_at_index_find(BMesh *bm, int index);
124 BMFace *BM_face_at_index_find(BMesh *bm, int index);
125 BMLoop *BM_loop_at_index_find(BMesh *bm, int index);
126 
135 
136 // XXX
137 
141 int BM_mesh_elem_count(BMesh *bm, char htype);
142 
157 void BM_mesh_remap(BMesh *bm, const uint *vert_idx, const uint *edge_idx, const uint *face_idx);
158 
165 void BM_mesh_rebuild(BMesh *bm,
166  const struct BMeshCreateParams *params,
167  struct BLI_mempool *vpool,
168  struct BLI_mempool *epool,
169  struct BLI_mempool *lpool,
170  struct BLI_mempool *fpool);
171 
172 typedef struct BMAllocTemplate {
175 
176 /* used as an extern, defined in bmesh.h */
179 
180 #define BMALLOC_TEMPLATE_FROM_BM(bm) \
181  { \
182  (CHECK_TYPE_INLINE(bm, BMesh *), (bm)->totvert), (bm)->totedge, (bm)->totloop, (bm)->totface \
183  }
184 
185 #define _VA_BMALLOC_TEMPLATE_FROM_ME_1(me) \
186  { \
187  (CHECK_TYPE_INLINE(me, Mesh *), (me)->totvert), (me)->totedge, (me)->totloop, (me)->totpoly, \
188  }
189 #define _VA_BMALLOC_TEMPLATE_FROM_ME_2(me_a, me_b) \
190  { \
191  (CHECK_TYPE_INLINE(me_a, Mesh *), \
192  CHECK_TYPE_INLINE(me_b, Mesh *), \
193  (me_a)->totvert + (me_b)->totvert), \
194  (me_a)->totedge + (me_b)->totedge, (me_a)->totloop + (me_b)->totloop, \
195  (me_a)->totpoly + (me_b)->totpoly, \
196  }
197 #define BMALLOC_TEMPLATE_FROM_ME(...) \
198  VA_NARGS_CALL_OVERLOAD(_VA_BMALLOC_TEMPLATE_FROM_ME_, __VA_ARGS__)
199 
200 /* Vertex coords access. */
201 void BM_mesh_vert_coords_get(BMesh *bm, float (*vert_coords)[3]);
202 float (*BM_mesh_vert_coords_alloc(BMesh *bm, int *r_vert_len))[3];
203 void BM_mesh_vert_coords_apply(BMesh *bm, const float (*vert_coords)[3]);
205  const float (*vert_coords)[3],
206  const float mat[4][4]);
typedef float(TangentPoint)[2]
#define BLI_assert(a)
Definition: BLI_assert.h:46
#define BLI_INLINE
unsigned int uint
Definition: BLI_sys_types.h:67
@ BM_FACE
Definition: bmesh_class.h:386
@ BM_VERT
Definition: bmesh_class.h:383
@ BM_EDGE
Definition: bmesh_class.h:384
ATTR_WARN_UNUSED_RESULT BMesh * bm
void BM_mesh_elem_toolflags_clear(BMesh *bm)
Definition: bmesh_mesh.cc:109
void BM_mesh_vert_coords_apply_with_mat4(BMesh *bm, const float(*vert_coords)[3], const float mat[4][4])
Definition: bmesh_mesh.cc:1338
void BM_mesh_elem_index_ensure_ex(BMesh *bm, char htype, int elem_offset[4])
Definition: bmesh_mesh.cc:332
const BMAllocTemplate bm_mesh_allocsize_default
Definition: bmesh_mesh.cc:23
void BM_mesh_toolflags_set(BMesh *bm, bool use_toolflags)
Definition: bmesh_mesh.cc:1275
void BM_mesh_data_free(BMesh *bm)
BMesh Free Mesh Data.
Definition: bmesh_mesh.cc:146
void BM_mesh_remap(BMesh *bm, const uint *vert_idx, const uint *edge_idx, const uint *face_idx)
Definition: bmesh_mesh.cc:726
void BM_mesh_vert_coords_apply(BMesh *bm, const float(*vert_coords)[3])
Definition: bmesh_mesh.cc:1328
void BM_mesh_clear(BMesh *bm)
BMesh Clear Mesh.
Definition: bmesh_mesh.cc:237
void BM_mesh_elem_table_free(BMesh *bm, char htype)
Definition: bmesh_mesh.cc:633
const BMAllocTemplate bm_mesh_chunksize_default
Definition: bmesh_mesh.cc:24
void bmesh_edit_begin(BMesh *bm, BMOpTypeFlag type_flag)
BMesh Begin Edit.
void BM_mesh_elem_toolflags_ensure(BMesh *bm)
Definition: bmesh_mesh.cc:75
void BM_mesh_rebuild(BMesh *bm, const struct BMeshCreateParams *params, struct BLI_mempool *vpool, struct BLI_mempool *epool, struct BLI_mempool *lpool, struct BLI_mempool *fpool)
Definition: bmesh_mesh.cc:1020
void BM_mesh_elem_index_ensure(BMesh *bm, char htype)
Definition: bmesh_mesh.cc:446
BMVert * BM_vert_at_index_find(BMesh *bm, int index)
Definition: bmesh_mesh.cc:648
BMFace * BM_face_at_index_find_or_table(BMesh *bm, int index)
Definition: bmesh_mesh.cc:700
BLI_INLINE BMFace * BM_face_at_index(BMesh *bm, const int index)
Definition: bmesh_mesh.h:115
BLI_INLINE BMEdge * BM_edge_at_index(BMesh *bm, const int index)
Definition: bmesh_mesh.h:109
void BM_mesh_free(BMesh *bm)
BMesh Free Mesh.
Definition: bmesh_mesh.cc:258
void BM_mesh_elem_table_ensure(BMesh *bm, char htype)
Definition: bmesh_mesh.cc:558
void BM_mesh_elem_table_init(BMesh *bm, char htype)
Definition: bmesh_mesh.cc:624
BMesh * BM_mesh_create(const struct BMAllocTemplate *allocsize, const struct BMeshCreateParams *params)
BMesh Make Mesh.
float(* BM_mesh_vert_coords_alloc(BMesh *bm, int *r_vert_len))[3]
Definition: bmesh_mesh.cc:1320
BMEdge * BM_edge_at_index_find(BMesh *bm, int index)
Definition: bmesh_mesh.cc:653
BMFace * BM_face_at_index_find(BMesh *bm, int index)
Definition: bmesh_mesh.cc:658
void BM_mesh_elem_index_validate(BMesh *bm, const char *location, const char *func, const char *msg_a, const char *msg_b)
Definition: bmesh_mesh.cc:451
void bmesh_edit_end(BMesh *bm, BMOpTypeFlag type_flag)
BMesh End Edit.
Definition: bmesh_mesh.cc:292
bool BM_mesh_elem_table_check(BMesh *bm)
Definition: bmesh_mesh.cc:524
BLI_INLINE BMVert * BM_vert_at_index(BMesh *bm, const int index)
Definition: bmesh_mesh.h:103
struct BMAllocTemplate BMAllocTemplate
void BM_mesh_vert_coords_get(BMesh *bm, float(*vert_coords)[3])
Definition: bmesh_mesh.cc:1310
int BM_mesh_elem_count(BMesh *bm, char htype)
Definition: bmesh_mesh.cc:708
BMVert * BM_vert_at_index_find_or_table(BMesh *bm, int index)
Definition: bmesh_mesh.cc:684
BMLoop * BM_loop_at_index_find(BMesh *bm, int index)
Definition: bmesh_mesh.cc:663
BMEdge * BM_edge_at_index_find_or_table(BMesh *bm, int index)
Definition: bmesh_mesh.cc:692
BMOpTypeFlag
static int elem_offset(const SDNA *sdna, const char *type, const char *name, const SDNA_Struct *old)
Definition: dna_genfile.c:954
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
BMEdge ** etable
Definition: bmesh_class.h:322
char elem_table_dirty
Definition: bmesh_class.h:311
BMVert ** vtable
Definition: bmesh_class.h:321
BMFace ** ftable
Definition: bmesh_class.h:323