# need help searching mesh (winged-edge data structure)

This topic is 4898 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

To find the neighboring triangles of a triangle in the model that I choose randomly, do I loop through the edges of a triangle to find it's neighbors? If so, then which of the neighboring triangles do I choose to make the next current triangle once I've found all the bordering neighboring triangles? Or do I just choose one edge of the original first triangle and make that neighboring triangle the new current triangle? Will that eventually take me down a path where I box myself in and find no more neighboring triangles, yet still leave me with unfound neighbors from the very beginning? (in other words, what if I chose triangles to the left somehow where it eventually took me in a circle of triangles, then I find no more left because I've sort of boxed myself in). Here's what I've come up with so far using the winged-edge data structure, but it still doesn't search the entire mesh topology.
processCurrentTriangle() {
(loop through edges) {
edge gives me 2 vertices (start, end)
left traversal gives me pred and succ edge
right traversal gives me pred and succ edge
edge gives me 2 faces (which means one new neighboring triangle)
mark new triangle as found (neighbor).
}

After all edges searched, add to region list.
Delete current triangle from mesh list list.
}

What I'm looking to do is group all the triangles that belong to a single region, so I'm finding all the regions of my model. At this point, I've found 3 new triangles, what to do ... If I choose one, then it'll take me to it's neighbors and I haven't yet processed the neighbors of the other two that I found. This is where I'm worried abount not getting all the neighboring triangles. I hope that made sense. Any help much appreciated.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 10
• 11
• 13
• 9
• 11
• ### Forum Statistics

• Total Topics
634091
• Total Posts
3015433
×