From f07d3ed9716055176cc95f89d27aba225c3db0db Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Wed, 11 Apr 2007 00:22:23 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@953 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/tristrip.h | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/source/src/tristrip.h b/source/src/tristrip.h index 64c15e8d..ea6134d6 100644 --- a/source/src/tristrip.h +++ b/source/src/tristrip.h @@ -25,7 +25,7 @@ struct tristrip { loopi(3) { - if(n[i]==neighbor) return false; + if(n[i]==neighbor) return true; else if(n[i]==old) { n[i] = neighbor; return true; } } if(dbgts && old==UNUSED) conoutf("excessive links"); @@ -68,23 +68,7 @@ struct tristrip } } - struct edge - { - ushort from, to; - - edge() {} - edge(ushort from, ushort to) : from(min(from, to)), to(max(from, to)) {} - - void link(ushort tri) - { - if(tri < from) - { - to = from; - from = tri; - } - else to = tri; - } - }; + struct edge { ushort from, to; }; void findconnectivity() { @@ -95,12 +79,22 @@ struct tristrip triangle &tri = triangles[i]; loopj(3) { - while(nodes.length()<=tri.v[j]) nodes.add(0); - nodes[tri.v[j]]++; + edge e = { tri.v[j==2 ? 0 : j+1], tri.v[j] }; + ushort owner = i; + edges.access(e, &owner); - edge e(tri.v[j], tri.v[j==2 ? 0 : j+1]); + while(nodes.length()<=tri.v[j]) nodes.add(0); + nodes[tri.v[j]]++; + } + } + loopv(triangles) + { + triangle &tri = triangles[i]; + loopj(3) + { + edge e = { tri.v[j], tri.v[j==2 ? 0 : j+1] }; ushort *owner = edges.access(e); - if(!owner) edges[e] = i; + if(!owner) continue; else if(!tri.link(*owner)) { if(dbgts) conoutf("failed linkage 1: %d -> %d", *owner, i); @@ -262,6 +256,7 @@ struct tristrip } if(dbgts) conoutf("strips = %d, tris = %d, inds = %d, merges = %d", numstrips, numtris, numtris + numstrips*2, (degen ? 2 : 1)*(numstrips-1)); } + }; static inline uint hthash(const tristrip::edge &x) { return x.from^x.to; }