- Home /
Determine neighbor boundary vertices order
There is a set of n vertices (Vector3 points) that are boundary of mesh hole, each described by index. For example: Task is to determin which vertex connects to which and produce ordered array of indices. Basing on example, and starting from '34' (starting vertex does not matter) result should be:
[34, 753, 43001, 43002, 43003, 654, 655, 35, 53, 10212, 23232, 36]
My approche was to:
-Calculate middle vertex vM (figure weight point):
vM = SUM(vertices)/vertices.length // pseudocode
-Choose I vertex, get IM direction and get all neighbor vertices on one side (in this example right side) of the red line (to avoid overlaping)
var localNormal = (vMNormal+ normalJ + normalI) / 3.0f;
var cross = Vector3.Cross(posI - posM, posJ - posI);
var side= Vector3.Dot(cross, localNormal);
if (side< 0)
continue;
-Get closest neighber point
var closest = Vector3.Dot((posI - vM).normalized, (posJ - vM).normalized);
Note: I is the start vertex, J is the next in loop to test vertex
Everything works fine until vertex 23232 . Vertex 36 technically is also on the right side but it was excluded. Even if 36 would not be excluded, basing on this alghoritm rules, priority have 43002, since it is closest to 23232. That means closest neighbor aproche is not valid. Do You know any other alghoritm to solve this problem?
Your answer
Follow this Question
Related Questions
Problem drawing a mesh with Graphics.DrawMeshNow 1 Answer
Why do some vertices in meshes of my game jitter when on Android phones 0 Answers
Is it possible to have a custom attribute in the mesh? 0 Answers
How can i get current state(position) of vertices of animated mesh(SkinnedMeshRenderer)? 4 Answers
Can't change verts on mesh after assigning to meshfilter. 1 Answer