A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Map: close the seam in every tree crown (fixes #2025) (#2051)
Berid3a24509f966
diff --git a/changelog.d/2025.md b/changelog.d/2025.mdnew file mode 100644index 000000000..c69e9444c--- /dev/null+++ b/changelog.d/2025.md@@ -0,0 +1,4 @@+### Fixed+- Tree crowns no longer have a vertical slit (#2025): the last column of every olive, cypress and citrus crown sits at+ the first column's radius, so light and shadow no longer leak through the seam at close zoom. The other vertices keep+ their seeded shape.diff --git a/unity/Assets/Scripts/Map/Kits/KitMesh.cs b/unity/Assets/Scripts/Map/Kits/KitMesh.csindex 8128f1ea8..5ef88a8dc 100644--- a/unity/Assets/Scripts/Map/Kits/KitMesh.cs+++ b/unity/Assets/Scripts/Map/Kits/KitMesh.cs@@ -303,12 +303,16 @@ namespace Statecraft.Game.Map.Kitsvar cols = new Color32[(rings + 1) * (segments + 1)];for (int j = 0; j <= rings; j++){- float phi = Mathf.PI * j / rings - Mathf.PI * 0.5f;+ float phi = Mathf.PI * j / rings - Mathf.PI * 0.5f, k0 = 0f;for (int i = 0; i <= segments; i++){float th = 2f * Mathf.PI * (i % segments) / segments;var n = new Vector3(Mathf.Cos(phi) * Mathf.Cos(th), Mathf.Sin(phi), Mathf.Cos(phi) * Mathf.Sin(th));- float k = 1f + (j == 0 || j == rings ? 0f : rnd.Range(-lumps, lumps));+ // The last column repeats the first one's angle, so it reuses the first one's lump; otherwise the crown has a+ // slit (#2025). The draw still happens, so every other vertex keeps its seeded shape.+ float lump = j == 0 || j == rings ? 0f : rnd.Range(-lumps, lumps);+ if (i == 0) k0 = lump;+ float k = 1f + (i == segments ? k0 : lump);var p = Vector3.Scale(n, radius) * k;if (p.y < -radius.y * flatBottom) p.y = -radius.y * flatBottom; // a flatter underside, as clipped trees havevar c = speck > 0f && rnd.Chance(speck) ? speckColour : colour;diff --git a/unity/Assets/Tests/EditMode/KitTests.cs b/unity/Assets/Tests/EditMode/KitTests.csindex 5dce6bafe..803c5de1a 100644--- a/unity/Assets/Tests/EditMode/KitTests.cs+++ b/unity/Assets/Tests/EditMode/KitTests.cs@@ -1325,6 +1325,25 @@ public class KitTestsAssert.AreEqual(0, km.BadNormals);}+ /// <summary>#2025: a crown's last column repeats the first column's angle, so it must sit at the same radius too, or every+ /// olive, cypress and orchard crown has a vertical slit that light and shadow leak through. Lumps, segments and rings+ /// as the olive (largest lumps), cypress and orchard crowns in Vegetation.</summary>+ [Test]+ public void EveryCrownClosesItsSeam()+ {+ foreach (var (lumps, segments, rings) in new[] { (0.18f, 6, 4), (0.16f, 7, 4), (0.15f, 6, 3), (0.08f, 7, 7), (0.10f, 7, 5), (0.12f, 6, 4) })+ {+ var km = new KitMesh(); var rnd = new KitRandom("seam");+ km.Crown(Vector3.zero, new Vector3(2f, 1.5f, 1.9f), new Color32(40, 80, 30, 255), ref rnd, lumps, segments, rings);+ var p = new List<Vector3>(); km.Positions(0, km.VertexCount, p);+ for (int j = 0; j <= rings; j++)+ {+ Vector3 first = p[j * (segments + 1)], last = p[j * (segments + 1) + segments];+ Assert.Less(Vector3.Distance(first, last), 1e-4f, $"lumps {lumps}, {segments}x{rings}: ring {j} opens at {first} / {last}");+ }+ }+ }+[Test]public void TheKitShaderRunsOnWebGL2(){