public bool SimilarTriangle(Triangle *first, Triangle *second, out Cluster cluster, Vector3[] vertices)
    {
        int *      firstPtr  = (int *)first;
        int *      secondPtr = (int *)second;
        Vector2Int tempInt   = Vector2Int.zero;
        int *      sameValue = (int *)&tempInt;
        int        count     = 0;

        for (int i = 0; i < 3; ++i)
        {
            for (int j = 0; j < 3; ++j)
            {
                if (firstPtr[i] == secondPtr[j])
                {
                    if (count >= 2)
                    {
                        goto CONTINUELOGIC;
                    }
                    sameValue[count] = firstPtr[i];
                    count++;
                }
            }
        }
CONTINUELOGIC:
        if (count < 2)
        {
            cluster = new Cluster(0, 0, 0, 0);
            return(false);
        }
        else
        {
            int secondLastOne;
            for (secondLastOne = 0; secondLastOne < 3; ++secondLastOne)
            {
                if (secondPtr[secondLastOne] != sameValue[0] && secondPtr[secondLastOne] != sameValue[1])
                {
                    break;
                }
            }
            int firstLastOne;
            for (firstLastOne = 0; firstLastOne < 3; ++firstLastOne)
            {
                if (firstPtr[firstLastOne] != sameValue[0] && firstPtr[firstLastOne] != sameValue[1])
                {
                    break;
                }
            }
            cluster = new Cluster(firstPtr[firstLastOne], sameValue[0], sameValue[1], secondPtr[secondLastOne]);

            Vector3 originNormal  = Vector3.Cross(vertices[first->y] - vertices[first->x], vertices[first->z] - vertices[first->y]).normalized;
            Vector3 currentNormal = Vector3.Cross(vertices[cluster.y] - vertices[cluster.x], vertices[cluster.z] - vertices[cluster.y]).normalized;
            if (Vector3.Dot(originNormal, currentNormal) < 0)
            {
                int i = cluster.y;
                cluster.y = cluster.z;
                cluster.z = i;
            }
            return(true);
        }
    }
示例#2
0
 public void Add(Triangle *ptr)
 {
     if (start != null)
     {
         start->last = ptr;
         ptr->next   = start;
     }
     start = ptr;
     count++;
 }
示例#3
0
            public Triangle *Pop()
            {
                if (start->next != null)
                {
                    start->next->last = null;
                }
                Triangle *last = start;

                start = start->next;
                count--;
                return(last);
            }
 public Cluster DegenerateCluster(Triangle *triangle)
 {
     return(new Cluster(triangle->x, triangle->y, triangle->z, triangle->z));
 }
 public void GetAllTriangles(int[] indices, out Triangle *triangles, out int length)
 {
     triangles = (Triangle *)UnsafeUtility.AddressOf(ref indices[0]);
     length    = indices.Length / 3;
 }