mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
A*
Further optimized by using DCS API land.isVisible instead of Moose IsLoS function.
This commit is contained in:
@@ -154,7 +154,7 @@ ASTAR.INF=1/0
|
||||
|
||||
--- ASTAR class version.
|
||||
-- @field #string version
|
||||
ASTAR.version="0.2.0"
|
||||
ASTAR.version="0.3.0"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- TODO list
|
||||
@@ -469,25 +469,29 @@ function ASTAR.LoS(nodeA, nodeB, corridor)
|
||||
local dx=corridor and corridor/2 or nil
|
||||
local dy=dx
|
||||
|
||||
local cA=nodeA.coordinate:SetAltitude(0, true)
|
||||
local cB=nodeB.coordinate:SetAltitude(0, true)
|
||||
local cA=nodeA.coordinate:GetVec3()
|
||||
local cB=nodeB.coordinate:GetVec3()
|
||||
cA.y=offset
|
||||
cB.y=offset
|
||||
|
||||
local los=cA:IsLOS(cB, offset)
|
||||
local los=land.isVisible(cA, cB)
|
||||
|
||||
if los and corridor then
|
||||
local heading=cA:HeadingTo(cB)
|
||||
|
||||
-- Heading from A to B.
|
||||
local heading=nodeA.coordinate:HeadingTo(nodeB.coordinate)
|
||||
|
||||
local Ap=cA:Translate(dx, heading+90)
|
||||
local Bp=cB:Translate(dx, heading+90)
|
||||
local Ap=UTILS.VecTranslate(cA, dx, heading+90)
|
||||
local Bp=UTILS.VecTranslate(cB, dx, heading+90)
|
||||
|
||||
los=Ap:IsLOS(Bp, offset)
|
||||
los=land.isVisible(Ap, Bp) --Ap:IsLOS(Bp, offset)
|
||||
|
||||
if los then
|
||||
|
||||
local Am=cA:Translate(dy, heading-90)
|
||||
local Bm=cB:Translate(dy, heading-90)
|
||||
local Am=UTILS.VecTranslate(cA, dx, heading-90)
|
||||
local Bm=UTILS.VecTranslate(cB, dx, heading-90)
|
||||
|
||||
los=Am:IsLOS(Bm, offset)
|
||||
los=land.isVisible(Am, Bm)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -587,6 +591,7 @@ function ASTAR:FindStartNode()
|
||||
self.startNode=node
|
||||
|
||||
if dist>1000 then
|
||||
self:I(self.lid.."Adding start node to node grid!")
|
||||
self:AddNode(node)
|
||||
end
|
||||
|
||||
@@ -604,6 +609,7 @@ function ASTAR:FindEndNode()
|
||||
self.endNode=node
|
||||
|
||||
if dist>1000 then
|
||||
self:I(self.lid.."Adding end node to node grid!")
|
||||
self:AddNode(node)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user