public void InitMeshConnections()
{
Profiler.BeginSample("Generate Mesh Connections");
// a half edge representation would be nice, but really just care about adjacentcy for now..
vertexConnections = new List<int>[meshFilter.sharedMesh.vertexCount];
for (int i = 0; i < vertexConnections.Length; ++i)
{
vertexConnections[i] = new List<int>();
}
int[] tris = meshFilter.sharedMesh.triangles;
for (int i = 0; i < tris.Length; i=i+3)
{
int c0 = tris[i];
int c1 = tris[i + 1];
int c2 = tris[i + 2];
List<int> l = vertexConnections[c0];
if (!l.Contains(c1))
{
l.Add(c1);
}
if (!l.Contains(c2))
{
l.Add(c2);
}
l = vertexConnections[c1];
if (!l.Contains(c2))
{
l.Add(c2);
}
if (!l.Contains(c0))
{
l.Add(c0);
}
l = vertexConnections[c2];
if (!l.Contains(c1))
{
l.Add(c1);
}
if (!l.Contains(c0))
{
l.Add(c0);
}
}
Profiler.EndSample();
}