Skip to content

A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.

Hex tiles: a test runs the house simplifier on house 04 (Refs #1901) (#2074)

Beri1acc1ed41765
diff --git a/changelog.d/laneOL-1994-simplifier-test.md b/changelog.d/laneOL-1994-simplifier-test.md
new file mode 100644
index 000000000..8ae25366f
--- /dev/null
+++ b/changelog.d/laneOL-1994-simplifier-test.md
@@ -0,0 +1,2 @@
+- Hex tiles: an edit-mode test runs the generated houses' simplifier (`HexHouseLevels.Simplify`) on house 04 and checks
+ the fresh mesh keeps the seams and the texture, so a broken simplifier fails a test before the next rebuild (#1901).
diff --git a/unity/Assets/Editor/HexTiles/Tests/HexHouseLevelTests.cs b/unity/Assets/Editor/HexTiles/Tests/HexHouseLevelTests.cs
index 558cd4932..84295b70b 100644
--- a/unity/Assets/Editor/HexTiles/Tests/HexHouseLevelTests.cs
+++ b/unity/Assets/Editor/HexTiles/Tests/HexHouseLevelTests.cs
@@ -85,9 +85,37 @@ public class HexHouseLevelTests
[TestCaseSource(nameof(Houses))]
public void TheLighterLevelKeepsTheSeamsAndTheTexture(string id)
{
- var source = SourceMesh(id);
var light = AssetDatabase.LoadAssetAtPath<Mesh>(Light(id) + ".asset");
Assert.IsNotNull(light, id + ": no lighter level");
+ KeepsTheSeamsAndTheTexture(id, SourceMesh(id), light);
+
+ // No new see-through (the hex tiles' wholeness check, HexModelMeshTests).
+ var full = HexMeshCheck.Of(AssetDatabase.LoadAssetAtPath<GameObject>(Stem(id) + ".prefab"));
+ var lighter = HexMeshCheck.Of(AssetDatabase.LoadAssetAtPath<GameObject>(Light(id) + ".prefab"));
+ TestContext.WriteLine($"{id}: full {full}; light {lighter}");
+ Assert.That(lighter.SeeThroughShare, Is.LessThanOrEqualTo(full.SeeThroughShare + 0.0005f), id);
+ Assert.AreEqual(AssetDatabase.LoadAssetAtPath<Material>(Stem(id) + ".mat"),
+ AssetDatabase.LoadAssetAtPath<GameObject>(Light(id) + ".prefab").GetComponentInChildren<MeshRenderer>().sharedMaterial, id + ": Tal's material");
+ }
+
+ /// <summary>The checks above test the committed -light files, so a broken HexHouseLevels.Simplify would only show at the
+ /// next rebuild (owner, PR #1994, 30 October 2026). This runs it on house 04, the one the Tiberias boards draw, with
+ /// Build's settings, and holds the fresh mesh to the same seam and texture promises.</summary>
+ [Test]
+ public void TheSimplifierKeepsTheSeamsAndTheTextureOfHouse04()
+ {
+ const string id = "generated-1948-04-dark-basalt-house";
+ var source = SourceMesh(id);
+ int texels = AssetDatabase.LoadAssetAtPath<Material>(Stem(id) + ".mat").mainTexture.width;
+ var light = HexHouseLevels.Simplify(source, HexHouseLevels.UvToleranceTexels / texels, HexHouseLevels.EdgeTolerance, HexHouseLevels.MaxError);
+ try { KeepsTheSeamsAndTheTexture(id, source, light); }
+ finally { UnityEngine.Object.DestroyImmediate(light); }
+ }
+
+ /// <summary>The lighter mesh's promises that need no prefab: fewer triangles, every vertex one of the source's, no seam
+ /// or edge opened, the chart corners kept, the texture border within the tolerances.</summary>
+ static void KeepsTheSeamsAndTheTexture(string id, Mesh source, Mesh light)
+ {
int sourceTris = source.triangles.Length / 3, lightTris = light.triangles.Length / 3;
Assert.That(lightTris, Is.LessThan(sourceTris), id);
@@ -131,14 +159,6 @@ public class HexHouseLevelTests
$"{id}: removed seam vertex {i} lies off the border left behind (nearest in UV {seams.Min(s => Off(suv[i], s.ua, s.ub)) * texels:F2} texels, in 3D {seams.Min(s => Off(sv[i], s.pa, s.pb)) / size:P3})");
}
TestContext.WriteLine($"{id}: {removed} seam corners removed, each within the tolerances of a kept seam segment");
-
- // No new see-through (the hex tiles' wholeness check, HexModelMeshTests).
- var full = HexMeshCheck.Of(AssetDatabase.LoadAssetAtPath<GameObject>(Stem(id) + ".prefab"));
- var lighter = HexMeshCheck.Of(AssetDatabase.LoadAssetAtPath<GameObject>(Light(id) + ".prefab"));
- TestContext.WriteLine($"{id}: full {full}; light {lighter}");
- Assert.That(lighter.SeeThroughShare, Is.LessThanOrEqualTo(full.SeeThroughShare + 0.0005f), id);
- Assert.AreEqual(AssetDatabase.LoadAssetAtPath<Material>(Stem(id) + ".mat"),
- AssetDatabase.LoadAssetAtPath<GameObject>(Light(id) + ".prefab").GetComponentInChildren<MeshRenderer>().sharedMaterial, id + ": Tal's material");
}
/// <summary>Open (one face) and non-manifold (three or more) edges after welding by position, and the positions on them.</summary>