Blender V5.0
bmesh_mesh.hh File Reference

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(...)

Functions

void BM_mesh_elem_toolflags_ensure (BMesh *bm)
void BM_mesh_elem_toolflags_clear (BMesh *bm)
BMeshBM_mesh_create (const BMAllocTemplate *allocsize, const BMeshCreateParams *params)
 BMesh Make Mesh.
void BM_mesh_free (BMesh *bm)
 BMesh Free Mesh.
void BM_mesh_data_free (BMesh *bm)
 BMesh Free Mesh Data.
void BM_mesh_clear (BMesh *bm)
 BMesh Clear Mesh.
void bmesh_edit_begin (BMesh *bm, BMOpTypeFlag type_flag)
 BMesh Begin Edit.
void bmesh_edit_end (BMesh *bm, BMOpTypeFlag type_flag)
 BMesh End Edit.
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 BMeshCreateParams *params, BLI_mempool *vpool, BLI_mempool *epool, BLI_mempool *lpool, BLI_mempool *fpool)
void BM_mesh_vert_normals_get (BMesh *bm, blender::MutableSpan< blender::float3 > normals)
void BM_mesh_vert_coords_get (BMesh *bm, blender::MutableSpan< blender::float3 > positions)
blender::Array< blender::float3BM_mesh_vert_coords_alloc (BMesh *bm)
void BM_mesh_vert_coords_apply (BMesh *bm, blender::Span< blender::float3 > vert_coords)
void BM_mesh_vert_coords_apply_with_mat4 (BMesh *bm, blender::Span< blender::float3 > vert_coords, const blender::float4x4 &transform)

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)->verts_num), \
(me)->edges_num, \
(me)->corners_num, \
(me)->faces_num, \
}
#define CHECK_TYPE_INLINE(val, type)

Definition at line 188 of file bmesh_mesh.hh.

◆ _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)->verts_num + (me_b)->verts_num), \
(me_a)->edges_num + (me_b)->edges_num, \
(me_a)->corners_num + (me_b)->corners_num, \
(me_a)->faces_num + (me_b)->faces_num, \
}

Definition at line 195 of file bmesh_mesh.hh.

◆ BMALLOC_TEMPLATE_FROM_BM

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

Definition at line 185 of file bmesh_mesh.hh.

Referenced by BM_mesh_copy(), and BM_mesh_toolflags_set().

◆ BMALLOC_TEMPLATE_FROM_ME

Function Documentation

◆ BM_edge_at_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()

◆ 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)

BMesh Clear Mesh.

Clear all data in bm

Definition at line 244 of file bmesh_mesh.cc.

References bm, bm_mempool_init(), bm_mesh_allocsize_default, BM_mesh_data_free(), and CustomData_reset().

Referenced by bpy_bmesh_clear().

◆ BM_mesh_create()

◆ BM_mesh_data_free()

◆ BM_mesh_elem_count()

◆ BM_mesh_elem_index_ensure()

void BM_mesh_elem_index_ensure ( BMesh * bm,
char htype )

Definition at line 457 of file bmesh_mesh.cc.

References bm, and BM_mesh_elem_index_ensure_ex().

Referenced by blender::bke::armature_deform_editmesh(), BKE_bmbvh_new_ex(), BKE_editmesh_cache_ensure_face_centers(), BKE_editmesh_cache_ensure_face_normals(), BKE_editmesh_cache_ensure_vert_normals(), BKE_editmesh_orco_tangents_calc(), BKE_editmesh_uv_tangents_calc(), BKE_mesh_foreach_mapped_edge(), BKE_mesh_foreach_mapped_loop(), bm_decim_triangulate_begin(), bm_edge_info_average_length_fallback(), BM_lnorspace_invalidate(), BM_lnorspace_rebuild(), BM_loop_normal_editdata_array_init_with_htype(), bm_loop_normal_mark_edges(), bm_loop_normal_mark_faces(), bm_loop_normal_mark_indiv(), bm_loop_normal_mark_verts(), 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_is_valid(), 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(), 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_calc_path_region_elem(), blender::ed::transform::mesh_partial_ensure(), blender::draw::mesh_render_data_create(), solidify_add_thickness(), blender::draw::statvis_calc_intersect(), blender::draw::statvis_calc_thickness(), stitch_process_data(), blender::ed::transform::transform_convert_mesh_islands_calc(), uv_find_nearest_edge(), uv_find_nearest_vert(), uv_select_overlap(), blender::ed::transform::uv_set_connectivity_distance(), uv_shortest_path_pick_invoke(), blender::ed::sculpt_paint::vert_random_access_ensure(), and blender::ed::object::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 462 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, and i.

◆ BM_mesh_elem_table_check()

bool BM_mesh_elem_table_check ( BMesh * bm)
See also
BM_mesh_elem_index_validate the same rationale applies to this function.

Definition at line 535 of file bmesh_mesh.cc.

References bm, BM_EDGE, BM_EDGES_OF_MESH, BM_FACE, BM_FACES_OF_MESH, BM_ITER_MESH_INDEX, BM_VERT, BM_VERTS_OF_MESH, and i.

Referenced by BM_mesh_elem_table_ensure(), and EDBM_update().

◆ BM_mesh_elem_table_ensure()

void BM_mesh_elem_table_ensure ( BMesh * bm,
char htype )

Definition at line 569 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, MEM_freeN(), and MEM_mallocN().

Referenced by bm_mesh_calc_uv_islands(), BM_mesh_elem_table_init(), BM_mesh_intersect(), BM_mesh_intersect_edges(), BM_mesh_remap(), blender::draw::bmesh_normals_domain(), bmo_recalc_face_normals_exec(), bpy_bmelemseq_ensure_lookup_table(), blender::ed::spreadsheet::calc_mesh_selection_mask(), blender::ed::spreadsheet::calc_mesh_selection_mask_faces(), construct_param_handle_subsurfed(), blender::ed::sculpt_paint::face_set::delete_geometry(), ED_mesh_mirror_spatial_table_begin(), ED_mesh_mirrtopo_init(), ED_transverts_create_from_obedit(), edbm_face_split_by_edges_exec(), EDBM_select_interior_faces(), edbm_select_similar_region_exec(), EDBM_verts_mirror_cache_begin_ex(), blender::draw::edit_select::Instance::edit_mesh_sync(), blender::ed::object::get_vert_def_nr(), give_parvert(), blender::ed::sculpt_paint::expand::init_from_face_set_boundary(), loopcut_init(), math_layer_info_init(), blender::geometry::boolean::mesh_bm_concat(), mesh_foreachScreenEdge(), mesh_foreachScreenEdge_clip_bb_segment(), mesh_foreachScreenFace(), mesh_foreachScreenVert(), blender::draw::mesh_render_data_create(), mesh_symmetry_snap_exec(), multires_unsubdivide_extract_grids(), multires_unsubdivide_prepare_original_bmesh_for_extract(), multires_unsubdivide_single_level(), stitch_init(), blender::ed::transform::transform_convert_mesh_islands_calc(), uv_select_linked_multi(), uv_select_overlap(), blender::ed::sculpt_paint::vert_random_access_ensure(), blender::ed::object::vgroup_parray_mirror_assign(), blender::ed::object::vgroup_parray_mirror_sync(), and blender::ed::object::vgroup_smooth_subset().

◆ BM_mesh_elem_table_free()

void BM_mesh_elem_table_free ( BMesh * bm,
char htype )

Definition at line 647 of file bmesh_mesh.cc.

References bm, BM_EDGE, BM_FACE, BM_VERT, and MEM_SAFE_FREE.

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)

Definition at line 116 of file bmesh_mesh.cc.

References BLI_mempool_destroy(), and bm.

Referenced by BM_mesh_data_free(), and select_linked_delimit_end().

◆ BM_mesh_elem_toolflags_ensure()

◆ BM_mesh_free()

◆ BM_mesh_rebuild()

void BM_mesh_rebuild ( BMesh * bm,
const BMeshCreateParams * params,
BLI_mempool * vpool,
BLI_mempool * epool,
BLI_mempool * lpool,
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 740 of file bmesh_mesh.cc.

References 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(), BMLoop::e, BMVert::e, BMLoop::f, i, LISTBASE_FOREACH, MEM_freeN(), MEM_malloc_arrayN(), BMDiskLink::next, BMDiskLink::prev, printf, BMLoop::v, BMEdge::v1, BMEdge::v1_disk_link, BMEdge::v2, and BMEdge::v2_disk_link.

Referenced by bpy_bmelemseq_sort(), and sort_bmelem_flag().

◆ BM_mesh_toolflags_set()

void BM_mesh_toolflags_set ( BMesh * bm,
bool use_toolflags )

Re-allocates mesh data with/without toolflags.

Definition at line 1291 of file bmesh_mesh.cc.

References BLI_mempool_destroy(), bm, bm_mempool_init_ex(), BM_mesh_rebuild(), BMALLOC_TEMPLATE_FROM_BM, and params.

Referenced by blender::ed::sculpt_paint::symmetrize_exec().

◆ BM_mesh_vert_coords_alloc()

◆ BM_mesh_vert_coords_apply()

void BM_mesh_vert_coords_apply ( BMesh * bm,
blender::Span< blender::float3 > vert_coords )

References bm.

◆ BM_mesh_vert_coords_apply_with_mat4()

void BM_mesh_vert_coords_apply_with_mat4 ( BMesh * bm,
blender::Span< blender::float3 > vert_coords,
const blender::float4x4 & transform )

References bm, and transform().

◆ BM_mesh_vert_coords_get()

void BM_mesh_vert_coords_get ( BMesh * bm,
blender::MutableSpan< blender::float3 > positions )

References bm.

◆ BM_mesh_vert_normals_get()

void BM_mesh_vert_normals_get ( BMesh * bm,
blender::MutableSpan< blender::float3 > normals )

References bm, and normals.

◆ BM_vert_at_index()

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

Definition at line 108 of file bmesh_mesh.hh.

References BLI_assert, BLI_INLINE, bm, and BM_VERT.

Referenced by blender::ed::sculpt_paint::flood_fill::FillDataBMesh::add_initial(), blender::ed::sculpt_paint::boundary::bend_data_init_bmesh(), bm_edgexvert_isect_cb(), blender::draw::bm_original_vert_get(), bm_vertxvert_isect_cb(), blender::ed::sculpt_paint::expand::boundary_from_enabled(), blender::ed::sculpt_paint::pose::calc_average_face_set_center(), blender::ed::spreadsheet::calc_mesh_selection_mask(), blender::ed::sculpt_paint::expand::calc_topology_falloff_from_verts(), blender::ed::sculpt_paint::cloth::calc_vert_neighbor_indices_bmesh(), blender::ed::transform::createTransEditVerts(), blender::ed::transform::createTransMeshSkin(), blender::ed::sculpt_paint::boundary::data_init(), blender::ed::sculpt_paint::mask::duplicate_mask(), blender::ed::sculpt_paint::hide::duplicate_visibility_bmesh(), ED_mesh_mirror_get_vert(), EDBM_verts_mirror_cache_begin_ex(), blender::ed::sculpt_paint::boundary::edit_data_init_bmesh(), editbmesh_get_x_mirror_vert_spatial(), blender::ed::sculpt_paint::expand::enabled_state_to_bitmap(), blender::ed::sculpt_paint::flood_fill::FillDataBMesh::execute(), blender::draw::extract_points_bm(), blender::draw::extract_points_subdiv_bm(), blender::ed::sculpt_paint::fake_neighbor_search(), blender::ed::sculpt_paint::find_symm_verts_bmesh(), blender::ed::object::get_vert_def_nr(), give_parvert(), blender::ed::sculpt_paint::auto_mask::init_boundary_masking_bmesh(), blender::ed::sculpt_paint::boundary::init_falloff_bmesh(), blender::ed::sculpt_paint::expand::init_from_face_set_boundary(), mesh_foreachScreenVert__mapFunc(), mesh_symmetry_snap_exec(), multires_unsubdivide_extract_grids(), multires_unsubdivide_prepare_original_bmesh_for_extract(), blender::ed::sculpt_paint::expand::normals_falloff_create(), blender::ed::sculpt_paint::paint_cursor_draw_3d_view_brush_cursor_inactive(), blender::ed::sculpt_paint::expand::reposition_pivot(), blender::ed::sculpt_paint::expand::sculpt_expand_invoke(), set_mapped_co(), blender::ed::sculpt_paint::boundary::slide_data_init_bmesh(), blender::ed::sculpt_paint::boundary::twist_data_init_bmesh(), unsubdivide_init_elem_ids(), blender::ed::object::vgroup_smooth_subset(), and blender::ed::sculpt_paint::expand::write_mask_data().

◆ 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 698 of file bmesh_mesh.cc.

References bm, BM_VERT, and BM_vert_at_index_find().

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.

Definition at line 282 of file bmesh_mesh.cc.

References bm, BM_mesh_normals_update(), BMO_OPTYPE_FLAG_UNTAN_MULTIRES, CD_MDISPS, and CustomData_has_layer().

Referenced by BMO_op_exec(), build_skin(), and blender::ed::transform::mesh_customdatacorrect_init_container_generic().

◆ bmesh_edit_end()

Variable Documentation

◆ bm_mesh_allocsize_default

◆ bm_mesh_chunksize_default

const BMAllocTemplate bm_mesh_chunksize_default
extern

Definition at line 31 of file bmesh_mesh.cc.

Referenced by bm_mempool_init_ex(), and CustomData_bmesh_init_pool().