@@ -38,16 +38,17 @@ bool ClosestPointQuery::get_closest_point(
3838{
3939 assert (max_distance > 0 .0f );
4040
41+ // nanoflann (the KDTree library) use squared distance. We do the same.
4142 const float max_distance2 = max_distance * max_distance;
4243
43- // Define how many points we take from the tree to find the closest point in the mesh.
44+ // Define how many points we take from the tree to find the closest point on the mesh.
4445 // A number that is too low will generate incorrect results when the mesh density is high.
45- // The points we process are the closest points to the query point.
46+ // The points we process are the nearest points in the cloud to the query point.
4647 const std::size_t point_to_process_max_count = 2000 ;
4748 std::vector<std::size_t > ret_index (point_to_process_max_count);
4849 std::vector<float > out_dist_sqr (point_to_process_max_count);
4950
50- // Use the KDTree to find the closest points.
51+ // Use the KDTree to find the nearest points to the `query_point` .
5152 const std::size_t num_results =
5253 m_tree_index.knnSearch (
5354 glm::value_ptr (query_point),
@@ -59,24 +60,24 @@ bool ClosestPointQuery::get_closest_point(
5960 float closest_distance2 = 0 .0f ;
6061
6162 // Find the closest point on the mesh using all points near to `query_point`.
62- // To do so, we use the triangle on which each point is laying and compute the closest
63- // point to the quer_point that is on the triangle.
64- // For all these "triangles points", we keep the L2 closest one to the query point.
63+ // To do so, we use the triangle on which each point is and compute the closest
64+ // point to query_point that is on the triangle.
65+ // For all these "triangles points", we keep the closest one to the query point.
6566 // FIXME: We analyse the same triangles multiple times.
6667 for (std::size_t i = 0 ; i < num_results; ++i)
6768 {
68- // Ask the triangle to the point cloud .
69+ // Ask to the point cloud which triangle is this point on .
6970 glm::vec3 v1, v2, v3;
7071 m_mesh_point_cloud.get_triangle (ret_index[i], v1, v2, v3);
7172
72- // Compute the point on the triangle.
73+ // Compute the closest point to `query_point` that is on the triangle.
7374 glm::vec3 p = closest_point_in_triangle (
7475 query_point,
7576 v1,
7677 v2,
7778 v3);
7879
79- // Keep the best .
80+ // From all triangles, keep the closest one .
8081 const float distance2_to_triangle = distance2 (p, query_point);
8182
8283 if (distance2_to_triangle < max_distance2
0 commit comments