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:
Niels Vaes 2024-05-19 12:46:17 +02:00 committed by GitHub
parent 90b588420f
commit c985d40ca0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3076,10 +3076,26 @@ 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
-- world space points we can use
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"],
y = object["mapY"] + point["y"] }
-- 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
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
-- we need to rotate the points around the center of the rects by an angle. UTILS.RotatePointAroundPivot was
@ -3096,6 +3112,7 @@ function ZONE_POLYGON:NewFromDrawing(DrawingName)
points = {p1, p2, p3, p4}
else
-- bring the Arrow code over from Shape/Polygon
-- something else that might be added in the future
end
end