GetConnectionSpecialCost() public method

public GetConnectionSpecialCost ( GraphNode a, GraphNode b, uint currentCost ) : uint
a GraphNode
b GraphNode
currentCost uint
return uint
 static int GetConnectionSpecialCost(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 4);
         Pathfinding.Path      obj  = (Pathfinding.Path)ToLua.CheckObject <Pathfinding.Path>(L, 1);
         Pathfinding.GraphNode arg0 = (Pathfinding.GraphNode)ToLua.CheckObject <Pathfinding.GraphNode>(L, 2);
         Pathfinding.GraphNode arg1 = (Pathfinding.GraphNode)ToLua.CheckObject <Pathfinding.GraphNode>(L, 3);
         uint arg2 = (uint)LuaDLL.luaL_checknumber(L, 4);
         uint o    = obj.GetConnectionSpecialCost(arg0, arg1, arg2);
         LuaDLL.lua_pushnumber(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Beispiel #2
0
        public override void Open(Path path, PathNode pathNode, PathHandler handler)
        {
            if (connections == null)
            {
                return;
            }

            // Flag2 indicates if this node needs special treatment
            // with regard to connection costs
            bool flag2 = pathNode.flag2;

            // Loop through all connections
            for (int i = connections.Length - 1; i >= 0; i--)
            {
                var conn  = connections[i];
                var other = conn.node;

                // Make sure we can traverse the neighbour
                if (path.CanTraverse(conn.node))
                {
                    PathNode pathOther = handler.GetPathNode(conn.node);

                    // Fast path out, worth it for triangle mesh nodes since they usually have degree 2 or 3
                    if (pathOther == pathNode.parent)
                    {
                        continue;
                    }

                    uint cost = conn.cost;

                    if (flag2 || pathOther.flag2)
                    {
                        // Get special connection cost from the path
                        // This is used by the start and end nodes
                        cost = path.GetConnectionSpecialCost(this, conn.node, cost);
                    }

                    // Test if we have seen the other node before
                    if (pathOther.pathID != handler.PathID)
                    {
                        // We have not seen the other node before
                        // So the path from the start through this node to the other node
                        // must be the shortest one so far

                        // Might not be assigned
                        pathOther.node = conn.node;

                        pathOther.parent = pathNode;
                        pathOther.pathID = handler.PathID;

                        pathOther.cost = cost;

                        pathOther.H = path.CalculateHScore(other);
                        pathOther.UpdateG(path);

                        handler.heap.Add(pathOther);
                    }
                    else
                    {
                        // If not we can test if the path from this node to the other one is a better one than the one already used
                        if (pathNode.G + cost + path.GetTraversalCost(other) < pathOther.G)
                        {
                            pathOther.cost   = cost;
                            pathOther.parent = pathNode;

                            other.UpdateRecursiveG(path, pathOther, handler);
                        }
                    }
                }
            }
        }
        public override void Open(Path path, PathNode pathNode, PathHandler handler)
        {
            if (connections == null)
            {
                return;
            }

            bool flag2 = pathNode.flag2;

            for (int i = connections.Length - 1; i >= 0; i--)
            {
                GraphNode other = connections[i];

                if (path.CanTraverse(other))
                {
                    PathNode pathOther = handler.GetPathNode(other);

                    //Fast path out, worth it for triangle mesh nodes since they usually have degree 2 or 3
                    if (pathOther == pathNode.parent)
                    {
                        continue;
                    }

                    uint cost = connectionCosts[i];

                    if (flag2 || pathOther.flag2)
                    {
                        cost = path.GetConnectionSpecialCost(this, other, cost);
                    }

                    if (pathOther.pathID != handler.PathID)
                    {
                        //Might not be assigned
                        pathOther.node = other;

                        pathOther.parent = pathNode;
                        pathOther.pathID = handler.PathID;

                        pathOther.cost = cost;

                        pathOther.H = path.CalculateHScore(other);
                        other.UpdateG(path, pathOther);

                        handler.PushNode(pathOther);
                    }
                    else
                    {
                        //If not we can test if the path from this node to the other one is a better one than the one already used
                        if (pathNode.G + cost + path.GetTraversalCost(other) < pathOther.G)
                        {
                            pathOther.cost   = cost;
                            pathOther.parent = pathNode;

                            other.UpdateRecursiveG(path, pathOther, handler);
                            //handler.PushNode (pathOther);
                        }
                        else if (pathOther.G + cost + path.GetTraversalCost(this) < pathNode.G && other.ContainsConnection(this))
                        {
                            //Or if the path from the other node to this one is better

                            pathNode.parent = pathOther;
                            pathNode.cost   = cost;

                            UpdateRecursiveG(path, pathNode, handler);

                            //handler.PushNode (pathNode);
                        }
                    }
                }
            }
        }
		public override void Open (Path path, PathNode pathNode, PathHandler handler) {
			if (connections == null) return;

			// Flag2 indicates if this node needs special treatment
			// with regard to connection costs
			bool flag2 = pathNode.flag2;

			// Loop through all connections
			for (int i=connections.Length-1;i >= 0;i--) {
				GraphNode other = connections[i];

				// Make sure we can traverse the neighbour
				if (path.CanTraverse (other)) {

					PathNode pathOther = handler.GetPathNode (other);

					// Fast path out, worth it for triangle mesh nodes since they usually have degree 2 or 3
					if (pathOther == pathNode.parent) {
						continue;
					}

					uint cost = connectionCosts[i];

					if (flag2 || pathOther.flag2) {
						// Get special connection cost from the path
						// This is used by the start and end nodes
						cost = path.GetConnectionSpecialCost (this,other,cost);
					}

					// Test if we have seen the other node before
					if (pathOther.pathID != handler.PathID) {
						// We have not seen the other node before
						// So the path from the start through this node to the other node
						// must be the shortest one so far

						// Might not be assigned
						pathOther.node = other;

						pathOther.parent = pathNode;
						pathOther.pathID = handler.PathID;

						pathOther.cost = cost;

						pathOther.H = path.CalculateHScore (other);
						other.UpdateG (path, pathOther);

						handler.PushNode (pathOther);
					} else {

						// If not we can test if the path from this node to the other one is a better one than the one already used
						if (pathNode.G + cost + path.GetTraversalCost(other) < pathOther.G) {

							pathOther.cost = cost;
							pathOther.parent = pathNode;

							other.UpdateRecursiveG (path, pathOther,handler);
						}
						else if (pathOther.G+cost+path.GetTraversalCost(this) < pathNode.G && other.ContainsConnection (this)) {
							// Or if the path from the other node to this one is better

							pathNode.parent = pathOther;
							pathNode.cost = cost;

							UpdateRecursiveG (path, pathNode,handler);
						}
					}
				}
			}
		}
		public override void Open (Path path, PathNode pathNode, PathHandler handler) {
			if (connections == null) return;
			
			bool flag2 = pathNode.flag2;
			
			for (int i=connections.Length-1;i >= 0;i--) {
				GraphNode other = connections[i];
				
				if (path.CanTraverse (other)) {
					
					PathNode pathOther = handler.GetPathNode (other);
					
					//Fast path out, worth it for triangle mesh nodes since they usually have degree 2 or 3
					if (pathOther == pathNode.parent) {
						continue;
					}
					
					uint cost = connectionCosts[i];
					
					if (flag2 || pathOther.flag2) {
						cost = path.GetConnectionSpecialCost (this,other,cost);
						
					}
					
					if (pathOther.pathID != handler.PathID) {
						//Might not be assigned
						pathOther.node = other;
						
						pathOther.parent = pathNode;
						pathOther.pathID = handler.PathID;
						
						pathOther.cost = cost;
						
						pathOther.H = path.CalculateHScore (other);
						other.UpdateG (path, pathOther);
						
						handler.PushNode (pathOther);
					} else {
						//If not we can test if the path from this node to the other one is a better one than the one already used
						if (pathNode.G + cost + path.GetTraversalCost(other) < pathOther.G) {
							
							pathOther.cost = cost;
							pathOther.parent = pathNode;
							
							other.UpdateRecursiveG (path, pathOther,handler);
							//handler.PushNode (pathOther);
							
						}
						else if (pathOther.G+cost+path.GetTraversalCost(this) < pathNode.G && other.ContainsConnection (this)) {
							//Or if the path from the other node to this one is better
							
							pathNode.parent = pathOther;
							pathNode.cost = cost;
							
							UpdateRecursiveG (path, pathNode,handler);
							
							//handler.PushNode (pathNode);
						}
					}
				}
			}
		}
 public override void Open(Path path, PathNode pathNode, PathHandler handler)
 {
     if (this.connections == null)
     {
         return;
     }
     bool flag = pathNode.flag2;
     for (int i = this.connections.Length - 1; i >= 0; i--)
     {
         GraphNode graphNode = this.connections[i];
         if (path.CanTraverse(graphNode))
         {
             PathNode pathNode2 = handler.GetPathNode(graphNode);
             if (pathNode2 != pathNode.parent)
             {
                 uint num = this.connectionCosts[i];
                 if (flag || pathNode2.flag2)
                 {
                     num = path.GetConnectionSpecialCost(this, graphNode, num);
                 }
                 if (pathNode2.pathID != handler.PathID)
                 {
                     pathNode2.node = graphNode;
                     pathNode2.parent = pathNode;
                     pathNode2.pathID = handler.PathID;
                     pathNode2.cost = num;
                     pathNode2.H = path.CalculateHScore(graphNode);
                     graphNode.UpdateG(path, pathNode2);
                     handler.PushNode(pathNode2);
                 }
                 else if (pathNode.G + num + path.GetTraversalCost(graphNode) < pathNode2.G)
                 {
                     pathNode2.cost = num;
                     pathNode2.parent = pathNode;
                     graphNode.UpdateRecursiveG(path, pathNode2, handler);
                 }
                 else if (pathNode2.G + num + path.GetTraversalCost(this) < pathNode.G && graphNode.ContainsConnection(this))
                 {
                     pathNode.parent = pathNode2;
                     pathNode.cost = num;
                     this.UpdateRecursiveG(path, pathNode, handler);
                 }
             }
         }
     }
 }