示例#1
0
        private void GenerateIndex(Mesh mesh)
        {
            TriangleArray triangles = mesh.GetSaneTriangles(0);

            for (int i = 0; i < triangles.Length; ++i)
            {
                IndexedTriangle triangle = triangles[i];

                for (int j = 0; j < 3; ++j)
                {
                    var edge = new IndexedEdge(
                        triangle[j],
                        triangle[(j + 1) % 3]
                        );
                    edgeToTriangleMap.Add(edge, i);
                }
            }
        }
示例#2
0
        /// Gets neighbor triangle index
        private int GetNeighborTriangle(int intersectedEdge)
        {
            // Note the reverse order of start and end indices
            IndexedEdge edge = new IndexedEdge(
                CurrentTriangle[(intersectedEdge + 1) % 3],
                CurrentTriangle[intersectedEdge]
                );

            int neighbor = meshIndex.FindTriangleByEdge(edge);

#if UNITY_EDITOR
            if (debugDrawEnabled)
            {
                mesh.DrawTriangle(neighbor, Color.yellow);
            }
#endif
            return(neighbor);
        }
示例#3
0
 public int FindTriangleByEdge(IndexedEdge edge) => edgeToTriangleMap[edge];