Blender  V2.93
Functions
bmesh_marking.c File Reference
#include <stddef.h>
#include "MEM_guardedalloc.h"
#include "DNA_scene_types.h"
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "bmesh.h"
#include "bmesh_structure.h"
#include "bmesh_private.h"

Go to the source code of this file.

Functions

static void recount_totsels (BMesh *bm)
 
void BM_mesh_select_mode_clean_ex (BMesh *bm, const short selectmode)
 Select Mode Clean. More...
 
void BM_mesh_select_mode_clean (BMesh *bm)
 
void BM_mesh_select_mode_flush_ex (BMesh *bm, const short selectmode)
 Select Mode Flush. More...
 
void BM_mesh_select_mode_flush (BMesh *bm)
 
void BM_mesh_deselect_flush (BMesh *bm)
 
void BM_mesh_select_flush (BMesh *bm)
 
void BM_vert_select_set (BMesh *bm, BMVert *v, const bool select)
 Select Vert. More...
 
void BM_edge_select_set (BMesh *bm, BMEdge *e, const bool select)
 Select Edge. More...
 
void BM_face_select_set (BMesh *bm, BMFace *f, const bool select)
 Select Face. More...
 
void BM_mesh_select_mode_set (BMesh *bm, int selectmode)
 
static int bm_mesh_flag_count (BMesh *bm, const char htype, const char hflag, const bool respecthide, const bool test_for_enabled)
 
int BM_mesh_elem_hflag_count_enabled (BMesh *bm, const char htype, const char hflag, const bool respecthide)
 
int BM_mesh_elem_hflag_count_disabled (BMesh *bm, const char htype, const char hflag, const bool respecthide)
 
void BM_elem_select_set (BMesh *bm, BMElem *ele, const bool select)
 
void BM_mesh_active_face_set (BMesh *bm, BMFace *f)
 
BMFaceBM_mesh_active_face_get (BMesh *bm, const bool is_sloppy, const bool is_selected)
 
BMEdgeBM_mesh_active_edge_get (BMesh *bm)
 
BMVertBM_mesh_active_vert_get (BMesh *bm)
 
BMElemBM_mesh_active_elem_get (BMesh *bm)
 
void BM_editselection_center (BMEditSelection *ese, float r_center[3])
 
void BM_editselection_normal (BMEditSelection *ese, float r_normal[3])
 
void BM_editselection_plane (BMEditSelection *ese, float r_plane[3])
 
static BMEditSelectionbm_select_history_create (BMHeader *ele)
 
bool _bm_select_history_check (BMesh *bm, const BMHeader *ele)
 
bool _bm_select_history_remove (BMesh *bm, BMHeader *ele)
 
void _bm_select_history_store_notest (BMesh *bm, BMHeader *ele)
 
void _bm_select_history_store_head_notest (BMesh *bm, BMHeader *ele)
 
void _bm_select_history_store (BMesh *bm, BMHeader *ele)
 
void _bm_select_history_store_head (BMesh *bm, BMHeader *ele)
 
void _bm_select_history_store_after_notest (BMesh *bm, BMEditSelection *ese_ref, BMHeader *ele)
 
void _bm_select_history_store_after (BMesh *bm, BMEditSelection *ese_ref, BMHeader *ele)
 
void BM_select_history_clear (BMesh *bm)
 
void BM_select_history_validate (BMesh *bm)
 
bool BM_select_history_active_get (BMesh *bm, BMEditSelection *ese)
 
GHashBM_select_history_map_create (BMesh *bm)
 
void BM_select_history_merge_from_targetmap (BMesh *bm, GHash *vert_map, GHash *edge_map, GHash *face_map, const bool use_chain)
 
void BM_mesh_elem_hflag_disable_test (BMesh *bm, const char htype, const char hflag, const bool respecthide, const bool overwrite, const char hflag_test)
 
void BM_mesh_elem_hflag_enable_test (BMesh *bm, const char htype, const char hflag, const bool respecthide, const bool overwrite, const char hflag_test)
 
void BM_mesh_elem_hflag_disable_all (BMesh *bm, const char htype, const char hflag, const bool respecthide)
 
void BM_mesh_elem_hflag_enable_all (BMesh *bm, const char htype, const char hflag, const bool respecthide)
 
static void vert_flush_hide_set (BMVert *v)
 
static void edge_flush_hide_set (BMEdge *e)
 
void BM_vert_hide_set (BMVert *v, const bool hide)
 
void BM_edge_hide_set (BMEdge *e, const bool hide)
 
void BM_face_hide_set (BMFace *f, const bool hide)
 
void _bm_elem_hide_set (BMesh *bm, BMHeader *head, const bool hide)
 
BMesh helper functions for selection & hide flushing.
static bool bm_vert_is_edge_select_any_other (const BMVert *v, const BMEdge *e_first)
 
static bool bm_vert_is_edge_visible_any (const BMVert *v)
 
static bool bm_edge_is_face_select_any_other (BMLoop *l_first)
 
static bool bm_edge_is_face_visible_any (const BMEdge *e)
 
Non Flushing Versions Element Selection
void BM_edge_select_set_noflush (BMesh *bm, BMEdge *e, const bool select)
 
void BM_face_select_set_noflush (BMesh *bm, BMFace *f, const bool select)
 

Detailed Description

Selection routines for bmesh structures. This is actually all old code ripped from editmesh_lib.c and slightly modified to work for bmesh's. This also means that it has some of the same problems.... something that that should be addressed eventually.

Definition in file bmesh_marking.c.

Function Documentation

◆ _bm_elem_hide_set()

void _bm_elem_hide_set ( BMesh bm,
BMHeader head,
const bool  hide 
)

◆ _bm_select_history_check()

bool _bm_select_history_check ( BMesh bm,
const BMHeader ele 
)

Definition at line 946 of file bmesh_marking.c.

References BLI_findptr(), bm, NULL, and BMesh::selected.

◆ _bm_select_history_remove()

bool _bm_select_history_remove ( BMesh bm,
BMHeader ele 
)

Definition at line 951 of file bmesh_marking.c.

References BLI_findptr(), BLI_freelinkN(), bm, and BMesh::selected.

◆ _bm_select_history_store()

void _bm_select_history_store ( BMesh bm,
BMHeader ele 
)

Definition at line 973 of file bmesh_marking.c.

References bm, BM_select_history_check, and BM_select_history_store_notest.

◆ _bm_select_history_store_after()

void _bm_select_history_store_after ( BMesh bm,
BMEditSelection ese_ref,
BMHeader ele 
)

◆ _bm_select_history_store_after_notest()

void _bm_select_history_store_after_notest ( BMesh bm,
BMEditSelection ese_ref,
BMHeader ele 
)

◆ _bm_select_history_store_head()

void _bm_select_history_store_head ( BMesh bm,
BMHeader ele 
)

Definition at line 980 of file bmesh_marking.c.

References bm, BM_select_history_check, and BM_select_history_store_head_notest.

◆ _bm_select_history_store_head_notest()

void _bm_select_history_store_head_notest ( BMesh bm,
BMHeader ele 
)

Definition at line 967 of file bmesh_marking.c.

References BLI_addhead(), bm, bm_select_history_create(), and BMesh::selected.

◆ _bm_select_history_store_notest()

void _bm_select_history_store_notest ( BMesh bm,
BMHeader ele 
)

Definition at line 961 of file bmesh_marking.c.

References BLI_addtail(), bm, bm_select_history_create(), and BMesh::selected.

◆ BM_edge_hide_set()

void BM_edge_hide_set ( BMEdge e,
const bool  hide 
)

◆ bm_edge_is_face_select_any_other()

static bool bm_edge_is_face_select_any_other ( BMLoop l_first)
static

Definition at line 116 of file bmesh_marking.c.

References BM_elem_flag_test, BM_ELEM_SELECT, BMLoop::f, and BMLoop::radial_next.

Referenced by BM_face_select_set().

◆ bm_edge_is_face_visible_any()

static bool bm_edge_is_face_visible_any ( const BMEdge e)
static

Definition at line 145 of file bmesh_marking.c.

References BM_elem_flag_test, BM_ELEM_HIDDEN, e, BMLoop::f, and BMLoop::radial_next.

Referenced by edge_flush_hide_set().

◆ BM_edge_select_set()

void BM_edge_select_set ( BMesh bm,
BMEdge e,
const bool  select 
)

Select Edge.

Changes selection state of a single edge in a mesh.

Definition at line 423 of file bmesh_marking.c.

References BLI_assert, bm, BM_EDGE, BM_elem_flag_disable, BM_elem_flag_enable, BM_elem_flag_test, BM_ELEM_HIDDEN, BM_ELEM_SELECT, bm_vert_is_edge_select_any_other(), BM_vert_select_set(), e, BMVert::head, BMHeader::htype, SCE_SELECT_VERTEX, select(), BMesh::selectmode, BMesh::totedgesel, and v.

Referenced by _bm_elem_hide_set(), BM_elem_select_set(), BM_face_select_set(), bm_face_split_by_edges_island_connect(), BM_mesh_bm_from_me(), BM_mesh_select_mode_clean_ex(), BM_mesh_select_mode_set(), bm_vert_connect_select_history(), do_lasso_select_mesh__doSelectEdge_pass0(), do_lasso_select_mesh__doSelectEdge_pass1(), do_mesh_box_select__doSelectEdge_pass0(), do_mesh_box_select__doSelectEdge_pass1(), edbm_add_edge_face_exec__tricky_extend_sel(), edbm_add_edge_face_exec__tricky_finalize_sel(), edbm_backbuf_check_and_select_edges(), edbm_intersect_select(), edbm_polybuild_transform_at_cursor_invoke(), edbm_region_to_loop_exec(), edbm_rip_edge_invoke(), edbm_ripsel_deselect_helper(), edbm_select_linked_exec(), edbm_select_linked_pick_ex(), edbm_select_loose_exec(), EDBM_select_mirrored(), edbm_select_non_manifold_exec(), EDBM_select_pick(), edbm_select_random_exec(), edbm_select_sharp_edges_exec(), EDBM_select_swap(), EDBM_selectmode_convert(), EDBM_selectmode_set(), edgering_select(), edgetag_set_cb(), knife_make_cuts(), knife_make_face_cuts(), mesh_circle_doSelectEdge(), mouse_mesh_shortest_path_edge(), similar_edge_select_exec(), uvedit_edge_select_disable(), and uvedit_edge_select_enable().

◆ BM_edge_select_set_noflush()

void BM_edge_select_set_noflush ( BMesh bm,
BMEdge e,
const bool  select 
)

◆ BM_editselection_center()

void BM_editselection_center ( BMEditSelection ese,
float  r_center[3] 
)

Generic way to get data from an EditSelection type These functions were written to be used by the Modifier widget when in Rotate about active mode, but can be used anywhere.

Definition at line 831 of file bmesh_marking.c.

References BM_EDGE, BM_FACE, BM_face_calc_center_median(), BM_VERT, BMVert::co, copy_v3_v3(), BMEditSelection::ele, BMEditSelection::htype, mid_v3_v3v3(), BMEdge::v1, and BMEdge::v2.

Referenced by BM_editselection_plane(), ED_object_calc_active_center_for_editmode(), transform_convert_mesh_islands_calc(), and uv_map_transform_center().

◆ BM_editselection_normal()

void BM_editselection_normal ( BMEditSelection ese,
float  r_normal[3] 
)

◆ BM_editselection_plane()

void BM_editselection_plane ( BMEditSelection ese,
float  r_plane[3] 
)

Calculate a plane that is right angles to the edge/vert/faces normal also make the plane run along an axis that is related to the geometry, because this is used for the gizmos Y axis.

Definition at line 880 of file bmesh_marking.c.

References BM_editselection_center(), BM_VERT, cross_v3_v3v3(), BMEditSelection::ele, BMEditSelection::htype, normalize_v3(), BMEditSelection::prev, and sub_v3_v3v3().

Referenced by getTransformOrientation_ex(), and transform_convert_mesh_islands_calc().

◆ BM_elem_select_set()

void BM_elem_select_set ( BMesh bm,
BMElem ele,
const bool  select 
)

◆ BM_face_hide_set()

void BM_face_hide_set ( BMFace f,
const bool  hide 
)

◆ BM_face_select_set()

void BM_face_select_set ( BMesh bm,
BMFace f,
const bool  select 
)

Select Face.

Changes selection state of a single face in a mesh.

Note
This allows a temporarily invalid state - where for eg an edge bay be de-selected, but an adjacent face remains selected.

Rely on BM_mesh_select_mode_flush to correct these cases.

Note
flushing based on mode, see T46494
use BM_edge_select_set_noflush, vertex flushing is handled last.

Definition at line 469 of file bmesh_marking.c.

References BLI_assert, bm, bm_edge_is_face_select_any_other(), BM_edge_select_set(), BM_edge_select_set_noflush(), BM_elem_flag_disable, BM_elem_flag_enable, BM_elem_flag_test, BM_ELEM_HIDDEN, BM_ELEM_SELECT, BM_FACE, BM_FACE_FIRST_LOOP, bm_vert_is_edge_select_any_other(), BM_vert_select_set(), BMLoop::e, BMFace::head, BMHeader::htype, BMLoop::next, SCE_SELECT_EDGE, SCE_SELECT_VERTEX, select(), BMesh::selectmode, BMesh::totfacesel, and BMLoop::v.

Referenced by _bm_elem_hide_set(), BM_elem_select_set(), bm_face_split_by_edges(), bm_face_split_by_edges_island_connect(), BM_mesh_bm_from_me(), BM_mesh_select_mode_set(), do_lasso_select_mesh__doSelectFace(), do_mesh_box_select__doSelectFace(), edbm_add_edge_face_exec__tricky_finalize_sel(), edbm_backbuf_check_and_select_faces(), EDBM_deselect_by_material(), edbm_extrude_discrete_faces(), edbm_loop_to_region_exec(), edbm_mod_weighted_strength_exec(), edbm_polybuild_transform_at_cursor_invoke(), edbm_select_face_by_sides_exec(), EDBM_select_interior_faces(), edbm_select_linked_exec(), edbm_select_linked_flat_faces_exec(), edbm_select_linked_pick_ex(), edbm_select_loose_exec(), EDBM_select_mirrored(), EDBM_select_pick(), edbm_select_random_exec(), edbm_select_similar_region_exec(), EDBM_select_swap(), EDBM_selectmode_convert(), EDBM_selectmode_set(), facetag_set_cb(), fmap_select(), mesh_circle_doSelectFace(), similar_face_select_exec(), uv_hide_exec(), uvedit_edge_select_disable(), uvedit_edge_select_enable(), uvedit_face_select_disable(), uvedit_face_select_enable(), uvedit_uv_select_disable(), and uvedit_uv_select_enable().

◆ BM_face_select_set_noflush()

void BM_face_select_set_noflush ( BMesh bm,
BMFace f,
const bool  select 
)

◆ BM_mesh_active_edge_get()

BMEdge* BM_mesh_active_edge_get ( BMesh bm)

◆ BM_mesh_active_elem_get()

BMElem* BM_mesh_active_elem_get ( BMesh bm)

◆ BM_mesh_active_face_get()

BMFace* BM_mesh_active_face_get ( BMesh bm,
const bool  is_sloppy,
const bool  is_selected 
)

◆ BM_mesh_active_face_set()

void BM_mesh_active_face_set ( BMesh bm,
BMFace f 
)

◆ BM_mesh_active_vert_get()

BMVert* BM_mesh_active_vert_get ( BMesh bm)

◆ BM_mesh_deselect_flush()

void BM_mesh_deselect_flush ( BMesh bm)

◆ BM_mesh_elem_hflag_count_disabled()

int BM_mesh_elem_hflag_count_disabled ( BMesh bm,
const char  htype,
const char  hflag,
const bool  respecthide 
)

Definition at line 707 of file bmesh_marking.c.

References bm, and bm_mesh_flag_count().

Referenced by bmo_slot_buffer_from_hflag().

◆ BM_mesh_elem_hflag_count_enabled()

int BM_mesh_elem_hflag_count_enabled ( BMesh bm,
const char  htype,
const char  hflag,
const bool  respecthide 
)

Definition at line 699 of file bmesh_marking.c.

References bm, and bm_mesh_flag_count().

Referenced by bmo_slot_buffer_from_hflag().

◆ BM_mesh_elem_hflag_disable_all()

void BM_mesh_elem_hflag_disable_all ( BMesh bm,
const char  htype,
const char  hflag,
const bool  respecthide 
)

Definition at line 1266 of file bmesh_marking.c.

References bm, and BM_mesh_elem_hflag_disable_test().

Referenced by BKE_mesh_remesh_voxel_fix_poles(), BM_mesh_bisect_plane(), BM_mesh_calc_edge_groups_as_arrays(), BM_mesh_esubdivide(), BM_mesh_intersect(), BM_mesh_region_match(), BM_mesh_wireframe(), bmo_bevel_exec(), bmo_bisect_plane_exec(), bmo_edgenet_fill_exec(), bmo_face_attribute_fill_exec(), bmo_holes_fill_exec(), bmo_inset_individual_exec(), bmo_inset_region_exec(), bmo_offset_edgeloops_exec(), bmo_split_edges_exec(), bmo_subdivide_edgering_exec(), bmo_triangulate_exec(), bmo_wireframe_exec(), bridge_loop_pair(), build_hull(), do_lasso_select_mesh_uv(), ED_vgroup_mirror(), edbm_bridge_edge_loops_for_single_editmesh(), edbm_bridge_tag_boundary_edges(), edbm_delete_edgeloop_exec(), edbm_delete_loose_exec(), EDBM_flag_disable_all(), edbm_intersect_select(), edbm_loop_to_region_exec(), edbm_offset_edgeloop_exec(), EDBM_op_call_and_selectf(), edbm_region_to_loop_exec(), edbm_select_linked_flat_faces_exec(), edbm_split_exec(), edbm_wireframe_exec(), geometry_extract_apply(), geometry_extract_tag_face_set(), geometry_extract_tag_masked_faces(), hull_merge_triangles(), knifeproject_exec(), lineart_geometry_object_load(), mesh_separate_loose(), mesh_separate_material(), mesh_separate_selected(), mesh_separate_tagged(), mesh_symmetry_snap_exec(), multires_unsubdivide_prepare_original_bmesh_for_extract(), multires_unsubdivide_single_level(), sculpt_face_set_delete_geometry(), sculpt_gesture_trim_normals_update(), sculpt_symmetrize_exec(), skin_fix_hole_no_good_verts(), skin_smooth_hulls(), slice_paint_mask(), smart_uv_project_calculate_project_normals(), special_aftertrans_update__mesh(), unsubdivide_build_base_mesh_from_tags(), uv_box_select_exec(), uv_circle_select_exec(), uv_select_edgering(), uv_select_flush_from_tag_face(), uv_select_flush_from_tag_loop(), uv_select_more_less(), uv_select_overlap(), and uv_weld_align().

◆ BM_mesh_elem_hflag_disable_test()

void BM_mesh_elem_hflag_disable_test ( BMesh bm,
const char  htype,
const char  hflag,
const bool  respecthide,
const bool  overwrite,
const char  hflag_test 
)

◆ BM_mesh_elem_hflag_enable_all()

void BM_mesh_elem_hflag_enable_all ( BMesh bm,
const char  htype,
const char  hflag,
const bool  respecthide 
)

◆ BM_mesh_elem_hflag_enable_test()

void BM_mesh_elem_hflag_enable_test ( BMesh bm,
const char  htype,
const char  hflag,
const bool  respecthide,
const bool  overwrite,
const char  hflag_test 
)

◆ bm_mesh_flag_count()

static int bm_mesh_flag_count ( BMesh bm,
const char  htype,
const char  hflag,
const bool  respecthide,
const bool  test_for_enabled 
)
static

◆ BM_mesh_select_flush()

void BM_mesh_select_flush ( BMesh bm)

◆ BM_mesh_select_mode_clean()

void BM_mesh_select_mode_clean ( BMesh bm)

Definition at line 229 of file bmesh_marking.c.

References bm, BM_mesh_select_mode_clean_ex(), and BMesh::selectmode.

Referenced by EDBM_select_less().

◆ BM_mesh_select_mode_clean_ex()

void BM_mesh_select_mode_clean_ex ( BMesh bm,
const short  selectmode 
)

Select Mode Clean.

Remove isolated selected elements when in a mode doesn't support them. eg: in edge-mode a selected vertex must be connected to a selected edge.

Note
this could be made a part of BM_mesh_select_mode_flush_ex

Definition at line 169 of file bmesh_marking.c.

References bm, BM_edge_select_set(), BM_EDGES_OF_MESH, BM_elem_flag_disable, BM_elem_flag_test, BM_ELEM_SELECT, BM_FACE_FIRST_LOOP, BM_FACES_OF_MESH, BM_ITER_MESH, BM_vert_select_set(), BM_VERTS_OF_MESH, BMLoop::e, e, BMLoop::next, SCE_SELECT_EDGE, SCE_SELECT_FACE, SCE_SELECT_VERTEX, BMesh::totedgesel, BMesh::totfacesel, BMesh::totvertsel, and v.

Referenced by BM_mesh_select_mode_clean(), and edbm_rip_invoke__edge().

◆ BM_mesh_select_mode_flush()

void BM_mesh_select_mode_flush ( BMesh bm)

◆ BM_mesh_select_mode_flush_ex()

void BM_mesh_select_mode_flush_ex ( BMesh bm,
const short  selectmode 
)

Select Mode Flush.

Makes sure to flush selections 'upwards' (ie: all verts of an edge selects the edge and so on). This should only be called by system and not tool authors.

Definition at line 241 of file bmesh_marking.c.

References bm, BM_EDGES_OF_MESH, BM_elem_flag_disable, BM_elem_flag_enable, BM_elem_flag_set, BM_elem_flag_test, BM_ELEM_HIDDEN, BM_ELEM_SELECT, BM_FACE_FIRST_LOOP, BM_FACES_OF_MESH, BM_ITER_MESH, BM_select_history_validate(), BMLoop::e, e, BMLoop::next, recount_totsels(), SCE_SELECT_EDGE, SCE_SELECT_VERTEX, and BMLoop::v.

Referenced by BM_mesh_select_mode_flush(), EDBM_selectmode_flush_ex(), and uv_shortest_path_pick_ex().

◆ BM_mesh_select_mode_set()

void BM_mesh_select_mode_set ( BMesh bm,
int  selectmode 
)

◆ BM_select_history_active_get()

bool BM_select_history_active_get ( BMesh bm,
BMEditSelection ese 
)

◆ BM_select_history_clear()

void BM_select_history_clear ( BMesh bm)

◆ bm_select_history_create()

static BMEditSelection* bm_select_history_create ( BMHeader ele)
static

◆ BM_select_history_map_create()

GHash* BM_select_history_map_create ( BMesh bm)

◆ BM_select_history_merge_from_targetmap()

void BM_select_history_merge_from_targetmap ( BMesh bm,
GHash vert_map,
GHash edge_map,
GHash face_map,
const bool  use_chain 
)

◆ BM_select_history_validate()

void BM_select_history_validate ( BMesh bm)

◆ BM_vert_hide_set()

void BM_vert_hide_set ( BMVert v,
const bool  hide 
)

◆ bm_vert_is_edge_select_any_other()

static bool bm_vert_is_edge_select_any_other ( const BMVert v,
const BMEdge e_first 
)
static

Definition at line 73 of file bmesh_marking.c.

References BM_elem_flag_test, BM_ELEM_SELECT, bmesh_disk_edge_next(), and v.

Referenced by BM_edge_select_set(), and BM_face_select_set().

◆ bm_vert_is_edge_visible_any()

static bool bm_vert_is_edge_visible_any ( const BMVert v)
static

Definition at line 102 of file bmesh_marking.c.

References BM_elem_flag_test, BM_ELEM_HIDDEN, bmesh_disk_edge_next(), BMVert::e, and v.

Referenced by vert_flush_hide_set().

◆ BM_vert_select_set()

void BM_vert_select_set ( BMesh bm,
BMVert v,
const bool  select 
)

◆ edge_flush_hide_set()

static void edge_flush_hide_set ( BMEdge e)
static

Hide unless any connected elements are visible. Run this after hiding a connected face.

Definition at line 1299 of file bmesh_marking.c.

References bm_edge_is_face_visible_any(), BM_elem_flag_set, BM_ELEM_HIDDEN, and e.

Referenced by BM_face_hide_set().

◆ recount_totsels()

static void recount_totsels ( BMesh bm)
static

◆ vert_flush_hide_set()

static void vert_flush_hide_set ( BMVert v)
static

Hide unless any connected elements are visible. Run this after hiding a connected edge or face.

Definition at line 1290 of file bmesh_marking.c.

References BM_elem_flag_set, BM_ELEM_HIDDEN, bm_vert_is_edge_visible_any(), and v.

Referenced by BM_edge_hide_set(), and BM_face_hide_set().