Blender V4.3
bmesh_mesh.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
11#include "BLI_array.hh"
13#include "BLI_span.hh"
14
15#include "bmesh_class.hh"
16
17struct BMAllocTemplate;
18
21
23 bool use_toolflags : 1;
24};
25
36
42void BM_mesh_free(BMesh *bm);
57
65void bmesh_edit_begin(BMesh *bm, BMOpTypeFlag type_flag);
69void bmesh_edit_end(BMesh *bm, BMOpTypeFlag type_flag);
70
71void BM_mesh_elem_index_ensure_ex(BMesh *bm, char htype, int elem_offset[4]);
72void BM_mesh_elem_index_ensure(BMesh *bm, char htype);
86 BMesh *bm, const char *location, const char *func, const char *msg_a, const char *msg_b);
87
88#ifndef NDEBUG
93#endif
94
98void BM_mesh_toolflags_set(BMesh *bm, bool use_toolflags);
99
100void BM_mesh_elem_table_ensure(BMesh *bm, char htype);
101/* use BM_mesh_elem_table_ensure where possible to avoid full rebuild */
102void BM_mesh_elem_table_init(BMesh *bm, char htype);
103void BM_mesh_elem_table_free(BMesh *bm, char htype);
104
106{
107 BLI_assert((index >= 0) && (index < bm->totvert));
109 return bm->vtable[index];
110}
112{
113 BLI_assert((index >= 0) && (index < bm->totedge));
115 return bm->etable[index];
116}
118{
119 BLI_assert((index >= 0) && (index < bm->totface));
121 return bm->ftable[index];
122}
123
128
137
138// XXX
139
143int BM_mesh_elem_count(BMesh *bm, char htype);
144
159void BM_mesh_remap(BMesh *bm, const uint *vert_idx, const uint *edge_idx, const uint *face_idx);
160
169 BLI_mempool *vpool,
170 BLI_mempool *epool,
171 BLI_mempool *lpool,
172 BLI_mempool *fpool);
173
177
178/* used as an extern, defined in bmesh.h */
181
182#define BMALLOC_TEMPLATE_FROM_BM(bm) \
183 { \
184 (CHECK_TYPE_INLINE(bm, BMesh *), (bm)->totvert), (bm)->totedge, (bm)->totloop, (bm)->totface \
185 }
186
187#define _VA_BMALLOC_TEMPLATE_FROM_ME_1(me) \
188 { \
189 (CHECK_TYPE_INLINE(me, Mesh *), (me)->verts_num), (me)->edges_num, (me)->corners_num, \
190 (me)->faces_num, \
191 }
192#define _VA_BMALLOC_TEMPLATE_FROM_ME_2(me_a, me_b) \
193 { \
194 (CHECK_TYPE_INLINE(me_a, Mesh *), \
195 CHECK_TYPE_INLINE(me_b, Mesh *), \
196 (me_a)->verts_num + (me_b)->verts_num), \
197 (me_a)->edges_num + (me_b)->edges_num, (me_a)->corners_num + (me_b)->corners_num, \
198 (me_a)->faces_num + (me_b)->faces_num, \
199 }
200#define BMALLOC_TEMPLATE_FROM_ME(...) \
201 VA_NARGS_CALL_OVERLOAD(_VA_BMALLOC_TEMPLATE_FROM_ME_, __VA_ARGS__)
202
204
205/* Vertex coords access. */
208void BM_mesh_vert_coords_apply(BMesh *bm, const float (*vert_coords)[3]);
210 const float (*vert_coords)[3],
211 const float mat[4][4]);
#define BLI_assert(a)
Definition BLI_assert.h:50
#define BLI_INLINE
unsigned int uint
ATTR_WARN_UNUSED_RESULT 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])
void BM_mesh_elem_index_ensure_ex(BMesh *bm, char htype, int elem_offset[4])
const BMAllocTemplate bm_mesh_allocsize_default
Definition bmesh_mesh.cc:29
blender::Array< blender::float3 > BM_mesh_vert_coords_alloc(BMesh *bm)
BLI_INLINE BMEdge * BM_edge_at_index(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.
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.
BMEdge * BM_edge_at_index_find(BMesh *bm, int index)
void BM_mesh_elem_table_free(BMesh *bm, char htype)
BMVert * BM_vert_at_index_find_or_table(BMesh *bm, int index)
const BMAllocTemplate bm_mesh_chunksize_default
Definition bmesh_mesh.cc:30
void bmesh_edit_begin(BMesh *bm, BMOpTypeFlag type_flag)
BMesh Begin Edit.
void BM_mesh_vert_normals_get(BMesh *bm, blender::MutableSpan< blender::float3 > positions)
void BM_mesh_rebuild(BMesh *bm, const BMeshCreateParams *params, BLI_mempool *vpool, BLI_mempool *epool, BLI_mempool *lpool, BLI_mempool *fpool)
void BM_mesh_elem_toolflags_ensure(BMesh *bm)
Definition bmesh_mesh.cc:81
BMLoop * BM_loop_at_index_find(BMesh *bm, int index)
void BM_mesh_elem_index_ensure(BMesh *bm, char htype)
BLI_INLINE BMVert * BM_vert_at_index(BMesh *bm, const int index)
void BM_mesh_vert_coords_get(BMesh *bm, blender::MutableSpan< blender::float3 > positions)
void BM_mesh_free(BMesh *bm)
BMesh Free Mesh.
BLI_INLINE BMFace * BM_face_at_index(BMesh *bm, const int index)
void BM_mesh_elem_table_ensure(BMesh *bm, char htype)
BMEdge * BM_edge_at_index_find_or_table(BMesh *bm, int index)
void BM_mesh_elem_table_init(BMesh *bm, char htype)
void BM_mesh_elem_index_validate(BMesh *bm, const char *location, const char *func, const char *msg_a, const char *msg_b)
BMFace * BM_face_at_index_find(BMesh *bm, int index)
BMFace * BM_face_at_index_find_or_table(BMesh *bm, int index)
void bmesh_edit_end(BMesh *bm, BMOpTypeFlag type_flag)
BMesh End Edit.
bool BM_mesh_elem_table_check(BMesh *bm)
int BM_mesh_elem_count(BMesh *bm, char htype)
BMesh * BM_mesh_create(const BMAllocTemplate *allocsize, const BMeshCreateParams *params)
BMesh Make Mesh.
BMVert * BM_vert_at_index_find(BMesh *bm, int index)
#define BM_FACE
#define BM_EDGE
#define BM_VERT
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
BMEdge ** etable
char elem_table_dirty
BMVert ** vtable
BMFace ** ftable