Blender  V2.93
Classes | Macros | Typedefs | Functions | Variables
bmesh_mesh.c File Reference
#include "MEM_guardedalloc.h"
#include "DNA_listBase.h"
#include "DNA_scene_types.h"
#include "BLI_bitmap.h"
#include "BLI_linklist_stack.h"
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_stack.h"
#include "BLI_task.h"
#include "BLI_utildefines.h"
#include "BKE_editmesh.h"
#include "BKE_global.h"
#include "BKE_mesh.h"
#include "BKE_multires.h"
#include "atomic_ops.h"
#include "intern/bmesh_private.h"

Go to the source code of this file.

Classes

struct  BMEdgesCalcVectorsData
 
struct  BMVertsCalcNormalsData
 

Macros

#define BM_LNORSPACE_UPDATE   _FLAG_MF
 
#define FLT_EQ_NONAN(_fa, _fb)   (*((const uint32_t *)&_fa) == *((const uint32_t *)&_fb))
 
#define LNOR_SPACE_TRIGO_THRESHOLD   (1.0f - 1e-4f)
 
#define CLEAR_SPACEARRAY_THRESHOLD(x)   ((x) / 2)
 
#define MAP_VERT(ele)   vtable_dst[BM_elem_index_get(ele)]
 
#define MAP_EDGE(ele)   etable_dst[BM_elem_index_get(ele)]
 
#define MAP_LOOP(ele)   ltable_dst[BM_elem_index_get(ele)]
 
#define MAP_FACE(ele)   ftable_dst[BM_elem_index_get(ele)]
 
#define REMAP_VERT(ele)
 
#define REMAP_EDGE(ele)
 
#define REMAP_LOOP(ele)
 
#define REMAP_FACE(ele)
 

Typedefs

typedef struct BMEdgesCalcVectorsData BMEdgesCalcVectorsData
 
typedef struct BMVertsCalcNormalsData BMVertsCalcNormalsData
 

Functions

static void bm_mempool_init_ex (const BMAllocTemplate *allocsize, const bool use_toolflags, BLI_mempool **r_vpool, BLI_mempool **r_epool, BLI_mempool **r_lpool, BLI_mempool **r_fpool)
 
static void bm_mempool_init (BMesh *bm, const BMAllocTemplate *allocsize, const bool use_toolflags)
 
void BM_mesh_elem_toolflags_ensure (BMesh *bm)
 
void BM_mesh_elem_toolflags_clear (BMesh *bm)
 
BMeshBM_mesh_create (const BMAllocTemplate *allocsize, const struct BMeshCreateParams *params)
 BMesh Make 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 BM_mesh_free (BMesh *bm)
 BMesh Free Mesh. More...
 
static void mesh_edges_calc_vectors_cb (void *userdata, MempoolIterData *mp_e)
 
static void bm_mesh_edges_calc_vectors (BMesh *bm, float(*edgevec)[3], const float(*vcos)[3])
 
static void mesh_verts_calc_normals_accum_cb (void *userdata, MempoolIterData *mp_f)
 
static void mesh_verts_calc_normals_normalize_cb (void *userdata, MempoolIterData *mp_v)
 
static void bm_mesh_verts_calc_normals (BMesh *bm, const float(*edgevec)[3], const float(*fnos)[3], const float(*vcos)[3], float(*vnos)[3])
 
static void mesh_faces_calc_normals_cb (void *UNUSED(userdata), MempoolIterData *mp_f)
 
void BM_mesh_normals_update (BMesh *bm)
 BMesh Compute Normals. More...
 
void BM_verts_calc_normal_vcos (BMesh *bm, const float(*fnos)[3], const float(*vcos)[3], float(*vnos)[3])
 BMesh Compute Normals from/to external data. More...
 
static void bm_mesh_edges_sharp_tag (BMesh *bm, const float(*vnos)[3], const float(*fnos)[3], float(*r_lnos)[3], const float split_angle, const bool do_sharp_edges_tag)
 
bool BM_loop_check_cyclic_smooth_fan (BMLoop *l_curr)
 
static void bm_mesh_loops_calc_normals (BMesh *bm, const float(*vcos)[3], const float(*fnos)[3], float(*r_lnos)[3], MLoopNorSpaceArray *r_lnors_spacearr, const short(*clnors_data)[2], const int cd_loop_clnors_offset, const bool do_rebuild)
 
static bool bm_mesh_loops_split_lnor_fans (BMesh *bm, MLoopNorSpaceArray *lnors_spacearr, const float(*new_lnors)[3])
 
static void bm_mesh_loops_assign_normal_data (BMesh *bm, MLoopNorSpaceArray *lnors_spacearr, short(*r_clnors_data)[2], const int cd_loop_clnors_offset, const float(*new_lnors)[3])
 
static void bm_mesh_loops_custom_normals_set (BMesh *bm, const float(*vcos)[3], const float(*vnos)[3], const float(*fnos)[3], MLoopNorSpaceArray *r_lnors_spacearr, short(*r_clnors_data)[2], const int cd_loop_clnors_offset, float(*new_lnors)[3], const int cd_new_lnors_offset, bool do_split_fans)
 
static void bm_mesh_loops_calc_normals_no_autosmooth (BMesh *bm, const float(*vnos)[3], const float(*fnos)[3], float(*r_lnos)[3])
 
void BM_loops_calc_normal_vcos (BMesh *bm, const float(*vcos)[3], const float(*vnos)[3], const float(*fnos)[3], const bool use_split_normals, const float split_angle, float(*r_lnos)[3], MLoopNorSpaceArray *r_lnors_spacearr, short(*clnors_data)[2], const int cd_loop_clnors_offset, const bool do_rebuild)
 BMesh Compute Loop Normals from/to external data. More...
 
void BM_edges_sharp_from_angle_set (BMesh *bm, const float split_angle)
 
void BM_lnorspacearr_store (BMesh *bm, float(*r_lnors)[3])
 
void BM_lnorspace_invalidate (BMesh *bm, const bool do_invalidate_all)
 
void BM_lnorspace_rebuild (BMesh *bm, bool preserve_clnor)
 
void BM_lnorspace_update (BMesh *bm)
 
void BM_normals_loops_edges_tag (BMesh *bm, const bool do_edges)
 
void BM_lnorspace_err (BMesh *bm)
 
static void bm_loop_normal_mark_indiv_do_loop (BMLoop *l, BLI_bitmap *loops, MLoopNorSpaceArray *lnor_spacearr, int *totloopsel, const bool do_all_loops_of_vert)
 
static int bm_loop_normal_mark_indiv (BMesh *bm, BLI_bitmap *loops, const bool do_all_loops_of_vert)
 
static void loop_normal_editdata_init (BMesh *bm, BMLoopNorEditData *lnor_ed, BMVert *v, BMLoop *l, const int offset)
 
BMLoopNorEditDataArrayBM_loop_normal_editdata_array_init (BMesh *bm, const bool do_all_loops_of_vert)
 
void BM_loop_normal_editdata_array_free (BMLoopNorEditDataArray *lnors_ed_arr)
 
bool BM_custom_loop_normals_to_vector_layer (BMesh *bm)
 
void BM_custom_loop_normals_from_vector_layer (BMesh *bm, bool add_sharp_edges)
 
void bmesh_edit_begin (BMesh *UNUSED(bm), BMOpTypeFlag UNUSED(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, const char htype, int elem_offset[4])
 
void BM_mesh_elem_index_ensure (BMesh *bm, const 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_elem_table_ensure (BMesh *bm, const char htype)
 
void BM_mesh_elem_table_init (BMesh *bm, const char htype)
 
void BM_mesh_elem_table_free (BMesh *bm, const char htype)
 
BMVertBM_vert_at_index_find (BMesh *bm, const int index)
 
BMEdgeBM_edge_at_index_find (BMesh *bm, const int index)
 
BMFaceBM_face_at_index_find (BMesh *bm, const int index)
 
BMLoopBM_loop_at_index_find (BMesh *bm, const int index)
 
BMVertBM_vert_at_index_find_or_table (BMesh *bm, const int index)
 
BMEdgeBM_edge_at_index_find_or_table (BMesh *bm, const int index)
 
BMFaceBM_face_at_index_find_or_table (BMesh *bm, const int index)
 
int BM_mesh_elem_count (BMesh *bm, const 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, BLI_mempool *vpool_dst, BLI_mempool *epool_dst, BLI_mempool *lpool_dst, BLI_mempool *fpool_dst)
 
void BM_mesh_toolflags_set (BMesh *bm, bool use_toolflags)
 
BMesh Coordinate Access
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 = {512, 1024, 2048, 512}
 
const BMAllocTemplate bm_mesh_chunksize_default = {512, 1024, 2048, 512}
 

Detailed Description

BM mesh level functions.

Definition in file bmesh_mesh.c.

Macro Definition Documentation

◆ BM_LNORSPACE_UPDATE

#define BM_LNORSPACE_UPDATE   _FLAG_MF

Helpers for BM_mesh_normals_update and BM_verts_calc_normal_vcos

Definition at line 327 of file bmesh_mesh.c.

◆ CLEAR_SPACEARRAY_THRESHOLD

#define CLEAR_SPACEARRAY_THRESHOLD (   x)    ((x) / 2)

Definition at line 1416 of file bmesh_mesh.c.

◆ FLT_EQ_NONAN

#define FLT_EQ_NONAN (   _fa,
  _fb 
)    (*((const uint32_t *)&_fa) == *((const uint32_t *)&_fb))

◆ LNOR_SPACE_TRIGO_THRESHOLD

#define LNOR_SPACE_TRIGO_THRESHOLD   (1.0f - 1e-4f)

Definition at line 1011 of file bmesh_mesh.c.

◆ MAP_EDGE

#define MAP_EDGE (   ele)    etable_dst[BM_elem_index_get(ele)]

◆ MAP_FACE

#define MAP_FACE (   ele)    ftable_dst[BM_elem_index_get(ele)]

◆ MAP_LOOP

#define MAP_LOOP (   ele)    ltable_dst[BM_elem_index_get(ele)]

◆ MAP_VERT

#define MAP_VERT (   ele)    vtable_dst[BM_elem_index_get(ele)]

◆ REMAP_EDGE

#define REMAP_EDGE (   ele)
Value:
{ \
if (remap & BM_EDGE) { \
ele = MAP_EDGE(ele); \
} \
} \
((void)0)
@ BM_EDGE
Definition: bmesh_class.h:384
#define MAP_EDGE(ele)

◆ REMAP_FACE

#define REMAP_FACE (   ele)
Value:
{ \
if (remap & BM_FACE) { \
ele = MAP_FACE(ele); \
} \
} \
((void)0)
@ BM_FACE
Definition: bmesh_class.h:386
#define MAP_FACE(ele)

◆ REMAP_LOOP

#define REMAP_LOOP (   ele)
Value:
{ \
if (remap & BM_LOOP) { \
ele = MAP_LOOP(ele); \
} \
} \
((void)0)
@ BM_LOOP
Definition: bmesh_class.h:385
#define MAP_LOOP(ele)

◆ REMAP_VERT

#define REMAP_VERT (   ele)
Value:
{ \
if (remap & BM_VERT) { \
ele = MAP_VERT(ele); \
} \
} \
((void)0)
@ BM_VERT
Definition: bmesh_class.h:383
#define MAP_VERT(ele)

Typedef Documentation

◆ BMEdgesCalcVectorsData

◆ BMVertsCalcNormalsData

Function Documentation

◆ BM_custom_loop_normals_from_vector_layer()

void BM_custom_loop_normals_from_vector_layer ( BMesh bm,
bool  add_sharp_edges 
)

◆ BM_custom_loop_normals_to_vector_layer()

bool BM_custom_loop_normals_to_vector_layer ( BMesh bm)

◆ BM_edge_at_index_find()

BMEdge* BM_edge_at_index_find ( BMesh bm,
const int  index 
)

◆ BM_edge_at_index_find_or_table()

BMEdge* BM_edge_at_index_find_or_table ( BMesh bm,
const int  index 
)

◆ BM_edges_sharp_from_angle_set()

void BM_edges_sharp_from_angle_set ( BMesh bm,
const float  split_angle 
)

Define sharp edges as needed to mimic 'autosmooth' from angle threshold.

Used when defining an empty custom loop normals data layer, to keep same shading as with autosmooth!

Definition at line 1382 of file bmesh_mesh.c.

References bm, bm_mesh_edges_sharp_tag(), M_PI, and NULL.

Referenced by bevel_harden_normals(), BKE_editmesh_lnorspace_update(), and mesh_customdata_custom_splitnormals_add_exec().

◆ BM_face_at_index_find()

BMFace* BM_face_at_index_find ( BMesh bm,
const int  index 
)

◆ BM_face_at_index_find_or_table()

BMFace* BM_face_at_index_find_or_table ( BMesh bm,
const int  index 
)

◆ BM_lnorspace_err()

void BM_lnorspace_err ( BMesh bm)

Auxiliary function only used by rebuild to detect if any spaces were not marked as invalid. Reports error if any of the lnor spaces change after rebuilding, meaning that all the possible lnor spaces to be rebuilt were not correctly marked.

Definition at line 1623 of file bmesh_mesh.c.

References BKE_lnor_spacearr_free(), BKE_lnor_spacearr_init(), BLI_assert, bm, BM_loops_calc_normal_vcos(), BM_SPACEARR_DIRTY_ALL, CD_CUSTOMLOOPNORMAL, clear(), compare_ff(), compare_v3v3(), CustomData_get_offset(), float(), BMesh::ldata, BMesh::lnor_spacearr, MLoopNorSpaceArray::lspacearr, M_PI, MEM_callocN, MEM_freeN, MLNOR_SPACEARR_BMLOOP_PTR, NULL, MLoopNorSpace::ref_alpha, MLoopNorSpace::ref_beta, BMesh::spacearr_dirty, BMesh::totloop, MLoopNorSpace::vec_lnor, MLoopNorSpace::vec_ortho, and MLoopNorSpace::vec_ref.

Referenced by BM_lnorspace_rebuild().

◆ BM_lnorspace_invalidate()

void BM_lnorspace_invalidate ( BMesh bm,
const bool  do_invalidate_all 
)

◆ BM_lnorspace_rebuild()

void BM_lnorspace_rebuild ( BMesh bm,
bool  preserve_clnor 
)

◆ BM_lnorspace_update()

void BM_lnorspace_update ( BMesh bm)

◆ BM_lnorspacearr_store()

void BM_lnorspacearr_store ( BMesh bm,
float(*)  r_lnors[3] 
)

◆ BM_loop_at_index_find()

BMLoop* BM_loop_at_index_find ( BMesh bm,
const int  index 
)

◆ BM_loop_check_cyclic_smooth_fan()

bool BM_loop_check_cyclic_smooth_fan ( BMLoop l_curr)

Check whether given loop is part of an unknown-so-far cyclic smooth fan, or not. Needed because cyclic smooth fans have no obvious 'entry point', and yet we need to walk them once, and only once.

Definition at line 636 of file bmesh_mesh.c.

References BLI_assert, BM_elem_flag_enable, BM_elem_flag_test, BM_ELEM_TAG, BM_vert_step_fan_loop(), and BMLoop::e.

Referenced by bm_mesh_loops_calc_normals(), edbm_average_normals_exec(), and normals_split().

◆ BM_loop_normal_editdata_array_free()

void BM_loop_normal_editdata_array_free ( BMLoopNorEditDataArray lnors_ed_arr)

◆ BM_loop_normal_editdata_array_init()

BMLoopNorEditDataArray* BM_loop_normal_editdata_array_init ( BMesh bm,
const bool  do_all_loops_of_vert 
)

◆ bm_loop_normal_mark_indiv()

static int bm_loop_normal_mark_indiv ( BMesh bm,
BLI_bitmap loops,
const bool  do_all_loops_of_vert 
)
static

◆ bm_loop_normal_mark_indiv_do_loop()

static void bm_loop_normal_mark_indiv_do_loop ( BMLoop l,
BLI_bitmap loops,
MLoopNorSpaceArray lnor_spacearr,
int *  totloopsel,
const bool  do_all_loops_of_vert 
)
static

◆ BM_loops_calc_normal_vcos()

void BM_loops_calc_normal_vcos ( BMesh bm,
const float(*)  vcos[3],
const float(*)  vnos[3],
const float(*)  fnos[3],
const bool  use_split_normals,
const float  split_angle,
float(*)  r_lnos[3],
MLoopNorSpaceArray r_lnors_spacearr,
short(*)  clnors_data[2],
const int  cd_loop_clnors_offset,
const bool  do_rebuild 
)

BMesh Compute Loop Normals from/to external data.

Compute split normals, i.e. vertex normals associated with each poly (hence 'loop normals'). Useful to materialize sharp edges (or non-smooth faces) without actually modifying the geometry (splitting edges).

Definition at line 1346 of file bmesh_mesh.c.

References BLI_assert, bm, bm_mesh_edges_sharp_tag(), bm_mesh_loops_calc_normals(), bm_mesh_loops_calc_normals_no_autosmooth(), and M_PI.

Referenced by BM_lnorspace_err(), BM_lnorspace_rebuild(), BM_lnorspacearr_store(), and mesh_render_data_update_normals().

◆ bm_mempool_init()

static void bm_mempool_init ( BMesh bm,
const BMAllocTemplate allocsize,
const bool  use_toolflags 
)
static

◆ bm_mempool_init_ex()

static void bm_mempool_init_ex ( const BMAllocTemplate allocsize,
const bool  use_toolflags,
BLI_mempool **  r_vpool,
BLI_mempool **  r_epool,
BLI_mempool **  r_lpool,
BLI_mempool **  r_fpool 
)
static

◆ BM_mesh_clear()

void BM_mesh_clear ( BMesh bm)

◆ BM_mesh_create()

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

◆ BM_mesh_data_free()

void BM_mesh_data_free ( BMesh bm)

◆ bm_mesh_edges_calc_vectors()

static void bm_mesh_edges_calc_vectors ( BMesh bm,
float(*)  edgevec[3],
const float(*)  vcos[3] 
)
static

◆ bm_mesh_edges_sharp_tag()

static void bm_mesh_edges_sharp_tag ( BMesh bm,
const float(*)  vnos[3],
const float(*)  fnos[3],
float(*)  r_lnos[3],
const float  split_angle,
const bool  do_sharp_edges_tag 
)
static

◆ BM_mesh_elem_count()

int BM_mesh_elem_count ( BMesh bm,
const char  htype 
)

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

Definition at line 2444 of file bmesh_mesh.c.

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,
const char  htype 
)

Definition at line 2152 of file bmesh_mesh.c.

References bm, BM_mesh_elem_index_ensure_ex(), and NULL.

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_custom_loop_normals_to_vector_layer(), 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_decimate_dissolve_ex(), BM_mesh_edgenet(), bm_mesh_edges_calc_vectors(), bm_mesh_edges_sharp_tag(), BM_mesh_intersect(), bm_mesh_loops_calc_normals(), bm_mesh_loops_calc_normals_no_autosmooth(), BM_mesh_normals_update(), 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_bmbvh(), lattice_deform_coords_impl(), lineart_geometry_object_load(), 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(), statvis_calc_distort(), statvis_calc_intersect(), statvis_calc_thickness(), stitch_process_data(), 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,
const 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.

Code that calls this functions may depend on dirty indices on being set. Keep this function read-only.

Definition at line 2169 of file bmesh_mesh.c.

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 BMesh::elem_index_dirty.

◆ 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,
const char  htype 
)

Definition at line 2276 of file bmesh_mesh.c.

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, NULL, BMesh::totedge, BMesh::totface, BMesh::totvert, BMesh::vtable, and BMesh::vtable_tot.

Referenced by 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(), blender::ed::spreadsheet::GeometryDataSource::get_selected_element_indices(), get_vert_def_nr(), give_parvert(), lineart_geometry_object_load(), loopcut_init(), math_layer_info_init(), 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(), 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,
const char  htype 
)

Definition at line 2361 of file bmesh_mesh.c.

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,
const 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_loops_assign_normal_data()

static void bm_mesh_loops_assign_normal_data ( BMesh bm,
MLoopNorSpaceArray lnors_spacearr,
short(*)  r_clnors_data[2],
const int  cd_loop_clnors_offset,
const float(*)  new_lnors[3] 
)
static

◆ bm_mesh_loops_calc_normals()

static void bm_mesh_loops_calc_normals ( BMesh bm,
const float(*)  vcos[3],
const float(*)  fnos[3],
float(*)  r_lnos[3],
MLoopNorSpaceArray r_lnors_spacearr,
const short(*)  clnors_data[2],
const int  cd_loop_clnors_offset,
const bool  do_rebuild 
)
static

BMesh version of BKE_mesh_normals_loop_split() in mesh_evaluate.c Will use first clnors_data array, and fallback to cd_loop_clnors_offset (use NULL and -1 to not use clnors).

Note
This sets BM_ELEM_TAG which is used in tool code (e.g. T84426). we could add a low-level API flag for this, see BM_ELEM_API_FLAG_ENABLE and friends.

Definition at line 676 of file bmesh_mesh.c.

References BKE_lnor_space_add_loop(), BKE_lnor_space_create(), BKE_lnor_space_custom_data_to_normal(), BKE_lnor_space_define(), BKE_lnor_spacearr_free(), BKE_lnor_spacearr_init(), BLI_assert, BLI_SMALLSTACK_DECLARE, BLI_SMALLSTACK_POP, BLI_SMALLSTACK_PUSH, BLI_stack_free(), BLI_stack_is_empty(), BLI_stack_new, BLI_stack_push(), bm, BM_edge_other_vert(), BM_ELEM_API_FLAG_TEST, BM_ELEM_CD_GET_VOID_P, BM_elem_flag_disable, BM_elem_flag_enable, BM_elem_flag_test, BM_elem_index_get, BM_elem_index_set, BM_ELEM_TAG, BM_FACE, BM_FACE_FIRST_LOOP, BM_FACES_OF_MESH, BM_ITER_MESH, BM_ITER_MESH_INDEX, BM_LNORSPACE_UPDATE, BM_LOOP, BM_loop_check_cyclic_smooth_fan(), BM_mesh_elem_index_ensure(), BM_SPACEARR_DIRTY_ALL, BM_VERT, BM_vert_step_fan_loop(), BMVert::co, copy_v3_v3(), dot_v3v3(), BMLoop::e, BMesh::elem_index_dirty, BMLoop::f, LIKELY, madd_v3_v3fl(), MLNOR_SPACEARR_BMLOOP_PTR, BMLoop::next, BMFace::no, nor, normal, normalize_v3(), NULL, BMLoop::prev, saacos(), BMesh::spacearr_dirty, sub_v3_v3v3(), BMesh::totloop, UNLIKELY, and BMLoop::v.

Referenced by BM_loops_calc_normal_vcos(), and bm_mesh_loops_custom_normals_set().

◆ bm_mesh_loops_calc_normals_no_autosmooth()

static void bm_mesh_loops_calc_normals_no_autosmooth ( BMesh bm,
const float(*)  vnos[3],
const float(*)  fnos[3],
float(*)  r_lnos[3] 
)
static

◆ bm_mesh_loops_custom_normals_set()

static void bm_mesh_loops_custom_normals_set ( BMesh bm,
const float(*)  vcos[3],
const float(*)  vnos[3],
const float(*)  fnos[3],
MLoopNorSpaceArray r_lnors_spacearr,
short(*)  r_clnors_data[2],
const int  cd_loop_clnors_offset,
float(*)  new_lnors[3],
const int  cd_new_lnors_offset,
bool  do_split_fans 
)
static

Compute internal representation of given custom normals (as an array of float[2] or data layer).

It also makes sure the mesh matches those custom normals, by marking new sharp edges to split the smooth fans when loop normals for the same vertex are different, or averaging the normals instead, depending on the do_split_fans parameter.

Definition at line 1198 of file bmesh_mesh.c.

References BKE_lnor_spacearr_clear(), bm, BM_ELEM_CD_GET_VOID_P, BM_elem_index_get, BM_FACES_OF_MESH, BM_ITER_ELEM, BM_ITER_MESH, BM_LOOPS_OF_FACE, bm_mesh_edges_sharp_tag(), bm_mesh_loops_assign_normal_data(), bm_mesh_loops_calc_normals(), bm_mesh_loops_split_lnor_fans(), copy_v3_v3(), float(), is_zero_v3(), l, M_PI, MEM_freeN, MEM_mallocN, normal, normalize_v3(), NULL, and BMesh::totloop.

Referenced by BM_custom_loop_normals_from_vector_layer().

◆ bm_mesh_loops_split_lnor_fans()

static bool bm_mesh_loops_split_lnor_fans ( BMesh bm,
MLoopNorSpaceArray lnors_spacearr,
const float(*)  new_lnors[3] 
)
static

◆ BM_mesh_normals_update()

void BM_mesh_normals_update ( BMesh bm)

◆ BM_mesh_rebuild()

void BM_mesh_rebuild ( BMesh bm,
const struct BMeshCreateParams params,
BLI_mempool vpool_dst,
BLI_mempool epool_dst,
BLI_mempool lpool_dst,
BLI_mempool fpool_dst 
)

◆ 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 2476 of file bmesh_mesh.c.

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, NULL, 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 3074 of file bmesh_mesh.c.

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 3084 of file bmesh_mesh.c.

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

static void bm_mesh_verts_calc_normals ( BMesh bm,
const float(*)  edgevec[3],
const float(*)  fnos[3],
const float(*)  vcos[3],
float(*)  vnos[3] 
)
static

◆ BM_normals_loops_edges_tag()

void BM_normals_loops_edges_tag ( BMesh bm,
const bool  do_edges 
)

◆ BM_vert_at_index_find()

BMVert* BM_vert_at_index_find ( BMesh bm,
const int  index 
)

◆ BM_vert_at_index_find_or_table()

BMVert* BM_vert_at_index_find_or_table ( BMesh bm,
const 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 2417 of file bmesh_mesh.c.

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

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

◆ BM_verts_calc_normal_vcos()

void BM_verts_calc_normal_vcos ( BMesh bm,
const float(*)  fnos[3],
const float(*)  vcos[3],
float(*)  vnos[3] 
)

BMesh Compute Normals from/to external data.

Computes the vertex normals of a mesh into vnos, using given vertex coordinates (vcos) and polygon normals (fnos).

Definition at line 538 of file bmesh_mesh.c.

References bm, bm_mesh_edges_calc_vectors(), bm_mesh_verts_calc_normals(), float(), MEM_freeN, MEM_mallocN, and BMesh::totedge.

Referenced by BKE_editmesh_cache_ensure_vert_normals().

◆ bmesh_edit_begin()

void bmesh_edit_begin ( BMesh UNUSEDbm,
BMOpTypeFlag   UNUSEDtype_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 1975 of file bmesh_mesh.c.

References bm, BM_mesh_normals_update(), BMO_OPTYPE_FLAG_UNTAN_MULTIRES, CD_MDISPS, CustomData_has_layer(), and BMesh::ldata.

Referenced by BMO_op_exec(), build_skin(), and mesh_customdatacorrect_init_container_generic().

◆ bmesh_edit_end()

void bmesh_edit_end ( BMesh bm,
BMOpTypeFlag  type_flag 
)

◆ loop_normal_editdata_init()

static void loop_normal_editdata_init ( BMesh bm,
BMLoopNorEditData lnor_ed,
BMVert v,
BMLoop l,
const int  offset 
)
static

◆ mesh_edges_calc_vectors_cb()

static void mesh_edges_calc_vectors_cb ( void *  userdata,
MempoolIterData mp_e 
)
static

Definition at line 337 of file bmesh_mesh.c.

References BM_elem_index_get, BMVert::co, data, e, normalize_v3(), and sub_v3_v3v3().

Referenced by bm_mesh_edges_calc_vectors().

◆ mesh_faces_calc_normals_cb()

static void mesh_faces_calc_normals_cb ( void *  UNUSEDuserdata,
MempoolIterData mp_f 
)
static

Definition at line 488 of file bmesh_mesh.c.

References BM_face_normal_update().

Referenced by BM_mesh_normals_update().

◆ mesh_verts_calc_normals_accum_cb()

static void mesh_verts_calc_normals_accum_cb ( void *  userdata,
MempoolIterData mp_f 
)
static

◆ mesh_verts_calc_normals_normalize_cb()

static void mesh_verts_calc_normals_normalize_cb ( void *  userdata,
MempoolIterData mp_v 
)
static

Variable Documentation

◆ bm_mesh_allocsize_default

const BMAllocTemplate bm_mesh_allocsize_default = {512, 1024, 2048, 512}

◆ bm_mesh_chunksize_default

const BMAllocTemplate bm_mesh_chunksize_default = {512, 1024, 2048, 512}

Definition at line 47 of file bmesh_mesh.c.

Referenced by bm_mempool_init_ex(), and CustomData_bmesh_init_pool().