Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/mesh/editmesh_select.c
| Show First 20 Lines • Show All 1,147 Lines • ▼ Show 20 Lines | for (uint base_index = 0; base_index < bases_len; base_index++) { | ||||
| if (use_boundary && (use_vert || use_edge)) { | if (use_boundary && (use_vert || use_edge)) { | ||||
| BMEdge *e; | BMEdge *e; | ||||
| BMIter eiter; | BMIter eiter; | ||||
| BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) { | BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) { | ||||
| if ((BM_elem_flag_test(e, BM_ELEM_HIDDEN) == false) && | if ((BM_elem_flag_test(e, BM_ELEM_HIDDEN) == false) && | ||||
| (BM_edge_is_boundary(e))) | (BM_edge_is_boundary(e))) | ||||
| { | { | ||||
| float depth; | |||||
| if (use_vert) { | if (use_vert) { | ||||
| for (uint j = 0; j < 2; j++) { | for (uint j = 0; j < 2; j++) { | ||||
| BMVert *v = *((&e->v1) + j); | BMVert *v = *((&e->v1) + j); | ||||
| float point[3]; | float point[3]; | ||||
| mul_v3_m4v3(point, obedit->obmat, coords ? coords[BM_elem_index_get(v)] : v->co); | mul_v3_m4v3(point, obedit->obmat, coords ? coords[BM_elem_index_get(v)] : v->co); | ||||
| const float dist_sq_test = dist_squared_to_ray_v3( | const float dist_sq_test = dist_squared_to_ray_v3_normalized( | ||||
| ray_origin, ray_direction, | ray_origin, ray_direction, point); | ||||
| point, &depth); | |||||
| if (dist_sq_test < dist_sq_best) { | if (dist_sq_test < dist_sq_best) { | ||||
| dist_sq_best = dist_sq_test; | dist_sq_best = dist_sq_test; | ||||
| best.base_index = base_index; | best.base_index = base_index; | ||||
| best.ele = (BMElem *)v; | best.ele = (BMElem *)v; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (use_edge) { | if (use_edge) { | ||||
| float point[3]; | float point[3]; | ||||
| #if 0 | #if 0 | ||||
| const float dist_sq_test = dist_squared_ray_to_seg_v3( | const float dist_sq_test = dist_squared_ray_to_seg_v3( | ||||
| ray_origin, ray_direction, | ray_origin, ray_direction, | ||||
| e->v1->co, e->v2->co, | e->v1->co, e->v2->co, | ||||
| point, &depth); | point, &depth); | ||||
| #else | #else | ||||
| if (coords) { | if (coords) { | ||||
| mid_v3_v3v3(point, coords[BM_elem_index_get(e->v1)], coords[BM_elem_index_get(e->v2)]); | mid_v3_v3v3(point, coords[BM_elem_index_get(e->v1)], coords[BM_elem_index_get(e->v2)]); | ||||
| } | } | ||||
| else { | else { | ||||
| mid_v3_v3v3(point, e->v1->co, e->v2->co); | mid_v3_v3v3(point, e->v1->co, e->v2->co); | ||||
| } | } | ||||
| mul_m4_v3(obedit->obmat, point); | mul_m4_v3(obedit->obmat, point); | ||||
| const float dist_sq_test = dist_squared_to_ray_v3( | const float dist_sq_test = dist_squared_to_ray_v3_normalized( | ||||
| ray_origin, ray_direction, | ray_origin, ray_direction, point); | ||||
| point, &depth); | |||||
| if (dist_sq_test < dist_sq_best) { | if (dist_sq_test < dist_sq_best) { | ||||
| dist_sq_best = dist_sq_test; | dist_sq_best = dist_sq_test; | ||||
| best.base_index = base_index; | best.base_index = base_index; | ||||
| best.ele = (BMElem *)e; | best.ele = (BMElem *)e; | ||||
| } | } | ||||
| #endif | #endif | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* Non boundary case. */ | /* Non boundary case. */ | ||||
| if (use_vert) { | if (use_vert) { | ||||
| BMVert *v; | BMVert *v; | ||||
| BMIter viter; | BMIter viter; | ||||
| BM_ITER_MESH (v, &viter, bm, BM_VERTS_OF_MESH) { | BM_ITER_MESH (v, &viter, bm, BM_VERTS_OF_MESH) { | ||||
| if (BM_elem_flag_test(v, BM_ELEM_HIDDEN) == false) { | if (BM_elem_flag_test(v, BM_ELEM_HIDDEN) == false) { | ||||
| float point[3]; | float point[3]; | ||||
| mul_v3_m4v3(point, obedit->obmat, v->co); | mul_v3_m4v3(point, obedit->obmat, v->co); | ||||
| float depth; | const float dist_sq_test = dist_squared_to_ray_v3_normalized( | ||||
| const float dist_sq_test = dist_squared_to_ray_v3( | ray_origin, ray_direction, v->co); | ||||
| ray_origin, ray_direction, | |||||
| v->co, &depth); | |||||
| if (dist_sq_test < dist_sq_best) { | if (dist_sq_test < dist_sq_best) { | ||||
| dist_sq_best = dist_sq_test; | dist_sq_best = dist_sq_test; | ||||
| best.base_index = base_index; | best.base_index = base_index; | ||||
| best.ele = (BMElem *)v; | best.ele = (BMElem *)v; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (use_edge) { | if (use_edge) { | ||||
| BMEdge *e; | BMEdge *e; | ||||
| BMIter eiter; | BMIter eiter; | ||||
| BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) { | BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) { | ||||
| if (BM_elem_flag_test(e, BM_ELEM_HIDDEN) == false) { | if (BM_elem_flag_test(e, BM_ELEM_HIDDEN) == false) { | ||||
| float point[3]; | float point[3]; | ||||
| if (coords) { | if (coords) { | ||||
| mid_v3_v3v3(point, coords[BM_elem_index_get(e->v1)], coords[BM_elem_index_get(e->v2)]); | mid_v3_v3v3(point, coords[BM_elem_index_get(e->v1)], coords[BM_elem_index_get(e->v2)]); | ||||
| } | } | ||||
| else { | else { | ||||
| mid_v3_v3v3(point, e->v1->co, e->v2->co); | mid_v3_v3v3(point, e->v1->co, e->v2->co); | ||||
| } | } | ||||
| mul_m4_v3(obedit->obmat, point); | mul_m4_v3(obedit->obmat, point); | ||||
| float depth; | const float dist_sq_test = dist_squared_to_ray_v3_normalized( | ||||
| const float dist_sq_test = dist_squared_to_ray_v3( | ray_origin, ray_direction, point); | ||||
| ray_origin, ray_direction, | |||||
| point, &depth); | |||||
| if (dist_sq_test < dist_sq_best) { | if (dist_sq_test < dist_sq_best) { | ||||
| dist_sq_best = dist_sq_test; | dist_sq_best = dist_sq_test; | ||||
| best.base_index = base_index; | best.base_index = base_index; | ||||
| best.ele = (BMElem *)e; | best.ele = (BMElem *)e; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (use_face) { | if (use_face) { | ||||
| BMFace *f; | BMFace *f; | ||||
| BMIter fiter; | BMIter fiter; | ||||
| BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) { | BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) { | ||||
| if (BM_elem_flag_test(f, BM_ELEM_HIDDEN) == false) { | if (BM_elem_flag_test(f, BM_ELEM_HIDDEN) == false) { | ||||
| float point[3]; | float point[3]; | ||||
| if (coords) { | if (coords) { | ||||
| BM_face_calc_center_median_vcos(bm, f, point, coords); | BM_face_calc_center_median_vcos(bm, f, point, coords); | ||||
| } | } | ||||
| else { | else { | ||||
| BM_face_calc_center_median(f, point); | BM_face_calc_center_median(f, point); | ||||
| } | } | ||||
| mul_m4_v3(obedit->obmat, point); | mul_m4_v3(obedit->obmat, point); | ||||
| float depth; | const float dist_sq_test = dist_squared_to_ray_v3_normalized( | ||||
| const float dist_sq_test = dist_squared_to_ray_v3( | ray_origin, ray_direction, point); | ||||
| ray_origin, ray_direction, | |||||
| point, &depth); | |||||
| if (dist_sq_test < dist_sq_best) { | if (dist_sq_test < dist_sq_best) { | ||||
| dist_sq_best = dist_sq_test; | dist_sq_best = dist_sq_test; | ||||
| best.base_index = base_index; | best.base_index = base_index; | ||||
| best.ele = (BMElem *)f; | best.ele = (BMElem *)f; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 3,481 Lines • Show Last 20 Lines | |||||