Closed
Description
Describe the bug
When a script assigns a new polygon to a MapObject, all the polygon points will end up as (0,0).
To Reproduce
Steps to reproduce the behavior:
- Install the test script
/// <reference types="@mapeditor/tiled-api" />
const TouchPolygon = tiled.registerAction("Touch Polygon", (action) => {
let asset = tiled.activeAsset
let selected = asset.selectedObjects
if (!selected) {
return
}
for (let object of selected) {
let polygon = object.polygon
if (!polygon)
continue
asset.macro("Touch Polygon", () => {
// Doc says: "To modify the polygon of a MapObject, change or set up the polygon array and then assign it to MapObject.polygon"
object.polygon = polygon.map((p) => ({ x: p.x, y: p.y }))
tiled.log(polygon)
tiled.log(object.polygon)
})
}
})
TouchPolygon.text = "Touch Polygon"
tiled.extendMenu("MapView.Objects", [
{ action: "Touch Polygon" }
])
- Create a polygon or polyline object
- Right-click on the object and select "Touch Polygon"
- See console output
Expected behavior
The polygon is unchanged and two identical point arrays are output to console.
Actual behavior
The polygon collapses as all its points are zeroed. This is confirmed by console output, in which the second array has the same number of points but they are all QPointF(0,0).
Specifications:
- OS: Linux Mint Vera
- Tiled Version: 1.10.2
Activity