Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/mesh/editmesh_select.c
| Show First 20 Lines • Show All 261 Lines • ▼ Show 20 Lines | if ((data->hit_cycle.vert == NULL) && (index > data->cycle_index_prev) && | ||||
| data->hit_cycle.dist_bias = dist_test_bias; | data->hit_cycle.dist_bias = dist_test_bias; | ||||
| data->hit_cycle.dist = dist_test; | data->hit_cycle.dist = dist_test; | ||||
| data->hit_cycle.index = index; | data->hit_cycle.index = index; | ||||
| data->hit_cycle.vert = eve; | data->hit_cycle.vert = eve; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /** | |||||
| * Nearest vertex under the cursor. | |||||
| * | |||||
| * \param dist_px_manhattan_p: (in/out), minimal distance to the nearest and at the end, | |||||
| * actual distance. | |||||
| * \param use_select_bias: | |||||
| * - When true, selected vertices are given a 5 pixel bias | |||||
| * to make them further than unselect verts. | |||||
| * - When false, unselected vertices are given the bias. | |||||
| * \param use_cycle: Cycle over elements within #FIND_NEAR_CYCLE_THRESHOLD_MIN in order of index. | |||||
| */ | |||||
| BMVert *EDBM_vert_find_nearest_ex(ViewContext *vc, | BMVert *EDBM_vert_find_nearest_ex(ViewContext *vc, | ||||
| float *dist_px_manhattan_p, | float *dist_px_manhattan_p, | ||||
| const bool use_select_bias, | const bool use_select_bias, | ||||
| bool use_cycle, | bool use_cycle, | ||||
| Base **bases, | Base **bases, | ||||
| uint bases_len, | uint bases_len, | ||||
| uint *r_base_index) | uint *r_base_index) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 419 Lines • ▼ Show 20 Lines | if ((data->hit_cycle.face == NULL) && (index > data->cycle_index_prev) && | ||||
| data->hit_cycle.dist_bias = dist_test_bias; | data->hit_cycle.dist_bias = dist_test_bias; | ||||
| data->hit_cycle.dist = dist_test; | data->hit_cycle.dist = dist_test; | ||||
| data->hit_cycle.index = index; | data->hit_cycle.index = index; | ||||
| data->hit_cycle.face = efa; | data->hit_cycle.face = efa; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /** | |||||
| * \param use_zbuf_single_px: Special case, when using the back-buffer selection, | |||||
| * only use the pixel at `vc->mval` instead of using `dist_px_manhattan_p` to search over a larger | |||||
| * region. This is needed because historically selection worked this way for a long time, however | |||||
| * it's reasonable that some callers might want to expand the region too. So add an argument to do | |||||
| * this, | |||||
| */ | |||||
| BMFace *EDBM_face_find_nearest_ex(ViewContext *vc, | BMFace *EDBM_face_find_nearest_ex(ViewContext *vc, | ||||
| float *dist_px_manhattan_p, | float *dist_px_manhattan_p, | ||||
| float *r_dist_center, | float *r_dist_center, | ||||
| const bool use_zbuf_single_px, | const bool use_zbuf_single_px, | ||||
| const bool use_select_bias, | const bool use_select_bias, | ||||
| bool use_cycle, | bool use_cycle, | ||||
| BMFace **r_efa_zbuf, | BMFace **r_efa_zbuf, | ||||
| Base **bases, | Base **bases, | ||||
| ▲ Show 20 Lines • Show All 1,481 Lines • ▼ Show 20 Lines | while (ese) { | ||||
| if (ese->htype == BM_FACE) { | if (ese->htype == BM_FACE) { | ||||
| BLI_freelinkN(&(em->bm->selected), ese); | BLI_freelinkN(&(em->bm->selected), ese); | ||||
| } | } | ||||
| ese = nextese; | ese = nextese; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* when switching select mode, makes sure selection is consistent for editing */ | |||||
| /* also for paranoia checks to make sure edge or face mode works */ | |||||
| void EDBM_selectmode_set(BMEditMesh *em) | void EDBM_selectmode_set(BMEditMesh *em) | ||||
| { | { | ||||
| BMVert *eve; | BMVert *eve; | ||||
| BMEdge *eed; | BMEdge *eed; | ||||
| BMFace *efa; | BMFace *efa; | ||||
| BMIter iter; | BMIter iter; | ||||
| em->bm->selectmode = em->selectmode; | em->bm->selectmode = em->selectmode; | ||||
| Show All 38 Lines | if (em->bm->totfacesel) { | ||||
| if (BM_elem_flag_test(efa, BM_ELEM_SELECT)) { | if (BM_elem_flag_test(efa, BM_ELEM_SELECT)) { | ||||
| BM_face_select_set(em->bm, efa, true); | BM_face_select_set(em->bm, efa, true); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /** | |||||
| * Expand & Contract the Selection | |||||
| * (used when changing modes and Ctrl key held) | |||||
| * | |||||
| * Flush the selection up: | |||||
| * - vert -> edge | |||||
| * - vert -> face | |||||
| * - edge -> face | |||||
| * | |||||
| * Flush the selection down: | |||||
| * - face -> edge | |||||
| * - face -> vert | |||||
| * - edge -> vert | |||||
| */ | |||||
| void EDBM_selectmode_convert(BMEditMesh *em, | void EDBM_selectmode_convert(BMEditMesh *em, | ||||
| const short selectmode_old, | const short selectmode_old, | ||||
| const short selectmode_new) | const short selectmode_new) | ||||
| { | { | ||||
| BMesh *bm = em->bm; | BMesh *bm = em->bm; | ||||
| BMVert *eve; | BMVert *eve; | ||||
| BMEdge *eed; | BMEdge *eed; | ||||
| ▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | else if (selectmode_new == SCE_SELECT_VERTEX) { | ||||
| } | } | ||||
| } | } | ||||
| /* deselect faces without verts selected */ | /* deselect faces without verts selected */ | ||||
| BM_mesh_deselect_flush(bm); | BM_mesh_deselect_flush(bm); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* user facing function, does notification */ | |||||
| bool EDBM_selectmode_toggle_multi(bContext *C, | bool EDBM_selectmode_toggle_multi(bContext *C, | ||||
| const short selectmode_new, | const short selectmode_new, | ||||
| const int action, | const int action, | ||||
| const bool use_extend, | const bool use_extend, | ||||
| const bool use_expand) | const bool use_expand) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| ▲ Show 20 Lines • Show All 159 Lines • ▼ Show 20 Lines | bool EDBM_selectmode_set_multi(bContext *C, const short selectmode) | ||||
| if (changed) { | if (changed) { | ||||
| WM_main_add_notifier(NC_SCENE | ND_TOOLSETTINGS, NULL); | WM_main_add_notifier(NC_SCENE | ND_TOOLSETTINGS, NULL); | ||||
| DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE); | DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE); | ||||
| } | } | ||||
| return changed; | return changed; | ||||
| } | } | ||||
| /** | |||||
| * Use to disable a selectmode if its enabled, Using another mode as a fallback | |||||
| * if the disabled mode is the only mode set. | |||||
| * | |||||
| * \return true if the mode is changed. | |||||
| */ | |||||
| bool EDBM_selectmode_disable(Scene *scene, | bool EDBM_selectmode_disable(Scene *scene, | ||||
| BMEditMesh *em, | BMEditMesh *em, | ||||
| const short selectmode_disable, | const short selectmode_disable, | ||||
| const short selectmode_fallback) | const short selectmode_fallback) | ||||
| { | { | ||||
| /* note essential, but switch out of vertex mode since the | /* note essential, but switch out of vertex mode since the | ||||
| * selected regions won't be nicely isolated after flushing */ | * selected regions won't be nicely isolated after flushing */ | ||||
| if (em->selectmode & selectmode_disable) { | if (em->selectmode & selectmode_disable) { | ||||
| ▲ Show 20 Lines • Show All 2,704 Lines • Show Last 20 Lines | |||||