Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/mesh/meshtools.c
| Show First 20 Lines • Show All 870 Lines • ▼ Show 20 Lines | BLI_INLINE void mesh_mirror_topo_table_get_meshes(Object *ob, | ||||
| else { | else { | ||||
| me_mirror = me; | me_mirror = me; | ||||
| } | } | ||||
| *r_me_mirror = me_mirror; | *r_me_mirror = me_mirror; | ||||
| *r_em_mirror = em_mirror; | *r_em_mirror = em_mirror; | ||||
| } | } | ||||
| /** | |||||
| * Mode is 's' start, or 'e' end, or 'u' use | |||||
| * if end, ob can be NULL. | |||||
| * \note This is supposed return -1 on error, | |||||
| * which callers are currently checking for, but is not used so far. | |||||
| */ | |||||
| void ED_mesh_mirror_topo_table_begin(Object *ob, Mesh *me_eval) | void ED_mesh_mirror_topo_table_begin(Object *ob, Mesh *me_eval) | ||||
| { | { | ||||
| Mesh *me_mirror; | Mesh *me_mirror; | ||||
| BMEditMesh *em_mirror; | BMEditMesh *em_mirror; | ||||
| mesh_mirror_topo_table_get_meshes(ob, me_eval, &me_mirror, &em_mirror); | mesh_mirror_topo_table_get_meshes(ob, me_eval, &me_mirror, &em_mirror); | ||||
| ED_mesh_mirrtopo_init(em_mirror, me_mirror, &mesh_topo_store, false); | ED_mesh_mirrtopo_init(em_mirror, me_mirror, &mesh_topo_store, false); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 114 Lines • ▼ Show 20 Lines | BMVert *editbmesh_get_x_mirror_vert(Object *ob, | ||||
| const bool use_topology) | const bool use_topology) | ||||
| { | { | ||||
| if (use_topology) { | if (use_topology) { | ||||
| return editbmesh_get_x_mirror_vert_topo(ob, em, eve, index); | return editbmesh_get_x_mirror_vert_topo(ob, em, eve, index); | ||||
| } | } | ||||
| return editbmesh_get_x_mirror_vert_spatial(ob, em, co); | return editbmesh_get_x_mirror_vert_spatial(ob, em, co); | ||||
| } | } | ||||
| /** | |||||
| * Wrapper for object-mode/edit-mode. | |||||
| * | |||||
| * call #BM_mesh_elem_table_ensure first for editmesh. | |||||
| */ | |||||
| int ED_mesh_mirror_get_vert(Object *ob, int index) | int ED_mesh_mirror_get_vert(Object *ob, int index) | ||||
| { | { | ||||
| Mesh *me = ob->data; | Mesh *me = ob->data; | ||||
| BMEditMesh *em = me->edit_mesh; | BMEditMesh *em = me->edit_mesh; | ||||
| bool use_topology = (me->editflag & ME_EDIT_MIRROR_TOPO) != 0; | bool use_topology = (me->editflag & ME_EDIT_MIRROR_TOPO) != 0; | ||||
| int index_mirr; | int index_mirr; | ||||
| if (em) { | if (em) { | ||||
| ▲ Show 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | static int mirror_facerotation(MFace *a, MFace *b) | ||||
| return -1; | return -1; | ||||
| } | } | ||||
| static bool mirror_facecmp(const void *a, const void *b) | static bool mirror_facecmp(const void *a, const void *b) | ||||
| { | { | ||||
| return (mirror_facerotation((MFace *)a, (MFace *)b) == -1); | return (mirror_facerotation((MFace *)a, (MFace *)b) == -1); | ||||
| } | } | ||||
| /* This is a Mesh-based copy of mesh_get_x_mirror_faces() */ | |||||
| int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em, Mesh *me_eval) | int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em, Mesh *me_eval) | ||||
| { | { | ||||
| Mesh *me = ob->data; | Mesh *me = ob->data; | ||||
| MVert *mv, *mvert; | MVert *mv, *mvert; | ||||
| MFace mirrormf, *mf, *hashmf, *mface; | MFace mirrormf, *mf, *hashmf, *mface; | ||||
| GHash *fhash; | GHash *fhash; | ||||
| int *mirrorverts, *mirrorfaces; | int *mirrorverts, *mirrorfaces; | ||||
| ▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em, Mesh *me_eval) | ||||
| MEM_freeN(mirrorverts); | MEM_freeN(mirrorverts); | ||||
| return mirrorfaces; | return mirrorfaces; | ||||
| } | } | ||||
| /* selection, vertex and face */ | /* selection, vertex and face */ | ||||
| /* returns 0 if not found, otherwise 1 */ | /* returns 0 if not found, otherwise 1 */ | ||||
| /** | |||||
| * Face selection in object mode, | |||||
| * currently only weight-paint and vertex-paint use this. | |||||
| * | |||||
| * \return boolean true == Found | |||||
| */ | |||||
| bool ED_mesh_pick_face(bContext *C, Object *ob, const int mval[2], uint dist_px, uint *r_index) | bool ED_mesh_pick_face(bContext *C, Object *ob, const int mval[2], uint dist_px, uint *r_index) | ||||
| { | { | ||||
| ViewContext vc; | ViewContext vc; | ||||
| Mesh *me = ob->data; | Mesh *me = ob->data; | ||||
| BLI_assert(me && GS(me->id.name) == ID_ME); | BLI_assert(me && GS(me->id.name) == ID_ME); | ||||
| if (!me || me->totpoly == 0) { | if (!me || me->totpoly == 0) { | ||||
| ▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | if (ED_view3d_project_float_object(region, co, sco, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { | ||||
| const float len_test = len_manhattan_v2v2(mval, sco); | const float len_test = len_manhattan_v2v2(mval, sco); | ||||
| if (len_test < *r_len_best) { | if (len_test < *r_len_best) { | ||||
| *r_len_best = len_test; | *r_len_best = len_test; | ||||
| *r_v_idx_best = v_idx; | *r_v_idx_best = v_idx; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /** | |||||
| * Use when the back buffer stores face index values. but we want a vert. | |||||
| * This gets the face then finds the closest vertex to mval. | |||||
| */ | |||||
| bool ED_mesh_pick_face_vert( | bool ED_mesh_pick_face_vert( | ||||
| bContext *C, Object *ob, const int mval[2], uint dist_px, uint *r_index) | bContext *C, Object *ob, const int mval[2], uint dist_px, uint *r_index) | ||||
| { | { | ||||
| Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| uint poly_index; | uint poly_index; | ||||
| Mesh *me = ob->data; | Mesh *me = ob->data; | ||||
| BLI_assert(me && GS(me->id.name) == ID_ME); | BLI_assert(me && GS(me->id.name) == ID_ME); | ||||
| ▲ Show 20 Lines • Show All 279 Lines • Show Last 20 Lines | |||||