New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automapping: Explicitly detect map edges #3858
Comments
Some time ago I built out my own autotiling system (before trying out and leaning into Tiled's) I came to the conclusion that a lot of features are very context-depedent (like a regex), and I'll just keep finding new match cases that users would want over time. As far as I got on the particular problem in this issue, I defined rule-specific logic for out-of-bounds tiles as either being "always positive" match, "always negative" match, or "match as if extruded". Again, this property was defined on the " Regardless, I still ended up with a realization that these things are ultimately complex, and all cases can't be captured. So, line of thinking on my autotile system was to allow custom-defined matching. For Tiled, this would mean adding a new When looking through the Tiled source, it seemed like the roadblock in this would be injecting a script interpreter for this MatchType around here, and all the work involved in verifying and validating the script. These were my thoughts on the topic at least. |
Well, in fact since Tiled 1.9, rules can have individual properties by placing rectangle objects over those rules and setting certain properties on them. However, I think another option which hasn't been mentioned here, would be the ability to specify that the outside of a map should be considered equal to a specific tile. Then, you can use that tile to match it, or in some cases, using this option will be enough to make your rules behave as desired on the edges. The main issue with this type of configuration is that there is currently no custom "tile reference" property, though this has already been asked about before (#3235). |
I think this adds unnecessary complications when instead the outside of a map could match MatchType "OutsideMap" or something. I don't see much benefit in customising which tile the outside of the map matches, since it's so easy to add a specific special tile as an input option to rules. We already have options for treating the outside as empty ( Edit: Ideally, I'd like for "OutsideMap" to always match tiles outside the map regardless of the |
While an "OutsideMap" matching tile might sound like a good idea from a user's perspective, it's a somewhat different story from the implementation side. Currently, all match types reflect some set of tiles that are either desired or not desired and the input matching function can just loop over those and compare them (so, in this process, the "match type" is no longer relevant at all - it is currently only inspected during the "rule compilation" step). So, dragging "match type" into the matching code is somewhat involved and likely to affect performance, whereas adding a fallback tile to use for "outside the map" would be relatively straight-forward, heh. |
Makes sense D: Maybe it could use a fake "outside the map" tile from a secret Tileset that only Tiled knows about? This could behave like any other tile to the matching code. MatchType "OutsideMap" would match this tile, and the out-of-bounds area would be treated as populated with this tile when the relevant options are set. Still not ideal though, as I think it would be best to be able to address the out-of-bounds region independently of the "tiles" that "populate" it, allowing mixing both out of bounds matching and the different MatchOutsideMap modes within a single rule. |
How about a tile layer (similar to Imagine a twisty tree 6x8 derived from an This could cause issues when multiple overflow rules could seemingly produce conflicting ideas of what tile exists in the overflow space, placing different "imaginary overflow tiles" to fit their match, creating a "Schrodinger's tile" situation. |
Yeah, that's an interesting idea, that should make the comparison only a little bit more complicated given that we'd still need to also support the case where tiles outside the map are treated as empty. To come back about a section from your first post:
In your above example of the tree, it seems you're suggesting to match as usual, considering "outside map OR part of tree" a match. Or was the reference to "edge" matching something else than "outside of map" matching? In any case I hope we can treat the layers the same, with "input" layers doing OR and "inputnot" layers doing AND. |
For that example rule, that is correct. For another rule, such as one defining a frame for a map or map-edge cleanup, I may have the outside-the-map tile as the only input at those locations. As for that bit from the OP: I think there I was considering rules that I'd want to only match the border, while also checking for specific overflows (most useful with As for making sure Empty matches also work, could it perhaps be made that when |
In the comments for #3100, the possibility of adding a MatchType for explicitly matching tiles outside the map was discussed, but there was no consensus and the issue was closed without implementing anything like this. I still think some way to have rules that only match at map edges would be a useful feature.
Use-cases for matching (near) map borders:
It is already possible to accomplish edge detection like this using a guide layer: a filled guide layer and rules with
MatchOutsideMap
and no overflow/wrap means that any location on the guide layer that is empty must be outside the map. However, this means the rules can't useOverflowBorder
andWrapBorder
, unless the layer is prepared such that it contains different tiles at the edges than the interior.Theoretically Automapping can even be used to generate this guide layer, though not with "Automap While Drawing".
Still, it would be nice to not have to use additional guide layers to get at information that should be trivial to access: is this cell next to a particular map border?
Unfortunately, I don't have any good ideas on the UI for this. Some things I've considered:
OutsideMap
MatchType. This would match any cell that is outside the map oninput
layers, and any cell inside the map oninputnot
layers. Infinite maps would never match this special tile (except oninputnot
layers).MatchOutsideMap
to betrue
to work, since otherwise Tiled doesn't build match regions where any cells are outside the map. This means all the other rules have to be designed with that in mind.MatchOutsideMap
.OutsideMap
, haveMapEdge
MatchType, which matches the edge itself rather than cells, and thus works regardless ofMatchOutsideMap
.MapBorder
matches cells that touch the map border, andMapInterior
matches cells that do not. These should be enough to determine where in the map you are, without needing to ever look outside the map.OutsideMatch
, except these tiles would be entirely within the map bounds.Another important issue is that if matching the borders is done using regular input layers, it can be unclear how this interacts with other input tiles at the same location. Unlike other tiles, I feel like the map border stuff should AND with the other tiles, not OR like input layers currently are. So, perhaps it might be good to use a new layer "type" to define border locations, e.g.
border
layers just to make it completely unambiguous.My current favourite option is the MatchType tiles that look at a phantom guide layer, and I am ambivalent as to whether they must be placed on a special layer. I'd love to hear if anyone has better ideas!
The text was updated successfully, but these errors were encountered: