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.

Map: MATKOT's whole-town models stand on their towns' cores far off, no kit houses in them (refs #663 #917 #659) (#994)

Eyal Golane975c39102ba
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a23225d66..2848142f8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -68,6 +68,15 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIB
goldens do not move (refs #107).
### Changed
+- MATKOT's whole-town models now stand on their towns far off, and the towns draw no procedural houses at any zoom
+ (refs #663, #917, #659; owner, 18 October 2026: "Whole model far, buildings near"). Each mapped town's model stands
+ on the town's core (where most of its building models stand, inside its kit footprint, clear of the next town and of
+ the sea, so Tel Aviv's no longer covers Jaffa and Haifa's stays out of the bay), as wide as that core, upright,
+ tilted to its ground (at most 10 degrees) and seated at its lowest point, so it never floats and a hillside no longer
+ cuts through it. Below about 40 km it gives way to
+ the single building models (#700), with the same hysteresis band. Mosques, churches, walls and ports keep the kit.
+ The 110 km view-distance switch and the "beside the town" spot are gone; a ma'abara or shikun still stands beside its
+ camp or housing project.
- The population-tier badge on the twelve city and town pills keeps the values it shipped with, now owner-approved: tiers 1
to 9 doubling from 1,000 people, at every zoom, at the start of the name and mirrored in Hebrew (owner, 18 October 2026,
"Accept as shipped"). Rosh Pinna keeps tier 1 from its May 1948 figure of 350, which the data marks `wikipedia-only`
diff --git a/unity/Assets/Scripts/Map/Collection/CollectionCatalog.cs b/unity/Assets/Scripts/Map/Collection/CollectionCatalog.cs
index 84c8a252c..1a726fb32 100644
--- a/unity/Assets/Scripts/Map/Collection/CollectionCatalog.cs
+++ b/unity/Assets/Scripts/Map/Collection/CollectionCatalog.cs
@@ -11,7 +11,7 @@ namespace Statecraft.Game.Map.Collection
/// <summary>The 31 non-building models of The 1948 Collection, made by MATKOT with Tripo Studio and
/// offered in #507 (issue #664; the owner ruled them OK to use, 15 October 2026), and #507's nine whole-town models (issue
- /// #663; owner, 17 October 2026: "The nine whole-town models ship"), drawn as overview landmarks (<see cref="TownLandmarks"/>).
+ /// #663; owner, 17 October 2026: "The nine whole-town models ship"), standing on their towns far off (<see cref="TownLandmarks"/>).
/// They are slimmed by
/// tools/slim_collection.py and live in <see cref="Folder"/>/&lt;id&gt;/, outside every Resources folder. Each ships as two
/// prefabs, &lt;id&gt;-far and &lt;id&gt;-near, in its category's AssetBundle, which the game streams after the first frame
diff --git a/unity/Assets/Scripts/Map/Collection/TownLandmarks.cs b/unity/Assets/Scripts/Map/Collection/TownLandmarks.cs
index 1f54573b0..433f4dae0 100644
--- a/unity/Assets/Scripts/Map/Collection/TownLandmarks.cs
+++ b/unity/Assets/Scripts/Map/Collection/TownLandmarks.cs
@@ -8,36 +8,35 @@ using UnityEngine.Rendering;
namespace Statecraft.Game.Map.Collection
{
- /// <summary>The nine whole-town models of The 1948 Collection as overview landmarks (issue #663; owner ruling of 17 October
- /// 2026: "The nine whole-town models ship (this reverses the 15 Oct 'layout references only' ruling). They are slimmed,
- /// streamed after the first frame, and pass the load gate. The ma'abara and the shikun appear only from their sourced
- /// 1950s dates."). The models are MATKOT's, made with Tripo Studio and offered in #507; which town each
- /// stands at is #507's own mapping (BuildingPreview at 3ef0a7a5): White City at Tel Aviv, the stone city at Jerusalem, the
- /// port city at Haifa, the moshava town at the six moshavot, Nahalal at the moshav, the compound at every kibbutz, the
- /// stone village at every Arab town, the ma'abara at a transit camp and the shikun at a housing project.
- /// Each stands beside its town, never on it: on the nearest free ground clear of every kit footprint (towns, 1948
- /// localities, Bedouin camps: MapScene.KitFootprints), every route corridor, the water, the units and every other
- /// landmark (<see cref="Spot"/>), so the settlement kits (#820) and the close-zoom building models (#700) are untouched.
- /// They draw only at the overview zoom (a camera's view distance from <see cref="OverviewEnterM"/> on, back off below
- /// <see cref="OverviewExitM"/>), where a kit town is a few pixels across; at the gameplay and close zooms nothing changes.
+ /// <summary>The nine whole-town models of The 1948 Collection (issue #663; owner ruling of 17 October 2026: "The nine
+ /// whole-town models ship (this reverses the 15 Oct 'layout references only' ruling). They are slimmed, streamed after
+ /// the first frame, and pass the load gate. The ma'abara and the shikun appear only from their sourced 1950s dates.").
+ /// The models are MATKOT's, made with Tripo Studio and offered in #507; which town each stands at is #507's own mapping
+ /// (BuildingPreview at 3ef0a7a5): White City at Tel Aviv, the stone city at Jerusalem, the port city at Haifa, the
+ /// moshava town at the six moshavot, Nahalal at the moshav, the compound at every kibbutz, the stone village at every
+ /// Arab town, the ma'abara at a transit camp and the shikun at a housing project.
+ /// Owner ruling of 18 October 2026 (recorded on #917, #663, #659 and #700): the towns are MATKOT's models, "Whole model
+ /// far, buildings near". Far off, a mapped town's whole-town model stands ON its town, on its core (<see cref="CoreOf"/>:
+ /// where most of its building models stand, inside its kit footprint, clear of the next town and of the sea), as wide as
+ /// that core, tilted to its ground and seated so it never floats (<see cref="SeatOn"/>).
+ /// Up close, where #700's building models draw the same town (TownModelLayer.CloseAt, with its hysteresis), the
+ /// whole-town model hides (<see cref="Choose"/>). The town's procedural houses never draw, at any zoom: its kit mesh gives
+ /// way to its close mesh (the kit without its buildings; its mosques, churches, walls and port stay, as #700 keeps them)
+ /// for good (TownModelLayer.Suppress). A placement's landmark (the ma'abara, the shikun) still stands beside its camp or
+ /// housing project, on free ground (<see cref="Spot"/>), <see cref="SizeM"/> across, and hides up close too.
/// Each model is the strategic zoom's mesh (CollectionDetail.Far, at most 4,500 triangles), asked of
- /// <see cref="CollectionStream"/> when the first landmark needs it, so it is never fetched before the first frame, and
- /// the spots are worked out only once a model has come. It fails open: a model that does not stream logs one warning
- /// and its landmarks are not drawn; the map and the game run on.</summary>
+ /// <see cref="CollectionStream"/> when the first landmark needs it, so it is never fetched before the first frame. It fails
+ /// open: a model that does not stream logs one warning, its landmarks are not drawn and its towns keep their kit houses
+ /// far off (they are not suppressed); without #700's building models (TownModelLayer.HasModels false) the whole-town
+ /// models draw at every zoom, so no mapped town is ever left without buildings.</summary>
+ [ExecuteAlways]
public sealed class TownLandmarks : MonoBehaviour
{
public const string Name = "TownLandmarks";
- /// <summary>The view distances (m) of the switch, with hysteresis: from 110 km on the landmarks draw, below 98 km they
- /// go (owner on #917, 17 October 2026: "Larger, from 120 km"). The game starts at 120 km (CameraRig.Distance), so the
- /// player sees them at once, as at the overview (diorama02 and the minimap's whole-map button:
- /// CameraController.MaxDistance, 250 km); the gameplay view (60 km, gameplay03) and every closer zoom, where the
- /// per-building kits draw, do not. The band is wider than one wheel notch (CameraController.ZoomPerStep, 10% of the
- /// distance).</summary>
- public const float OverviewEnterM = 110000f, OverviewExitM = 98000f;
-
- /// <summary>A landmark's largest edge on the ground (m): about 41 px across at 250 km and 86 px at 120 km on a 1080 px
- /// screen (CameraRig.Fov 35 degrees). Symbolic, like the kits' scale (owner on #917: "Larger", about 6 km).</summary>
+ /// <summary>A placement's landmark's largest edge on the ground (m), beside its camp or housing project: about 41 px
+ /// across at 250 km and 86 px at 120 km on a 1080 px screen (CameraRig.Fov 35 degrees; owner on #917: "Larger", about
+ /// 6 km). A town's whole-town model is as wide as the town's kit footprint instead.</summary>
public const float SizeM = 6000f;
/// <summary>The ma'abara from the date the first one is reported: Kachansky, "The Ma'abarot" (Yad Ben-Zvi, 1987),
@@ -97,32 +96,34 @@ namespace Statecraft.Game.Map.Collection
public static string? ModelFor(string action, DateTime date) =>
ByAction.TryGetValue(action, out var row) && row.From is { } from && date >= from ? row.Model : null;
- /// <summary>One landmark to draw: its key (the settlement id, or the placement's box name), its model, and the centre
- /// and radius (m, world x/z) of the ground its town or placement holds.</summary>
+ /// <summary>One landmark to draw: its key (the settlement id, or the placement's box name), its model, the centre
+ /// and radius (m, world x/z) of the ground its town or placement holds, and whether it stands on that ground (a town)
+ /// or beside it (a placement).</summary>
public readonly struct Want : IEquatable<Want>
{
- public readonly string Key, Model; public readonly Vector2 At; public readonly float Radius;
- public Want(string key, string model, Vector2 at, float radius) { Key = key; Model = model; At = at; Radius = radius; }
- public bool Equals(Want o) => Key == o.Key && Model == o.Model && At == o.At && Radius == o.Radius;
+ public readonly string Key, Model; public readonly Vector2 At; public readonly float Radius; public readonly bool OnTown;
+ public Want(string key, string model, Vector2 at, float radius, bool onTown)
+ { Key = key; Model = model; At = at; Radius = radius; OnTown = onTown; }
+ public bool Equals(Want o) => Key == o.Key && Model == o.Model && At == o.At && Radius == o.Radius && OnTown == o.OnTown;
public override bool Equals(object? o) => o is Want w && Equals(w);
- public override int GetHashCode() => (Key, Model, At, Radius).GetHashCode();
+ public override int GetHashCode() => (Key, Model, At, Radius, OnTown).GetHashCode();
}
- /// <summary>The landmarks the map wants as at <paramref name="date"/>: one per mapped settlement (its kit footprint's
- /// radius, or its marker box's half edge without kits) and one per mapped placement from its date (its hex's
- /// half width), in a fixed order: settlements as the file lists them, then placements as placed.</summary>
+ /// <summary>The landmarks the map wants as at <paramref name="date"/>: one per mapped settlement, on its kit footprint
+ /// (its centre and radius; without kits its marker box's half edge), and one per mapped placement from its date (its
+ /// hex's half width), in a fixed order: settlements as the file lists them, then placements as placed.</summary>
public static List<Want> Wants(MapScene map, DateTime date, IEnumerable<Placement> placements, Content content)
{
- var radius = new Dictionary<string, float>(StringComparer.Ordinal);
- foreach (var (_, r, id) in map.KitFootprints) if (!radius.ContainsKey(id)) radius[id] = r;
+ var footprint = new Dictionary<string, (Vector2 centre, float radius)>(StringComparer.Ordinal);
+ foreach (var (c, r, id) in map.KitFootprints) if (!footprint.ContainsKey(id)) footprint[id] = (c, r);
var wants = new List<Want>();
foreach (var s in map.Settlements)
{
var model = ModelFor(s);
if (model == null) continue;
var w = map.Frame.ToWorld(s.Lon, s.Lat, 0);
- float r = radius.TryGetValue(s.Id, out var kr) ? kr : 0.5f * SettlementPlacer.MarkerHeightM(s.Type);
- wants.Add(new Want(s.Id, model, new Vector2(w.x, w.z), r));
+ var (at, r) = footprint.TryGetValue(s.Id, out var f) ? f : (new Vector2(w.x, w.z), 0.5f * SettlementPlacer.MarkerHeightM(s.Type));
+ wants.Add(new Want(s.Id, model, at, r, onTown: true));
}
float hexHalf = 500f * map.Hexes.hex_size_km;
foreach (var p in placements)
@@ -131,7 +132,7 @@ namespace Statecraft.Game.Map.Collection
var hex = model == null ? null : content.HexAt(p.Q, p.R);
if (hex == null) continue;
var w = map.Frame.ToWorld(hex.Lon, hex.Lat, 0);
- wants.Add(new Want($"{p.Action}_{p.Q}_{p.R}", model!, new Vector2(w.x, w.z), hexHalf));
+ wants.Add(new Want($"{p.Action}_{p.Q}_{p.R}", model!, new Vector2(w.x, w.z), hexHalf, onTown: false));
}
return wants;
}
@@ -157,6 +158,97 @@ namespace Statecraft.Game.Map.Collection
public const int Rings = 8, Bearings = 16;
+ /// <summary>The share of a town's building plots (#700's models at the world scale, SettlementKits.ModelScale) its
+ /// core holds: the whole-town model is as wide as the disc round them (<see cref="CoreOf"/>).</summary>
+ public const float CoreShare = 0.7f;
+ /// <summary>The most of the ground under a whole-town model that may be water (a coastal town keeps its shore).</summary>
+ public const float MaxWaterShare = 0.2f;
+ /// <summary>A whole-town model's half edge stays under this share of the distance to the nearest other game settlement,
+ /// so its ground rectangle (its corners reach about 1.41 half edges out) never covers that town.</summary>
+ public const float NeighbourShare = 0.65f;
+
+ /// <summary>A town's core (owner, 18 October 2026, through the coordinator: sized "so Tel Aviv doesn't cover Jaffa and
+ /// Haifa doesn't reach into the bay"): the centroid of the <see cref="CoreShare"/> of its building plots
+ /// (<paramref name="plots"/>) nearest its centre (<paramref name="centre"/>), and the radius that holds that share round
+ /// it, no more than its kit footprint (<paramref name="footprint"/>), under <see cref="NeighbourShare"/> of the distance
+ /// to the nearest of <paramref name="others"/>, then pulled in (by tenths, to a third of where it started) while more
+ /// than <see cref="MaxWaterShare"/> of the disc is water. With fewer than five plots: the centre and the footprint,
+ /// under the same two limits.</summary>
+ public static (Vector2 centre, float radius) CoreOf(Vector2 centre, float footprint, IReadOnlyList<Vector2> plots, IEnumerable<Vector2> others,
+ Func<float, float, bool> water)
+ {
+ Vector2 c = centre; float r = footprint;
+ if (plots.Count >= 5)
+ {
+ var near = plots.OrderBy(p => (p - centre).sqrMagnitude).Take(Mathf.Max(5, Mathf.CeilToInt(CoreShare * plots.Count))).ToList();
+ c = near.Aggregate(Vector2.zero, (a, p) => a + p) / near.Count;
+ var d = near.Select(p => (p - c).magnitude).OrderBy(x => x).ToList();
+ r = Mathf.Min(footprint, d[d.Count - 1]);
+ }
+ foreach (var o in others) r = Mathf.Min(r, NeighbourShare * (o - c).magnitude);
+ float floor = r / 3f;
+ for (int i = 0; i < 12 && r > floor && WaterShare(c, r, water) > MaxWaterShare; i++) r = Mathf.Max(floor, 0.9f * r);
+ return (c, r);
+ }
+
+ /// <summary>The share of 11 x 11 points in the disc at <paramref name="c"/> of <paramref name="r"/> that are water.</summary>
+ public static float WaterShare(Vector2 c, float r, Func<float, float, bool> water)
+ {
+ int n = 0, wet = 0;
+ for (int i = 0; i <= 10; i++)
+ for (int k = 0; k <= 10; k++)
+ {
+ var q = c + new Vector2(-r + 2f * r * i / 10f, -r + 2f * r * k / 10f);
+ if ((q - c).sqrMagnitude > r * r * 1.0001f) continue;
+ n++; if (water(q.x, q.y)) wet++;
+ }
+ return n == 0 ? 0f : (float)wet / n;
+ }
+
+ /// <summary>The steepest a whole-town model leans with its ground (degrees).</summary>
+ public const float MaxTiltDeg = 10f;
+ /// <summary>Samples across the footprint's square (per side) for <see cref="SeatOn"/>.</summary>
+ public const int SeatSamples = 11;
+
+ /// <summary>Where a whole-town model sits: the centre of its town (world x/z), its largest horizontal edge (m), the
+ /// normal of its base plane and that plane's height (m) at the centre.</summary>
+ public readonly struct Seat
+ {
+ public readonly Vector2 Centre; public readonly float Edge; public readonly Vector3 Normal; public readonly float BaseY;
+ public Seat(Vector2 centre, float edge, Vector3 normal, float baseY) { Centre = centre; Edge = edge; Normal = normal; BaseY = baseY; }
+ }
+
+ /// <summary>The base plane of a model over the disc at <paramref name="centre"/> of <paramref name="radius"/>: the
+ /// least-squares plane of the ground heights <paramref name="y"/> at <see cref="SeatSamples"/> squared points in the disc
+ /// (water points left out, <paramref name="water"/>), its slope clamped to <see cref="MaxTiltDeg"/>, then lowered to
+ /// the lowest of them, so no land point lies below it: the model follows its slope and never floats (the kibbutz cut
+ /// into its hill on #917 when it stood level at its centre's height). Returns the plane's normal and its height at the
+ /// centre; on flat or all-water ground, level at the centre's height.</summary>
+ public static (Vector3 normal, float baseY) SeatOn(Vector2 centre, float radius, Func<float, float, float> y, Func<float, float, bool> water)
+ {
+ var pts = new List<(float dx, float dz, float h)>();
+ for (int i = 0; i < SeatSamples; i++)
+ for (int k = 0; k < SeatSamples; k++)
+ {
+ float dx = radius * (2f * i / (SeatSamples - 1) - 1f), dz = radius * (2f * k / (SeatSamples - 1) - 1f);
+ if (dx * dx + dz * dz > radius * radius * 1.0001f || water(centre.x + dx, centre.y + dz)) continue; // the rim kept despite rounding
+ pts.Add((dx, dz, y(centre.x + dx, centre.y + dz)));
+ }
+ if (pts.Count < 3) return (Vector3.up, y(centre.x, centre.y));
+ // Least squares h = a + b dx + c dz (in doubles: the sums of squares of 10 km offsets).
+ double n = pts.Count, sx = 0, sz = 0, sh = 0, sxx = 0, szz = 0, sxz = 0, sxh = 0, szh = 0;
+ foreach (var (dx, dz, h) in pts) { sx += dx; sz += dz; sh += h; sxx += dx * dx; szz += dz * dz; sxz += dx * dz; sxh += dx * h; szh += dz * h; }
+ double mx = sx / n, mz = sz / n, mh = sh / n;
+ double cxx = sxx / n - mx * mx, czz = szz / n - mz * mz, cxz = sxz / n - mx * mz, cxh = sxh / n - mx * mh, czh = szh / n - mz * mh;
+ double det = cxx * czz - cxz * cxz;
+ double b = det > 1e-6 ? (cxh * czz - czh * cxz) / det : 0, c = det > 1e-6 ? (czh * cxx - cxh * cxz) / det : 0;
+ double slope = Math.Sqrt(b * b + c * c), max = Math.Tan(MaxTiltDeg * Mathf.Deg2Rad);
+ if (slope > max) { b *= max / slope; c *= max / slope; }
+ double low = double.MaxValue;
+ foreach (var (dx, dz, h) in pts) low = Math.Min(low, h - (b * dx + c * dz));
+ return (new Vector3((float)-b, 1f, (float)-c).normalized, (float)low);
+ }
+
/// <summary>Whether a disc at <paramref name="p"/> of radius <paramref name="r"/> stays off every disc of
/// <paramref name="discs"/> (edge to edge).</summary>
public static bool Clear(Vector2 p, float r, IEnumerable<(Vector2 centre, float radius)> discs)
@@ -170,7 +262,8 @@ namespace Statecraft.Game.Map.Collection
MapScene? map;
readonly Dictionary<string, GameObject?> prefabs = new Dictionary<string, GameObject?>(StringComparer.Ordinal);
readonly HashSet<string> asked = new HashSet<string>(StringComparer.Ordinal);
- readonly Dictionary<int, bool> overviewFor = new Dictionary<int, bool>();
+ /// <summary>Each camera's last choice (by instance id): TownModelLayer.CloseAt's hysteresis.</summary>
+ readonly Dictionary<int, bool> closeFor = new Dictionary<int, bool>();
readonly List<Renderer> renderers = new List<Renderer>();
List<Want> wants = new List<Want>();
DateTime date;
@@ -180,8 +273,10 @@ namespace Statecraft.Game.Map.Collection
public readonly List<(string Key, string Model, Vector3 At)> Placed = new List<(string, string, Vector3)>();
/// <summary>The landmarks wanted but not drawn: their model did not stream, or no spot was free (a test aid).</summary>
public readonly List<string> Missing = new List<string>();
- /// <summary>For the last camera: whether it drew the landmarks.</summary>
- public bool LastOverview { get; private set; }
+ /// <summary>Where each town's whole-town model sits, by settlement id (a test aid).</summary>
+ public readonly Dictionary<string, Seat> Seats = new Dictionary<string, Seat>(StringComparer.Ordinal);
+ /// <summary>For the last camera: whether it hid the landmarks (up close, where #700's building models draw).</summary>
+ public bool LastHidden { get; private set; }
public IReadOnlyList<Want> Wanted => wants;
/// <summary>Shows the landmarks the map wants as at <paramref name="date"/> (GameRoot calls it on every change, beside
@@ -233,10 +328,11 @@ namespace Statecraft.Game.Map.Collection
var old = transform.GetChild(i).gameObject;
if (Application.isPlaying) { old.transform.SetParent(null); Destroy(old); } else DestroyImmediate(old);
}
- renderers.Clear(); Placed.Clear(); Missing.Clear();
+ renderers.Clear(); Placed.Clear(); Missing.Clear(); Seats.Clear();
if (!wants.Any(w => prefabs.TryGetValue(w.Model, out var p) && p != null))
{
Missing.AddRange(wants.Where(w => prefabs.ContainsKey(w.Model)).Select(w => w.Key));
+ Layer()?.Suppress(Array.Empty<string>());
return;
}
var ground = PlacementLayer.CampGround(map);
@@ -256,34 +352,61 @@ namespace Statecraft.Game.Map.Collection
}
return !ground.OnRoute(p, rad) && !ground.OnToken(p, rad) && !ground.OnToken(p, rad, date);
}
+ var layer = Layer();
+ // Every game settlement's centre (its kit footprint's), for the cores' neighbour limit.
+ var gameIds = new HashSet<string>(map.Settlements.Select(x => x.Id), StringComparer.Ordinal);
+ var townCentres = map.KitFootprints.Where(f => gameIds.Contains(f.id)).Select(f => (c: f.centre, id: f.id)).ToList();
foreach (var w in wants)
{
if (!prefabs.TryGetValue(w.Model, out var prefab)) continue; // still streaming
- var at = prefab == null ? null : Spot(w.At, w.Radius, r, Free);
- if (at == null) { Missing.Add(w.Key); continue; }
- taken.Add((at.Value, r));
- var go = Instantiate(prefab!, transform, false);
+ if (prefab == null) { Missing.Add(w.Key); continue; }
+ Vector2 at; float edge, baseY; Vector3 normal = Vector3.up;
+ if (w.OnTown)
+ {
+ // On the town's core, not its whole kit footprint (Tel Aviv's held Jaffa, Haifa's the bay).
+ var plots = layer == null ? (IReadOnlyList<Vector2>)Array.Empty<Vector2>()
+ : layer.InstancesOf(w.Key).Select(m => m.Plot).Distinct().ToList();
+ var others = wants.Where(o => o.OnTown && o.Key != w.Key).Select(o => o.At).Concat(townCentres.Where(o => o.id != w.Key).Select(o => o.c));
+ var (core, rad) = CoreOf(w.At, w.Radius, plots, others, ground.Water);
+ at = core; edge = 2f * rad;
+ (normal, baseY) = SeatOn(at, rad, ground.Y, ground.Water);
+ }
+ else
+ {
+ var spot = Spot(w.At, w.Radius, r, Free);
+ if (spot == null) { Missing.Add(w.Key); continue; }
+ at = spot.Value; edge = SizeM; baseY = ground.Y(at.x, at.y);
+ taken.Add((at, r));
+ }
+ var go = Instantiate(prefab, transform, false);
go.name = w.Key;
// The yaw goes on top of the prefab's own rotation: every Collection Far prefab's root carries the FBX axis
// conversion (-90 degrees about X; bakeAxisConversion is off), and setting the yaw alone laid each model on its
- // side (owner, 18 October 2026: the models "seem to be on their side on the map").
- go.transform.localRotation = Quaternion.Euler(0f, YawOf(w.Model), 0f) * prefab!.transform.localRotation;
+ // side (owner, 18 October 2026: the models "seem to be on their side on the map"; #979).
+ go.transform.localRotation = Quaternion.Euler(0f, YawOf(w.Model), 0f) * prefab.transform.localRotation;
var bounds = Bounds(go);
- float edge = Mathf.Max(bounds.size.x, bounds.size.z);
- go.transform.localScale *= edge > 1e-3f ? SizeM / edge : 1f;
- var pos = new Vector3(at.Value.x, ground.Y(at.Value.x, at.Value.y), at.Value.y);
- // The model's base, after the scale, stands on the ground at its spot.
+ float size = Mathf.Max(bounds.size.x, bounds.size.z);
+ go.transform.localScale *= size > 1e-3f ? edge / size : 1f;
+ // The model's base, after the scale, stands on its seat, centred on its town or spot; then it leans with the
+ // ground about that point (level for a placement).
+ var pos = new Vector3(at.x, baseY, at.y);
go.transform.position = pos;
var b = Bounds(go);
go.transform.position += new Vector3(pos.x - b.center.x, pos.y - b.min.y, pos.z - b.center.z);
+ var tilt = Quaternion.FromToRotation(Vector3.up, normal);
+ go.transform.SetPositionAndRotation(pos + tilt * (go.transform.position - pos), tilt * go.transform.rotation);
foreach (var rr in go.GetComponentsInChildren<Renderer>(true))
{
rr.shadowCastingMode = ShadowCastingMode.On;
- rr.forceRenderingOff = !LastOverview;
+ rr.forceRenderingOff = LastHidden;
renderers.Add(rr);
}
+ if (w.OnTown) Seats[w.Key] = new Seat(at, edge, normal, baseY);
Placed.Add((w.Key, w.Model, pos));
}
+ // The towns that have their whole-town model never draw their kit houses (owner, 18 October 2026: no procedural
+ // houses in those towns at any zoom); a town whose model did not stream keeps them.
+ if (layer != null) layer.Suppress(Seats.Keys);
Debug.Log($"LANDMARKS: {Placed.Count} town landmarks placed, {Missing.Count} not drawn");
}
@@ -296,31 +419,29 @@ namespace Statecraft.Game.Map.Collection
return b;
}
- /// <summary>The camera's view distance (m): along its view ray to the map's ground plane (y = 0, where the camera rig's
- /// look-at stands), so it is the rig's zoom (CameraRig.Distance). A camera looking up or level sees no ground: far.</summary>
- public static float ViewDistance(Camera cam)
- {
- var t = cam.transform;
- return t.forward.y < -1e-4f ? t.position.y / -t.forward.y : float.PositiveInfinity;
- }
+ /// <summary>The camera's view distance (m), as TownModelLayer measures it (the rig's zoom); the people, wildlife and
+ /// road vehicle layers read it from here.</summary>
+ public static float ViewDistance(Camera cam) => Kits.TownModelLayer.ViewDistance(cam);
- /// <summary>Whether a camera at <paramref name="distanceM"/> draws the landmarks, given its last choice
- /// (<paramref name="was"/>, null for none).</summary>
- public static bool OverviewAt(float distanceM, bool? was) =>
- was == true ? distanceM >= OverviewExitM : distanceM >= OverviewEnterM;
+ /// <summary>#700's building layer of this map (null without kits).</summary>
+ Kits.TownModelLayer? Layer() => map == null ? null : map.GetComponentInChildren<Kits.TownModelLayer>(true);
void OnEnable() => RenderPipelineManager.beginCameraRendering += Choose;
void OnDisable() => RenderPipelineManager.beginCameraRendering -= Choose;
- /// <summary>Before each camera culls: the landmarks on at its overview zoom, off otherwise.</summary>
+ /// <summary>Before each camera culls: the landmarks hide where #700's building models draw the towns
+ /// (TownModelLayer.CloseAt at the camera's view distance, with its hysteresis), and draw everywhere else. Without the
+ /// building models (no kits, or TownModelLayer.HasModels false) they draw at every zoom.</summary>
internal void Choose(ScriptableRenderContext context, Camera cam)
{
if (cam.cameraType == CameraType.Preview || cam.cameraType == CameraType.Reflection) return;
+ var layer = Layer();
int id = cam.GetInstanceID();
- bool on = OverviewAt(ViewDistance(cam), overviewFor.TryGetValue(id, out var was) ? was : (bool?)null);
- overviewFor[id] = on;
- LastOverview = on;
- foreach (var r in renderers) if (r != null) r.forceRenderingOff = !on;
+ bool close = Kits.TownModelLayer.CloseAt(Kits.TownModelLayer.ViewDistance(cam), closeFor.TryGetValue(id, out var was) ? was : (bool?)null);
+ closeFor[id] = close;
+ bool hide = close && layer != null && layer.HasModels;
+ LastHidden = hide;
+ foreach (var r in renderers) if (r != null) r.forceRenderingOff = hide;
}
}
}
diff --git a/unity/Assets/Scripts/Map/Kits/TownModelLayer.cs b/unity/Assets/Scripts/Map/Kits/TownModelLayer.cs
index a9bb34316..0995fafd4 100644
--- a/unity/Assets/Scripts/Map/Kits/TownModelLayer.cs
+++ b/unity/Assets/Scripts/Map/Kits/TownModelLayer.cs
@@ -38,6 +38,8 @@ namespace Statecraft.Game.Map.Kits
readonly List<(Renderer kit, Renderer? close)> swaps = new List<(Renderer, Renderer?)>();
/// <summary>Each camera's last choice (by instance id), for the hysteresis.</summary>
readonly Dictionary<int, bool> closeFor = new Dictionary<int, bool>();
+ /// <summary>The towns whose kit buildings never draw (<see cref="Suppress"/>), by settlement id.</summary>
+ readonly HashSet<string> suppressed = new HashSet<string>(System.StringComparer.Ordinal);
TownModelSet? set;
public bool Draw { get; set; } = true;
/// <summary>Whether the layer has a complete model list (else the towns keep their kits at every zoom).</summary>
@@ -94,6 +96,21 @@ namespace Statecraft.Game.Map.Kits
Show(false);
}
+ /// <summary>Owner ruling of 18 October 2026 ("Whole model far, buildings near"; no procedural houses in a town with a
+ /// whole-town model, at any zoom): the towns <paramref name="ids"/> (the settlement ids TownLandmarks stood a
+ /// whole-town model on) show their close mesh at every zoom, their kit mesh at none. Far off their whole-town model
+ /// stands on them, up close these models do. Replaces the last list; an empty list gives every town #700's swap back.
+ /// It holds without a complete model list too (the whole-town model then draws at every zoom: TownLandmarks).</summary>
+ public void Suppress(IEnumerable<string> ids)
+ {
+ suppressed.Clear();
+ suppressed.UnionWith(ids);
+ Show(set != null && LastClose);
+ }
+
+ /// <summary>Whether town <paramref name="id"/>'s kit buildings never draw (a test aid).</summary>
+ public bool Suppressed(string id) => suppressed.Contains(id);
+
/// <summary>The models placed for a town or locality (a test aid).</summary>
public int CountFor(string id) => perPlace.TryGetValue(id, out var l) ? l.Count : 0;
@@ -132,13 +149,15 @@ namespace Statecraft.Game.Map.Kits
foreach (var t in tiles) foreach (var m in t.m) yield return (t.model, m);
}
- /// <summary>Kit buildings (false) or close meshes (true) for the camera about to render.</summary>
+ /// <summary>Kit buildings (false) or close meshes (true) for the camera about to render; a suppressed town's close mesh
+ /// at either.</summary>
void Show(bool close)
{
foreach (var (kit, closeR) in swaps)
{
- if (kit != null) kit.forceRenderingOff = close;
- if (closeR != null) closeR.forceRenderingOff = !close;
+ bool c = close || (kit != null && suppressed.Contains(kit.name));
+ if (kit != null) kit.forceRenderingOff = c;
+ if (closeR != null) closeR.forceRenderingOff = !c;
}
}
diff --git a/unity/Assets/Scripts/UI/GameRoot.cs b/unity/Assets/Scripts/UI/GameRoot.cs
index 9092ccc5e..435f2ac3e 100644
--- a/unity/Assets/Scripts/UI/GameRoot.cs
+++ b/unity/Assets/Scripts/UI/GameRoot.cs
@@ -444,7 +444,7 @@ namespace Statecraft.Game.UI
{
if (Bridge == null) return;
Statecraft.Game.Map.Routes.RouteLayer.ShowAt(map, Bridge.State.Date); // dated routes (the Burma Road from June 1948)
- // MATKOT's whole-town models as overview landmarks, streamed after the first frame (#663); the ma'abara from its date.
+ // MATKOT's whole-town models on their towns far off (#663, "Whole model far, buildings near"), streamed after the first frame; the ma'abara from its date.
Statecraft.Game.Map.Collection.TownLandmarks.ShowAt(map, Bridge.State.Date, Bridge.State.Placements, Bridge.Content);
// MATKOT's ibex and striped hyena, sparse in their sourced terrain zones and visible only at close zoom (#670).
Statecraft.Game.Map.Collection.WildlifeLayer.Show(map);
diff --git a/unity/Assets/Tests/EditMode/TownLandmarksTests.cs b/unity/Assets/Tests/EditMode/TownLandmarksTests.cs
index b8214964b..b982370ae 100644
--- a/unity/Assets/Tests/EditMode/TownLandmarksTests.cs
+++ b/unity/Assets/Tests/EditMode/TownLandmarksTests.cs
@@ -1,11 +1,13 @@
#nullable enable
using System;
+using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using NUnit.Framework;
using Statecraft.Game.Map;
using Statecraft.Game.Map.Collection;
+using Statecraft.Game.Map.Kits;
using Statecraft.Sim;
using UnityEditor;
using UnityEditor.SceneManagement;
@@ -85,52 +87,174 @@ public class TownLandmarksTests
Assert.IsNull(TownLandmarks.ModelFor("no_such_action", new DateTime(1951, 1, 1)));
}
- /// <summary>The overview switch itself: a camera at the 120 km start view draws the landmarks, one at the 60 km gameplay
- /// view does not (forceRenderingOff on every landmark renderer, as the camera is about to render).</summary>
- [Test]
- public void TheLandmarksDrawAtTheStartViewAndNotAtTheGameplayView()
+ /// <summary>The towns with a whole-town model, in the file's order.</summary>
+ static List<Settlement> Mapped(MapScene map) => map.Settlements.Where(s => TownLandmarks.ModelFor(s) != null).ToList();
+
+ TownLandmarks ShowAll(MapScene map)
{
- var map = OpenMap();
var c = ContentLoader.Load(Statecraft.Game.Paths.Content);
var t = TownLandmarks.ShowAt(map, new DateTime(1949, 1, 1), Array.Empty<Placement>(), c)!;
AnswerAll();
+ return t;
+ }
+
+ /// <summary>Renders the map's own camera at <paramref name="distanceM"/> over <paramref name="at"/> (the hooks run as
+ /// in the player: RenderPipelineManager.beginCameraRendering).</summary>
+ static void RenderAt(MapScene map, Vector2 at, float distanceM)
+ {
+ var cam = Camera.main; var rig = cam.GetComponent<CameraRig>();
+ rig.LookAt = new Vector3(at.x, 0f, at.y); rig.Distance = distanceM; rig.Yaw = 0f; rig.Apply();
+ RenderSample.Render(cam, 320, 180);
+ }
+
+ /// <summary>Owner ruling, 18 October 2026 (on #917, #663, #659 and #700): the towns are MATKOT's models, "Whole model far,
+ /// buildings near". Far off, each mapped town's whole-town model stands ON its town, inside its kit footprint
+ /// (MapScene.KitFootprints), as wide as its core (TownLandmarks.CoreOf: where most of its building models stand), not
+ /// beside the town at a fixed 6 km.</summary>
+ [Test]
+ public void EveryTownLandmarkStandsOnItsTownSizedToItsCore()
+ {
+ var map = OpenMap();
+ var t = ShowAll(map);
+ CollectionAssert.IsEmpty(t.Missing);
+ var footprint = new Dictionary<string, (Vector2 centre, float radius)>();
+ foreach (var (centre, radius, id) in map.KitFootprints) if (!footprint.ContainsKey(id)) footprint[id] = (centre, radius);
+ var mapped = Mapped(map);
+ Assert.Greater(mapped.Count, 20);
+ foreach (var s in mapped)
+ {
+ var child = t.transform.Find(s.Id);
+ Assert.IsNotNull(child, s.Id + " has its landmark");
+ var (centre, radius) = footprint[s.Id];
+ var b = WorldBounds(child!.gameObject);
+ Assert.Less(new Vector2(b.center.x - centre.x, b.center.z - centre.y).magnitude, radius, $"{s.Id} stands on its town");
+ Assert.LessOrEqual(Mathf.Max(b.size.x, b.size.z), 1.12f * 2f * radius, $"{s.Id} is no wider than its footprint ({radius:0} m radius)");
+ Assert.IsTrue(t.Seats.TryGetValue(s.Id, out var seat), s.Id);
+ Assert.AreEqual(seat.Edge, Mathf.Max(b.size.x, b.size.z), 0.12f * seat.Edge, $"{s.Id} is as wide as its core ({0.5f * seat.Edge:0} m radius)");
+ }
+ }
+
+ /// <summary>The coordinator for the owner, 18 October 2026: the whole-town model is sized to its town's core, "so Tel Aviv
+ /// doesn't cover Jaffa and Haifa doesn't reach into the bay". No town's whole-town model covers another game settlement:
+ /// no other settlement's kit footprint centre lies inside its ground rectangle (its world bounds on x/z).</summary>
+ [Test]
+ public void NoTownLandmarkCoversAnotherSettlement()
+ {
+ var map = OpenMap();
+ var t = ShowAll(map);
+ var ids = map.Settlements.Select(s => s.Id).ToHashSet();
+ var centres = new Dictionary<string, Vector2>();
+ foreach (var (c, _, id) in map.KitFootprints) if (ids.Contains(id) && !centres.ContainsKey(id)) centres[id] = c;
+ var bad = new List<string>();
+ foreach (var s in Mapped(map))
+ {
+ var b = WorldBounds(t.transform.Find(s.Id)!.gameObject);
+ foreach (var (id, c) in centres)
+ if (id != s.Id && c.x > b.min.x && c.x < b.max.x && c.y > b.min.z && c.y < b.max.z) bad.Add($"{s.Id}'s model covers {id}");
+ }
+ CollectionAssert.IsEmpty(bad);
+ }
+
+ /// <summary>No whole-town model reaches far into the sea or a lake: at most TownLandmarks.MaxWaterShare
+ /// (a fifth; a coastal town keeps its shore) of the ground under its disc (its largest edge across) is water.</summary>
+ [Test]
+ public void NoTownLandmarkReachesIntoTheSea()
+ {
+ var map = OpenMap();
+ var t = ShowAll(map);
+ var ground = PlacementLayer.CampGround(map);
+ var bad = new List<string>(); var lines = new List<string>();
+ foreach (var s in Mapped(map))
+ {
+ var b = WorldBounds(t.transform.Find(s.Id)!.gameObject);
+ var c = new Vector2(b.center.x, b.center.z);
+ float r = 0.5f * Mathf.Max(b.size.x, b.size.z);
+ int n = 0, wet = 0;
+ for (int i = 0; i <= 10; i++)
+ for (int k = 0; k <= 10; k++)
+ {
+ var q = c + new Vector2(-r + 2f * r * i / 10f, -r + 2f * r * k / 10f);
+ if ((q - c).sqrMagnitude > r * r) continue;
+ n++; if (ground.Water(q.x, q.y)) wet++;
+ }
+ float share = n == 0 ? 0f : (float)wet / n;
+ lines.Add($"{s.Id} {share:0.00}");
+ if (share > 0.2f + 1e-3f) bad.Add($"{s.Id}: {share:P0} of its model's ground is water");
+ }
+ TestContext.WriteLine(string.Join(", ", lines));
+ CollectionAssert.IsEmpty(bad);
+ }
+
+ /// <summary>The swap with #700's building models: the landmarks draw where TownModelLayer draws the kits' far view and
+ /// hide where it draws the building models (TownModelLayer.CloseAt: in below CloseEnterM, out above CloseExitM), with
+ /// the same hysteresis, at the start view (120 km), the gameplay view (60 km), both sides of the band and the closest
+ /// zoom.</summary>
+ [Test]
+ public void TheLandmarksSwapWithTheBuildingModelsAtTheThreshold()
+ {
+ var map = OpenMap();
+ var t = ShowAll(map);
+ var layer = map.transform.Find(KitLayer.RootName).GetComponentInChildren<TownModelLayer>();
+ Assert.IsTrue(layer.HasModels);
var renderers = t.GetComponentsInChildren<Renderer>(true);
Assert.Greater(renderers.Length, 0);
- Camera At(float distanceM)
+ var tel = map.KitFootprints.First(f => f.id == "tel_aviv").centre;
+ foreach (var (d, close, why) in new[]
{
- var cam = new GameObject($"cam {distanceM}").AddComponent<Camera>();
- cam.transform.rotation = Quaternion.Euler(CameraRig.Pitch, 0f, 0f);
- cam.transform.position = new Vector3(50000f, 0f, 50000f) - cam.transform.forward * distanceM;
- Assert.AreEqual(distanceM, TownLandmarks.ViewDistance(cam), 1f);
- return cam;
+ (120000f, false, "the start view"), (60000f, false, "the gameplay view"),
+ (TownModelLayer.CloseEnterM + 1000f, false, "inside the band, coming in"), (TownModelLayer.CloseEnterM - 1000f, true, "past the threshold"),
+ (TownModelLayer.CloseExitM - 2000f, true, "inside the band, going out"), (TownModelLayer.CloseExitM + 1000f, false, "out of the band"),
+ (CameraController.MinDistance, true, "the closest zoom"),
+ })
+ {
+ RenderAt(map, tel, d);
+ Assert.AreEqual(close, layer.LastClose, $"{d / 1000f} km, {why}: the building models");
+ Assert.IsTrue(renderers.All(r => r.forceRenderingOff == close), $"{d / 1000f} km, {why}: the whole-town models " + (close ? "hide" : "draw"));
}
- var start = At(120000f); var play = At(60000f);
- t.Choose(default, start);
- Assert.IsTrue(renderers.All(r => !r.forceRenderingOff), "drawn at the 120 km start view");
- t.Choose(default, play);
- Assert.IsTrue(renderers.All(r => r.forceRenderingOff), "hidden at the 60 km gameplay view");
- Object.DestroyImmediate(start.gameObject); Object.DestroyImmediate(play.gameObject);
}
+ /// <summary>No procedural houses in a mapped town at any zoom (owner, 18 October 2026): its kit mesh never draws, its
+ /// close mesh (the kit without its buildings: its mosques, churches, walls and port, as #700 keeps them) draws far and
+ /// near. A town without a whole-town model keeps #700's swap: its kit far off, its close mesh up close.</summary>
[Test]
- public void TheOverviewSwitchHasHysteresis()
+ public void AMappedTownDrawsNoProceduralHousesAtAnyZoom()
{
- // Owner on #917 (17 October 2026): "Larger, from 120 km" (enter at 110 km).
- var rig = new GameObject("rig").AddComponent<CameraRig>();
- try { Assert.IsTrue(TownLandmarks.OverviewAt(rig.Distance, null), "the starting view (CameraRig.Distance, 120 km)"); }
- finally { Object.DestroyImmediate(rig.gameObject); }
- Assert.IsTrue(TownLandmarks.OverviewAt(110000f, null), "on from 110 km");
- Assert.IsFalse(TownLandmarks.OverviewAt(109000f, null));
- Assert.IsFalse(TownLandmarks.OverviewAt(60000f, null), "gameplay03: the per-building kits draw");
- Assert.IsFalse(TownLandmarks.OverviewAt(60000f, true), "gameplay03, coming in from the overview");
- Assert.IsTrue(TownLandmarks.OverviewAt(250000f, null), "the farthest zoom");
- Assert.IsTrue(TownLandmarks.OverviewAt(100000f, true), "stays on in the band");
- Assert.IsFalse(TownLandmarks.OverviewAt(100000f, false), "stays off in the band");
- Assert.IsFalse(TownLandmarks.OverviewAt(97000f, true));
- Assert.Greater(TownLandmarks.OverviewEnterM / TownLandmarks.OverviewExitM, 1f / (1f - CameraController.ZoomPerStep),
- "the band is wider than one wheel notch");
- Assert.AreEqual(6000f, TownLandmarks.SizeM, "about 6 km across");
- Assert.AreEqual(CameraController.MaxDistance, 250000f, "the overview is within the camera's reach");
+ var map = OpenMap();
+ var t = ShowAll(map);
+ var root = map.transform.Find(KitLayer.RootName);
+ var mapped = Mapped(map);
+ var plain = map.Settlements.First(s => TownLandmarks.ModelFor(s) == null);
+ var plainKit = root.Find(plain.Id).GetComponent<MeshRenderer>();
+ foreach (var (d, close) in new[] { (120000f, false), (60000f, false), (TownModelLayer.CloseEnterM - 1000f, true), (CameraController.MinDistance, true) })
+ {
+ RenderAt(map, map.KitFootprints.First(f => f.id == "tel_aviv").centre, d);
+ foreach (var s in mapped)
+ {
+ Assert.IsTrue(root.Find(s.Id).GetComponent<MeshRenderer>().forceRenderingOff, $"{s.Id}'s kit houses at {d / 1000f} km");
+ var closeR = root.Find(s.Id + KitLayer.CloseSuffix)?.GetComponent<MeshRenderer>();
+ if (closeR != null) Assert.IsFalse(closeR.forceRenderingOff, $"{s.Id}'s landmarks and ground at {d / 1000f} km");
+ }
+ Assert.AreEqual(close, plainKit.forceRenderingOff, $"{plain.Id} (no whole-town model) keeps #700's swap at {d / 1000f} km");
+ }
+ }
+
+ /// <summary>The fail-open check: without #700's building models (no model list) nothing would draw a mapped town up
+ /// close, so its whole-town model stays at every zoom, and its kit houses still never draw.</summary>
+ [UnityTest]
+ public IEnumerator WithoutTheBuildingModelsTheWholeTownModelStaysUpClose()
+ {
+ EditorSceneManager.OpenScene("Assets/Map.unity", OpenSceneMode.Single);
+ var map = Object.FindFirstObjectByType<MapScene>();
+ map.ConfigureTownModels(null!);
+ LogAssert.Expect(LogType.Error, new Regex("town models: the map scene has no model list"));
+ map.Build();
+ yield return null;
+ var t = ShowAll(map);
+ var root = map.transform.Find(KitLayer.RootName);
+ Assert.IsFalse(root.GetComponentInChildren<TownModelLayer>().HasModels);
+ RenderAt(map, map.KitFootprints.First(f => f.id == "tel_aviv").centre, CameraController.MinDistance);
+ Assert.IsTrue(t.GetComponentsInChildren<Renderer>(true).All(r => !r.forceRenderingOff), "the whole-town models draw at the closest zoom");
+ Assert.IsTrue(root.Find("tel_aviv").GetComponent<MeshRenderer>().forceRenderingOff, "Tel Aviv's kit houses still never draw");
}
/// <summary>Owner, 18 October 2026: the models "seem to be on their side on the map". Every Collection Far prefab's root
@@ -151,8 +275,9 @@ public class TownLandmarksTests
var prefab = Far(model);
var child = t.transform.Find(key);
Assert.IsNotNull(child, key);
- var want = t.transform.rotation * Quaternion.Euler(0f, TownLandmarks.YawOf(model), 0f) * prefab.transform.localRotation;
- Assert.Less(Quaternion.Angle(want, child!.rotation), 0.01f, $"{key} ({model}) keeps its prefab's rotation under its yaw");
+ var tilt = t.Seats.TryGetValue(key, out var seat) ? Quaternion.FromToRotation(Vector3.up, seat.Normal) : Quaternion.identity;
+ var want = t.transform.rotation * tilt * Quaternion.Euler(0f, TownLandmarks.YawOf(model), 0f) * prefab.transform.localRotation;
+ Assert.Less(Quaternion.Angle(want, child!.rotation), 0.01f, $"{key} ({model}) keeps its prefab's rotation under its yaw and its seat's tilt");
if (!heights.TryGetValue(model, out var h))
{
// The model as its prefab stands (unparented, its own rotation): a yaw about the vertical keeps this height.
@@ -160,8 +285,11 @@ public class TownLandmarksTests
try { heights[model] = h = WorldBounds(probe).size.y / probe.transform.localScale.y; }
finally { Object.DestroyImmediate(probe); }
}
+ // Untilted (the seat's tilt taken off about the base), the landmark is as tall as its model at its scale.
+ var keep = child.rotation; child.rotation = Quaternion.Inverse(tilt) * child.rotation;
float scale = child.localScale.y;
- Assert.AreEqual(h * scale, WorldBounds(child.gameObject).size.y, 0.01f * h * scale, $"{key} ({model}) is as tall as its model");
+ try { Assert.AreEqual(h * scale, WorldBounds(child.gameObject).size.y, 0.01f * h * scale, $"{key} ({model}) is as tall as its model"); }
+ finally { child.rotation = keep; }
}
}
@@ -173,6 +301,40 @@ public class TownLandmarksTests
return b;
}
+ /// <summary>The whole-town model on a slope (the kibbutz model cut into its hill at the closest zoom, on #917): each one
+ /// is tilted to the least-squares plane of the ground under its footprint (at most TownLandmarks.MaxTiltDeg) and seated at
+ /// its lowest point, so it never floats: no land under its footprint lies below its base plane. Degania Alef stands on a
+ /// slope, so its model leans with the ground.</summary>
+ [Test]
+ public void AWholeTownModelFollowsItsGroundAndNeverFloats()
+ {
+ var map = OpenMap();
+ var t = ShowAll(map);
+ var ground = PlacementLayer.CampGround(map);
+ var lines = new List<string>();
+ foreach (var s in Mapped(map))
+ {
+ Assert.IsTrue(t.Seats.TryGetValue(s.Id, out var seat), s.Id);
+ float tilt = Vector3.Angle(Vector3.up, seat.Normal);
+ Assert.LessOrEqual(tilt, TownLandmarks.MaxTiltDeg + 0.01f, s.Id);
+ float r = 0.5f * seat.Edge, deepest = 0f;
+ for (int i = 0; i <= 10; i++)
+ for (int k = 0; k <= 10; k++)
+ {
+ var q = seat.Centre + new Vector2(-r + 2f * r * i / 10f, -r + 2f * r * k / 10f);
+ if ((q - seat.Centre).sqrMagnitude > 0.999f * r * r || !ground.Inside(q.x, q.y) || ground.Water(q.x, q.y)) continue;
+ var d = q - seat.Centre;
+ float plane = seat.BaseY - (seat.Normal.x * d.x + seat.Normal.z * d.y) / seat.Normal.y;
+ float above = ground.Y(q.x, q.y) - plane;
+ Assert.GreaterOrEqual(above, -0.5f, $"{s.Id} floats {-above:0.0} m above its ground at {q}");
+ deepest = Mathf.Max(deepest, above);
+ }
+ lines.Add($"{s.Id} tilt {tilt:0.0} deg, ground up to {deepest:0} m above its base");
+ }
+ TestContext.WriteLine(string.Join("; ", lines));
+ Assert.Greater(Vector3.Angle(Vector3.up, t.Seats["degania_alef"].Normal), 0.5f, "Degania Alef leans with its slope");
+ }
+
[Test]
public void ASpotIsTheFirstFreeOneAndNoneWhenAllAreTaken()
{
@@ -188,7 +350,7 @@ public class TownLandmarksTests
/// <summary>Nothing is drawn until the stream answers (it never serves a request in the frame that made it), and only
/// the strategic zoom's mesh is asked for, once per model.</summary>
[Test]
- public void TheLandmarksStreamInAndStandClearOfEveryKitAndEachOther()
+ public void TheLandmarksStreamInOncePerModel()
{
var map = OpenMap();
var c = ContentLoader.Load(Statecraft.Game.Paths.Content);
@@ -210,24 +372,6 @@ public class TownLandmarksTests
// Owner on #917 (17 October 2026): "Keep at all seven" arab_town rows.
Assert.AreEqual(7, map.Settlements.Count(s => s.Type == "arab_town"));
Assert.AreEqual(7, t.Placed.Count(p => p.Model == TownLandmarks.StoneVillage), "the stone village at all seven");
- float r = 0.5f * TownLandmarks.SizeM;
- var at = t.Placed.Select(p => new Vector2(p.At.x, p.At.z)).ToList();
- foreach (var (p, (key, _, _)) in at.Zip(t.Placed, (p, q) => (p, q)))
- {
- foreach (var f in map.KitFootprints)
- Assert.GreaterOrEqual((p - f.centre).magnitude, f.radius + r - 1f, $"{key} stands on {f.id}'s kit");
- foreach (var q in at) if (q != p) Assert.GreaterOrEqual((p - q).magnitude, 2f * r - 1f, $"{key} on another landmark");
- var w = t.Wanted.Single(x => x.Key == key);
- Assert.Less((p - w.At).magnitude, w.Radius + r * (TownLandmarks.Rings + 1), $"{key} is beside its town");
- }
- foreach (Transform child in t.transform)
- {
- var b = child.GetComponentsInChildren<Renderer>().Select(x => x.bounds).Aggregate((a, x) => { a.Encapsulate(x); return a; });
- Assert.AreEqual(TownLandmarks.SizeM, Mathf.Max(b.size.x, b.size.z), 1f, child.name + " is drawn at the landmark size");
- var spot = t.Placed.Single(p => p.Key == child.name).At;
- Assert.Less(new Vector2(b.center.x - spot.x, b.center.z - spot.z).magnitude, 1f, child.name + " is centred on its spot");
- Assert.AreEqual(spot.y, b.min.y, 1f, child.name + " stands on the ground");
- }
}
[Test]