Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

fix(render): refresh tilemap meshes after layout changes

yhh7a4816c44c5c
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6724f7796..82005c27e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,8 @@ published separately; it ships inside the editor.
### Fixed
+- **Tilemap atlas and grid edits refresh cached meshes.** Changing columns, texture dimensions, atlas borders or grid layout updates UVs and geometry without repainting tile data. Cached meshes now compare their resolved layout inputs, while unchanged inputs retain their geometry; editor pixel checks compare live edits with a fresh repaint.
+
- **Static siblings reuse their parent transform snapshot.** Unchanged static bodies sharing a parent avoid repeated child-world-pose reads while dynamic bodies keep composition active. Parent movement and direct child edits still update their poses in place, and cached parent snapshots are removed when no static body references them.
- **Transformless hierarchy groups preserve child world poses.** A grouping entity without its own Transform no longer stops composition of its descendants. Root groups start from identity, intermediate groups carry the ancestor matrix through, and dirty propagation and traversal guards continue through those nodes.
diff --git a/desktop b/desktop
index 53e998bad..ba95cde51 160000
--- a/desktop
+++ b/desktop
@@ -1 +1 @@
-Subproject commit 53e998badfa4dfce0d377c0c29b6107502bb893d
+Subproject commit ba95cde5127b5a6c8c24f2860f365397b20a0071
diff --git a/src/esengine/renderer/plugins/TilemapRenderPlugin.cpp b/src/esengine/renderer/plugins/TilemapRenderPlugin.cpp
index 226b6f96f..fa3fcf2e1 100644
--- a/src/esengine/renderer/plugins/TilemapRenderPlugin.cpp
+++ b/src/esengine/renderer/plugins/TilemapRenderPlugin.cpp
@@ -315,6 +315,14 @@ void TilemapRenderPlugin::collect(RenderCollectContext& collect_ctx) {
auto& layerCache = cachedLayer != layer_caches_.end() ? cachedLayer->second : layer_caches_[entity];
layerCache.generation = layer.generation;
+ const LayoutInputs layout{layer.tile_width, layer.tile_height, layer.grid_type,
+ layer.hex_side_length, layer.hex_stagger_axis_x, layer.hex_stagger_index_even};
+ if (layerCache.layout != layout || layerCache.tilesets != slots || layerCache.resolved != resolved) {
+ layerCache.chunks.clear();
+ layerCache.layout = layout;
+ layerCache.tilesets = slots;
+ layerCache.resolved = resolved;
+ }
auto& chunkCaches = layerCache.chunks;
// Per-slot merged geometry for this layer (one draw call per slot/texture).
diff --git a/src/esengine/renderer/plugins/TilemapRenderPlugin.hpp b/src/esengine/renderer/plugins/TilemapRenderPlugin.hpp
index 9a7b3f82d..11fef5140 100644
--- a/src/esengine/renderer/plugins/TilemapRenderPlugin.hpp
+++ b/src/esengine/renderer/plugins/TilemapRenderPlugin.hpp
@@ -73,11 +73,25 @@ private:
u32 atlasCols = 0;
u32 atlasRows = 0;
bool valid = false;
+ bool operator==(const ResolvedSlot&) const = default;
+ };
+
+ struct LayoutInputs {
+ f32 tileWidth = 0;
+ f32 tileHeight = 0;
+ tilemap::GridType gridType = tilemap::GridType::Orthogonal;
+ f32 hexSideLength = 0;
+ bool staggerAxisX = false;
+ bool staggerIndexEven = false;
+ bool operator==(const LayoutInputs&) const = default;
};
using ChunkMap = std::unordered_map<tilemap::ChunkCoord, ChunkCache, tilemap::ChunkCoordHash>;
struct LayerCache {
u32 generation = 0;
+ LayoutInputs layout;
+ std::vector<tilemap::TilesetSlot> tilesets;
+ std::vector<ResolvedSlot> resolved;
ChunkMap chunks;
};
using LayerChunkMap = std::unordered_map<Entity, LayerCache>;
diff --git a/src/esengine/tilemap/TilesetTable.hpp b/src/esengine/tilemap/TilesetTable.hpp
index dd5713e92..5aa4605b0 100644
--- a/src/esengine/tilemap/TilesetTable.hpp
+++ b/src/esengine/tilemap/TilesetTable.hpp
@@ -27,6 +27,7 @@ struct TilesetSlot {
// send the exact cell rect; 0 = a packed atlas, where it must inset half a
// texel and stretch the tile instead.
uint32_t extrude = 0;
+ bool operator==(const TilesetSlot&) const = default;
};
/**
diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjs
index 2ce67a0f2..6afe84276 100644
--- a/tools/releaseNotes.mjs
+++ b/tools/releaseNotes.mjs
@@ -28,6 +28,8 @@ export const NOTES_FLOOR = 'v0.65.0';
* the reader recognises anyway.
*/
export const NOTED = {
+ 'fix(render): refresh tilemap meshes after layout changes':
+ { note: 'Tilemap atlas and grid edits refresh cached meshes.' },
'perf(physics): reuse static parent transform snapshots':
{ note: 'Static siblings reuse their parent transform snapshot.' },
'fix(ecs): compose transforms through transformless groups':