Add setTerrain functionality to TileLayerEdit by a-morphous · Pull Request #3758 · mapeditor/tiled (original) (raw)
added 3 commits
…rates tiles for all of them
Moved part of WangPainter back to WangBrush (BrushMode / TileMode). Tile mode could be re-introduced in WangPainter, if it is useful enough for a scripting API function.
Merged the remainder of WangPainter with WangFiller, renaming the result to WangPainter. It did not seem like there was any advantage to separating these.
Fixed leaking WangPainter instance in TileLayerWangEdit.
Even though I like WangPainter more, I'm sticking with WangFiller for now to keep the patch easier to read.
Exposed WangId as Q_GADGET, so that in JS we can do WangId.Top, etc. to specify Wang indexes. Also made the masks enum available, though it may not have a use with the current API. A WangId value is currently useless on the script side.
Changed the parameter order to be consistently: position, index, color.
Fixed registration of TileLayerWangEdit (needed for Qt 5).
Added nullptr check to TileLayer.wangEdit.
Added error when calling TileLayerWangEdit.setEdge with non-edge index.
Added overloads to TileLayerWangEdit functions taking QPoint, which might be convenient in some cases.
Renamed TileLayerWangEdit.setTerrain to setWangIndex, to better reflect its low-level behavior.
Instead of WangId.Top, you now type WangIndex.Top in JS. This allowed for more intuitively using the WangIndex type as a function parameter.
Also exposed the "corrections enabled" setting of WangFiller, which could be useful.
Finally, updated the JS API docs.
Destroy the TileLayerWangEdit when the EditableWangSet is deleted. This might be too early in some cases, since the WangSet might still be alive, but it's the safest option for now.
Support creating a TileLayerWangEdit even when there is no MapDocument. The layer still has to be part of a map though, since we need to know the orientation. A check has been added to wangEdit().
Protect against issues when the originally referred map is deleted by copying its parameters (though not sure about the exact flow, which might already delete the EditableTileLayer).
When corrections are disabled, and the Wang set is not complete, a matching tile is only placed when it will not make it impossible to place a matching tile on any of its neighboring cells.
For incomplete Wang sets with transitions to empty, it can happen that a matching tile requires an empty WangId as neighbor. However, the empty WangId is never explicitly part of a WangSet. As such, we should probably never discard a match when it requires an empty neighbor.
Since the TileLayerWangEdit allows the WangFiller to be reused, we need to make sure it starts off with a clean state.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})