Blender  V3.3
Classes | Macros | Functions
editmesh_intersect.c File Reference
#include "MEM_guardedalloc.h"
#include "DNA_object_types.h"
#include "BLI_buffer.h"
#include "BLI_linklist_stack.h"
#include "BLI_math.h"
#include "BLI_memarena.h"
#include "BLI_stack.h"
#include "BKE_context.h"
#include "BKE_editmesh.h"
#include "BKE_editmesh_bvh.h"
#include "BKE_layer.h"
#include "BKE_report.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "WM_types.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "ED_mesh.h"
#include "ED_screen.h"
#include "intern/bmesh_private.h"
#include "mesh_intern.h"
#include "tools/bmesh_boolean.h"
#include "tools/bmesh_intersect.h"
#include "tools/bmesh_separate.h"

Go to the source code of this file.

Classes

struct  LinkBase
 

Macros

#define USE_NET_ISLAND_CONNECT
 

Functions

static int bm_face_isect_self (BMFace *f, void *UNUSED(user_data))
 
static int bm_face_isect_pair (BMFace *f, void *UNUSED(user_data))
 
static int bm_face_isect_pair_swap (BMFace *f, void *UNUSED(user_data))
 
static void edbm_intersect_select (BMEditMesh *em, struct Mesh *me, bool do_select)
 
Boolean Intersect
Note
internally this is nearly exactly the same as 'MESH_OT_intersect', however from a user perspective they are quite different, so expose as different tools.
static int edbm_intersect_boolean_exec (bContext *C, wmOperator *op)
 
static void edbm_intersect_boolean_ui (bContext *UNUSED(C), wmOperator *op)
 
void MESH_OT_intersect_boolean (struct wmOperatorType *ot)
 
Face Split by Edges
static void bm_face_split_by_edges (BMesh *bm, BMFace *f, const char hflag, BLI_Buffer *edge_net_temp_buf)
 
static bool bm_vert_in_faces_radial (BMVert *v, BMEdge *e_radial, BMFace *f_ignore)
 
static void ghash_insert_face_edge_link (GHash *gh, BMFace *f_key, BMEdge *e_val, MemArena *mem_arena)
 
static int bm_edge_sort_length_cb (const void *e_a_v, const void *e_b_v)
 
static void bm_face_split_by_edges_island_connect (BMesh *bm, BMFace *f, LinkNode *e_link, const int e_link_len, MemArena *mem_arena_edgenet)
 
static BMEdgebm_face_split_edge_find (BMEdge *e_a, BMFace *f_a, BMVert *v_pivot, BMFace **ftable, const int ftable_len, float r_v_pivot_co[3], float *r_v_pivot_fac)
 
static int edbm_face_split_by_edges_exec (bContext *C, wmOperator *UNUSED(op))
 
void MESH_OT_face_split_by_edges (struct wmOperatorType *ot)
 

Simple Intersect (self-intersect)

Cut intersections into geometry.

enum  { ISECT_SEL = 0 , ISECT_SEL_UNSEL = 1 }
 
enum  { ISECT_SEPARATE_ALL = 0 , ISECT_SEPARATE_CUT = 1 , ISECT_SEPARATE_NONE = 2 }
 
enum  { ISECT_SOLVER_FAST = 0 , ISECT_SOLVER_EXACT = 1 }
 
static int edbm_intersect_exec (bContext *C, wmOperator *op)
 
static void edbm_intersect_ui (bContext *UNUSED(C), wmOperator *op)
 
void MESH_OT_intersect (struct wmOperatorType *ot)
 

Macro Definition Documentation

◆ USE_NET_ISLAND_CONNECT

#define USE_NET_ISLAND_CONNECT

Definition at line 43 of file editmesh_intersect.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
ISECT_SEL 
ISECT_SEL_UNSEL 

Definition at line 120 of file editmesh_intersect.c.

◆ anonymous enum

anonymous enum
Enumerator
ISECT_SEPARATE_ALL 
ISECT_SEPARATE_CUT 
ISECT_SEPARATE_NONE 

Definition at line 125 of file editmesh_intersect.c.

◆ anonymous enum

anonymous enum
Enumerator
ISECT_SOLVER_FAST 
ISECT_SOLVER_EXACT 

Definition at line 131 of file editmesh_intersect.c.

Function Documentation

◆ bm_edge_sort_length_cb()

static int bm_edge_sort_length_cb ( const void e_a_v,
const void e_b_v 
)
static

◆ bm_face_isect_pair()

static int bm_face_isect_pair ( BMFace f,
void UNUSEDuser_data 
)
static

Compare selected/unselected.

Definition at line 59 of file editmesh_intersect.c.

References BM_elem_flag_test, BM_ELEM_HIDDEN, and BM_ELEM_SELECT.

Referenced by edbm_intersect_boolean_exec(), and edbm_intersect_exec().

◆ bm_face_isect_pair_swap()

static int bm_face_isect_pair_swap ( BMFace f,
void UNUSEDuser_data 
)
static

A flipped version of bm_face_isect_pair use for boolean 'difference', which depends on order.

Definition at line 74 of file editmesh_intersect.c.

References BM_elem_flag_test, BM_ELEM_HIDDEN, and BM_ELEM_SELECT.

Referenced by edbm_intersect_boolean_exec().

◆ bm_face_isect_self()

static int bm_face_isect_self ( BMFace f,
void UNUSEDuser_data 
)
static

Compare selected with itself.

Definition at line 48 of file editmesh_intersect.c.

References BM_elem_flag_test, and BM_ELEM_SELECT.

Referenced by edbm_intersect_exec().

◆ bm_face_split_by_edges()

static void bm_face_split_by_edges ( BMesh bm,
BMFace f,
const char  hflag,
BLI_Buffer edge_net_temp_buf 
)
static

◆ bm_face_split_by_edges_island_connect()

static void bm_face_split_by_edges_island_connect ( BMesh bm,
BMFace f,
LinkNode e_link,
const int  e_link_len,
MemArena mem_arena_edgenet 
)
static

◆ bm_face_split_edge_find()

static BMEdge* bm_face_split_edge_find ( BMEdge e_a,
BMFace f_a,
BMVert v_pivot,
BMFace **  ftable,
const int  ftable_len,
float  r_v_pivot_co[3],
float r_v_pivot_fac 
)
static

Check if v_pivot should be spliced into an existing edge.

Detect one of 3 cases:

  • v_pivot is shared by 2+ edges from different faces. in this case return the closest edge shared by all faces.
  • v_pivot is an end-point of an edge which has no other edges connected. in this case return the closest edge in f_a to the v_pivot.
  • v_pivot has only edges from the same face connected, in this case return NULL. This is the most common case - no action is needed.
Returns
the edge to be split.
Note
Currently we don't snap to verts or split chains by verts on-edges.

Definition at line 704 of file editmesh_intersect.c.

References BLI_assert, BLI_SMALLSTACK_DECLARE, BLI_SMALLSTACK_POP, BLI_SMALLSTACK_PUSH, BM_DISK_EDGE_NEXT, BM_edge_exists(), BM_elem_flag_disable, BM_elem_flag_enable, BM_elem_flag_test, BM_elem_index_get, BM_ELEM_INTERNAL_TAG, BM_FACE_FIRST_LOOP, CLAMP, BMVert::co, copy_v3_v3(), BMVert::e, BMLoop::e, BMLoop::f, interp_v3_v3v3(), len_squared_v3v3(), line_point_factor_v3(), BMLoop::next, NULL, BMLoop::radial_next, UNLIKELY, UNUSED_VARS_NDEBUG, BMEdge::v1, and BMEdge::v2.

Referenced by edbm_face_split_by_edges_exec().

◆ bm_vert_in_faces_radial()

static bool bm_vert_in_faces_radial ( BMVert v,
BMEdge e_radial,
BMFace f_ignore 
)
static

Check if a vert is in any of the faces connected to the edge, f_ignore is a face we happen to know isn't shared by the vertex.

Definition at line 573 of file editmesh_intersect.c.

References BLI_assert, BM_vert_in_face(), BMLoop::f, BMEdge::l, BMLoop::radial_next, and v.

Referenced by edbm_face_split_by_edges_exec().

◆ edbm_face_split_by_edges_exec()

static int edbm_face_split_by_edges_exec ( bContext C,
wmOperator UNUSEDop 
)
static

Definition at line 809 of file editmesh_intersect.c.

References angle_signed_on_axis_v3v3v3_v3(), BKE_bmbvh_find_face_closest(), BKE_bmbvh_free(), BKE_bmbvh_new(), BKE_editmesh_from_object(), BKE_view_layer_array_from_objects_in_edit_mode_unique_data, BLI_assert, BLI_buffer_declare_static, BLI_buffer_free, BLI_ghash_free(), BLI_ghash_ptr_new(), BLI_ghashIterator_getKey(), BLI_ghashIterator_getValue(), BLI_memarena_clear(), BLI_memarena_free(), BLI_memarena_new(), BLI_MEMARENA_STD_BUFSIZE, BLI_SMALLSTACK_DECLARE, BLI_SMALLSTACK_IS_EMPTY, BLI_SMALLSTACK_POP, BLI_SMALLSTACK_PUSH, BLI_stack_free(), BLI_stack_is_empty(), BLI_stack_new, BLI_stack_pop(), BLI_stack_push(), BMEditMesh::bm, bm, BM_EDGE, BM_edge_is_wire(), BM_edge_other_vert(), BM_edge_split(), BM_EDGES_OF_MESH, BM_elem_flag_disable, BM_elem_flag_enable, BM_elem_flag_test, BM_elem_index_get, BM_elem_index_set, BM_ELEM_INTERNAL_TAG, BM_ELEM_SELECT, BM_ELEM_TAG, BM_FACE, bm_face_split_by_edges(), bm_face_split_by_edges_island_connect(), bm_face_split_edge_find(), BM_FACES_OF_MESH, BM_ITER_ELEM, BM_ITER_MESH, BM_ITER_MESH_INDEX, BM_LOOPS_OF_VERT, BM_mesh_elem_index_ensure(), BM_mesh_elem_table_ensure(), BM_vert_in_face(), bm_vert_in_faces_radial(), BM_vert_splice(), BM_VERTS_OF_EDGE, BM_VERTS_OF_MESH, BMBVH_RESPECT_SELECT, C, BMVert::co, CTX_data_view_layer(), CTX_wm_view3d(), Object::data, dot_v3v3(), e, EDBM_update(), BMesh::elem_index_dirty, BMLoop::f, fabsf, BMesh::ftable, ghash_insert_face_edge_link(), GHASH_ITER, l, LinkNode::link, LinkBase::list, LinkBase::list_len, BMEditMesh::looptris, mem_arena, MEM_freeN, mid_v3_v3v3(), LinkNode::next, BMLoop::next, BMFace::no, normalize_v3(), NULL, OPERATOR_FINISHED, BMLoop::prev, sub_v3_v3v3(), BMesh::totedgesel, BMesh::totface, BMesh::totfacesel, BMEditMesh::tottri, BMLoop::v, v, and BMEdge::v1.

Referenced by MESH_OT_face_split_by_edges().

◆ edbm_intersect_boolean_exec()

static int edbm_intersect_boolean_exec ( bContext C,
wmOperator op 
)
static

◆ edbm_intersect_boolean_ui()

static void edbm_intersect_boolean_ui ( bContext UNUSEDC,
wmOperator op 
)
static

◆ edbm_intersect_exec()

static int edbm_intersect_exec ( bContext C,
wmOperator op 
)
static

◆ edbm_intersect_select()

static void edbm_intersect_select ( BMEditMesh em,
struct Mesh me,
bool  do_select 
)
static

◆ edbm_intersect_ui()

static void edbm_intersect_ui ( bContext UNUSEDC,
wmOperator op 
)
static

◆ ghash_insert_face_edge_link()

static void ghash_insert_face_edge_link ( GHash gh,
BMFace f_key,
BMEdge e_val,
MemArena mem_arena 
)
static

◆ MESH_OT_face_split_by_edges()

void MESH_OT_face_split_by_edges ( struct wmOperatorType ot)

◆ MESH_OT_intersect()

void MESH_OT_intersect ( struct wmOperatorType ot)

◆ MESH_OT_intersect_boolean()

void MESH_OT_intersect_boolean ( struct wmOperatorType ot)