Supports closed line segments, rects and freely drawn polygons.
Added the correct way of generating a point within a polygon with trial and error
Added a way to get the surface area.
Added a helper class (_ZONE_TRIANGLE), which shouldn't ever be used on its own. It's there to support the update ZONE_POLYGON.
Some test code, assuming there's a poygon drawn in the mission editor called "poly":
-- make a new zone from a drawing
poly = ZONE_POLYGON:NewFromDrawing("poly")
-- draw the zone for everyone, include the individual triangles that make up the polygon
poly:DrawZone(-1, {1,0,0}, 1, {1,0,0}, 255, 4, false, true)
-- generate 500 random points, evenly distributed in the polygon
for i=1, 500 do
COORDINATE:NewFromVec2(poly:GetRandomVec2()):CircleToAll(1000)
end
-- remove the drawing from the game
poly:UndrawZone()
Supports closed line segments, rects and freely drawn polygons.
Added the correct way of generating a point within a polygon with trial and error
Added a way to get the surface area.
Added a helper class (_ZONE_TRIANGLE), which shouldn't ever be used on its own. It's there to support the update ZONE_POLYGON.
Some test code, assuming there's a poygon drawn in the mission editor called "poly":