void extrude( btHullTriangle t0, int v ) { int3 t = t0.v; int n = m_tris.Count; btHullTriangle ta = allocateTriangle( v, t[1], t[2] ); ta.n = new int3( t0.n[0], n + 1, n + 2 ); m_tris[t0.n[0]].neib( t[1], t[2] , n + 0 ); btHullTriangle tb = allocateTriangle( v, t[2], t[0] ); tb.n = new int3( t0.n[1], n + 2, n + 0 ); m_tris[t0.n[1]].neib( t[2], t[0] , n + 1 ); btHullTriangle tc = allocateTriangle( v, t[0], t[1] ); tc.n = new int3( t0.n[2], n + 0, n + 1 ); m_tris[t0.n[2]].neib( t[0], t[1] , n + 2 ); checkit( ta ); checkit( tb ); checkit( tc ); if( hasvert( m_tris[ta.n[0]].v, v ) ) removeb2b( ta, m_tris[ta.n[0]] ); if( hasvert( m_tris[tb.n[0]].v, v ) ) removeb2b( tb, m_tris[tb.n[0]] ); if( hasvert( m_tris[tc.n[0]].v, v ) ) removeb2b( tc, m_tris[tc.n[0]] ); deAllocateTriangle( t0 ); }
void deAllocateTriangle( btHullTriangle tri ) { Debug.Assert( m_tris[tri.id] == tri ); m_tris[tri.id] = null; }
btHullTriangle allocateTriangle( int a, int b, int c ) { btHullTriangle tr = new btHullTriangle( a, b, c ); tr.id = m_tris.Count; m_tris.Add( tr ); return tr; }
void checkit( btHullTriangle t ) { int i; Debug.Assert( m_tris[t.id] == t ); for( i = 0; i < 3; i++ ) { int i1 = ( i + 1 ) % 3; int i2 = ( i + 2 ) % 3; int a = ( t.v )[i1]; int b = ( t.v )[i2]; // release compile fix Debug.Assert( a != b ); Debug.Assert( m_tris[t.n[i]].neib( b, a ) == t.id ); } }
void removeb2b( btHullTriangle s, btHullTriangle t ) { b2bfix( s, t ); deAllocateTriangle( s ); deAllocateTriangle( t ); }
void b2bfix( btHullTriangle s, btHullTriangle t ) { int i; for( i = 0; i < 3; i++ ) { int i1 = ( i + 1 ) % 3; int i2 = ( i + 2 ) % 3; int a = ( s.v )[i1]; int b = ( s.v )[i2]; Debug.Assert( m_tris[s.neib( a, b )].neib( b, a ) == s.id ); Debug.Assert( m_tris[t.neib( a, b )].neib( b, a ) == t.id ); m_tris[s.neib( a, b )].neib( b, a, t.neib( b, a ) ); m_tris[t.neib( b, a )].neib( a, b, s.neib( a, b ) ); } }