Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/pbvh_bmesh.c
| Context not available. | |||||
| float *r_face_normal) | float *r_face_normal) | ||||
| { | { | ||||
| bool hit = false; | bool hit = false; | ||||
| float nearest_vertex_co[3] = {0.0f}; | |||||
| float min_depth = FLT_MAX; | |||||
| float nearest_vertex_co[3] = {0.0f}; | |||||
| float location[3] = {0.0f}; | |||||
| if (use_original && node->bm_tot_ortri) { | if (use_original && node->bm_tot_ortri) { | ||||
| for (int i = 0; i < node->bm_tot_ortri; i++) { | for (int i = 0; i < node->bm_tot_ortri; i++) { | ||||
| const int *t = node->bm_ortri[i]; | const int *t = node->bm_ortri[i]; | ||||
| Context not available. | |||||
| BMVert *v_tri[3]; | BMVert *v_tri[3]; | ||||
| BM_face_as_array_vert_tri(f, v_tri); | BM_face_as_array_vert_tri(f, v_tri); | ||||
| hit |= ray_face_intersection_tri( | |||||
| if (ray_face_intersection_tri( | ray_start, isect_precalc, v_tri[0]->co, v_tri[1]->co, v_tri[2]->co, depth); | ||||
| ray_start, isect_precalc, v_tri[0]->co, v_tri[1]->co, v_tri[2]->co, depth)) { | |||||
| hit = true; | if (hit && *depth < min_depth) { | ||||
| min_depth = *depth; | |||||
| if (r_face_normal) { | normal_tri_v3(r_face_normal, v_tri[0]->co, v_tri[1]->co, v_tri[2]->co); | ||||
| normal_tri_v3(r_face_normal, v_tri[0]->co, v_tri[1]->co, v_tri[2]->co); | madd_v3_v3v3fl(location, ray_start, ray_normal, *depth); | ||||
| } | for (int j = 0; j < 3; j++) { | ||||
| if (len_squared_v3v3(location, v_tri[j]->co) < | |||||
| if (r_active_vertex_index) { | len_squared_v3v3(location, nearest_vertex_co)) { | ||||
| float location[3] = {0.0f}; | copy_v3_v3(nearest_vertex_co, v_tri[j]->co); | ||||
| madd_v3_v3v3fl(location, ray_start, ray_normal, *depth); | *r_active_vertex_index = BM_elem_index_get(v_tri[j]); | ||||
| for (int j = 0; j < 3; j++) { | |||||
| if (len_squared_v3v3(location, v_tri[j]->co) < | |||||
| len_squared_v3v3(location, nearest_vertex_co)) { | |||||
| copy_v3_v3(nearest_vertex_co, v_tri[j]->co); | |||||
| *r_active_vertex_index = BM_elem_index_get(v_tri[j]); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||