godot icon indicating copy to clipboard operation
godot copied to clipboard

Add a new terrain painting mode in TileMap to force diagonal connection

Open groud opened this issue 2 years ago • 3 comments

Allows connecting diagonally when required. This was kind of need for having the behavior asked in https://github.com/godotengine/godot/issues/71829.

https://user-images.githubusercontent.com/6093119/214547729-b298f3a4-80dd-428a-a944-c3c27f71f5ae.mp4

groud avatar Jan 25 '23 11:01 groud

Amazing this looks great, thanks so much for the work and your attention to this issue, much apreciated.

OddlifeDev avatar Jan 25 '23 13:01 OddlifeDev

Since this PR breaks API compatibility, which we should avoid in minor releases, this makes it less than ideal solution. Still, if we prefer to break existing projects to some degree to achieve this functionality, then we need to make sure the risk is minimized for possible future changes of the sort. So I propose to unity these boolean flags into a single method parameter exposed as a bitfield enum.

So instead of adding a new flag, we replace existing flag with a bitfield parameter and expose two options for it, ignore_empty_terrains and connect_corners. This allows us to add more configuration options in future without creating compatibility breakage, or minimizing its effect. It also doesn't extend method's signature further (remember, that ideally methods should have no more than 3 parameters to be human-readable).

YuriSizov avatar Mar 03 '23 13:03 YuriSizov

I've updated the PR to use another function instead. I think it's simpler to use than a bitfield enum.

groud avatar Mar 06 '23 10:03 groud

I think this is a good feature to add, thank you for doing it. I am curious why it's a draw mode and not a terrain mode, though (or a sub-mode of corners and sides). It seems it could be more easily added as a terrain mode without breaking compatibility? It also doesn't have to be mutually exclusive with path drawing mode, right?

My understanding is the diagonal corner matching is just the difference, in corners and sides mode, between whether you match the single diagonal corner bit or all adjacent corner bits. Which was also the difference between 3x3 and 3x3 minimal modes in 3.x. This means that diagonal mode should require a full 256-tile set.

But perhaps I am missing something because I just tried testing it and can't get it working. As expected, the corners-mode won't match correctly with a 47-tile corners and sides tileset, but it also isn't working with a full 256-tile corners and sides tileset.

47 tiles:

corners_pr_47

256 tiles:

corners_pr_256

Here is an example using the same tileset and bitmasks of how it should be matching the 256-tile corners:

corners_pr_256_mockup

And here is the again issue, but with a bitmask tile template from TilePipe2, so it's easier to see what's happening:

corners_pr_256_bits

~~It seems the last tile painted is usually matched correctly at diagonal corners,~~ but the tile diagonal to it isn't always updating as expected. Edit: I just watched that last gif more closely and the painted tile also seems to be choosing corners incorrectly sometimes.

dandeliondino avatar Jun 19 '23 00:06 dandeliondino

i don't understand why this should be a separate drawing mode. surely whether diagonals should be taken into account is implicit in the terrain matching mode, i.e. if i didn't expect diagonals to connect, i would be using "match sides"?

JustMog avatar Sep 24 '23 21:09 JustMog