Skip to main content
GameDev.net gamedev.net
🔒 Locked

Connecting triangular faces

Started by JoeZ Feb 18, 2005 at 12:14 AM 1 replies 500+ views
Original Post
JoeZ
JoeZ
Hi, I would like to know if there is a better way to keep track of duplicated trangular face edges. I want to do it because I want to speed up the wireframe rendering speed. I am thinking to keep the vertex id in a vector then compare whether the connection is done, but this method will be slow take a lot of memory, since if an object has 1000 faces I have to compare 1000 faces x 3 edges /face = 3000 when I connect each pair of vertices. Is there a better way to do it? Thanks!
kaysik
kaysik
make a struct called line or something and add it to a stl::set. The struct only needs to hold both end points (or even just the index of both end points into your vertex array if thats easier). Then to generate your list of lines simple loop through all the triangles and add each edge to the set as you go. Because a set can only ever have 1 copy of something whenever you add a duplicate edge it'll be ignored. One problem will be to make sure that if one edge is P1 to P2 and the other is P2 to P1 that it doesnt' get added. The easiest way todo this is always add the higher vector to one slot and the lower one to the other.
JoeZ
JoeZ

I didn't know STL provides such a nice container.

Thanks kaysik!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.