private void connectVerts(Dictionary<Vector3, int> knownPositions, int[] verts)
{
// Array mapped to changed vertices
bool[] changed = {false, false, false};
// TODO: Remove foreach
// Loop through keys to check vertices
foreach(Vector3 key in knownPositions.Keys)
{
// All vertices changed
if(changed[0] && changed[1] && changed[2])
{
break;
}
// indices always size 3
for(int i = 0; i < 3; ++i)
{
if(!changed[i] && key.Equals(this.vertices[verts[i]]))
{
if(this.movementLookup[verts[i]] == null)
{
// Still not happy with the Vertice creation here....
// It happens a lot, can we clean this up?
this.movementLookup[verts[i]] = new Vertice(knownPositions[key], true, this);
}
verts[i] = knownPositions[key];
changed[i] = true;
}
}
}
// Array size always 3
for(int i = 0; i < 3; ++i)
{
// Check if not changed
if(!changed[i])
{
// Add to vistied vertice
knownPositions.Add (this.vertices[verts[i]], verts[i]);
}
// check if movmeent lookup has vert
if(this.movementLookup[verts[i]] == null)
{
// add new vertice
// Still not happy with the Vertice creation here....
// It happens a lot, can we clean this up?
this.movementLookup[verts[i]] = new Vertice(verts[i], false, this);
}
}
}