title: c++: Find the closest point on a mesh to a query point
body: <p>Here is what I need:
  Given a point(x,y,z) in 3d space, and a mesh compose of some vertices(x,y,z), to calculate and return the close point coordinate on that mesh.
  The function probably like this:</p>
  
  <pre><code>bool closePointOnMesh(const Point&amp; queryPoint, const Mesh&amp; myMesh, float maxDistance);
  </code></pre>
  
  <p>I have done some searching, and probably I will choose octree to reduce the calculation.</p>
  
  <p>But there are still many details that I can't understand:</p>
  
  <p>1: How the octree node been subdivided, so each node contains may contains 0~some triangles? It is easier to subdivided the cell further based on vertices and just store vertices directly. </p>
  
  <p>2: How the octree structure helps to reduce the calculation, I know if the cell is empty I will just disregard it. But do I need to get all the closest point within each triangle face in a octree cell to the queryPoint, so I finally get the most closest point of all?  that sound still heavy. Beside it will be more easier if I just iter through all the triangles, get the closest point from them, which means no need for the octree???</p>
  
  <p>3: Is there a fast way to get the closest point to a point within a triangle face?</p>
  
  <p>4: how the maxDistance limit helps to reduce the calculation? </p>