Beispiel #1
0
 public void Extrude(HullTriangle t0, int v)
 {
     int3 t = t0;
     int n = m_tris.Count;
     HullTriangle ta = AllocateTriangle(v, t.At(1), t.At(2));
     ta.n = new int3(t0.n.At(0), n + 1, n + 2);
     m_tris[t0.n.At(0)].Neib(t.At(1), t.At(2), n + 0);
     HullTriangle tb = AllocateTriangle(v, t.At(2), t.At(0));
     tb.n = new int3(t0.n.At(1), n + 2, n + 0);
     m_tris[t0.n.At(1)].Neib(t.At(2), t.At(0), n + 1);
     HullTriangle tc = AllocateTriangle(v, t.At(0), t.At(1));
     tc.n = new int3(t0.n.At(2), n + 0, n + 1);
     m_tris[t0.n.At(2)].Neib(t.At(0), t.At(1), n + 2);
     CheckIt(ta);
     CheckIt(tb);
     CheckIt(tc);
     if (HasVert(m_tris[ta.n.At(0)], v))
     {
         RemoveB2b(ta, m_tris[ta.n.At(0)]);
     }
     if (HasVert(m_tris[tb.n.At(0)], v))
     {
         RemoveB2b(tb, m_tris[tb.n.At(0)]);
     }
     if (HasVert(m_tris[tc.n.At(0)], v))
     {
         RemoveB2b(tc, m_tris[tc.n.At(0)]);
     }
     DeAllocateTriangle(t0);
 }
Beispiel #2
0
 public void DeAllocateTriangle(HullTriangle tri)
 {
     Debug.Assert(m_tris[tri.id] == tri);
     m_tris[tri.id] = null;
 }
Beispiel #3
0
 public HullTriangle AllocateTriangle(int a, int b, int c)
 {
     HullTriangle tr = new HullTriangle(a, b, c);
     tr.id = m_tris.Count;
     m_tris.Add(tr);
     return tr;
 }
Beispiel #4
0
        void CheckIt(HullTriangle t)
        {
            //(void)t;

            Debug.Assert(m_tris[t.id] == t);
            for (int i = 0; i < 3; i++)
            {
                int i1 = (i + 1) % 3;
                int i2 = (i + 2) % 3;
                int a = t.At(i1);
                int b = t.At(i2);

                // release compile fix
                //(void)i1;
                //(void)i2;
                //(void)a;
                //(void)b;

                Debug.Assert(a != b);
                Debug.Assert(m_tris[t.n.At(i)].Neib(b, a) == t.id);
            }
        }
Beispiel #5
0
        void RemoveB2b(HullTriangle s, HullTriangle t)
        {
            B2bFix(s, t);
            DeAllocateTriangle(s);

            DeAllocateTriangle(t);
        }
Beispiel #6
0
 public void B2bFix(HullTriangle s, HullTriangle t)
 {
     for (int i = 0; i < 3; i++)
     {
         int i1 = (i + 1) % 3;
         int i2 = (i + 2) % 3;
         int a = s.At(i1);
         int b = s.At(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));
     }
 }