#ZONE_ELASTIC - Fix zone filling

This commit is contained in:
Applevangelist 2025-03-06 12:25:53 +01:00
parent c808e4a4e2
commit 45ebf9a3c7

View File

@ -144,7 +144,7 @@ ZONE_BASE = {
-- @return #ZONE_BASE self
function ZONE_BASE:New( ZoneName )
local self = BASE:Inherit( self, FSM:New() )
self:F( ZoneName )
--self:F( ZoneName )
self.ZoneName = ZoneName
@ -157,7 +157,7 @@ end
-- @param #ZONE_BASE self
-- @return #string The name of the zone.
function ZONE_BASE:GetName()
self:F2()
--self:F2()
return self.ZoneName
end
@ -167,7 +167,7 @@ end
-- @param #string ZoneName The name of the zone.
-- @return #ZONE_BASE
function ZONE_BASE:SetName( ZoneName )
self:F2()
--self:F2()
self.ZoneName = ZoneName
end
@ -177,7 +177,7 @@ end
-- @param DCS#Vec2 Vec2 The Vec2 to test.
-- @return #boolean true if the Vec2 is within the zone.
function ZONE_BASE:IsVec2InZone( Vec2 )
self:F2( Vec2 )
--self:F2( Vec2 )
return false
end
@ -232,13 +232,13 @@ end
-- @param DCS#Distance Height The height to add to the land height where the center of the zone is located.
-- @return Core.Point#POINT_VEC2 The PointVec2 of the zone.
function ZONE_BASE:GetPointVec2()
self:F2( self.ZoneName )
--self:F2( self.ZoneName )
local Vec2 = self:GetVec2()
local PointVec2 = POINT_VEC2:NewFromVec2( Vec2 )
self:T2( { PointVec2 } )
--self:T2( { PointVec2 } )
return PointVec2
end
@ -248,7 +248,7 @@ end
-- @param DCS#Distance Height The height to add to the land height where the center of the zone is located.
-- @return DCS#Vec3 The Vec3 of the zone.
function ZONE_BASE:GetVec3( Height )
self:F2( self.ZoneName )
--self:F2( self.ZoneName )
Height = Height or 0
@ -256,7 +256,7 @@ function ZONE_BASE:GetVec3( Height )
local Vec3 = { x = Vec2.x, y = Height and Height or land.getHeight( self:GetVec2() ), z = Vec2.y }
self:T2( { Vec3 } )
--self:T2( { Vec3 } )
return Vec3
end
@ -266,13 +266,13 @@ end
-- @param DCS#Distance Height The height to add to the land height where the center of the zone is located.
-- @return Core.Point#POINT_VEC3 The PointVec3 of the zone.
function ZONE_BASE:GetPointVec3( Height )
self:F2( self.ZoneName )
--self:F2( self.ZoneName )
local Vec3 = self:GetVec3( Height )
local PointVec3 = POINT_VEC3:NewFromVec3( Vec3 )
self:T2( { PointVec3 } )
--self:T2( { PointVec3 } )
return PointVec3
end
@ -282,7 +282,7 @@ end
-- @param DCS#Distance Height The height to add to the land height where the center of the zone is located.
-- @return Core.Point#COORDINATE The Coordinate of the zone.
function ZONE_BASE:GetCoordinate( Height ) --R2.1
self:F2(self.ZoneName)
--self:F2(self.ZoneName)
local Vec3 = self:GetVec3( Height )
@ -363,7 +363,7 @@ end
--- Bound the zone boundaries with a tires.
-- @param #ZONE_BASE self
function ZONE_BASE:BoundZone()
self:F2()
--self:F2()
end
--- Set draw coalition of zone.
@ -510,7 +510,7 @@ end
-- @param #ZONE_BASE self
-- @param Utilities.Utils#SMOKECOLOR SmokeColor The smoke color.
function ZONE_BASE:SmokeZone( SmokeColor )
self:F2( SmokeColor )
--self:F2( SmokeColor )
end
@ -519,7 +519,7 @@ end
-- @param #number ZoneProbability A value between 0 and 1. 0 = 0% and 1 = 100% probability.
-- @return #ZONE_BASE self
function ZONE_BASE:SetZoneProbability( ZoneProbability )
self:F( { self:GetName(), ZoneProbability = ZoneProbability } )
--self:F( { self:GetName(), ZoneProbability = ZoneProbability } )
self.ZoneProbability = ZoneProbability or 1
return self
@ -529,7 +529,7 @@ end
-- @param #ZONE_BASE self
-- @return #number A value between 0 and 1. 0 = 0% and 1 = 100% probability.
function ZONE_BASE:GetZoneProbability()
self:F2()
--self:F2()
return self.ZoneProbability
end
@ -560,7 +560,7 @@ end
-- -- The result should be that Zone1 would be more probable selected than Zone2.
--
function ZONE_BASE:GetZoneMaybe()
self:F2()
--self:F2()
local Randomization = math.random()
if Randomization <= self.ZoneProbability then
@ -791,7 +791,7 @@ function ZONE_RADIUS:New( ZoneName, Vec2, Radius, DoNotRegisterZone )
-- Inherit ZONE_BASE.
local self = BASE:Inherit( self, ZONE_BASE:New( ZoneName ) ) -- #ZONE_RADIUS
self:F( { ZoneName, Vec2, Radius } )
--self:F( { ZoneName, Vec2, Radius } )
self.Radius = Radius
self.Vec2 = Vec2
@ -947,7 +947,7 @@ end
-- @param #number AddOffSet (optional) The angle to be added for the smoking start position.
-- @return #ZONE_RADIUS self
function ZONE_RADIUS:SmokeZone( SmokeColor, Points, AddHeight, AngleOffset )
self:F2( SmokeColor )
--self:F2( SmokeColor )
local Point = {}
local Vec2 = self:GetVec2()
@ -978,7 +978,7 @@ end
-- @param #number AddHeight (optional) The height to be added for the smoke.
-- @return #ZONE_RADIUS self
function ZONE_RADIUS:FlareZone( FlareColor, Points, Azimuth, AddHeight )
self:F2( { FlareColor, Azimuth } )
--self:F2( { FlareColor, Azimuth } )
local Point = {}
local Vec2 = self:GetVec2()
@ -1004,9 +1004,9 @@ end
-- @param #ZONE_RADIUS self
-- @return DCS#Distance The radius of the zone.
function ZONE_RADIUS:GetRadius()
self:F2( self.ZoneName )
--self:F2( self.ZoneName )
self:T2( { self.Radius } )
--self:T2( { self.Radius } )
return self.Radius
end
@ -1016,10 +1016,10 @@ end
-- @param DCS#Distance Radius The radius of the zone.
-- @return DCS#Distance The radius of the zone.
function ZONE_RADIUS:SetRadius( Radius )
self:F2( self.ZoneName )
--self:F2( self.ZoneName )
self.Radius = Radius
self:T2( { self.Radius } )
--self:T2( { self.Radius } )
return self.Radius
end
@ -1028,9 +1028,9 @@ end
-- @param #ZONE_RADIUS self
-- @return DCS#Vec2 The location of the zone.
function ZONE_RADIUS:GetVec2()
self:F2( self.ZoneName )
--self:F2( self.ZoneName )
self:T2( { self.Vec2 } )
--self:T2( { self.Vec2 } )
return self.Vec2
end
@ -1040,11 +1040,11 @@ end
-- @param DCS#Vec2 Vec2 The new location of the zone.
-- @return DCS#Vec2 The new location of the zone.
function ZONE_RADIUS:SetVec2( Vec2 )
self:F2( self.ZoneName )
--self:F2( self.ZoneName )
self.Vec2 = Vec2
self:T2( { self.Vec2 } )
--self:T2( { self.Vec2 } )
return self.Vec2
end
@ -1054,14 +1054,14 @@ end
-- @param DCS#Distance Height The height to add to the land height where the center of the zone is located.
-- @return DCS#Vec3 The point of the zone.
function ZONE_RADIUS:GetVec3( Height )
self:F2( { self.ZoneName, Height } )
--self:F2( { self.ZoneName, Height } )
Height = Height or 0
local Vec2 = self:GetVec2()
local Vec3 = { x = Vec2.x, y = land.getHeight( self:GetVec2() ) + Height, z = Vec2.y }
self:T2( { Vec3 } )
--self:T2( { Vec3 } )
return Vec3
end
@ -1138,7 +1138,7 @@ function ZONE_RADIUS:Scan( ObjectCategories, UnitCategories )
self.ScanData.Units[ZoneObject] = ZoneObject
self:F2( { Name = ZoneObject:getName(), Coalition = CoalitionDCSUnit } )
--self:F2( { Name = ZoneObject:getName(), Coalition = CoalitionDCSUnit } )
end
end
@ -1149,7 +1149,7 @@ function ZONE_RADIUS:Scan( ObjectCategories, UnitCategories )
self.ScanData.Scenery[SceneryType] = self.ScanData.Scenery[SceneryType] or {}
self.ScanData.Scenery[SceneryType][SceneryName] = SCENERY:Register( tostring(SceneryName), ZoneObject)
table.insert(self.ScanData.SceneryTable,self.ScanData.Scenery[SceneryType][SceneryName] )
self:T( { SCENERY = self.ScanData.Scenery[SceneryType][SceneryName] } )
--self:T( { SCENERY = self.ScanData.Scenery[SceneryType][SceneryName] } )
end
end
@ -1409,7 +1409,7 @@ function ZONE_RADIUS:SearchZone( EvaluateFunction, ObjectCategories )
local ZoneCoord = self:GetCoordinate()
local ZoneRadius = self:GetRadius()
self:F({ZoneCoord = ZoneCoord, ZoneRadius = ZoneRadius, ZoneCoordLL = ZoneCoord:ToStringLLDMS()})
--self:F({ZoneCoord = ZoneCoord, ZoneRadius = ZoneRadius, ZoneCoordLL = ZoneCoord:ToStringLLDMS()})
local SphereSearch = {
id = world.VolumeType.SPHERE,
@ -1436,7 +1436,7 @@ end
-- @param DCS#Vec2 Vec2 The location to test.
-- @return #boolean true if the location is within the zone.
function ZONE_RADIUS:IsVec2InZone( Vec2 )
self:F2( Vec2 )
--self:F2( Vec2 )
if not Vec2 then return false end
@ -1456,7 +1456,7 @@ end
-- @param DCS#Vec3 Vec3 The point to test.
-- @return #boolean true if the point is within the zone.
function ZONE_RADIUS:IsVec3InZone( Vec3 )
self:F2( Vec3 )
--self:F2( Vec3 )
if not Vec3 then return false end
local InZone = self:IsVec2InZone( { x = Vec3.x, y = Vec3.z } )
@ -1521,11 +1521,11 @@ end
-- @param #number outer (optional) Maximal distance from the outer edge of the zone. Default is the radius of the zone.
-- @return Core.Point#POINT_VEC2 The @{Core.Point#POINT_VEC2} object reflecting the random 3D location within the zone.
function ZONE_RADIUS:GetRandomPointVec2( inner, outer )
self:F( self.ZoneName, inner, outer )
--self:F( self.ZoneName, inner, outer )
local PointVec2 = POINT_VEC2:NewFromVec2( self:GetRandomVec2( inner, outer ) )
self:T3( { PointVec2 } )
--self:T3( { PointVec2 } )
return PointVec2
end
@ -1536,11 +1536,11 @@ end
-- @param #number outer (optional) Maximal distance from the outer edge of the zone. Default is the radius of the zone.
-- @return DCS#Vec3 The random location within the zone.
function ZONE_RADIUS:GetRandomVec3( inner, outer )
self:F( self.ZoneName, inner, outer )
--self:F( self.ZoneName, inner, outer )
local Vec2 = self:GetRandomVec2( inner, outer )
self:T3( { x = Vec2.x, y = self.y, z = Vec2.y } )
--self:T3( { x = Vec2.x, y = self.y, z = Vec2.y } )
return { x = Vec2.x, y = self.y, z = Vec2.y }
end
@ -1552,11 +1552,11 @@ end
-- @param #number outer (optional) Maximal distance from the outer edge of the zone. Default is the radius of the zone.
-- @return Core.Point#POINT_VEC3 The @{Core.Point#POINT_VEC3} object reflecting the random 3D location within the zone.
function ZONE_RADIUS:GetRandomPointVec3( inner, outer )
self:F( self.ZoneName, inner, outer )
--self:F( self.ZoneName, inner, outer )
local PointVec3 = POINT_VEC3:NewFromVec2( self:GetRandomVec2( inner, outer ) )
self:T3( { PointVec3 } )
--self:T3( { PointVec3 } )
return PointVec3
end
@ -1685,7 +1685,7 @@ function ZONE_RADIUS:GetRandomCoordinateWithoutBuildings(inner,outer,distance,ma
T1=timer.getTime()
self:T(string.format("Found a coordinate: %s | Iterations: %d | Time: %.3f",tostring(found),iterations,T1-T0))
--self:T(string.format("Found a coordinate: %s | Iterations: %d | Time: %.3f",tostring(found),iterations,T1-T0))
if found then return rcoord else return nil end
@ -1754,7 +1754,7 @@ function ZONE:New( ZoneName )
-- Create a new ZONE_RADIUS.
local self=BASE:Inherit( self, ZONE_RADIUS:New(ZoneName, {x=Zone.point.x, y=Zone.point.z}, Zone.radius, true))
self:F(ZoneName)
--self:F(ZoneName)
-- Color of zone.
self.Color={1, 0, 0, 0.15}
@ -1824,7 +1824,7 @@ function ZONE_UNIT:New( ZoneName, ZoneUNIT, Radius, Offset)
self.relative_to_unit = Offset.relative_to_unit or false
end
self:F( { ZoneName, ZoneUNIT:GetVec2(), Radius } )
--self:F( { ZoneName, ZoneUNIT:GetVec2(), Radius } )
self.ZoneUNIT = ZoneUNIT
self.LastVec2 = ZoneUNIT:GetVec2()
@ -1840,7 +1840,7 @@ end
-- @param #ZONE_UNIT self
-- @return DCS#Vec2 The location of the zone based on the @{Wrapper.Unit#UNIT}location and the offset, if any.
function ZONE_UNIT:GetVec2()
self:F2( self.ZoneName )
--self:F2( self.ZoneName )
local ZoneVec2 = self.ZoneUNIT:GetVec2()
if ZoneVec2 then
@ -1873,7 +1873,7 @@ function ZONE_UNIT:GetVec2()
return self.LastVec2
end
self:T2( { ZoneVec2 } )
--self:T2( { ZoneVec2 } )
return nil
end
@ -1882,7 +1882,7 @@ end
-- @param #ZONE_UNIT self
-- @return DCS#Vec2 The random location within the zone.
function ZONE_UNIT:GetRandomVec2()
self:F( self.ZoneName )
--self:F( self.ZoneName )
local RandomVec2 = {}
--local Vec2 = self.ZoneUNIT:GetVec2() -- FF: This does not take care of the new offset feature!
@ -1896,7 +1896,7 @@ function ZONE_UNIT:GetRandomVec2()
RandomVec2.x = Vec2.x + math.cos( angle ) * math.random() * self:GetRadius();
RandomVec2.y = Vec2.y + math.sin( angle ) * math.random() * self:GetRadius();
self:T( { RandomVec2 } )
--self:T( { RandomVec2 } )
return RandomVec2
end
@ -1906,7 +1906,7 @@ end
-- @param DCS#Distance Height The height to add to the land height where the center of the zone is located.
-- @return DCS#Vec3 The point of the zone.
function ZONE_UNIT:GetVec3( Height )
self:F2( self.ZoneName )
--self:F2( self.ZoneName )
Height = Height or 0
@ -1914,7 +1914,7 @@ function ZONE_UNIT:GetVec3( Height )
local Vec3 = { x = Vec2.x, y = land.getHeight( self:GetVec2() ) + Height, z = Vec2.y }
self:T2( { Vec3 } )
--self:T2( { Vec3 } )
return Vec3
end
@ -1940,7 +1940,7 @@ ZONE_GROUP = {
-- @return #ZONE_GROUP self
function ZONE_GROUP:New( ZoneName, ZoneGROUP, Radius )
local self = BASE:Inherit( self, ZONE_RADIUS:New( ZoneName, ZoneGROUP:GetVec2(), Radius, true ) )
self:F( { ZoneName, ZoneGROUP:GetVec2(), Radius } )
--self:F( { ZoneName, ZoneGROUP:GetVec2(), Radius } )
self._.ZoneGROUP = ZoneGROUP
self._.ZoneVec2Cache = self._.ZoneGROUP:GetVec2()
@ -1956,7 +1956,7 @@ end
-- @param #ZONE_GROUP self
-- @return DCS#Vec2 The location of the zone based on the @{Wrapper.Group} location.
function ZONE_GROUP:GetVec2()
self:F( self.ZoneName )
--self:F( self.ZoneName )
local ZoneVec2 = nil
@ -1967,7 +1967,7 @@ function ZONE_GROUP:GetVec2()
ZoneVec2 = self._.ZoneVec2Cache
end
self:T( { ZoneVec2 } )
--self:T( { ZoneVec2 } )
return ZoneVec2
end
@ -1976,7 +1976,7 @@ end
-- @param #ZONE_GROUP self
-- @return DCS#Vec2 The random location of the zone based on the @{Wrapper.Group} location.
function ZONE_GROUP:GetRandomVec2()
self:F( self.ZoneName )
--self:F( self.ZoneName )
local Point = {}
local Vec2 = self._.ZoneGROUP:GetVec2()
@ -1985,7 +1985,7 @@ function ZONE_GROUP:GetRandomVec2()
Point.x = Vec2.x + math.cos( angle ) * math.random() * self:GetRadius();
Point.y = Vec2.y + math.sin( angle ) * math.random() * self:GetRadius();
self:T( { Point } )
--self:T( { Point } )
return Point
end
@ -1996,11 +1996,11 @@ end
-- @param #number outer (optional) Maximal distance from the outer edge of the zone. Default is the radius of the zone.
-- @return Core.Point#POINT_VEC2 The @{Core.Point#POINT_VEC2} object reflecting the random 3D location within the zone.
function ZONE_GROUP:GetRandomPointVec2( inner, outer )
self:F( self.ZoneName, inner, outer )
--self:F( self.ZoneName, inner, outer )
local PointVec2 = POINT_VEC2:NewFromVec2( self:GetRandomVec2() )
self:T3( { PointVec2 } )
--self:T3( { PointVec2 } )
return PointVec2
end
@ -2046,7 +2046,7 @@ function _ZONE_TRIANGLE:New(p1, p2, p3)
end
self.SurfaceArea = math.abs((p2.x - p1.x) * (p3.y - p1.y) - (p3.x - p1.x) * (p2.y - p1.y)) * 0.5
return self
end
@ -2183,7 +2183,7 @@ function ZONE_POLYGON_BASE:New( ZoneName, PointsArray )
-- Inherit ZONE_BASE.
local self = BASE:Inherit( self, ZONE_BASE:New( ZoneName ) )
self:F( { ZoneName, PointsArray } )
--self:F( { ZoneName, PointsArray } )
if PointsArray then
@ -2351,7 +2351,7 @@ end
-- @param #ZONE_POLYGON_BASE self
-- @return DCS#Vec2 The location of the zone based on the @{Wrapper.Group} location.
function ZONE_POLYGON_BASE:GetVec2()
self:F( self.ZoneName )
--self:F( self.ZoneName )
local Bounds = self:GetBoundingSquare()
@ -2434,9 +2434,9 @@ end
-- @param #ZONE_POLYGON_BASE self
-- @return #ZONE_POLYGON_BASE self
function ZONE_POLYGON_BASE:Flush()
self:F2()
--self:F2()
self:F( { Polygon = self.ZoneName, Coordinates = self._.Polygon } )
--self:F( { Polygon = self.ZoneName, Coordinates = self._.Polygon } )
return self
end
@ -2455,7 +2455,7 @@ function ZONE_POLYGON_BASE:BoundZone( UnBound )
j = #self._.Polygon
while i <= #self._.Polygon do
self:T( { i, j, self._.Polygon[i], self._.Polygon[j] } )
--self:T( { i, j, self._.Polygon[i], self._.Polygon[j] } )
local DeltaX = self._.Polygon[j].x - self._.Polygon[i].x
local DeltaY = self._.Polygon[j].y - self._.Polygon[i].y
@ -2563,7 +2563,7 @@ function ZONE_POLYGON_BASE:ReFill(Color,Alpha)
self.FillTriangles = {}
end
-- refill
for _, triangle in pairs(self._Triangles) do
for _,triangle in pairs(self._Triangles) do
local draw_ids = triangle:Fill(coalition,color,alpha,nil)
self.FillTriangles = draw_ids
table.combine(self.DrawID, draw_ids)
@ -2707,7 +2707,7 @@ end
-- @param #number Segments (Optional) Number of segments within boundary line. Default 10.
-- @return #ZONE_POLYGON_BASE self
function ZONE_POLYGON_BASE:SmokeZone( SmokeColor, Segments )
self:F2( SmokeColor )
--self:F2( SmokeColor )
Segments=Segments or 10
@ -2715,7 +2715,7 @@ function ZONE_POLYGON_BASE:SmokeZone( SmokeColor, Segments )
local j=#self._.Polygon
while i <= #self._.Polygon do
self:T( { i, j, self._.Polygon[i], self._.Polygon[j] } )
--self:T( { i, j, self._.Polygon[i], self._.Polygon[j] } )
local DeltaX = self._.Polygon[j].x - self._.Polygon[i].x
local DeltaY = self._.Polygon[j].y - self._.Polygon[i].y
@ -2740,7 +2740,7 @@ end
-- @param #number AddHeight (optional) The height to be added for the smoke.
-- @return #ZONE_POLYGON_BASE self
function ZONE_POLYGON_BASE:FlareZone( FlareColor, Segments, Azimuth, AddHeight )
self:F2(FlareColor)
--self:F2(FlareColor)
Segments=Segments or 10
@ -2750,7 +2750,7 @@ function ZONE_POLYGON_BASE:FlareZone( FlareColor, Segments, Azimuth, AddHeight )
local j=#self._.Polygon
while i <= #self._.Polygon do
self:T( { i, j, self._.Polygon[i], self._.Polygon[j] } )
--self:T( { i, j, self._.Polygon[i], self._.Polygon[j] } )
local DeltaX = self._.Polygon[j].x - self._.Polygon[i].x
local DeltaY = self._.Polygon[j].y - self._.Polygon[i].y
@ -2773,7 +2773,7 @@ end
-- @param DCS#Vec2 Vec2 The location to test.
-- @return #boolean true if the location is within the zone.
function ZONE_POLYGON_BASE:IsVec2InZone( Vec2 )
self:F2( Vec2 )
--self:F2( Vec2 )
if not Vec2 then return false end
local Next
local Prev
@ -2783,18 +2783,18 @@ function ZONE_POLYGON_BASE:IsVec2InZone( Vec2 )
Prev = #self._.Polygon
while Next <= #self._.Polygon do
self:T( { Next, Prev, self._.Polygon[Next], self._.Polygon[Prev] } )
--self:T( { Next, Prev, self._.Polygon[Next], self._.Polygon[Prev] } )
if ( ( ( self._.Polygon[Next].y > Vec2.y ) ~= ( self._.Polygon[Prev].y > Vec2.y ) ) and
( Vec2.x < ( self._.Polygon[Prev].x - self._.Polygon[Next].x ) * ( Vec2.y - self._.Polygon[Next].y ) / ( self._.Polygon[Prev].y - self._.Polygon[Next].y ) + self._.Polygon[Next].x )
) then
InPolygon = not InPolygon
end
self:T2( { InPolygon = InPolygon } )
--self:T2( { InPolygon = InPolygon } )
Prev = Next
Next = Next + 1
end
self:T( { InPolygon = InPolygon } )
--self:T( { InPolygon = InPolygon } )
return InPolygon
end
@ -2803,7 +2803,7 @@ end
-- @param DCS#Vec3 Vec3 The point to test.
-- @return #boolean true if the point is within the zone.
function ZONE_POLYGON_BASE:IsVec3InZone( Vec3 )
self:F2( Vec3 )
--self:F2( Vec3 )
if not Vec3 then return false end
@ -2838,11 +2838,11 @@ end
-- @param #ZONE_POLYGON_BASE self
-- @return @{Core.Point#POINT_VEC2}
function ZONE_POLYGON_BASE:GetRandomPointVec2()
self:F2()
--self:F2()
local PointVec2 = POINT_VEC2:NewFromVec2( self:GetRandomVec2() )
self:T2( PointVec2 )
--self:T2( PointVec2 )
return PointVec2
end
@ -2851,11 +2851,11 @@ end
-- @param #ZONE_POLYGON_BASE self
-- @return @{Core.Point#POINT_VEC3}
function ZONE_POLYGON_BASE:GetRandomPointVec3()
self:F2()
--self:F2()
local PointVec3 = POINT_VEC3:NewFromVec2( self:GetRandomVec2() )
self:T2( PointVec3 )
--self:T2( PointVec3 )
return PointVec3
end
@ -2865,11 +2865,11 @@ end
-- @param #ZONE_POLYGON_BASE self
-- @return Core.Point#COORDINATE
function ZONE_POLYGON_BASE:GetRandomCoordinate()
self:F2()
--self:F2()
local Coordinate = COORDINATE:NewFromVec2( self:GetRandomVec2() )
self:T2( Coordinate )
--self:T2( Coordinate )
return Coordinate
end
@ -2886,7 +2886,7 @@ function ZONE_POLYGON_BASE:GetBoundingSquare()
local y2 = self._.Polygon[1].y
for i = 2, #self._.Polygon do
self:T2( { self._.Polygon[i], x1, y1, x2, y2 } )
--self:T2( { self._.Polygon[i], x1, y1, x2, y2 } )
x1 = ( x1 > self._.Polygon[i].x ) and self._.Polygon[i].x or x1
x2 = ( x2 < self._.Polygon[i].x ) and self._.Polygon[i].x or x2
y1 = ( y1 > self._.Polygon[i].y ) and self._.Polygon[i].y or y1
@ -2909,7 +2909,7 @@ function ZONE_POLYGON_BASE:GetBoundingVec2()
local y2 = self._.Polygon[1].y
for i = 2, #self._.Polygon do
self:T2( { self._.Polygon[i], x1, y1, x2, y2 } )
--self:T2( { self._.Polygon[i], x1, y1, x2, y2 } )
x1 = ( x1 > self._.Polygon[i].x ) and self._.Polygon[i].x or x1
x2 = ( x2 < self._.Polygon[i].x ) and self._.Polygon[i].x or x2
y1 = ( y1 > self._.Polygon[i].y ) and self._.Polygon[i].y or y1
@ -2948,7 +2948,7 @@ function ZONE_POLYGON_BASE:Boundary(Coalition, Color, Radius, Alpha, Segments, C
Limit = #self._.Polygon
end
while i <= #self._.Polygon do
self:T( { i, j, self._.Polygon[i], self._.Polygon[j] } )
--self:T( { i, j, self._.Polygon[i], self._.Polygon[j] } )
if j ~= Limit then
local DeltaX = self._.Polygon[j].x - self._.Polygon[i].x
local DeltaY = self._.Polygon[j].y - self._.Polygon[i].y
@ -3019,7 +3019,7 @@ function ZONE_POLYGON:New( ZoneName, ZoneGroup )
local GroupPoints = ZoneGroup:GetTaskRoute()
local self = BASE:Inherit( self, ZONE_POLYGON_BASE:New( ZoneName, GroupPoints ) )
self:F( { ZoneName, ZoneGroup, self._.Polygon } )
--self:F( { ZoneName, ZoneGroup, self._.Polygon } )
-- Zone objects are added to the _DATABASE and SET_ZONE objects.
_EVENTDISPATCHER:CreateEventNewZone( self )
@ -3035,7 +3035,7 @@ end
function ZONE_POLYGON:NewFromPointsArray( ZoneName, PointsArray )
local self = BASE:Inherit( self, ZONE_POLYGON_BASE:New( ZoneName, PointsArray ) )
self:F( { ZoneName, self._.Polygon } )
--self:F( { ZoneName, self._.Polygon } )
-- Zone objects are added to the _DATABASE and SET_ZONE objects.
_EVENTDISPATCHER:CreateEventNewZone( self )
@ -3055,7 +3055,7 @@ function ZONE_POLYGON:NewFromGroupName( GroupName )
local GroupPoints = ZoneGroup:GetTaskRoute()
local self = BASE:Inherit( self, ZONE_POLYGON_BASE:New( GroupName, GroupPoints ) )
self:F( { GroupName, ZoneGroup, self._.Polygon } )
--self:F( { GroupName, ZoneGroup, self._.Polygon } )
-- Zone objects are added to the _DATABASE and SET_ZONE objects.
_EVENTDISPATCHER:CreateEventNewZone( self )
@ -3221,7 +3221,7 @@ function ZONE_POLYGON:Scan( ObjectCategories, UnitCategories )
self.ScanData.Units[ZoneObject] = ZoneObject
self:F2( { Name = ZoneObject:getName(), Coalition = CoalitionDCSUnit } )
--self:F2( { Name = ZoneObject:getName(), Coalition = CoalitionDCSUnit } )
end
end
@ -3232,7 +3232,7 @@ function ZONE_POLYGON:Scan( ObjectCategories, UnitCategories )
self.ScanData.Scenery[SceneryType] = self.ScanData.Scenery[SceneryType] or {}
self.ScanData.Scenery[SceneryType][SceneryName] = SCENERY:Register( SceneryName, ZoneObject )
table.insert(self.ScanData.SceneryTable,self.ScanData.Scenery[SceneryType][SceneryName])
self:T( { SCENERY = self.ScanData.Scenery[SceneryType][SceneryName] } )
--self:T( { SCENERY = self.ScanData.Scenery[SceneryType][SceneryName] } )
end
end
@ -3573,8 +3573,8 @@ do -- ZONE_ELASTIC
function ZONE_ELASTIC:Update(Delay, Draw)
-- Debug info.
self:T(string.format("Updating ZONE_ELASTIC %s", tostring(self.ZoneName)))
--self:T(string.format("Updating ZONE_ELASTIC %s", tostring(self.ZoneName)))
-- Copy all points.
local points=UTILS.DeepCopy(self.points or {})
@ -3592,6 +3592,9 @@ do -- ZONE_ELASTIC
-- Update polygon verticies from points.
self._.Polygon=self:_ConvexHull(points)
self._Triangles = self:_Triangulate()
self.SurfaceArea = self:_CalculateSurfaceArea()
if Draw~=false then
if self.DrawID or Draw==true then
@ -3987,7 +3990,7 @@ do -- ZONE_AIRBASE
-- @param #ZONE_AIRBASE self
-- @return DCS#Vec2 The location of the zone based on the AIRBASE location.
function ZONE_AIRBASE:GetVec2()
self:F( self.ZoneName )
--self:F( self.ZoneName )
local ZoneVec2 = nil
@ -3998,7 +4001,7 @@ do -- ZONE_AIRBASE
ZoneVec2 = self._.ZoneVec2Cache
end
self:T( { ZoneVec2 } )
--self:T( { ZoneVec2 } )
return ZoneVec2
end
@ -4009,11 +4012,11 @@ do -- ZONE_AIRBASE
-- @param #number outer (optional) Maximal distance from the outer edge of the zone. Default is the radius of the zone.
-- @return Core.Point#POINT_VEC2 The @{Core.Point#POINT_VEC2} object reflecting the random 3D location within the zone.
function ZONE_AIRBASE:GetRandomPointVec2( inner, outer )
self:F( self.ZoneName, inner, outer )
--self:F( self.ZoneName, inner, outer )
local PointVec2 = POINT_VEC2:NewFromVec2( self:GetRandomVec2() )
self:T3( { PointVec2 } )
--self:T3( { PointVec2 } )
return PointVec2
end