public bool GetPortal(GraphNode _other, System.Collections.Generic.List <Vector3> left, System.Collections.Generic.List <Vector3> right, bool backwards, out int aIndex, out int bIndex)
{
aIndex = -1;
bIndex = -1;
//If the nodes are in different graphs, this function has no idea on how to find a shared edge.
if (_other.GraphIndex != GraphIndex)
{
return(false);
}
TriangleMeshNode other = _other as TriangleMeshNode;
if (!backwards)
{
int first = -1;
int second = -1;
int av = GetVertexCount();
int bv = other.GetVertexCount();
/** \todo Maybe optimize with pa=av-1 instead of modulus... */
for (int a = 0; a < av; a++)
{
int va = GetVertexIndex(a);
for (int b = 0; b < bv; b++)
{
if (va == other.GetVertexIndex((b + 1) % bv) && GetVertexIndex((a + 1) % av) == other.GetVertexIndex(b))
{
first = a;
second = b;
a = av;
break;
}
}
}
aIndex = first;
bIndex = second;
if (first != -1)
{
if (left != null)
{
//All triangles should be clockwise so second is the rightmost vertex (seen from this node)
left.Add((Vector3)GetVertex(first));
right.Add((Vector3)GetVertex((first + 1) % av));
}
}
else
{
for (int i = 0; i < connections.Length; i++)
{
if (connections[i].GraphIndex != GraphIndex)
{
NodeLink3Node mid = connections[i] as NodeLink3Node;
if (mid != null && mid.GetOther(this) == other)
{
// We have found a node which is connected through a NodeLink3Node
if (left != null)
{
mid.GetPortal(other, left, right, false);
return(true);
}
}
}
}
return(false);
}
}
return(true);
}