Tilemaps: a painted cell builds only the meshes it changes (#424)

A new paragraph on the fifth round: a patched list of tiles says what
it came from, and groupByTile and layerRows keep every group no changed
entry falls into, so its mesh is not built again. With the numbers of
the brush stroke on 60x60 and 120x120.

The closing sentence of the #348 paragraph about the mesh still
growing with the map is folded into the new one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
adminandClaude Opus 5.5 committed 2026-10-14 18:38:09 +02:00
1 parent ae9afcad81
commit e33da8932d
1 file changed
+17 -3
+17 -3
@@ -392,9 +392,23 @@ A fourth round (#348) made a painted cell cost what is around it, not the whole
Measured with the same map: one painted cell costs the scene's item list 3.5 ms on 60x60 and 4.0 ms
on 120x120, against 3.4 ms without painting (headless, before 16.8 and 54.6 ms). A brush stroke on
the map doubled to 120x120 runs at 42 fps instead of 28, p95 of a frame 52 instead of 92 ms. What
still grows with the map is the mesh: a painted cell builds the geometry of every tile on that layer
again, since the layer's tiles come as a new list and are grouped by tile afresh.
the map doubled to 120x120 runs at 42 fps instead of 28, p95 of a frame 52 instead of 92 ms.
A fifth round (#424) took out the meshes: a painted cell built the geometry of every tile on that
layer again, since the layer's tiles came as a new list and were grouped by tile afresh.
- A patched list of tiles says what it came from and which entries went and came
(`tilesPatch`). A cell around the painted ones that is drawn the same keeps its entry, and a
patch that changes nothing drawn hands back the very same list.
- `groupByTile` and `layerRows` patch the groups of the list before (`patchedGroups`). A group no
changed entry falls into is the very same array, so its mesh is not built again. On a layer
sorted by Y that goes for each row and for the groups in it.
- A tile new to the layer still works the whole layer out again, as before.
Measured with the same stroke: meshes built per frame 21.9 to 0.94 on 60x60 and 40.7 to 1.22 on
120x120, 49 to 51 fps and 42 to 46 fps. Painting now costs both sizes the same, about 10 fps below
the same view without painting. What is left between the two sizes is drawing the larger map, which
the view without painting shows as well.
A frame still costs what it touches: an object standing **inside** many outlined cells is tested
against each of them, so an outline of a hundred corners around every cell of a lake is dearer than