Repository: godot
Issue: Tilemap terrain in "match corners" mode can't draw a minimal path; should probably paint corners, not centers
Labels: enhancement,topic:editor,topic:2d

### Tested versions

Only tried 4.2.1.stable.arch_linux.

### System information

Godot v4.2.1.stable unknown - Arch Linux #1 SMP PREEMPT_DYNAMIC Sun, 21 Jan 2024 22:14:10 +0000 - X11 - GLES3 (Compatibility) - NVIDIA GeForce GTX 1660 (nvidia; 545.29.06) - AMD Ryzen 5 1600 Six-Core Processor (12 Threads)

### Issue description

This is my first exposure to the new tilemap in Godot 4.  Love it.  Being able to paint collision shapes?  Chef kiss.  Fantastic.

I tend to go for 47-tile "blob" tilesets (Godot 4 calls this "match corners and sides"), but for once I'm doing a top-down game, where transitions matter.  So I thought maybe a corner-based tileset would be a better idea — that's only 14 tiles for every pair of terrains that could touch.

![screenshot of a vastly reduced triad of tilesets for every combination of grass/water/sand](https://github.com/godotengine/godot/assets/94112/f59d0e53-c118-4b93-a855-5c3bf4f9e116)

I included the oddball "island" tiles because my artist partner had already drawn them anyway, and went to go set some terrain bits in Godot.

Lo!  This does not work well.  If I draw four tiles in a counter-clockwise motion, the results look like this, in order:

![one sand island, then two, then three, then a corrupt combination of big sand and islands](https://github.com/godotengine/godot/assets/94112/e930057f-c200-4339-a9da-bbcb861e947c)

Okay.  Let's ditch the island tiles, then.  (But then what's the point of the center terrain bit?)  Now a single click produces this:

![a 3×3 block of sand](https://github.com/godotengine/godot/assets/94112/0f714dee-4d12-48eb-bc42-36bcba81fda6)

In fact **it seems impossible to create a 2-wide strip of "match corners" terrain**.  This strikes me as counterintuitive, since the first thought that entered my head when I decided to make a corner-based tileset was "and we can still make a minimum-width area by just using two tiles".

And the behavior here is still weird, such as if I try to make the strip wider by painting above it:

![a 5-tile tall strip of sand, but the second row is corrupted with partial grass tiles](https://github.com/godotengine/godot/assets/94112/774f9dc8-e27d-4979-8115-d6b4b3b21ca7)

The path mode doesn't fare any better (perhaps #68222 only applied to normal mode?):

![same results as before, but now the edges are missing and are just full grass tiles](https://github.com/godotengine/godot/assets/94112/cff793d4-23cf-4129-be55-fd321ab17672)

----

I think the problem is that the tilemap is trying to paint one _tile_ at a time.  That makes perfect sense for "blob" tilesets, and I even specifically appreciate that Godot lets me set the terrain of the _center_ of a tile — Tiled doesn't do this, so it's impossible to paint a single tile using its terrain tool.

But for a corner tileset, I want to paint _corners_.  The whole idea is that the transition is running down the _middle_ of the tile, so the middle of the tile isn't any one terrain.  Instead I expect to click a grid _intersection_ and have the four neighboring tiles change:

![](https://github.com/godotengine/godot/assets/94112/c4394837-196e-41a5-954a-45a935ee694c)

This behavior _does_ make sense for, say, procedural generation, where a developer may want to simply draw a bunch of terrain and then have the edges all be magically fixed to look nice.  (Though I don't know how you'd create a two-tile-wide strip with that approach.)  But for live drawing, starting the update from a tile's center makes some obvious patterns impossible.  And it doesn't work well anyway — I tried to make use of the center bit for those tiny one-tile islands, and it interfered with drawing anything larger.

----

Corner/edge painting is also useful in full "match corners and sides" mode — _sometimes_.  For example, the obvious way to render a block of terrain is as a single contiguous blob:

![](https://github.com/godotengine/godot/assets/94112/70f83307-0cb6-4521-be13-b65d6c514389)

But Tiled allows me to erase individual _corners and edges_, adding in some holes that make the result more visually interesting:

![](https://github.com/godotengine/godot/assets/94112/b0f468b3-e401-4160-b5b1-aa694440f4c2)

----

I see a number of issues still open on terrain, but hardly any of them are about corners mode, so here's one.  :)  cc @groud I suppose?

### Steps to reproduce

Make a match-corners tileset and try to draw with it.

### Minimal reproduction project (MRP)

[match-corners.zip](https://github.com/godotengine/godot/files/14155800/match-corners.zip)