Blender V5.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
10
11#include "BLI_array.hh"
14#include "BLI_span.hh"
15
16#include "bmesh_class.hh"
17
19
20namespace blender {
21
22struct BMAllocTemplate;
23
26
28 bool use_toolflags : 1;
29};
30
40BMesh *BM_mesh_create(const BMAllocTemplate *allocsize, const BMeshCreateParams *params);
41
47void BM_mesh_free(BMesh *bm);
62
70void bmesh_edit_begin(BMesh *bm, BMOpTypeFlag type_flag);
74void bmesh_edit_end(BMesh *bm, BMOpTypeFlag type_flag);
75
76void BM_mesh_elem_index_ensure_ex(BMesh *bm, char htype, int elem_offset[4]);
77void BM_mesh_elem_index_ensure(BMesh *bm, char htype);
91 BMesh *bm, const char *location, const char *func, const char *msg_a, const char *msg_b);
92
93#ifndef NDEBUG
98#endif
99
103void BM_mesh_toolflags_set(BMesh *bm, bool use_toolflags);
104
105void BM_mesh_elem_table_ensure(BMesh *bm, char htype);
106/* use BM_mesh_elem_table_ensure where possible to avoid full rebuild */
107void BM_mesh_elem_table_init(BMesh *bm, char htype);
108void BM_mesh_elem_table_free(BMesh *bm, char htype);
109
111{
112 BLI_assert((index >= 0) && (index < bm->totvert));
114 return bm->vtable[index];
115}
117{
118 BLI_assert((index >= 0) && (index < bm->totedge));
120 return bm->etable[index];
121}
123{
124 BLI_assert((index >= 0) && (index < bm->totface));
126 return bm->ftable[index];
127}
128
129BMVert *BM_vert_at_index_find(BMesh *bm, int index);
130BMEdge *BM_edge_at_index_find(BMesh *bm, int index);
131BMFace *BM_face_at_index_find(BMesh *bm, int index);
132BMLoop *BM_loop_at_index_find(BMesh *bm, int index);
133
139BMVert *BM_vert_at_index_find_or_table(BMesh *bm, int index);
140BMEdge *BM_edge_at_index_find_or_table(BMesh *bm, int index);
141BMFace *BM_face_at_index_find_or_table(BMesh *bm, int index);
142
143// XXX
144
148int BM_mesh_elem_count(BMesh *bm, char htype);
149
164void BM_mesh_remap(BMesh *bm, const uint *vert_idx, const uint *edge_idx, const uint *face_idx);
165
172void BM_mesh_rebuild(BMesh *bm,
173 const BMeshCreateParams *params,
174 BLI_mempool *vpool,
175 BLI_mempool *epool,
176 BLI_mempool *lpool,
177 BLI_mempool *fpool);
178
182
183/* used as an extern, defined in bmesh.h */
186
187#define BMALLOC_TEMPLATE_FROM_BM(bm) \
188 {(CHECK_TYPE_INLINE(bm, BMesh *), (bm)->totvert), (bm)->totedge, (bm)->totloop, (bm)->totface}
189
190#define _VA_BMALLOC_TEMPLATE_FROM_ME_1(me) \
191 { \
192 (CHECK_TYPE_INLINE(me, Mesh *), (me)->verts_num), \
193 (me)->edges_num, \
194 (me)->corners_num, \
195 (me)->faces_num, \
196 }
197#define _VA_BMALLOC_TEMPLATE_FROM_ME_2(me_a, me_b) \
198 { \
199 (CHECK_TYPE_INLINE(me_a, Mesh *), \
200 CHECK_TYPE_INLINE(me_b, Mesh *), \
201 (me_a)->verts_num + (me_b)->verts_num), \
202 (me_a)->edges_num + (me_b)->edges_num, \
203 (me_a)->corners_num + (me_b)->corners_num, \
204 (me_a)->faces_num + (me_b)->faces_num, \
205 }
206#define BMALLOC_TEMPLATE_FROM_ME(...) \
207 VA_NARGS_CALL_OVERLOAD(_VA_BMALLOC_TEMPLATE_FROM_ME_, __VA_ARGS__)
208
209void BM_mesh_vert_normals_get(BMesh *bm, MutableSpan<float3> normals);
210
211/* Vertex coords access. */
212void BM_mesh_vert_coords_get(const BMesh *bm, MutableSpan<float3> positions);
213Array<float3> BM_mesh_vert_coords_alloc(const BMesh *bm);
214void BM_mesh_vert_coords_apply(BMesh *bm, Span<float3> vert_coords);
216 Span<float3> vert_coords,
217 const float4x4 &transform);
218
219} // namespace blender
#define BLI_INLINE
SIMD_FORCE_INLINE btVector3 transform(const btVector3 &point) const
#define index(i)
MatBase< 4, 4 > float4x4
BMesh Iterators.
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void BM_mesh_vert_normals_get(BMesh *bm, MutableSpan< float3 > normals)
void BM_mesh_elem_index_validate(BMesh *bm, const char *location, const char *func, const char *msg_a, const char *msg_b)
void BM_mesh_elem_index_ensure(BMesh *bm, const char htype)
BMFace * BM_face_at_index_find(BMesh *bm, const int index)
void BM_mesh_elem_toolflags_ensure(BMesh *bm)
Definition bmesh_mesh.cc:78
void BM_mesh_free(BMesh *bm)
BMesh Free Mesh.
void BM_mesh_data_free(BMesh *bm)
BMesh Free Mesh Data.
unsigned int uint
Definition BKE_text.h:55
void BM_mesh_vert_coords_apply_with_mat4(BMesh *bm, const Span< float3 > vert_coords, const float4x4 &transform)
BLI_INLINE BMEdge * BM_edge_at_index(BMesh *bm, const int index)
void BM_mesh_elem_table_ensure(BMesh *bm, const char htype)
void BM_mesh_vert_coords_apply(BMesh *bm, const Span< float3 > vert_coords)
BMVert * BM_vert_at_index_find_or_table(BMesh *bm, const int index)
void BM_mesh_rebuild(BMesh *bm, const BMeshCreateParams *params, BLI_mempool *vpool_dst, BLI_mempool *epool_dst, BLI_mempool *lpool_dst, BLI_mempool *fpool_dst)
BMLoop * BM_loop_at_index_find(BMesh *bm, const int index)
void BM_mesh_vert_coords_get(const BMesh *bm, MutableSpan< float3 > positions)
const BMAllocTemplate bm_mesh_chunksize_default
Definition bmesh_mesh.cc:27
BMVert * BM_vert_at_index_find(BMesh *bm, const int index)
BMEdge * BM_edge_at_index_find(BMesh *bm, const int index)
BMFace * BM_face_at_index_find_or_table(BMesh *bm, const int index)
int BM_mesh_elem_count(BMesh *bm, const char htype)
void BM_mesh_clear(BMesh *bm)
BMesh Clear Mesh.
const BMAllocTemplate bm_mesh_allocsize_default
Definition bmesh_mesh.cc:26
Array< float3 > BM_mesh_vert_coords_alloc(const BMesh *bm)
BLI_INLINE BMVert * BM_vert_at_index(BMesh *bm, const int index)
void BM_mesh_toolflags_set(BMesh *bm, bool use_toolflags)
void bmesh_edit_begin(BMesh *, BMOpTypeFlag)
BMesh Begin Edit.
void BM_mesh_elem_table_init(BMesh *bm, const char htype)
BLI_INLINE BMFace * BM_face_at_index(BMesh *bm, const int index)
void BM_mesh_elem_table_free(BMesh *bm, const char htype)
void bmesh_edit_end(BMesh *bm, BMOpTypeFlag type_flag)
BMesh End Edit.
void BM_mesh_elem_index_ensure_ex(BMesh *bm, const char htype, int elem_offset[4])
BMesh * BM_mesh_create(const BMAllocTemplate *allocsize, const BMeshCreateParams *params)
BMesh Make Mesh.
void BM_mesh_elem_toolflags_clear(BMesh *bm)
void BM_mesh_remap(BMesh *bm, const uint *vert_idx, const uint *edge_idx, const uint *face_idx)
BMEdge * BM_edge_at_index_find_or_table(BMesh *bm, const int index)
bool BM_mesh_elem_table_check(BMesh *bm)