Blender V5.3
editmesh_select.cc File Reference
#include <algorithm>
#include <optional>
#include "MEM_guardedalloc.h"
#include "BLI_array.hh"
#include "BLI_function_ref.hh"
#include "BLI_heap.hh"
#include "BLI_listbase.hh"
#include "BLI_math_bits.hh"
#include "BLI_math_geom_c.hh"
#include "BLI_math_matrix_c.hh"
#include "BLI_math_rotation_c.hh"
#include "BLI_math_vector_c.hh"
#include "BLI_rand_c.hh"
#include "BLI_utildefines_stack.hh"
#include "BLI_vector.hh"
#include "BKE_attribute.h"
#include "BKE_attribute.hh"
#include "BKE_context.hh"
#include "BKE_customdata.hh"
#include "BKE_deform.hh"
#include "BKE_editmesh.hh"
#include "BKE_layer.hh"
#include "BKE_mesh.hh"
#include "BKE_mesh_wrapper.hh"
#include "BKE_object.hh"
#include "BKE_report.hh"
#include "WM_api.hh"
#include "WM_types.hh"
#include "RNA_access.hh"
#include "RNA_define.hh"
#include "RNA_enum_types.hh"
#include "ED_mesh.hh"
#include "ED_object.hh"
#include "ED_screen.hh"
#include "ED_select_utils.hh"
#include "ED_transform.hh"
#include "ED_uvedit.hh"
#include "ED_view3d.hh"
#include "BLT_translation.hh"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "bmesh_tools.hh"
#include "DEG_depsgraph.hh"
#include "DEG_depsgraph_query.hh"
#include "DRW_select_buffer.hh"
#include "mesh_intern.hh"

Go to the source code of this file.

Classes

struct  blender::NearestVertUserData_Hit
struct  blender::NearestVertUserData
struct  blender::NearestEdgeUserData_ZBuf
struct  blender::NearestEdgeUserData_Hit
struct  blender::NearestEdgeUserData
struct  blender::NearestFaceUserData_ZBuf
struct  blender::NearestFaceUserData_Hit
struct  blender::NearestFaceUserData
struct  blender::DelimitData

Namespaces

namespace  blender
 BMesh Iterators.

Macros

#define BMO_ELE_TAG   1
#define USE_DELAY_FACE_GROUP_COST_CALC

Functions

Generic Poll Functions
static bool blender::edbm_vert_or_edge_select_mode_poll (bContext *C)
Select Mirror
void blender::EDBM_select_mirrored (BMEditMesh *em, Mesh *mesh, int axis, bool extend, int *r_totmirr, int *r_totfail)
static bool UNUSED_FUNCTION blender::EDBM_select_mirrored_extend_all (Object *obedit, BMEditMesh *em)
Back-Buffer OpenGL Selection
static BMElem * blender::edbm_select_id_bm_elem_get (const Span< Base * > bases, const uint sel_id, uint &r_base_index)
Alternate Find Nearest Vert/Edge (optional boundary)
Note
This uses ray-cast method instead of back-buffer, currently used for poly-build.
bool blender::EDBM_unified_findnearest_from_raycast (ViewContext *vc, const Span< Base * > bases, bool use_boundary_vertices, bool use_boundary_edges, int *r_base_index_vert, int *r_base_index_edge, int *r_base_index_face, BMVert **r_eve, BMEdge **r_eed, BMFace **r_efa)
Select Similar Region Operator
static wmOperatorStatus blender::edbm_select_similar_region_exec (bContext *C, wmOperator *op)
void blender::MESH_OT_select_similar_region (wmOperatorType *ot)
Select Mode Vert/Edge/Face Operator
static wmOperatorStatus blender::edbm_select_mode_exec (bContext *C, wmOperator *op)
static wmOperatorStatus blender::edbm_select_mode_invoke (bContext *C, wmOperator *op, const wmEvent *event)
static std::string blender::edbm_select_mode_get_description (bContext *, wmOperatorType *, PointerRNA *ptr)
void blender::MESH_OT_select_mode (wmOperatorType *ot)
Select Loop (Non Modal) Operator
static void blender::walker_select_count (BMesh *bm, int walkercode, void *start, int r_count_by_select[2], BMWFlag flags, BMWDelimitFlag delimit)
static bool blender::walker_select (BMesh *bm, int walkercode, void *start, const bool select, BMWFlag flags, BMWDelimitFlag delimit, FunctionRef< void(BMElem *)> foreach_elem_fn)
static wmOperatorStatus blender::edbm_edge_loop_multiselect_exec (bContext *C, wmOperator *op)
static wmOperatorStatus blender::edbm_edge_ring_multiselect_exec (bContext *C, wmOperator *op)
static wmOperatorStatus blender::edbm_boundary_loop_multiselect_exec (bContext *C, wmOperator *op)
void blender::MESH_OT_select_edge_loop_multi (wmOperatorType *ot)
void blender::MESH_OT_select_edge_ring_multi (wmOperatorType *ot)
void blender::MESH_OT_select_boundary_loop_multi (wmOperatorType *ot)
Select Loop & Ring (Cursor Pick) Utilities
static void blender::mouse_mesh_loop_face (BMesh *bm, BMEdge *eed, bool select, bool select_clear, BMWDelimitFlag delimit)
static void blender::mouse_mesh_loop_edge_ring (BMesh *bm, BMEdge *eed, bool select, bool select_clear, BMWDelimitFlag delimit)
static void blender::mouse_mesh_loop_edge (BMesh *bm, BMEdge *eed, bool select, bool select_clear, bool select_cycle, BMWDelimitFlag delimit)
static void blender::edbm_select_loop_or_ring_by_edge (BMEditMesh *em, Object *obedit, BMEdge *eed, bool select, bool select_clear, bool select_cycle, bool ring, BMWDelimitFlag delimit)
static bool blender::edbm_select_loop_or_ring_pick (bContext *C, const int mval[2], Object **r_obedit, BMEdge **r_eed)
Select Loop & Ring (Cursor Pick) Shared Operator Helpers
static void blender::edbm_select_loop_or_ring_properties (wmOperatorType *ot)
static wmOperatorStatus blender::edbm_select_loop_or_ring_exec_impl (bContext *C, wmOperator *op, bool ring, BMWDelimitFlag delimit)
static wmOperatorStatus blender::edbm_select_loop_or_ring_invoke_impl (bContext *C, wmOperator *op, const wmEvent *event)
Select Loop & Ring (Cursor Pick) Operators
static wmOperatorStatus blender::edbm_select_loop_exec (bContext *C, wmOperator *op)
static wmOperatorStatus blender::edbm_select_loop_invoke (bContext *C, wmOperator *op, const wmEvent *event)
static wmOperatorStatus blender::edbm_select_ring_exec (bContext *C, wmOperator *op)
static wmOperatorStatus blender::edbm_select_ring_invoke (bContext *C, wmOperator *op, const wmEvent *event)
static bool blender::edbm_select_loop_poll_property (const bContext *C, wmOperator *, const PropertyRNA *prop)
static bool blender::edbm_select_ring_poll_property (const bContext *C, wmOperator *, const PropertyRNA *prop)
void blender::MESH_OT_loop_select (wmOperatorType *ot)
void blender::MESH_OT_edgering_select (wmOperatorType *ot)
(De)Select All Operator
static wmOperatorStatus blender::edbm_select_all_exec (bContext *C, wmOperator *op)
void blender::MESH_OT_select_all (wmOperatorType *ot)
Select Interior Faces Operator
static wmOperatorStatus blender::edbm_faces_select_interior_exec (bContext *C, wmOperator *)
void blender::MESH_OT_select_interior_faces (wmOperatorType *ot)
Select Picking API

Here actual select happens, Gets called via generic mouse select operator.

bool blender::EDBM_select_pick (bContext *C, const int mval[2], const SelectPick_Params &params)
Select Mode Utilities
static void blender::edbm_strip_selections (BMesh *bm, const short selectmode)
void blender::EDBM_selectmode_set (BMEditMesh *em, BMesh *bm, short selectmode)
void blender::EDBM_selectmode_convert (BMesh *bm, short selectmode_old, short selectmode_new)
bool blender::EDBM_selectmode_toggle_multi (bContext *C, short selectmode_toggle, int action, bool use_extend, bool use_expand)
bool blender::EDBM_selectmode_set_multi_ex (Scene *scene, Span< Object * > objects, const short selectmode)
bool blender::EDBM_selectmode_set_multi (bContext *C, short selectmode)
static bool blender::edbm_selectmode_sync_multi_ex (Span< Object * > objects)
bool blender::EDBM_selectmode_disable (Scene *scene, BMEditMesh *em, BMesh *bm, short selectmode_disable, short selectmode_fallback)
Select Toggle
bool blender::EDBM_deselect_by_material (BMesh *bm, short index, bool select)
void blender::EDBM_select_toggle_all (BMesh *bm)
void blender::EDBM_select_swap (BMEditMesh *em, BMesh *bm)
bool blender::EDBM_mesh_deselect_all_multi_ex (const Span< Base * > bases)
bool blender::EDBM_mesh_deselect_all_multi (bContext *C)
bool blender::EDBM_selectmode_disable_multi_ex (Scene *scene, const Span< Base * > bases, const short selectmode_disable, const short selectmode_fallback)
bool blender::EDBM_selectmode_disable_multi (bContext *C, short selectmode_disable, short selectmode_fallback)
Select Interior Faces

Overview of the algorithm:

  • Groups faces surrounded by edges with 3+ faces using them.
  • Calculates a cost of each face group comparing its angle with the faces connected to its non-manifold edges.
  • Mark the face group as interior, and mark connected face groups for recalculation.
  • Continue to remove the face groups with the highest 'cost'.
static bool blender::bm_interior_loop_filter_fn (const BMLoop *l, void *)
static bool blender::bm_interior_edge_is_manifold_except_face_index (BMEdge *e, int face_index, BMLoop *r_l_pair[2])
static float blender::bm_interior_face_group_calc_cost (ListBaseT< BMFaceLink > *ls, const float *edge_lengths)
bool blender::EDBM_select_interior_faces (BMesh *bm)
Select Linked (Cursor Pick) Operator
static wmOperatorStatus blender::edbm_select_linked_pick_exec (bContext *C, wmOperator *op)
static void blender::edbm_select_linked_pick_ex (BMesh *bm, const short selectmode, BMElem *ele, bool sel, int delimit)
static wmOperatorStatus blender::edbm_select_linked_pick_invoke (bContext *C, wmOperator *op, const wmEvent *event)
void blender::MESH_OT_select_linked_pick (wmOperatorType *ot)
Select by Pole Count Operator
static wmOperatorStatus blender::edbm_select_by_pole_count_exec (bContext *C, wmOperator *op)
void blender::MESH_OT_select_by_pole_count (wmOperatorType *ot)
Select Face by Sides Operator
static wmOperatorStatus blender::edbm_select_face_by_sides_exec (bContext *C, wmOperator *op)
void blender::MESH_OT_select_face_by_sides (wmOperatorType *ot)
Select Loose Operator
static wmOperatorStatus blender::edbm_select_loose_exec (bContext *C, wmOperator *op)
void blender::MESH_OT_select_loose (wmOperatorType *ot)
Select Mirror Operator
static wmOperatorStatus blender::edbm_select_mirror_exec (bContext *C, wmOperator *op)
void blender::MESH_OT_select_mirror (wmOperatorType *ot)
Select More Operator
static wmOperatorStatus blender::edbm_select_more_exec (bContext *C, wmOperator *op)
void blender::MESH_OT_select_more (wmOperatorType *ot)
static wmOperatorStatus blender::edbm_select_less_exec (bContext *C, wmOperator *op)
void blender::MESH_OT_select_less (wmOperatorType *ot)
Select N'th Operator
static bool blender::bm_edge_is_select_isolated (BMEdge *e)
static BMEdge * blender::bm_step_over_vert_to_next_selected_edge_in_chain (const BMEdge *e_curr, BMVert *v)
static BMVert * blender::bm_step_to_next_selected_vert_in_chain (BMVert *v_curr, BMVert *v_prev)
static BMFace * blender::bm_step_over_shared_edge_to_next_selected_face_in_chain (BMFace *f_curr, BMFace *f_prev)
static bool blender::bm_verts_form_cyclic_chain (BMVert *v_start)
static bool blender::bm_edges_form_cyclic_chain (BMEdge *e_start)
static bool blender::bm_faces_form_cyclic_chain (BMFace *f_start)
static void blender::walker_deselect_nth_vertex_chain (BMesh *bm, const CheckerIntervalParams *op_params, BMVert *v_start)
static void blender::walker_deselect_nth_edge_chain (BMesh *bm, const CheckerIntervalParams *op_params, BMEdge *e_start)
static void blender::walker_deselect_nth_face_chain (BMesh *bm, const CheckerIntervalParams *op_params, BMFace *f_start)
static void blender::walker_deselect_nth (BMesh *bm, const CheckerIntervalParams *op_params, BMHeader *h_act)
static void blender::deselect_nth_active (BMesh *bm, const short selectmode, BMVert **r_eve, BMEdge **r_eed, BMFace **r_efa)
static bool blender::edbm_deselect_nth (BMesh *bm, const short selectmode, const CheckerIntervalParams *op_params)
static wmOperatorStatus blender::edbm_select_nth_exec (bContext *C, wmOperator *op)
void blender::MESH_OT_select_nth (wmOperatorType *ot)
ViewContext blender::em_setup_viewcontext (bContext *C)
Select Sharp Edges Operator
static wmOperatorStatus blender::edbm_select_sharp_edges_exec (bContext *C, wmOperator *op)
void blender::MESH_OT_edges_select_sharp (wmOperatorType *ot)
Select Linked Flat Faces Operator
static wmOperatorStatus blender::edbm_select_linked_flat_faces_exec (bContext *C, wmOperator *op)
void blender::MESH_OT_faces_select_linked_flat (wmOperatorType *ot)
Select Non-Manifold Operator
static wmOperatorStatus blender::edbm_select_non_manifold_exec (bContext *C, wmOperator *op)
void blender::MESH_OT_select_non_manifold (wmOperatorType *ot)
Select Random Operator
static wmOperatorStatus blender::edbm_select_random_exec (bContext *C, wmOperator *op)
void blender::MESH_OT_select_random (wmOperatorType *ot)
Select Ungrouped Operator
static bool blender::edbm_select_ungrouped_poll (bContext *C)
static wmOperatorStatus blender::edbm_select_ungrouped_exec (bContext *C, wmOperator *op)
void blender::MESH_OT_select_ungrouped (wmOperatorType *ot)
Select Region to Loop Operator
static wmOperatorStatus blender::edbm_region_to_loop_exec (bContext *C, wmOperator *)
void blender::MESH_OT_region_to_loop (wmOperatorType *ot)
Select Loop to Region Operator
static int blender::loop_find_region (BMLoop *l, int flag, Set< BMFace * > &visit_face_set, BMFace ***region_out)
static int blender::verg_radial (const void *va, const void *vb)
static int blender::loop_find_regions (BMesh *bm, const bool selbigger)
static wmOperatorStatus blender::edbm_loop_to_region_exec (bContext *C, wmOperator *op)
void blender::MESH_OT_loop_to_region (wmOperatorType *ot)
static bool blender::edbm_select_by_attribute_poll (bContext *C)
static std::optional< BMIterType > blender::domain_to_iter_type (const bke::AttrDomain domain)
static wmOperatorStatus blender::edbm_select_by_attribute_exec (bContext *C, wmOperator *)
void blender::MESH_OT_select_by_attribute (wmOperatorType *ot)

Find Nearest Vert/Edge/Face

Note
Screen-space manhattan distances are used here, since its faster and good enough for the purpose of selection.
dist_bias is used so we can bias against selected items. when choosing between elements of a single type, but return the real distance to avoid the bias interfering with distance comparisons when mixing types.
#define FIND_NEAR_SELECT_BIAS   5
#define FIND_NEAR_CYCLE_THRESHOLD_MIN   3
static void blender::findnearestvert__doClosest (void *user_data, BMVert *eve, const float screen_co[2], int index)
BMVert * blender::EDBM_vert_find_nearest_ex (ViewContext *vc, float *dist_px_manhattan_p, const bool use_select_bias, bool use_cycle, const Span< Base * > bases, uint *r_base_index)
BMVert * blender::EDBM_vert_find_nearest (ViewContext *vc, float *dist_px_manhattan_p)
static void blender::find_nearest_edge_center__doZBuf (void *user_data, BMEdge *eed, const float screen_co_a[2], const float screen_co_b[2], int)
static void blender::find_nearest_edge__doClosest (void *user_data, BMEdge *eed, const float screen_co_a[2], const float screen_co_b[2], int index)
BMEdge * blender::EDBM_edge_find_nearest_ex (ViewContext *vc, float *dist_px_manhattan_p, float *r_dist_center_px_manhattan, const bool use_select_bias, bool use_cycle, BMEdge **r_eed_zbuf, const Span< Base * > bases, uint *r_base_index)
BMEdge * blender::EDBM_edge_find_nearest (ViewContext *vc, float *dist_px_manhattan_p)
static void blender::find_nearest_face_center__doZBuf (void *user_data, BMFace *efa, const float screen_co[2], int)
static void blender::findnearestface__doClosest (void *user_data, BMFace *efa, const float screen_co[2], int index)
BMFace * blender::EDBM_face_find_nearest_ex (ViewContext *vc, float *dist_px_manhattan_p, float *r_dist_center, const bool use_zbuf_single_px, const bool use_select_bias, bool use_cycle, BMFace **r_efa_zbuf, const Span< Base * > bases, uint *r_base_index)
BMFace * blender::EDBM_face_find_nearest (ViewContext *vc, float *dist_px_manhattan_p)
static bool blender::unified_findnearest (ViewContext *vc, const Span< Base * > bases, int *r_base_index, BMVert **r_eve, BMEdge **r_eed, BMFace **r_efa)
bool blender::EDBM_unified_findnearest (ViewContext *vc, const Span< Base * > bases, int *r_base_index, BMVert **r_eve, BMEdge **r_eed, BMFace **r_efa)

Select Linked Operator

#define USE_LINKED_SELECT_DEFAULT_HACK
static bool blender::select_linked_delimit_test (BMEdge *e, int delimit, const DelimitData *delimit_data)
static int blender::select_linked_delimit_default_from_op (wmOperator *op, const int select_mode)
static void blender::select_linked_delimit_validate (BMesh *bm, int *delimit)
static void blender::select_linked_delimit_begin (BMesh *bm, int delimit)
static void blender::select_linked_delimit_end (BMesh *bm)
static wmOperatorStatus blender::edbm_select_linked_exec (bContext *C, wmOperator *op)
void blender::MESH_OT_select_linked (wmOperatorType *ot)

Common functions to count elements

enum  blender::eElemCountType { blender::ELEM_COUNT_LESS = 0 , blender::ELEM_COUNT_EQUAL , blender::ELEM_COUNT_GREATER , blender::ELEM_COUNT_NOT_EQUAL }
static const EnumPropertyItem blender::elem_count_compare_items []
static bool blender::is_count_a_match (const eElemCountType type, const int value_test, const int value_reference)

Select Axis Operator

enum  { blender::SELECT_AXIS_POS = 0 , blender::SELECT_AXIS_NEG = 1 , blender::SELECT_AXIS_ALIGN = 2 }
static wmOperatorStatus blender::edbm_select_axis_exec (bContext *C, wmOperator *op)
void blender::MESH_OT_select_axis (wmOperatorType *ot)

Macro Definition Documentation

◆ BMO_ELE_TAG

#define BMO_ELE_TAG   1

use #BMesh operator flags for a few operators.

Definition at line 72 of file editmesh_select.cc.

◆ FIND_NEAR_CYCLE_THRESHOLD_MIN

#define FIND_NEAR_CYCLE_THRESHOLD_MIN   3

◆ FIND_NEAR_SELECT_BIAS

#define FIND_NEAR_SELECT_BIAS   5

◆ USE_DELAY_FACE_GROUP_COST_CALC

#define USE_DELAY_FACE_GROUP_COST_CALC

◆ USE_LINKED_SELECT_DEFAULT_HACK

#define USE_LINKED_SELECT_DEFAULT_HACK

So we can have last-used default depend on selection mode (rare exception!).

Definition at line 3989 of file editmesh_select.cc.