mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Fix when DCS adds duplicate points to the points table of a drawing resulting in wrong triangulation (#2128)
* Adding a new TerminalType (100)that seems to be introduced in the update that brought Muwaffaq Salti. The base has a couple of spots (like 04, 05, 06) that can only accommodate smaller type fixed wing aircraft, like the F-16, but not bigger types like the Warthog of the Strike Eagle. Because we weren't checking for this new type, spawning in these particular spots always resulted in an airstart, because `_CheckTerminalType` would always return `false` * Adding Shapes over from old MOOSE branch * cleanup * adding HEXtoRGBA * removing Arrow.lua, it's part of Polygon.lua * Fix when DCS adds duplicate points to the `points` table of a drawing, resulting in wrong triangulation
This commit is contained in:
parent
90b588420f
commit
c985d40ca0
@ -3076,9 +3076,25 @@ function ZONE_POLYGON:NewFromDrawing(DrawingName)
|
|||||||
-- points for the drawings are saved in local space, so add the object's map x and y coordinates to get
|
-- points for the drawings are saved in local space, so add the object's map x and y coordinates to get
|
||||||
-- world space points we can use
|
-- world space points we can use
|
||||||
for _, point in UTILS.spairs(object["points"]) do
|
for _, point in UTILS.spairs(object["points"]) do
|
||||||
|
-- check if we want to skip adding a point
|
||||||
|
local skip = false
|
||||||
local p = {x = object["mapX"] + point["x"],
|
local p = {x = object["mapX"] + point["x"],
|
||||||
y = object["mapY"] + point["y"] }
|
y = object["mapY"] + point["y"] }
|
||||||
table.add(points, p)
|
|
||||||
|
-- Check if the same coordinates already exist in the list, skip if they do
|
||||||
|
-- This can happen when drawing a Polygon in Free mode, DCS adds points on
|
||||||
|
-- top of each other that are in the `mission` file, but not visible in the
|
||||||
|
-- Mission Editor
|
||||||
|
for _, pt in pairs(points) do
|
||||||
|
if pt.x == p.x and pt.y == p.y then
|
||||||
|
skip = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- if it's a unique point, add it
|
||||||
|
if not skip then
|
||||||
|
table.add(points, p)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
elseif object["polygonMode"] == "rect" then
|
elseif object["polygonMode"] == "rect" then
|
||||||
-- the points for a rect are saved as local coordinates with an angle. To get the world space points from this
|
-- the points for a rect are saved as local coordinates with an angle. To get the world space points from this
|
||||||
@ -3096,6 +3112,7 @@ function ZONE_POLYGON:NewFromDrawing(DrawingName)
|
|||||||
|
|
||||||
points = {p1, p2, p3, p4}
|
points = {p1, p2, p3, p4}
|
||||||
else
|
else
|
||||||
|
-- bring the Arrow code over from Shape/Polygon
|
||||||
-- something else that might be added in the future
|
-- something else that might be added in the future
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user