mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-20 07:43:07 +00:00
Nav updates
This commit is contained in:
@@ -2059,6 +2059,40 @@ do -- COORDINATE
|
||||
|
||||
return Path, Way, GotPath
|
||||
end
|
||||
|
||||
--- Returns a table of coordinates to a destination using only roads or railroads.
|
||||
-- The first point is the closest point on road of the given coordinate.
|
||||
-- By default, the last point is the closest point on road of the ToCoord. Hence, the coordinate itself and the final ToCoord are not necessarily included in the path.
|
||||
-- @param #COORDINATE self
|
||||
-- @param #COORDINATE ToCoord Coordinate of destination.
|
||||
-- @param #boolean IncludeEndpoints (Optional) Include the coordinate itself and the ToCoordinate in the path.
|
||||
-- @param #boolean Railroad (Optional) If true, path on railroad is returned. Default false.
|
||||
-- @return Core.Pathline#PATHLINE Pathline containing the points on road. If no path on road can be found, nil is returned or just the endpoints.
|
||||
function COORDINATE:GetPathlineOnRoad(ToCoord, IncludeEndpoints, Railroad)
|
||||
|
||||
-- Set road type.
|
||||
local RoadType="roads"
|
||||
if Railroad==true then
|
||||
RoadType="railroads"
|
||||
end
|
||||
|
||||
-- DCS API function returning a table of vec2.
|
||||
local path = land.findPathOnRoads(RoadType, self.x, self.z, ToCoord.x, ToCoord.z)
|
||||
|
||||
if IncludeEndpoints then
|
||||
path=path or {}
|
||||
table.insert(path, 1, self:GetVec2())
|
||||
table.insert(path, ToCoord:GetVec2())
|
||||
end
|
||||
|
||||
local pathline=nil
|
||||
if path then
|
||||
pathline=PATHLINE:NewFromVec2Array(RoadType, path)
|
||||
end
|
||||
|
||||
return pathline
|
||||
end
|
||||
|
||||
|
||||
--- Gets the surface type at the coordinate.
|
||||
-- @param #COORDINATE self
|
||||
|
||||
@@ -133,7 +133,7 @@ VECTOR = {
|
||||
|
||||
--- VECTOR class version.
|
||||
-- @field #string version
|
||||
VECTOR.version="0.0.3"
|
||||
VECTOR.version="0.1.0"
|
||||
|
||||
--- VECTOR unique ID
|
||||
_VECTORID=0
|
||||
@@ -147,7 +147,7 @@ VECTOR.__index = VECTOR
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
-- TODO: 3D rotation
|
||||
-- TODO: Markers
|
||||
-- DONE: Markers
|
||||
-- TODO: Documentation
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -966,10 +966,9 @@ function VECTOR:GetPathOnRoad(Vec)
|
||||
local vec1=self:GetVec2()
|
||||
local vec2=Vec:GetVec2()
|
||||
|
||||
local path=nil
|
||||
|
||||
local vec2points=land.findPathOnRoads("roads", vec1.x , vec1.y, vec2.x, vec2.y)
|
||||
|
||||
local path=nil
|
||||
if vec2points then
|
||||
path=PATHLINE:NewFromVec2Array("Road", vec2points)
|
||||
end
|
||||
@@ -1365,10 +1364,6 @@ end
|
||||
-- @param #VECTOR b Vector b.
|
||||
-- @return #boolean If `true`, both vectors are equal
|
||||
function VECTOR.__eq(a, b)
|
||||
--assert(VECTOR._IsVector(a) and VECTOR._IsVector(b), "ERROR in VECTOR.__eq: wrong argument types: (expected <vector> and <vector>)")
|
||||
env.info("FF __eq",showMessageBox)
|
||||
BASE:I(a)
|
||||
BASE:I(b)
|
||||
return a.x==b.x and a.y==b.y and a.z==b.z
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user