Jump to content
  • Advertisement
Sign in to follow this  
StoneDevil

Fast Duplicate Edge Detection

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, Im working on some stencil shadow rendering in managed directx with c#. When create my list of contour edges i am trying to check if i have already added the current edge to my list before i add it again. What is the best way to do this. I have an Edge struct with just two integers in it that reference the indices of the edge. and i have an array of Edges that i am adding to. Whats the best way to avoid duplicates? Thanks

Share this post


Link to post
Share on other sites
Advertisement
To be able to search relatively quickly for dups, be sure you order the indices for each edge - Edge.idx1 is always < Edge.idx2.

Then you can search to see if a newEdge is a duplicate (or something similar):

int i;
bool dup;

i = 0;
dup = false;
while( i < currentArraySize && newEdge.idx1 >= edgeArray ) {
if( newEdge.idx1==edgeArray.idx1 && newEdge.idx2==edgeArray.idx2 ) {
dup = true;
break;
}
i++;
}
if( !dup ) edgeArray.Add( newEdge );

Share this post


Link to post
Share on other sites
Fastest would be to mark the edge as used, if you have a spare bit in your edge structure. If not, some form of hash will likely work quite quickly. I'm not familiar enough with .NET to know what hash implementations are available and how fast they are.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!