How do I distinguish edge vertices?

image?alt text

I’m trying to displace the vertices highlighted in red but the way I’m selecting the vertices for displacement is by a distance radius based on the position I click with my mouse and I end up selecting the blue vertices. I want to only select the vertices up until the edges and not passed that. Other than distance, I don’t know how to select a batch of vertices. How would I go about this?.

Assuming you have all the vert & edge data you could use an algorithm along the lines of this:

  1. When the user clicks, get the closest vert to their mouse position (if there is no vert within your max distance, then early exit). Add this vert to your selection list.
  2. Traverse each neighbour of the first vert. Check if the neighbour is within max click distance, if they are, add them to the selection list.
  3. For each new vert within max dist, recursively traverse its vert’s neighbours (discounting those already travelled).
  4. And so on and so forth until there are no more connected verts within the max click distance.

This will only work if those middle points are not parts of a 2D or 3D mesh which is also connected to the edge verts. If that’s the case, then you may need to preprocess the mesh to identify the shell edges.

Also, depending on your design for what should and shouldn’t be selected, you could consider comparing the edge or vert normals (e.g. a selection could end when the angle between normals becomes too large)