[FIXED] ZONE_POLYGON from RECT ME drawing rotation not taken into account.

This commit is contained in:
smiki 2025-10-01 14:50:04 +02:00
parent aa3978b04d
commit 43b4a6834b

View File

@ -577,13 +577,22 @@ do -- Zones and Pathlines
-- For a rectangular polygon drawing, we have the width (y) and height (x). -- For a rectangular polygon drawing, we have the width (y) and height (x).
local w=objectData.width local w=objectData.width
local h=objectData.height local h=objectData.height
local rotation = UTILS.ToRadian(objectData.angle or 0)
-- Create points from center using with and height (width for y and height for x is a bit confusing, but this is how ED implemented it). local dx = vec2.x + math.abs(w)
local points={} local dy = vec2.y + math.abs(h)
points[1]={x=vec2.x-h/2, y=vec2.y+w/2} --Upper left
points[2]={x=vec2.x+h/2, y=vec2.y+w/2} --Upper right local sinRot = math.sin(-rotation)
points[3]={x=vec2.x+h/2, y=vec2.y-w/2} --Lower right local cosRot = math.cos(-rotation)
points[4]={x=vec2.x-h/2, y=vec2.y-w/2} --Lower left dx = (dx / 2)
dy = (dy / 2)
local points = {
{ x = -dx * cosRot - (-dy * sinRot) + vec2.x, y = -dx * sinRot + (-dy * cosRot) + vec2.y },
{ x = dx * cosRot - (-dy * sinRot) + vec2.x, y = dx * sinRot + (-dy * cosRot) + vec2.y },
{ x = dx * cosRot - (dy * sinRot) + vec2.x, y = dx * sinRot + (dy * cosRot) + vec2.y },
{ x = -dx * cosRot - (dy * sinRot) + vec2.x, y = -dx * sinRot + (dy * cosRot) + vec2.y },
}
--local coord=COORDINATE:NewFromVec2(vec2):MarkToAll("MapX, MapY") --local coord=COORDINATE:NewFromVec2(vec2):MarkToAll("MapX, MapY")