- Home /
How do I distinguish edge vertices?
image?
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?.
Answer by Cherie · Sep 08, 2021 at 05:04 PM
Assuming you have all the vert & edge data you could use an algorithm along the lines of this:
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.
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.
For each new vert within max dist, recursively traverse its vert's neighbours (discounting those already travelled).
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)
Your answer
Follow this Question
Related Questions
Edge detection using C# 1 Answer
TopDown local multiplayer camera edges collision? 1 Answer
Procedural Vertex Snapping 1 Answer
Real time vertex paint (or similar solution) possible? 2 Answers