protected virtual void Trace (PathNode from) {
int count = 0;
PathNode c = from;
while (c != null) {
c = c.parent;
count++;
if (count > 1024) {
Debug.LogWarning ("Inifinity loop? >1024 node path. Remove this message if you really have that long paths (Path.cs, Trace function)");
break;
}
}
//Ensure capacities for lists
AstarProfiler.StartProfile ("Check List Capacities");
if (path.Capacity < count) path.Capacity = count;
if (vectorPath.Capacity < count) vectorPath.Capacity = count;
AstarProfiler.EndProfile ();
c = from;
for (int i = 0;i<count;i++) {
path.Add (c.node);
c = c.parent;
}
int half = count/2;
for (int i=0;i<half;i++) {
GraphNode tmp = path[i];
path[i] = path[count-i-1];
path[count - i - 1] = tmp;
}
for (int i=0;i<count;i++) {
vectorPath.Add ((Vector3)path[i].position);
}
}