diff --git a/Moose Development/Moose/Core/Astar.lua b/Moose Development/Moose/Core/Astar.lua index df7c7e786..7a6d5667e 100644 --- a/Moose Development/Moose/Core/Astar.lua +++ b/Moose Development/Moose/Core/Astar.lua @@ -246,9 +246,9 @@ end function ASTAR:AddNode(Node) self.nodes[Node.id]=Node - self.Nnodes=self.Nnodes+1 + self.Nnodes=self.Nnodes+1 - self:T(self.lid..string.format("Adding node UID=%d", Node.id)) + self:T3(self.lid..string.format("Adding node UID=%d", Node.id)) --Node.coordinate:MarkToAll(string.format("Node ID=%d", Node.id)) return self @@ -285,6 +285,13 @@ function ASTAR:AddNodeFromPathlineName(Pathline) local node=self:AddNodeFromCoordinate(coord) node.pathline=Pathline node.pathpoint=point + + local name=node.pathline and node.pathline.name or "N/A" + local idx=node.pathline and node.pathline:_GetPointIndex(node.pathpoint) or "N/A" + + self:T(self.lid..string.format("Adding node UID=%d pathline=%s [%s]", node.id, name, tostring(idx))) + node.coordinate:MarkToAll(string.format("Node ID=%d\npathline=%s [%s]", node.id, name, tostring(idx))) + end else @@ -599,6 +606,8 @@ function ASTAR.Pathline(nodeA, nodeB, distmax) if nodeA.pathpoint.name==nodeB.pathpoint.name then + -- Nodes are on the same pathline. We use the index to check if they are neighbours. + local pathline=nodeA.pathline local idxA=pathline:_GetPointIndex(nodeA.pathpoint) @@ -609,10 +618,24 @@ function ASTAR.Pathline(nodeA, nodeB, distmax) end else - local dist=nodeA.coordinate:Get2DDistance(nodeB.coordinate) + +-- local dist=nodeA.coordinate:Get2DDistance(nodeB.coordinate) +-- if dist1 and i<#Nodes then + + local n=Nodes[i-1] --#ASTAR.Node + local N=Nodes[i+1] --#ASTAR.Node + + -- Check if previous and next nodes are + if n.pathline and N.pathline and n.pathline.name==N.pathline.name and n.pathline.name~=pathline.name then + env.info("FF 100 "..pathline.name) + pathline=n.pathline + end + + end + + -- Add pathline to table (if it is not already in). + if not UTILS.IsAnyInTable(pathlines, {pathline}, "name") then + env.info(string.format("Adding pathline %s", pathline.name, tostring(UTILS.IsAnyInTable(pathlines, pathline)))) + table.insert(pathlines, pathline) + end end return pathlines @@ -1024,6 +1081,7 @@ function ASTAR:_HeuristicCost(nodeA, nodeB) local cost=nodeA.cost[nodeB.id] if cost~=nil then self.ncostcache=self.ncostcache+1 + self:T(self.lid..string.format("Cost nodeA=%d --> nodeB=%d = %.1f (Cashed!)", nodeA.id, nodeB.id, cost)) return cost end diff --git a/Moose Development/Moose/Ops/FlightGroup.lua b/Moose Development/Moose/Ops/FlightGroup.lua index eb68cd0e3..8df3be56a 100644 --- a/Moose Development/Moose/Ops/FlightGroup.lua +++ b/Moose Development/Moose/Ops/FlightGroup.lua @@ -3898,6 +3898,7 @@ function FLIGHTGROUP:_InitGroup(Template) if not self.isAI then self.menu=self.menu or {} self.menu.atc=self.menu.atc or {} --#table + self.menu.nav=self.menu.nav or {} --#table self.menu.atc.root=self.menu.atc.root or MENU_GROUP:New(self.group, "ATC") --Core.Menu#MENU_GROUP self.menu.atc.help=self.menu.atc.help or MENU_GROUP:New(self.group, "Help", self.menu.atc.root) --Core.Menu#MENU_GROUP self.menu.nav.root=self.menu.nav.root or MENU_GROUP:New(self.group, "Navigation") --Core.Menu#MENU_GROUP