fix(core): LandblockMesh keys atlas lookup on TerrainInfo.Type

Task 1's subagent used the raw ushort as the map key because the test
used raw ushort 7 as the value. But the atlas map is built from
Region.TerrainInfo.LandSurfaces.TexMerge.TerrainDesc which keys on
TerrainTextureType enum values, extracted from bits 2-6 of the
TerrainInfo ushort per DatReaderWriter's Types/TerrainInfo.cs.

Reverts to using block.Terrain[hi].Type so the Task 2 TerrainAtlas can
actually find matching keys against real dat terrain. The test is
updated to encode Type=7 correctly as (7 << 2) in the raw ushort.
This commit is contained in:
Erik 2026-04-10 20:18:09 +02:00
parent 324abed6eb
commit 78ce099440
2 changed files with 13 additions and 10 deletions

View file

@ -34,10 +34,11 @@ public static class LandblockMesh
float height = heightTable[block.Height[hi]];
// TerrainInfo raw ushort value used as the atlas-layer map key.
// The map is keyed on the raw terrain ushort (which encodes Road,
// Type, and Scenery fields), matching what the test and caller supply.
uint terrainType = (ushort)block.Terrain[hi];
// TerrainInfo is bit-packed: bits 0-1 Road, bits 2-6 Type (5-bit
// TerrainTextureType enum), bits 11-15 Scenery. The atlas keys on
// Type only, matching Region.TerrainInfo.LandSurfaces.TexMerge.TerrainDesc
// which lists SurfaceTexture ids per TerrainTextureType.
uint terrainType = (uint)block.Terrain[hi].Type;
if (!terrainTypeToLayer.TryGetValue(terrainType, out var layer))
layer = 0;