You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the input region for a rule is empty, the top and left of the map are unaffected, the size of the unaffected area depends on whether modX/modY are set to a value above 1. While this seems like an odd scenario, modX and modY are useful enough in their own right that it makes perfect sense to leave out any explicit input. For example, if I want to populate a layer with just a checkerboard grid, all I need for that is an empty input, an output, and modX/modY with the size of the output.
Some examples follow, I put them at the bottom as it's a rather long section. In short, you'll see that a non-empty input behaves much more consistently (though not without surprises), and the underlying cause of the issue is probably something odd that happens when the input region is empty.
Suggested changes
When the input region of a rule is empty, treat it as being the same as that of the output, as that is most likely the intent. This'll avoid whatever strangeness is causing the margin, since the input region will just never be empty.
(Bit of a side issue) "Ignore" should match tiles outside the map as long as any part of the input region is inside the map.
In the Automapping documentation, explicitly state that the modX/modY behaviour is based on the input region, and not the combined region of the rule. The documentation current speaks of the rule "applying", which is ambiguous whether it's about input or output.
Test scenarios
My test rule in this case is a 2x2 green/brown circle as the output, varying modX/modY, and in some examples, "Ignore" special tiles in the input, which you will see on top of the output tiles. In all cases, offsetX/Y is unset. I have also experimented with different values for that, but different offset values never remove the empty area. The test map is 10x10 and empty before Automapping.
Scenarios with empty inputs
Scenario 1: modX/modY unset (1, according to the documentation, but 0 displayed in Tiled), empty input:
(The same result happens if modY and modY are explicitly set to 1)
The rule overwrites parts of itself and this is expected, but the 1 tile margin is unexpected.
Scenario 2: modX/modY set to 2, rule otherwise unchanged:
The rule produces a grid of the 2x2 pattern, but the 2-tile margin is unexpected.
Scenario 3: modX2, modY 3, rule otherwise unchanged:
Again results as expected, but again with the weird 2-tile margin.
Scenario 4: modX 4, modY 5, rule otherwise unchanged:
Once again, the results are exactly what I'd expect, save for the unexpected margin. The pattern continues, it seems like any value above 1 will cause a 2-tile margin.
Scenarios with non-empty inputs
Adding an actual input to the input layer reveals the likely source of the problem: the placement of the output is apparently calculated based on the position of the input region, and when the input is empty, it gets weird.
Scenario 5: modX/modY unset, input filled with "Ignore" special tiles in any of these three arrangements (i.e. the bounding box of the input region matches that of the output):
As expected, every part of the map is correctly filled with the output pattern, overlapping itself.
Scenario 6, modX 3, modY 3, rule otherwise unchanged from scenario 5:
Again, correct behaviour (though the fact that tiles outside the map apparently don't match "Ignore" is concerning! I expected the whole map to be filled with this pattern, not just the 3x3 regions that are wholly within it!)
Scenario 7: modX 3, modY 3, but with the "Ignore" tile in the top left of the rule:
Results as above, except now the whole map is filled because the "Ignore" gets to match tiles within the map.
Scenario 8: modX 3, modY 3, but with the "Ignore" tile in the bottom right of the rule:
The whole pattern is offset! This is why I'm guessing the issue has to do with the input region.
And finally of tests that are like scenarios 7-8, but with modX and modY unset:
Scenario 9: "Ignore" in the top left:
Scenario 10: "Ignore" in the bottom right:
In both of these, no mystery margin, but also rather meaningless results since the rule just overlaps itself. The slight difference in output is explained by the bottom left "Ignore" not matching tiles outside the map.
The text was updated successfully, but these errors were encountered:
Rules with an empty input region were causing issues, because they don't
have a valid bounding rectangle. They are also commonly created by
accident. If intended as a rule that always matches, such a rule can be
made by placing the special "Ignore" tile in the rule's input.
Rules with empty output region are no longer matched because they would
not produce any output anyway.
As a drive-by, AutoMapper no longer derives from QObject, which appears
to have only been done to access the tr() function. This is now made
available using Q_DECLARE_TR_FUNCTIONS instead.
Closesmapeditor#3834
bjorn
linked a pull request
Dec 5, 2024
that will
close
this issue
Problem
When the input region for a rule is empty, the top and left of the map are unaffected, the size of the unaffected area depends on whether modX/modY are set to a value above 1. While this seems like an odd scenario, modX and modY are useful enough in their own right that it makes perfect sense to leave out any explicit input. For example, if I want to populate a layer with just a checkerboard grid, all I need for that is an empty input, an output, and modX/modY with the size of the output.
Some examples follow, I put them at the bottom as it's a rather long section. In short, you'll see that a non-empty input behaves much more consistently (though not without surprises), and the underlying cause of the issue is probably something odd that happens when the input region is empty.
Suggested changes
Test scenarios
My test rule in this case is a 2x2 green/brown circle as the output, varying modX/modY, and in some examples, "Ignore" special tiles in the input, which you will see on top of the output tiles. In all cases, offsetX/Y is unset. I have also experimented with different values for that, but different offset values never remove the empty area. The test map is 10x10 and empty before Automapping.
Scenarios with empty inputs
Scenario 1: modX/modY unset (1, according to the documentation, but 0 displayed in Tiled), empty input:
(The same result happens if modY and modY are explicitly set to 1)
The rule overwrites parts of itself and this is expected, but the 1 tile margin is unexpected.
Scenario 2: modX/modY set to 2, rule otherwise unchanged:
The rule produces a grid of the 2x2 pattern, but the 2-tile margin is unexpected.
Scenario 3: modX2, modY 3, rule otherwise unchanged:
Again results as expected, but again with the weird 2-tile margin.
Scenario 4: modX 4, modY 5, rule otherwise unchanged:
Once again, the results are exactly what I'd expect, save for the unexpected margin. The pattern continues, it seems like any value above 1 will cause a 2-tile margin.
Scenarios with non-empty inputs
Adding an actual input to the input layer reveals the likely source of the problem: the placement of the output is apparently calculated based on the position of the input region, and when the input is empty, it gets weird.
Scenario 5: modX/modY unset, input filled with "Ignore" special tiles in any of these three arrangements (i.e. the bounding box of the input region matches that of the output):
As expected, every part of the map is correctly filled with the output pattern, overlapping itself.
Scenario 6, modX 3, modY 3, rule otherwise unchanged from scenario 5:
Again, correct behaviour (though the fact that tiles outside the map apparently don't match "Ignore" is concerning! I expected the whole map to be filled with this pattern, not just the 3x3 regions that are wholly within it!)
Scenario 7: modX 3, modY 3, but with the "Ignore" tile in the top left of the rule:
Results as above, except now the whole map is filled because the "Ignore" gets to match tiles within the map.
Scenario 8: modX 3, modY 3, but with the "Ignore" tile in the bottom right of the rule:
The whole pattern is offset! This is why I'm guessing the issue has to do with the input region.
And finally of tests that are like scenarios 7-8, but with modX and modY unset:
Scenario 9: "Ignore" in the top left:
Scenario 10: "Ignore" in the bottom right:
In both of these, no mystery margin, but also rather meaningless results since the rule just overlaps itself. The slight difference in output is explained by the bottom left "Ignore" not matching tiles outside the map.
The text was updated successfully, but these errors were encountered: