Blender  V3.3
Classes | Macros | Typedefs | Functions | Variables
bmesh_mesh.h File Reference
#include "bmesh_class.h"

Go to the source code of this file.

Classes

struct  BMeshCreateParams
 
struct  BMAllocTemplate
 

Macros

#define BMALLOC_TEMPLATE_FROM_BM(bm)
 
#define _VA_BMALLOC_TEMPLATE_FROM_ME_1(me)
 
#define _VA_BMALLOC_TEMPLATE_FROM_ME_2(me_a, me_b)
 
#define BMALLOC_TEMPLATE_FROM_ME(...)    VA_NARGS_CALL_OVERLOAD(_VA_BMALLOC_TEMPLATE_FROM_ME_, __VA_ARGS__)
 

Typedefs

typedef struct BMAllocTemplate BMAllocTemplate
 

Functions

void BM_mesh_elem_toolflags_ensure (BMesh *bm)
 
void BM_mesh_elem_toolflags_clear (BMesh *bm)
 
BMeshBM_mesh_create (const struct BMAllocTemplate *allocsize, const struct BMeshCreateParams *params)
 BMesh Make Mesh. More...
 
void BM_mesh_free (BMesh *bm)
 BMesh Free Mesh. More...
 
void BM_mesh_data_free (BMesh *bm)
 BMesh Free Mesh Data. More...
 
void BM_mesh_clear (BMesh *bm)
 BMesh Clear Mesh. More...
 
void bmesh_edit_begin (BMesh *bm, BMOpTypeFlag type_flag)
 BMesh Begin Edit. More...
 
void bmesh_edit_end (BMesh *bm, BMOpTypeFlag type_flag)
 BMesh End Edit. More...
 
void BM_mesh_elem_index_ensure_ex (BMesh *bm, char htype, int elem_offset[4])
 
void BM_mesh_elem_index_ensure (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)
 
bool BM_mesh_elem_table_check (BMesh *bm)
 
void BM_mesh_toolflags_set (BMesh *bm, bool use_toolflags)
 
void BM_mesh_elem_table_ensure (BMesh *bm, char htype)
 
void BM_mesh_elem_table_init (BMesh *bm, char htype)
 
void BM_mesh_elem_table_free (BMesh *bm, char htype)
 
BLI_INLINE BMVertBM_vert_at_index (BMesh *bm, const int index)
 
BLI_INLINE BMEdgeBM_edge_at_index (BMesh *bm, const int index)
 
BLI_INLINE BMFaceBM_face_at_index (BMesh *bm, const int index)
 
BMVertBM_vert_at_index_find (BMesh *bm, int index)
 
BMEdgeBM_edge_at_index_find (BMesh *bm, int index)
 
BMFaceBM_face_at_index_find (BMesh *bm, int index)
 
BMLoopBM_loop_at_index_find (BMesh *bm, int index)
 
BMVertBM_vert_at_index_find_or_table (BMesh *bm, int index)
 
BMEdgeBM_edge_at_index_find_or_table (BMesh *bm, int index)
 
BMFaceBM_face_at_index_find_or_table (BMesh *bm, int index)
 
int BM_mesh_elem_count (BMesh *bm, char htype)
 
void BM_mesh_remap (BMesh *bm, const uint *vert_idx, const uint *edge_idx, const uint *face_idx)
 
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)
 
void BM_mesh_vert_coords_get (BMesh *bm, float(*vert_coords)[3])
 
float(* BM_mesh_vert_coords_alloc (BMesh *bm, int *r_vert_len))[3]
 
void BM_mesh_vert_coords_apply (BMesh *bm, const float(*vert_coords)[3])
 
void BM_mesh_vert_coords_apply_with_mat4 (BMesh *bm, const float(*vert_coords)[3], const float mat[4][4])
 

Variables

const BMAllocTemplate bm_mesh_allocsize_default
 
const BMAllocTemplate bm_mesh_chunksize_default
 

Macro Definition Documentation

◆ _VA_BMALLOC_TEMPLATE_FROM_ME_1

#define _VA_BMALLOC_TEMPLATE_FROM_ME_1 (   me)
Value:
{ \
(CHECK_TYPE_INLINE(me, Mesh *), (me)->totvert), (me)->totedge, (me)->totloop, (me)->totpoly, \
}
#define CHECK_TYPE_INLINE(val, type)

Definition at line 185 of file bmesh_mesh.h.

◆ _VA_BMALLOC_TEMPLATE_FROM_ME_2

#define _VA_BMALLOC_TEMPLATE_FROM_ME_2 (   me_a,
  me_b 
)
Value:
{ \
(CHECK_TYPE_INLINE(me_a, Mesh *), \
CHECK_TYPE_INLINE(me_b, Mesh *), \
(me_a)->totvert + (me_b)->totvert), \
(me_a)->totedge + (me_b)->totedge, (me_a)->totloop + (me_b)->totloop, \
(me_a)->totpoly + (me_b)->totpoly, \
}

Definition at line 189 of file bmesh_mesh.h.

◆ BMALLOC_TEMPLATE_FROM_BM

#define BMALLOC_TEMPLATE_FROM_BM (   bm)
Value:
{ \
(CHECK_TYPE_INLINE(bm, BMesh *), (bm)->totvert), (bm)->totedge, (bm)->totloop, (bm)->totface \
}
ATTR_WARN_UNUSED_RESULT BMesh * bm

Definition at line 180 of file bmesh_mesh.h.

◆ BMALLOC_TEMPLATE_FROM_ME

#define BMALLOC_TEMPLATE_FROM_ME (   ...)     VA_NARGS_CALL_OVERLOAD(_VA_BMALLOC_TEMPLATE_FROM_ME_, __VA_ARGS__)

Definition at line 197 of file bmesh_mesh.h.

Typedef Documentation

◆ BMAllocTemplate

Function Documentation

◆ BM_edge_at_index()

BLI_INLINE BMEdge* BM_edge_at_index ( BMesh bm,
const int  index 
)

◆ BM_edge_at_index_find()

BMEdge* BM_edge_at_index_find ( BMesh bm,
int  index 
)

◆ BM_edge_at_index_find_or_table()

BMEdge* BM_edge_at_index_find_or_table ( BMesh bm,
int  index 
)

◆ BM_face_at_index()

BLI_INLINE BMFace* BM_face_at_index ( BMesh bm,
const int  index 
)

◆ BM_face_at_index_find()

BMFace* BM_face_at_index_find ( BMesh bm,
int  index 
)

◆ BM_face_at_index_find_or_table()

BMFace* BM_face_at_index_find_or_table ( BMesh bm,
int  index 
)

◆ BM_loop_at_index_find()

BMLoop* BM_loop_at_index_find ( BMesh bm,
int  index 
)

◆ BM_mesh_clear()

void BM_mesh_clear ( BMesh bm)

◆ BM_mesh_create()

BMesh* BM_mesh_create ( const struct BMAllocTemplate allocsize,
const struct BMeshCreateParams params 
)

BMesh Make Mesh.

Allocates a new BMesh structure.

Returns
The New bmesh
Note
ob is needed by multires

◆ BM_mesh_data_free()

void BM_mesh_data_free ( BMesh bm)

◆ BM_mesh_elem_count()

int BM_mesh_elem_count ( BMesh bm,
char  htype 
)

Return the amount of element of type 'type' in a given bmesh.

Definition at line 708 of file bmesh_mesh.cc.

References BLI_assert, bm, BM_ALL_NOLOOP, BM_EDGE, BM_FACE, BM_VERT, BMesh::totedge, BMesh::totface, and BMesh::totvert.

Referenced by SCULPT_vertex_count_get(), and TEST().

◆ BM_mesh_elem_index_ensure()

void BM_mesh_elem_index_ensure ( BMesh bm,
char  htype 
)

Definition at line 446 of file bmesh_mesh.cc.

References bm, and BM_mesh_elem_index_ensure_ex().

Referenced by armature_deform_coords_impl(), BKE_bmbvh_new_ex(), BKE_editmesh_cache_ensure_poly_centers(), BKE_editmesh_cache_ensure_poly_normals(), BKE_editmesh_cache_ensure_vert_normals(), BKE_editmesh_loop_tangent_calc(), BKE_mesh_foreach_mapped_edge(), BKE_mesh_foreach_mapped_loop(), BKE_pbvh_node_raycast(), bm_decim_triangulate_begin(), bm_edge_info_average_length_fallback(), BM_lnorspace_invalidate(), BM_lnorspace_rebuild(), BM_loop_normal_editdata_array_init(), bm_loop_normal_mark_indiv(), BM_mesh_calc_path_edge(), bm_mesh_calc_tessellation__multi_threaded(), BM_mesh_calc_tessellation_with_partial_ex(), BM_mesh_decimate_dissolve_ex(), BM_mesh_edgenet(), bm_mesh_edges_sharp_tag(), BM_mesh_intersect(), bm_mesh_loops_calc_normals__multi_threaded(), bm_mesh_loops_calc_normals__single_threaded(), bm_mesh_loops_calc_normals_no_autosmooth(), BM_mesh_partial_create_from_verts(), BM_mesh_region_match(), bm_mesh_verts_calc_normals(), BM_uv_element_map_create(), BM_uv_vert_map_create(), BMeshFairingContext::BMeshFairingContext(), bmo_offset_edgeloops_exec(), bmo_smooth_laplacian_vert_exec(), bpy_bmelemseq_index_update(), calc_solidify_normals(), construct_param_handle(), construct_param_handle_subsurfed(), DRW_text_edit_mesh_measure_stats(), ED_mesh_mirrtopo_init(), edbm_face_split_by_edges_exec(), edbm_mod_weighted_strength_exec(), EDBM_preselect_edgering_update_from_edge(), EDBM_preselect_elem_update_from_single(), edbm_select_linked_pick_invoke(), edbm_shortest_path_pick_invoke(), EDBM_unified_findnearest_from_raycast(), EDBM_verts_mirror_cache_begin_ex(), gizmo_preselect_edgering_test_select(), gizmo_preselect_elem_test_select(), knifetool_init_obinfo(), lattice_deform_coords_impl(), loopcut_finish(), math_layer_info_init(), mesh_calc_path_region_elem(), mesh_render_data_create(), SCULPT_stroke_get_location(), SCULPT_vertex_random_access_ensure(), snap_mesh_polygon(), snapEditMesh(), solidify_add_thickness(), blender::draw::statvis_calc_distort(), blender::draw::statvis_calc_intersect(), blender::draw::statvis_calc_thickness(), stitch_process_data(), tc_mesh_partial_ensure(), transform_convert_mesh_islands_calc(), uv_find_nearest_edge(), uv_find_nearest_vert(), uv_select_overlap(), uv_set_connectivity_distance(), uv_shortest_path_pick_invoke(), and vgroup_smooth_subset().

◆ BM_mesh_elem_index_ensure_ex()

void BM_mesh_elem_index_ensure_ex ( BMesh bm,
char  htype,
int  elem_offset[4] 
)

◆ BM_mesh_elem_index_validate()

void BM_mesh_elem_index_validate ( BMesh bm,
const char *  location,
const char *  func,
const char *  msg_a,
const char *  msg_b 
)

Array checking/setting macros.

Currently vert/edge/loop/face index data is being abused, in a few areas of the code.

To avoid correcting them afterwards, set 'bm->elem_index_dirty' however its possible this flag is set incorrectly which could crash blender.

Functions that calls this function may depend on dirty indices on being set.

This is read-only, so it can be used for assertions that don't impact behavior.

Definition at line 451 of file bmesh_mesh.cc.

References bm, BM_EDGE, BM_EDGES_OF_MESH, BM_elem_index_get, BM_FACE, BM_FACES_OF_MESH, BM_ITER_MESH, BM_VERT, BM_VERTS_OF_MESH, BMesh::elem_index_dirty, and void.

◆ BM_mesh_elem_table_check()

bool BM_mesh_elem_table_check ( BMesh bm)

◆ BM_mesh_elem_table_ensure()

void BM_mesh_elem_table_ensure ( BMesh bm,
char  htype 
)

Definition at line 558 of file bmesh_mesh.cc.

References BLI_assert, bm, BM_ALL_NOLOOP, BM_EDGE, BM_EDGES_OF_MESH, BM_FACE, BM_FACES_OF_MESH, BM_iter_as_array(), BM_mesh_elem_table_check(), BM_VERT, BM_VERTS_OF_MESH, BMesh::elem_table_dirty, BMesh::etable, BMesh::etable_tot, BMesh::ftable, BMesh::ftable_tot, MEM_freeN, MEM_mallocN, BMesh::totedge, BMesh::totface, BMesh::totvert, BMesh::vtable, and BMesh::vtable_tot.

Referenced by blender::ed::spreadsheet::GeometryDataSource::apply_selection_filter(), bm_mesh_calc_uv_islands(), BM_mesh_elem_table_init(), BM_mesh_intersect(), BM_mesh_intersect_edges(), BM_mesh_remap(), BMeshFairingContext::BMeshFairingContext(), bmo_recalc_face_normals_exec(), bpy_bmelemseq_ensure_lookup_table(), bvhtree_from_editmesh_edges_create_tree(), bvhtree_from_editmesh_verts_create_tree(), construct_param_handle_subsurfed(), draw_select_id_edit_mesh(), ED_mesh_mirror_spatial_table_begin(), ED_mesh_mirrtopo_init(), ED_transverts_create_from_obedit(), ED_vgroup_parray_mirror_assign(), ED_vgroup_parray_mirror_sync(), edbm_face_split_by_edges_exec(), EDBM_select_interior_faces(), edbm_select_similar_region_exec(), EDBM_verts_mirror_cache_begin_ex(), get_vert_def_nr(), give_parvert(), loopcut_init(), math_layer_info_init(), blender::nodes::node_geo_edge_split_cc::mesh_edge_split(), mesh_foreachScreenEdge(), mesh_foreachScreenEdge_clip_bb_segment(), mesh_foreachScreenFace(), mesh_foreachScreenVert(), mesh_render_data_create(), mesh_symmetry_snap_exec(), multires_unsubdivide_extract_grids(), multires_unsubdivide_prepare_original_bmesh_for_extract(), multires_unsubdivide_single_level(), sculpt_face_set_delete_geometry(), sculpt_face_sets_init_flood_fill(), SCULPT_stroke_get_location(), SCULPT_vertex_random_access_ensure(), snap_mesh_polygon(), snapEditMesh(), stitch_init(), transform_convert_mesh_islands_calc(), blender::nodes::node_geo_triangulate_cc::triangulate_mesh_selection(), uv_select_flush_from_loop_edge_flag(), uv_select_flush_from_tag_face(), uv_select_flush_from_tag_loop(), uv_select_linked_multi(), uv_select_overlap(), and vgroup_smooth_subset().

◆ BM_mesh_elem_table_free()

void BM_mesh_elem_table_free ( BMesh bm,
char  htype 
)

Definition at line 633 of file bmesh_mesh.cc.

References bm, BM_EDGE, BM_FACE, BM_VERT, BMesh::etable, BMesh::ftable, MEM_SAFE_FREE, and BMesh::vtable.

Referenced by BM_mesh_elem_table_init().

◆ BM_mesh_elem_table_init()

void BM_mesh_elem_table_init ( BMesh bm,
char  htype 
)

◆ BM_mesh_elem_toolflags_clear()

void BM_mesh_elem_toolflags_clear ( BMesh bm)

◆ BM_mesh_elem_toolflags_ensure()

void BM_mesh_elem_toolflags_ensure ( BMesh bm)

◆ BM_mesh_free()

void BM_mesh_free ( BMesh bm)

◆ BM_mesh_rebuild()

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 
)

◆ BM_mesh_remap()

void BM_mesh_remap ( BMesh bm,
const uint vert_idx,
const uint edge_idx,
const uint face_idx 
)

Remaps the vertices, edges and/or faces of the bmesh as indicated by vert/edge/face_idx arrays (xxx_idx[org_index] = new_index).

A NULL array means no changes.

Note
  • Does not mess with indices, just sets elem_index_dirty flag.
  • For verts/edges/faces only (as loops must remain "ordered" and "aligned" on a per-face basis...).
Warning
Be careful if you keep pointers to affected BM elements, or arrays, when using this func!

Definition at line 726 of file bmesh_mesh.cc.

References BMesh::act_face, BLI_assert, BLI_ghash_free(), BLI_ghash_insert(), BLI_ghash_lookup(), BLI_ghash_ptr_new_ex(), bm, BM_EDGE, BM_EDGES_OF_MESH, BM_ELEM_CD_GET_VOID_P, BM_FACE, BM_FACES_OF_MESH, BM_ITER_ELEM, BM_ITER_MESH, BM_LOOP, BM_LOOPS_OF_FACE, BM_mesh_elem_table_ensure(), BM_VERT, BM_VERTS_OF_MESH, CD_BM_ELEM_PYPTR, CustomData_get_offset(), BMVert::e, BMLoop::e, BMesh::edata, BMEditSelection::ele, BMesh::elem_index_dirty, BMesh::elem_table_dirty, BMesh::etable, BMLoop::f, ListBase::first, BMesh::ftable, BMEditSelection::htype, MEM_freeN, MEM_mallocN, BMDiskLink::next, BMEditSelection::next, BMesh::pdata, BMDiskLink::prev, BMesh::selected, BMesh::totedge, BMesh::totface, BMesh::totvert, BMLoop::v, BMEdge::v1, BMEdge::v1_disk_link, BMEdge::v2, BMEdge::v2_disk_link, BMesh::vdata, and BMesh::vtable.

Referenced by BM_log_mesh_elems_reorder(), and sort_bmelem_flag().

◆ BM_mesh_toolflags_set()

void BM_mesh_toolflags_set ( BMesh bm,
bool  use_toolflags 
)

◆ BM_mesh_vert_coords_alloc()

float(* BM_mesh_vert_coords_alloc ( BMesh bm,
int *  r_vert_len 
) )[3]

◆ BM_mesh_vert_coords_apply()

void BM_mesh_vert_coords_apply ( BMesh bm,
const float(*)  vert_coords[3] 
)

Definition at line 1328 of file bmesh_mesh.cc.

References bm, BM_ITER_MESH_INDEX, BM_VERTS_OF_MESH, BMVert::co, copy_v3_v3(), and v.

Referenced by ED_object_data_xform_restore().

◆ BM_mesh_vert_coords_apply_with_mat4()

void BM_mesh_vert_coords_apply_with_mat4 ( BMesh bm,
const float(*)  vert_coords[3],
const float  mat[4][4] 
)

Definition at line 1338 of file bmesh_mesh.cc.

References bm, BM_ITER_MESH_INDEX, BM_VERTS_OF_MESH, BMVert::co, mul_v3_m4v3(), and v.

Referenced by ED_object_data_xform_by_mat4().

◆ BM_mesh_vert_coords_get()

void BM_mesh_vert_coords_get ( BMesh bm,
float(*)  vert_coords[3] 
)

◆ BM_vert_at_index()

BLI_INLINE BMVert* BM_vert_at_index ( BMesh bm,
const int  index 
)

◆ BM_vert_at_index_find()

BMVert* BM_vert_at_index_find ( BMesh bm,
int  index 
)

◆ BM_vert_at_index_find_or_table()

BMVert* BM_vert_at_index_find_or_table ( BMesh bm,
int  index 
)

Use lookup table when available, else use slower find functions.

Note
Try to use BM_mesh_elem_table_ensure instead.

Definition at line 684 of file bmesh_mesh.cc.

References bm, BM_VERT, BM_vert_at_index_find(), BMesh::elem_table_dirty, and BMesh::vtable.

Referenced by EDBM_elem_from_index_any(), edbm_select_id_bm_elem_get(), and EDBM_vert_find_nearest_ex().

◆ bmesh_edit_begin()

void bmesh_edit_begin ( BMesh bm,
BMOpTypeFlag  type_flag 
)

BMesh Begin Edit.

Functions for setting up a mesh for editing and cleaning up after the editing operations are done. These are called by the tools/operator API for each time a tool is executed.

◆ bmesh_edit_end()

void bmesh_edit_end ( BMesh bm,
BMOpTypeFlag  type_flag 
)

Variable Documentation

◆ bm_mesh_allocsize_default

const BMAllocTemplate bm_mesh_allocsize_default
extern

◆ bm_mesh_chunksize_default

const BMAllocTemplate bm_mesh_chunksize_default
extern

Definition at line 24 of file bmesh_mesh.cc.

Referenced by bm_mempool_init_ex(), and CustomData_bmesh_init_pool().