Goal: Make the distance lines between two points on the surface of a mesh-based primitive (that is, a sphere, a cube, and so on).
Current solution: Crosses iteratively the line of distance between two ends and raycast "inverted" somehow. Since the distance line directly connects the two vertices through the mesh, the corresponding points on the mesh surface are needed.
Ray Ray = new Ray (); RaycastHit raycastHit; ray.origin = posOnDistanceLine; ray.direction = raycastNormal.normalized; // inverse ray since we can not cast rays from within the mesh ray.origin = ray.GetPoint (1); ray.direction = -ray.direction;
The lines are then drawn with the help of the unit
LineRenderer which is populated with vertex positions whenever a change in norms (compared to the previous broadcast) is identified.
Horrible performance (100 rays are thrown each time the end points move).
The solution does not always work and produces irregular and irregular lines / dots.
Is there a better approach to implement this?