128 int verts_len, edges_len, loops_len, faces_len;
139 bool changed =
false;
140 bool changed_was_set =
false;
147 changed_was_set =
true;
152 changed_was_set =
true;
158 changed_was_set =
true;
168 if (changed_was_set ==
false) {
173 if (changed ==
false) {
175 (em_state_prev.edges_len == em->
bm->
totedge) &&
176 (em_state_prev.loops_len == em->
bm->
totloop) &&
177 (em_state_prev.faces_len == em->
bm->
totface));
206 const char *select_slot_out,
207 const bool select_extend,
231 if (select_extend ==
false) {
278 .use_toolflags =
true,
313 .calc_object_remap =
true,
314 .update_shapekey_indices = !free_data,
398 "region_extend geom=%hvef use_contract=%b use_faces=%b use_face_step=%b",
420 "region_extend geom=%hvef use_contract=%b use_faces=%b use_face_step=%b",
464 int totverts, i, totuv, totfaces;
466 bool *winding =
NULL;
493 winding =
MEM_callocN(
sizeof(*winding) * totfaces,
"winding");
496 if (!vmap->
vert || !vmap->
buf) {
534 const float *uv, *uv2;
559 (!use_winding || winding[iterv->
poly_index] == winding[
v->poly_index])) {
566 iterv->
next = newvlist;
579 vmap->
vert[
a] = newvlist;
593 return vmap->
vert[
v];
596 #define INVALID_ISLAND ((unsigned int)-1)
609 islandbuf[islandbufsize].
l =
element->l;
621 int cd_loop_uv_offset)
627 for (
int i = 0; i < totuv; i++) {
632 head_table[
element - element_map->
buf] = head;
643 int islandbufsize = 0;
644 int stack_upper_bound = totuv;
646 "uv_island_element_stack");
647 int stacksize_uv = 0;
648 for (
int i = 0; i < totuv; i++) {
660 stack_uv[stacksize_uv++] =
element;
670 while (stacksize_uv) {
672 element = stack_uv[--stacksize_uv];
680 stack_uv[stacksize_uv++] = tail;
696 stack_uv[stacksize_uv++] = tail;
726 const bool uv_selected,
727 const bool use_winding,
728 const bool do_islands)
740 bool *winding =
NULL;
744 int totverts, totfaces, i, totuv, j;
788 winding =
MEM_callocN(
sizeof(*winding) * totfaces,
"winding");
837 const float *uv, *uv2;
838 bool uv_vert_sel, uv2_vert_sel;
864 const bool connected = (uv_vert_sel == uv2_vert_sel) &&
875 iterv->
next = newvlist;
888 element_map->
vert[i] = newvlist;
901 int *island_number =
NULL;
903 int nislands = 0, islandbufsize = 0;
908 islandbuf =
MEM_callocN(
sizeof(*islandbuf) * totuv,
"uvelement_island_buffer");
909 island_number =
MEM_mallocN(
sizeof(*island_number) * totfaces,
"uv_island_number_face");
915 if (use_uv_edge_connectivity) {
917 element_map,
scene, islandbuf,
map, uv_selected, cd_loop_uv_offset);
918 islandbufsize = totuv;
923 for (i = 0; i < totuv; i++) {
926 stack[0] = element_map->
buf[i].
l->
f;
930 while (stacksize > 0) {
931 efa = stack[--stacksize];
949 element_map,
element, nislands,
map, islandbuf, islandbufsize++);
957 stack[stacksize++] =
element->l->f;
976 if (element_map->
vert[i]) {
977 element_map->
vert[i] = &islandbuf[
map[element_map->
vert[i] - element_map->
buf]];
982 "UvElementMap_island_indices");
984 for (i = 0; i < totuv; i++) {
993 if (islandbuf[i].island != j) {
1001 element_map->
buf = islandbuf;
1028 if (element_map->
vert) {
1031 if (element_map->
buf) {
1095 intptr_t eve_i = index_lookup[index];
1096 return (eve_i == -1) ?
NULL : (
BMVert *)eve_i;
1116 #define BM_SEARCH_MAXDIST_MIRR 0.00002f
1117 #define BM_CD_LAYER_ID "__mirror_index"
1121 const bool use_self,
1122 const bool use_select,
1123 const bool respecthide,
1125 const bool use_topology,
1132 int cd_vmirr_offset = 0;
1134 const float maxdist_sq =
square_f(maxdist);
1142 if (r_index ==
NULL) {
1170 BLI_kdtree_3d_insert(
tree, i,
v->
co);
1172 BLI_kdtree_3d_balance(
tree);
1175 #define VERT_INTPTR(_v, _i) (r_index ? &r_index[_i] : BM_ELEM_CD_GET_VOID_P(_v, cd_vmirr_offset))
1192 if (v_mirr !=
NULL) {
1205 i_mirr = BLI_kdtree_3d_find_nearest(
tree, co,
NULL);
1214 if (v_mirr && (use_self || (v_mirr !=
v))) {
1231 BLI_kdtree_3d_free(
tree);
1237 const bool use_self,
1238 const bool use_select,
1239 const bool respecthide,
1240 const bool use_topology)
1259 if (mirr && *mirr >= 0 && *mirr < em->
bm->
totvert) {
1262 "err: should only be called between "
1263 "EDBM_verts_mirror_cache_begin and EDBM_verts_mirror_cache_end");
1275 BMVert *v1_mirr, *v2_mirr;
1279 LIKELY(v1_mirr != v2_mirr)) {
1290 BMLoop *l_iter, *l_first;
1298 }
while ((l_iter = l_iter->
next) != l_first);
1332 mirr->
co[0] *= -1.0f;
1351 bool changed =
true;
1389 const char iter_types[3] = {
1395 const bool sels[3] = {
1401 bool changed =
false;
1405 for (i = 0; i < 3; i++) {
1428 for (i = 0; i < 3; i++) {
1466 .face_normals =
true,
1472 const char iter_types[3] = {
1489 for (i = 0; i < 3; i++) {
1491 for (; ele; ele = BM_iter_step(&iter)) {
1511 if (
params->calc_normals) {
1515 if (
params->calc_looptri) {
1520 if (
params->is_destructive) {
1547 .calc_looptri = do_tessellation,
1548 .calc_normals =
false,
1549 .is_destructive = is_destructive,
1618 if (index < bm->totvert) {
1622 if (index < bm->totedge) {
1626 if (index < bm->totface) {
1636 int *r_object_index)
1639 int elem_index = -1;
1640 *r_object_index = -1;
1642 for (
uint base_index = 0; base_index < bases_len; base_index++) {
1643 Base *base_iter = bases[base_index];
1645 *r_object_index = base_index;
1662 Object *obedit = (object_index < bases_len) ? bases[object_index]->
object :
NULL;
1664 if (obedit !=
NULL) {
1708 float co1[3], co2[3], co3[3], dir1[3], dir2[3], dir3[3];
1709 float origin[3], invmat[4][4];
1712 const float mval_f[2] = {
1713 region->
winx / 2.0f,
1714 region->
winy / 2.0f,
1783 float mval[2], co_proj[3];
1795 .use_occlusion_test =
true,
typedef float(TangentPoint)[2]
struct Scene * CTX_data_scene(const bContext *C)
struct Object * CTX_data_edit_object(const bContext *C)
struct View3D * CTX_wm_view3d(const bContext *C)
CustomData interface, see also DNA_customdata_types.h.
bool CustomData_has_layer(const struct CustomData *data, int type)
int CustomData_get_named_layer_index(const struct CustomData *data, int type, const char *name)
int CustomData_get_layer_index(const struct CustomData *data, int type)
void * CustomData_bmesh_get_layer_n(const struct CustomData *data, void *block, int n)
int CustomData_get_n_offset(const struct CustomData *data, int type, int n)
int CustomData_get_offset(const struct CustomData *data, int type)
void BKE_editmesh_free_data(BMEditMesh *em)
void BKE_editmesh_looptri_calc(BMEditMesh *em)
void BKE_editmesh_looptri_and_normals_calc(BMEditMesh *em)
BMEditMesh * BKE_editmesh_create(BMesh *bm)
BMEditMesh * BKE_editmesh_from_object(struct Object *ob)
Return the BMEditMesh for a given object.
struct BMFace * BKE_bmbvh_ray_cast(BMBVHTree *tree, const float co[3], const float dir[3], float radius, float *r_dist, float r_hitout[3], float r_cagehit[3])
#define BKE_view_layer_array_from_bases_in_edit_mode(view_layer, v3d, r_len)
struct BMesh * BKE_mesh_to_bmesh(struct Mesh *me, struct Object *ob, bool add_key_index, const struct BMeshCreateParams *params)
void BKE_mesh_uv_vert_map_free(UvVertMap *vmap)
#define STD_UV_CONNECT_LIMIT
General operations, lookup, etc. for blender objects.
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
#define BLI_array_alloca(arr, realsize)
#define BLI_buffer_reinit_data(buffer_, type_, new_count_)
#define BLI_buffer_declare_static(type_, name_, flag_, static_count_)
#define BLI_buffer_free(name_)
A KD-tree for nearest neighbor search.
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
MINLINE float square_f(float a)
float cross_poly_v2(const float verts[][2], unsigned int nr)
bool invert_m4_m4(float R[4][4], const float A[4][4])
void mul_m4_v3(const float M[4][4], float r[3])
void mul_v3_m4v3(float r[3], const float M[4][4], const float v[3])
MINLINE float normalize_v3(float r[3])
MINLINE void sub_v3_v3(float r[3], const float a[3])
MINLINE float len_squared_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE bool compare_v2v2(const float a[2], const float b[2], float limit) ATTR_WARN_UNUSED_RESULT
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
void copy_vn_i(int *array_tar, int size, int val)
MINLINE float normalize_v3_length(float r[3], float unit_scale)
void mid_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void add_v3_v3(float r[3], const float a[3])
struct Depsgraph Depsgraph
void DEG_id_tag_update(struct ID *id, int flag)
Object is a sort of wrapper for general info.
@ SCE_SNAP_TARGET_NOT_ACTIVE
#define UV_SYNC_SELECTION
#define SCE_SELECT_VERTEX
@ SCE_SNAP_MODE_FACE_RAYCAST
void ED_mesh_mirror_topo_table_end(struct Object *ob)
void ED_mesh_mirrtopo_free(MirrTopoStore_t *mesh_topo_store)
void ED_mesh_mirror_spatial_table_end(struct Object *ob)
void ED_mesh_mirrtopo_init(struct BMEditMesh *em, struct Mesh *me, MirrTopoStore_t *mesh_topo_store, bool skip_em_vert_array_init)
bool ED_operator_view3d_active(struct bContext *C)
bool ED_operator_editmesh(struct bContext *C)
eSnapMode ED_transform_snap_object_project_view3d(struct SnapObjectContext *sctx, struct Depsgraph *depsgraph, const ARegion *region, const View3D *v3d, const eSnapMode snap_to, const struct SnapObjectParams *params, const float init_co[3], const float mval[2], const float prev_co[3], float *dist_px, float r_loc[3], float r_no[3])
SnapObjectContext * ED_transform_snap_object_context_create(struct Scene *scene, int flag)
void ED_transform_snap_object_context_destroy(SnapObjectContext *sctx)
bool uvedit_uv_select_test(const struct Scene *scene, struct BMLoop *l, int cd_loop_uv_offset)
bool uvedit_edge_select_test(const struct Scene *scene, struct BMLoop *l, int cd_loop_uv_offset)
bool ED_view3d_win_to_segment_clipped(const struct Depsgraph *depsgraph, const struct ARegion *region, const struct View3D *v3d, const float mval[2], float r_ray_start[3], float r_ray_end[3], bool do_clip_planes)
eV3DProjStatus ED_view3d_project_float_object(const struct ARegion *region, const float co[3], float r_co[2], eV3DProjTest flag)
void ED_view3d_init_mats_rv3d(const struct Object *ob, struct RegionView3D *rv3d)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
Read Guarded memory(de)allocation.
__forceinline const avxb select(const avxb &m, const avxb &t, const avxb &f)
#define BM_DEFAULT_NGON_STACK_SIZE
#define BM_FACE_FIRST_LOOP(p)
#define BM_ELEM_CD_GET_VOID_P(ele, offset)
BMesh * BM_mesh_copy(BMesh *bm_old)
bool BMO_error_pop(BMesh *bm, const char **r_msg, BMOperator **r_op, eBMOpErrorLevel *r_level)
#define BM_elem_index_get(ele)
#define BM_elem_flag_disable(ele, hflag)
#define BM_elem_flag_test(ele, hflag)
#define BM_elem_flag_enable(ele, hflag)
void BM_data_layer_add_named(BMesh *bm, CustomData *data, int type, const char *name)
void * BM_iter_at_index(BMesh *bm, const char itype, void *data, int index)
#define BM_ITER_ELEM(ele, iter, data, itype)
#define BM_ITER_MESH(ele, iter, bm, itype)
#define BM_ITER_MESH_INDEX(ele, iter, bm, itype, indexvar)
#define BM_ITER_ELEM_INDEX(ele, iter, data, itype, indexvar)
#define BM_iter_new(iter, bm, itype, data)
ATTR_WARN_UNUSED_RESULT BMesh * bm
void BM_mesh_elem_hflag_enable_all(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_select_flush(BMesh *bm)
void BM_mesh_select_mode_flush_ex(BMesh *bm, const short selectmode, eBMSelectionFlushFLags flags)
Select Mode Flush.
void BM_mesh_select_mode_clean(BMesh *bm)
void BM_mesh_deselect_flush(BMesh *bm)
void BM_mesh_elem_hflag_disable_all(BMesh *bm, const char htype, const char hflag, const bool respecthide)
BMFace * BM_mesh_active_face_get(BMesh *bm, const bool is_sloppy, const bool is_selected)
#define BM_elem_hide_set(bm, ele, hide)
@ BM_SELECT_LEN_FLUSH_RECALC_ALL
void BM_mesh_data_free(BMesh *bm)
BMesh Free Mesh Data.
void BM_mesh_clear(BMesh *bm)
BMesh Clear Mesh.
BMEdge * BM_edge_at_index_find_or_table(BMesh *bm, const int index)
BMFace * BM_face_at_index_find_or_table(BMesh *bm, const int index)
BMVert * BM_vert_at_index_find_or_table(BMesh *bm, const int index)
void BM_mesh_elem_table_ensure(BMesh *bm, const char htype)
void BM_mesh_elem_index_ensure(BMesh *bm, const char htype)
bool BM_mesh_elem_table_check(BMesh *bm)
BLI_INLINE BMFace * BM_face_at_index(BMesh *bm, const int index)
BLI_INLINE BMVert * BM_vert_at_index(BMesh *bm, const int index)
void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *me, const struct BMeshToMeshParams *params)
void BM_mesh_normals_update_ex(BMesh *bm, const struct BMeshNormalsUpdate_Params *params)
BMesh Compute Normals.
void BM_lnorspace_invalidate(BMesh *bm, const bool do_invalidate_all)
bool BMO_op_vinitf(BMesh *bm, BMOperator *op, int flag, const char *fmt, va_list vlist)
void BMO_slot_buffer_hflag_enable(BMesh *bm, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, char htype, char hflag, bool do_flush)
BMO_FLAG_BUFFER.
void BMO_slot_buffer_hflag_disable(BMesh *bm, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, char htype, char hflag, bool do_flush)
BMO_FLAG_BUFFER.
void BMO_op_exec(BMesh *bm, BMOperator *op)
BMESH OPSTACK EXEC OP.
bool BMO_op_initf(BMesh *bm, BMOperator *op, int flag, const char *fmt,...)
void BMO_op_finish(BMesh *bm, BMOperator *op)
BMESH OPSTACK FINISH OP.
BMOpSlot * BMO_slot_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identifier)
BMESH OPSTACK GET SLOT.
#define BMO_FLAG_DEFAULTS
ATTR_WARN_UNUSED_RESULT const void * element
BMEdge * BM_edge_exists(BMVert *v_a, BMVert *v_b)
bool BM_edge_in_face(const BMEdge *e, const BMFace *f)
BMFace * BM_face_exists(BMVert **varr, int len)
ATTR_WARN_UNUSED_RESULT const BMLoop * l
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
ATTR_WARN_UNUSED_RESULT const BMVert * v
const Depsgraph * depsgraph
bool EDBM_vert_color_check(BMEditMesh *em)
UvMapVert * BM_uv_vert_map_at_index(UvVertMap *vmap, uint v)
void EDBM_select_more(BMEditMesh *em, const bool use_face_step)
bool EDBM_op_callf(BMEditMesh *em, wmOperator *op, const char *fmt,...)
BMElem * EDBM_elem_from_selectmode(BMEditMesh *em, BMVert *eve, BMEdge *eed, BMFace *efa)
static void bm_uv_assign_island(UvElementMap *element_map, UvElement *element, int nisland, uint *map, UvElement *islandbuf, int islandbufsize)
BMVert * EDBM_verts_mirror_get(BMEditMesh *em, BMVert *v)
bool BMBVH_EdgeVisible(struct BMBVHTree *tree, BMEdge *e, struct Depsgraph *depsgraph, ARegion *region, View3D *v3d, Object *obedit)
void EDBM_flag_enable_all(BMEditMesh *em, const char hflag)
bool EDBM_op_init(BMEditMesh *em, BMOperator *bmop, wmOperator *op, const char *fmt,...)
bool EDBM_op_call_and_selectf(BMEditMesh *em, wmOperator *op, const char *select_slot_out, const bool select_extend, const char *fmt,...)
BMFace * EDBM_uv_active_face_get(BMEditMesh *em, const bool sloppy, const bool selected)
void EDBM_mesh_normals_update(BMEditMesh *em)
bool EDBM_mesh_reveal(BMEditMesh *em, bool select)
void EDBM_deselect_flush(BMEditMesh *em)
void EDBM_project_snap_verts(bContext *C, Depsgraph *depsgraph, ARegion *region, Object *obedit, BMEditMesh *em)
void EDBM_mesh_load_ex(Main *bmain, Object *ob, bool free_data)
UvVertMap * BM_uv_vert_map_create(BMesh *bm, const bool use_select, const bool use_winding)
static BMVert * cache_mirr_intptr_as_bmvert(const intptr_t *index_lookup, int index)
bool EDBM_op_finish(BMEditMesh *em, BMOperator *bmop, wmOperator *op, const bool do_report)
BMElem * EDBM_elem_from_index_any(BMEditMesh *em, uint index)
bool EDBM_uv_check(BMEditMesh *em)
void BM_uv_element_map_free(UvElementMap *element_map)
void EDBM_stats_update(BMEditMesh *em)
BMElem * EDBM_elem_from_index_any_multi(ViewLayer *view_layer, uint object_index, uint elem_index, Object **r_obedit)
bool EDBM_mesh_hide(BMEditMesh *em, bool swap)
void EDBM_verts_mirror_cache_begin_ex(BMEditMesh *em, const int axis, const bool use_self, const bool use_select, const bool respecthide, const bool use_topology, float maxdist, int *r_index)
UvElementMap * BM_uv_element_map_create(BMesh *bm, const Scene *scene, const bool uv_selected, const bool use_winding, const bool do_islands)
static void scale_point(float c1[3], const float p[3], const float s)
BMFace * EDBM_verts_mirror_get_face(BMEditMesh *em, BMFace *f)
void EDBM_mesh_free_data(BMEditMesh *em)
void EDBM_selectmode_flush(BMEditMesh *em)
void EDBM_mesh_clear(BMEditMesh *em)
void EDBM_mesh_load(Main *bmain, Object *ob)
BMBackup EDBM_redo_state_store(BMEditMesh *em)
void EDBM_update_extern(struct Mesh *me, const bool do_tessellation, const bool is_destructive)
#define VERT_INTPTR(_v, _i)
void EDBM_verts_mirror_cache_begin(BMEditMesh *em, const int axis, const bool use_self, const bool use_select, const bool respecthide, const bool use_topology)
bool EDBM_op_call_silentf(BMEditMesh *em, const char *fmt,...)
void EDBM_verts_mirror_cache_end(BMEditMesh *em)
void EDBM_verts_mirror_cache_clear(BMEditMesh *em, BMVert *v)
int EDBM_elem_to_index_any(BMEditMesh *em, BMElem *ele)
void EDBM_redo_state_restore(BMBackup *backup, BMEditMesh *em, bool recalc_looptri)
void EDBM_select_less(BMEditMesh *em, const bool use_face_step)
static BMFace * edge_ray_cast(struct BMBVHTree *tree, const float co[3], const float dir[3], float *r_hitout, BMEdge *e)
bool EDBM_view3d_poll(bContext *C)
void EDBM_flag_disable_all(BMEditMesh *em, const char hflag)
#define BM_SEARCH_MAXDIST_MIRR
void EDBM_mesh_normals_update_ex(BMEditMesh *em, const struct BMeshNormalsUpdate_Params *params)
void EDBM_mesh_make(Object *ob, const int select_mode, const bool add_key_index)
void EDBM_select_flush(BMEditMesh *em)
void EDBM_selectmode_to_scene(bContext *C)
UvElement * BM_uv_element_get(UvElementMap *map, BMFace *efa, BMLoop *l)
BMEdge * EDBM_verts_mirror_get_edge(BMEditMesh *em, BMEdge *e)
void EDBM_redo_state_restore_and_free(BMBackup *backup, BMEditMesh *em, bool recalc_looptri)
void EDBM_verts_mirror_apply(BMEditMesh *em, const int sel_from, const int sel_to)
void BM_uv_vert_map_free(UvVertMap *vmap)
void EDBM_update(Mesh *mesh, const struct EDBMUpdate_Params *params)
void EDBM_selectmode_flush_ex(BMEditMesh *em, const short selectmode)
int EDBM_elem_to_index_any_multi(ViewLayer *view_layer, BMEditMesh *em, BMElem *ele, int *r_object_index)
static int bm_uv_edge_select_build_islands(UvElementMap *element_map, const Scene *scene, UvElement *islandbuf, uint *map, bool uv_selected, int cd_loop_uv_offset)
void EDBM_redo_state_free(BMBackup *backup)
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_mallocN)(size_t len, const char *str)
SymEdge< T > * prev(const SymEdge< T > *se)
SocketIndexByIdentifierMap * map
struct BMLoop *(* looptris)[3]
struct BMEditSelection * next
eBMOpSlotSubType_Union slot_subtype
struct BMOpSlot slots_out[BMO_OP_MAX_SLOTS]
struct BMEditMesh * edit_mesh
struct ToolSettings * toolsettings
unsigned short loop_of_poly_index
unsigned short loop_of_poly_index
struct ReportList * reports
eBMOpSlotSubType_Elem elem
void WM_main_add_notifier(unsigned int type, void *reference)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)