public void AdvanceClosestBackwards()
        {
            PathTriangle closest = backwardsTails.Dequeue();

            List <PathTriangle> circumjacent = closest.GetReachableCircumjacent();
            PathTriangle        t;
            int count = circumjacent.Count;

            for (int i = 0; i < count; ++i)
            {
                t = circumjacent[i];
                if (t.LastUsedInBackwardsPathIteration < pathIteration)
                {
                    if (t.LastUsedInPathIteration >= pathIteration)
                    {
                        reachedTarget = true;
                        forwardPath   = t;
                        backwardsPath = closest;
                        break;
                    }
                    else
                    {
                        t.SetUsedInBackwardsPathIteration(pathIteration);
                        t.pathParent   = closest;
                        t.prevDistance = closest.prevDistance + closest.DistanceTo(t);
                        AddTailUnchecked(t, backwardsTails);
                    }
                }
            }
        }
예제 #2
0
 public Path(PathTriangle current, Path parent, float distanceToNode)
 {
     depth            = parent.depth + 1;
     this.current     = current;
     target           = parent.target;
     this.parent      = parent;
     previousDistance = distanceToNode;
     distance         = current.DistanceToTarget(target);
 }
        private MarchingCubesPathfinder(PathTriangle start, PathTriangle target, PathAccuracy accuracy, float estimatedStepProgress = 0.5f)
        {
            this.start   = start;
            this.target  = target;
            pathAccuracy = AccuracyFactor(accuracy);
            float estimatedLength    = start.DistanceToTarget(target);
            int   estimatedQueueSize = (int)Mathf.Clamp(estimatedStepProgress * estimatedLength * (1 - (pathAccuracy / 2)), 10, 10000);

            pathTails      = new BinaryHeap <float, PathTriangle>(float.MinValue, float.MaxValue, estimatedQueueSize / 2);
            backwardsTails = new BinaryHeap <float, PathTriangle>(float.MinValue, float.MaxValue, estimatedQueueSize / 2);
        }
예제 #4
0
 public Path(PathTriangle current, PathTriangle target)
 {
     parent       = null;
     this.current = current;
     this.target  = target;
 }
예제 #5
0
 public Path Advance(PathTriangle t)
 {
     return(new Path(t, this, previousDistance + t.DistanceTo(current)));
 }
 public static IList <PathTriangle> FindPath(PathTriangle start, PathTriangle target, PathAccuracy accuracy)
 {
     return(new MarchingCubesPathfinder(start, target, accuracy).GetPath());
 }
        public void AddTailUnchecked(PathTriangle p, BinaryHeap <float, PathTriangle> addHere)
        {
            float key = p.prevDistance * pathAccuracy + p.DistanceToTarget(target);

            addHere.Enqueue(key, p);
        }
 public bool DoesFieldCompletePath(PathTriangle tri)
 {
     return(tri.LastUsedInBackwardsPathIteration == tri.LastUsedInPathIteration);
 }