A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Map: thin, fading Dakota smoke columns; keep-clear box fits the aircraft (Refs #2604) (#2613)
Eyal Golan35b9c85a64c9
diff --git a/changelog.d/2604-dakota-smoke-columns.md b/changelog.d/2604-dakota-smoke-columns.mdnew file mode 100644index 000000000..81c1df34b--- /dev/null+++ b/changelog.d/2604-dakota-smoke-columns.md@@ -0,0 +1,12 @@+### Changed++- The smoke columns over Tel Aviv on the 15 May 1948 turn are reworked (#2604): four thin columns instead of six wide+ ones, each starting 260 m across on its bomb's impact and widening to 1.5 km as it rises 4 km, near-black at the foot+ and fading to light grey and half see-through toward the top, leaning gently downwind. They are drawn unlit, as the+ blast, so their shade no longer turns the whole column dark brown.++### Fixed++- Each Dakota's keep-clear box for the map names is now the aircraft and its flag as they fly, not a box for every+ heading and bank at once that reached about 3.7 km under the aircraft, so names in frame should no longer hide for a+ Dakota just off the frame's edge (#2604).diff --git a/unity/Assets/Scripts/Map/Collection/DakotaLoop.cs b/unity/Assets/Scripts/Map/Collection/DakotaLoop.csindex e65bad788..d3ebecbd0 100644--- a/unity/Assets/Scripts/Map/Collection/DakotaLoop.cs+++ b/unity/Assets/Scripts/Map/Collection/DakotaLoop.cs@@ -43,6 +43,9 @@ namespace Statecraft.Game.Map.Collection/// <summary>The flag that floats over the tail, or null.</summary>public Transform? Flag => flag;+ /// <summary>Half the flag's height (m), its centre's rise over its lower edge (0 without a flag).</summary>+ public float FlagHalf => flagHalf;+/// <summary>The aircraft's bombs, or null.</summary>internal DakotaBombRun? Bombs => bombs;@@ -87,13 +90,8 @@ namespace Statecraft.Game.Map.Collection{PlacedAt = seconds;float u = seconds - lag;- var at = SeaAirCollection.DakotaLoopOffset(u); var heading = SeaAirCollection.DakotaLoopHeading(u);- var forward = new Vector3(heading.x, 0f, heading.y);- // A turn about the vertical from east (+x) to the heading; Unity's yaw turns +x toward -z.- var yaw = Quaternion.Euler(0f, -Mathf.Atan2(heading.y, heading.x) * Mathf.Rad2Deg, 0f);- // The loop turns left (anticlockwise seen from above): a positive turn about the heading lowers the left wing.- float bank = SeaAirCollection.DakotaBankDegrees(u);- var turn = Quaternion.AngleAxis(bank, forward) * yaw;+ var at = SeaAirCollection.DakotaLoopOffset(u);+ var turn = SeaAirCollection.DakotaTurn(u, out var forward, out float bank);transform.localRotation = turn * level;var drawn = centre + new Vector3(at.x, 0f, at.y);transform.position = drawn - turn * offset;@@ -146,15 +144,24 @@ namespace Statecraft.Game.Map.Collectionstatic readonly int BaseColor = Shader.PropertyToID("_BaseColor"), BaseMap = Shader.PropertyToID("_BaseMap"), Cull = Shader.PropertyToID("_Cull");/// <summary>DESIGN VALUES: the flash the gun's colour; the dust a dusty grey-brown (a bomb's burst raises dust and/// rubble), thinning paler as it rises; the puffs drift a little east, each its own way. The blast keeps the- /// flipbook's own fire and smoke colours, its smoke a touch warmer (dust). The columns are dark grey-brown at the foot,- /// paler grey aloft, as the under-attack look's smoke (HexUnderAttackLook: 0.13 to 0.40) but browner for the burning- /// city's dust. The smoke flipbook's grey averages 0.44 where it is opaque (measured on its pixels), so these tints- /// are about twice the shade drawn: the columns run from about 0.14 to 0.38, the dust from 0.27 to 0.42.</summary>+ /// flipbook's own fire and smoke colours, its smoke a touch warmer (dust). The smoke flipbook's grey averages 0.44+ /// where it is opaque (measured on its pixels), so a tint is about 2.3 times the shade drawn: the dust runs from+ /// about 0.27 to 0.42.</summary>static readonly Color FlashColour = new Color(1f, 0.85f, 0.5f), SmokeFresh = new Color(0.62f, 0.56f, 0.48f), SmokeThin = new Color(0.95f, 0.92f, 0.86f);- static readonly Color BlastTint = new Color(1f, 0.95f, 0.88f), ColumnFoot = new Color(0.32f, 0.27f, 0.22f), ColumnTop = new Color(0.86f, 0.80f, 0.72f);+ static readonly Color BlastTint = new Color(1f, 0.95f, 0.88f);+ /// <summary>DESIGN VALUES (#2604, the columns read as "two flat, dark-brown blobs"): a column is near-black and+ /// brownish at its foot (burning rubble, about 0.13 drawn) and light grey aloft (about 0.68 drawn), the shade+ /// changing over the lower 70% of its height. The columns are drawn unlit, as the blast (the flipbook carries its own+ /// light and shade; #2490's lit columns came out uniformly dark), so the tint times the flipbook's 0.44 is the shade+ /// on screen; the top tint is over 1 for that reason (the shader multiplies, nothing clamps it before blending).</summary>+ internal static readonly Color ColumnFoot = new Color(0.30f, 0.26f, 0.22f), ColumnTop = new Color(1.55f, 1.53f, 1.50f);static readonly float[] PuffSide = { -0.07f, 0.03f, 0.08f }, PuffSpin = { 20f, 140f, 260f };- /// <summary>DESIGN VALUE: a column puff's alpha at its densest.</summary>- const float ColumnAlpha = 0.95f;+ /// <summary>DESIGN VALUES: a column puff's alpha at the foot and at the top of the column (#2604: "partly transparent+ /// at the top"). The puffs overlap more aloft, where they are wider, so the top's alpha is low: about five puffs+ /// overlap there, which still leaves it about half see-through. A newborn puff fades in over the first+ /// <see cref="ColumnFadeInShare"/> of the column's height (40 m), and an old one fades out over its top+ /// <see cref="ColumnFadeOutShare"/>.</summary>+ internal const float ColumnAlphaFoot = 0.95f, ColumnAlphaTop = 0.12f, ColumnFadeInShare = 0.01f, ColumnFadeOutShare = 0.3f;readonly List<Drop> drops;readonly int[] entry; // the drop at each release slot of the loop, or -1@@ -232,7 +239,8 @@ namespace Statecraft.Game.Map.Collection(columnAt, columnFrom) = ColumnSitesOf(drops, releases * SeaAirCollection.DakotaBombIntervalS, plane, planes);int n = columnAt.Length * SeaAirCollection.DakotaColumnPuffs;columnT = new Transform[n]; column = new Renderer[n]; columnF = new MeshFilter[n]; columnMat = new Material[n];- for (int i = 0; i < n; i++) (columnT[i], column[i], columnF[i]) = Part(parent, "BombColumn", smokeFrames[0], columnMat[i] = Mat(HexMaterials.AttackSmoke, looks.Smoke));+ // The columns unlit, as the blast (ColumnFoot, ColumnTop): their shade is the tint times the flipbook's own.+ for (int i = 0; i < n; i++) (columnT[i], column[i], columnF[i]) = Part(parent, "BombColumn", smokeFrames[0], columnMat[i] = Mat(HexMaterials.AttackBorder, looks.Smoke));}/// <summary>Aircraft <paramref name="plane"/>'s column sites among <paramref name="drops"/> on a loop of@@ -388,11 +396,39 @@ namespace Statecraft.Game.Map.Collectionreturn 1f - Mathf.SmoothStep(0f, 1f, (b - (1f - fade)) / fade);}+ /// <summary>A column puff's height share (0 at the impact, 1 at the column's top) at <paramref name="v"/> of its life:+ /// v to the power SeaAirCollection.DakotaColumnRisePower, so a puff leaves the impact slowly and speeds up as it rises.</summary>+ internal static float ColumnHeightShare(float v) => Mathf.Pow(Mathf.Clamp01(v), SeaAirCollection.DakotaColumnRisePower);++ /// <summary>A column puff's width (m) at height share <paramref name="h"/> (<see cref="ColumnHeightShare"/>), before+ /// its own jitter: from SeaAirCollection.DakotaColumnFootM at the impact, widening steadily to+ /// SeaAirCollection.DakotaColumnTopM at the top, as a plume spreads (#2604: "start thin at each+ /// impact, widen as they rise"). #2490 widened with the square root, so the column was nearly full width a quarter of the way up.</summary>+ internal static float ColumnWidth(float h) => Mathf.Lerp(SeaAirCollection.DakotaColumnFootM, SeaAirCollection.DakotaColumnTopM, h);++ /// <summary>A column puff's alpha at height share <paramref name="h"/>: fading in over <see cref="ColumnFadeInShare"/>,+ /// then falling with height from <see cref="ColumnAlphaFoot"/> toward <see cref="ColumnAlphaTop"/> (fast at first: the+ /// foot stays dense, the upper half thin), and fading out to nothing over the last <see cref="ColumnFadeOutShare"/>,+ /// so the top dissolves. Above the fade-in it only falls.</summary>+ internal static float ColumnAlphaAt(float h)+ {+ float fadeIn = Mathf.SmoothStep(0f, 1f, h / ColumnFadeInShare);+ float fadeOut = 1f - Mathf.SmoothStep(0f, 1f, (h - (1f - ColumnFadeOutShare)) / ColumnFadeOutShare);+ return fadeIn * Mathf.Lerp(ColumnAlphaFoot, ColumnAlphaTop, Mathf.Pow(Mathf.Clamp01(h), 0.6f)) * fadeOut;+ }++ /// <summary>A column puff's tint (alpha aside) at height share <paramref name="h"/>: <see cref="ColumnFoot"/> at the+ /// impact to <see cref="ColumnTop"/> by 70% of the way up.</summary>+ internal static Color ColumnTint(float h) => Color.Lerp(ColumnFoot, ColumnTop, Mathf.SmoothStep(0f, 1f, h / 0.7f));+/// <summary>Column <paramref name="c"/>, <paramref name="age"/> seconds after its first hit (hidden before it): a stream/// of SeaAirCollection.DakotaColumnPuffs puffs, each born every SeaAirCollection.DakotaColumnLifeS, a puff's share of/// a life apart, and only those born since the first hit, so the column grows from the ground over its first life and- /// then stands. A puff rises SeaAirCollection.DakotaColumnM over its life, widening from the column's foot to its top- /// width, leaning downwind, darkest and densest low, thinning paler aloft, its smoke boiling through the flipbook.</summary>+ /// then stands. A puff rises SeaAirCollection.DakotaColumnM over its life, slowly at first+ /// (<see cref="ColumnHeightShare"/>: the puffs crowd at the foot, so the thin stem stands unbroken on the impact, and+ /// spread aloft, where they are wide), widening (<see cref="ColumnWidth"/>), leaning downwind, its+ /// shade (<see cref="ColumnTint"/>) and alpha (<see cref="ColumnAlphaAt"/>) going from dark and dense at the foot to+ /// light grey and thin aloft, its smoke boiling through the flipbook.</summary>void ShowColumn(int c, double age){int P = SeaAirCollection.DakotaColumnPuffs;@@ -405,19 +441,19 @@ namespace Statecraft.Game.Map.Collectionbool on = age >= 0.0 && v * life <= age;column[k].enabled = on;if (!on) continue;- float own = Own(c * 7.31f + i * 1.93f + 0.5f);- float size = Mathf.Lerp(SeaAirCollection.DakotaColumnFootM, SeaAirCollection.DakotaColumnTopM, Mathf.Sqrt(v)) * (0.85f + 0.3f * own);- var wobble = new Vector3(Mathf.Sin(own * 19f + v * 5f), 0f, Mathf.Cos(own * 13f + v * 4f)) * (60f * Mathf.Sqrt(v));- // Its centre 0.45 of its size up: tilted to the board camera (50 degrees down), its lower edge stays over the ground.- var at = columnAt[c] + Vector3.up * (0.45f * size + v * SeaAirCollection.DakotaColumnM)- + HexUnderAttack.Smoke.Wind * (SeaAirCollection.DakotaColumnLeanM * Mathf.Pow(v, 1.4f)) + wobble;+ float own = Own(c * 7.31f + i * 1.93f + 0.5f), h = ColumnHeightShare(v);+ float size = ColumnWidth(h) * (0.85f + 0.3f * own);+ var wobble = new Vector3(Mathf.Sin(own * 19f + v * 5f), 0f, Mathf.Cos(own * 13f + v * 4f)) * (60f * Mathf.Sqrt(h));+ // Its centre 0.45 of its size up: tilted to the board camera (50 degrees down), its lower edge stays over the+ // ground, so the column's foot stands on the impact. It leans downwind more the higher it is.+ var at = columnAt[c] + Vector3.up * (0.45f * size + h * SeaAirCollection.DakotaColumnM)+ + HexUnderAttack.Smoke.Wind * (SeaAirCollection.DakotaColumnLeanM * Mathf.Pow(h, 1.3f)) + wobble;float spin = Spin(own);columnT[k].SetPositionAndRotation(at, view * Quaternion.Euler(0f, 0f, spin));columnT[k].localScale = Vector3.one * size;int frames = smokeFrames.Length;columnF[k].sharedMesh = smokeFrames[Mod((int)Math.Floor(((double)v * life * SeaAirCollection.DakotaColumnFps) + own * frames), frames)];- var colour = Color.Lerp(ColumnFoot, ColumnTop, Mathf.SmoothStep(0f, 1f, v / 0.8f));- colour.a = ColumnAlpha * Mathf.SmoothStep(0f, 1f, v / 0.06f) * (1f - Mathf.SmoothStep(0f, 1f, (v - 0.6f) / 0.4f));+ var colour = ColumnTint(h); colour.a = ColumnAlphaAt(h);columnMat[k].SetColor(BaseColor, colour);}}diff --git a/unity/Assets/Scripts/Map/Collection/SeaAirCollection.Dakota.cs b/unity/Assets/Scripts/Map/Collection/SeaAirCollection.Dakota.csindex 1b0b2ab4b..d18d21f5f 100644--- a/unity/Assets/Scripts/Map/Collection/SeaAirCollection.Dakota.cs+++ b/unity/Assets/Scripts/Map/Collection/SeaAirCollection.Dakota.cs@@ -122,13 +122,19 @@ namespace Statecraft.Game.Map.Collection/// turns, so the pair lights at most 2 x <see cref="DakotaColumns"/> over Tel Aviv). From its first hit a column is a/// stream of <see cref="DakotaColumnPuffs"/> puffs of Unity Labs' CC0 smoke flipbook (<see cref="DakotaSmokeTexture"/>,/// 8 x 8 frames, boiling at <see cref="DakotaColumnFps"/>), each rising <see cref="DakotaColumnM"/> over- /// <see cref="DakotaColumnLifeS"/>, widening from <see cref="DakotaColumnFootM"/> to <see cref="DakotaColumnTopM"/>- /// across and leaning <see cref="DakotaColumnLeanM"/> downwind (east, a little north, as the under-attack look's smoke,- /// HexUnderAttack.Smoke.Wind), less than <see cref="DakotaBombMarginM"/>, so a column stays over Tel Aviv's hex. It- /// grows from the ground over its first <see cref="DakotaColumnLifeS"/> and then burns for as long as the Dakotas fly.</summary>- public const int DakotaColumns = 3, DakotaColumnPuffs = 10, DakotaSmokeGrid = 8;- public const float DakotaColumnLifeS = 14f, DakotaColumnM = 3600f, DakotaColumnFootM = 700f, DakotaColumnTopM = 2300f,- DakotaColumnLeanM = 450f, DakotaColumnFps = 6f;+ /// <see cref="DakotaColumnLifeS"/> (slowly from the impact, faster aloft: its height share is its life's share to the+ /// power <see cref="DakotaColumnRisePower"/>), widening steadily with height from <see cref="DakotaColumnFootM"/> to+ /// <see cref="DakotaColumnTopM"/> across and leaning <see cref="DakotaColumnLeanM"/> downwind (east, a little north, as+ /// the under-attack look's smoke, HexUnderAttack.Smoke.Wind), less than <see cref="DakotaBombMarginM"/>, so a column+ /// stays over Tel Aviv's hex. It grows from the ground over its first <see cref="DakotaColumnLifeS"/> and then burns+ /// for as long as the Dakotas fly. Reworked for #2604, where #2490's six columns (700 m wide at the foot, 2.3 km aloft,+ /// ten puffs, dark all the way up) read in play as "two flat, dark-brown blobs" over the city that hid its feet and+ /// its buildings: now four columns, each a thin foot (260 m, under a fifth of #2490's foot puff area) on its impact,+ /// widening to 1.5 km at the top, 18 puffs crowding at the foot (three in its lowest 260 m) so the thin foot+ /// is a continuous stem, and spreading to about 330 m apart at the top, where they are 1.5 km wide; dark at the foot and light grey, half see-through, aloft (DakotaBombRun.ColumnTint, ColumnAlphaAt).</summary>+ public const int DakotaColumns = 2, DakotaColumnPuffs = 18, DakotaSmokeGrid = 8;+ public const float DakotaColumnLifeS = 16f, DakotaColumnM = 4000f, DakotaColumnFootM = 260f, DakotaColumnTopM = 1500f,+ DakotaColumnLeanM = 450f, DakotaColumnFps = 6f, DakotaColumnRisePower = 1.5f;/// <summary>The two Unity Labs flipbooks (Resources, "Free VFX image sequences and flipbooks", CC0; ASSETS.yaml).</summary>public const string DakotaBlastTexture = "Effects/Explosion01_5x5", DakotaSmokeTexture = "Effects/Cloud02_8x8";@@ -148,6 +154,19 @@ namespace Statecraft.Game.Map.Collectionreturn new Vector2(DakotaLoopHalfLengthM * Mathf.Cos(a), DakotaLoopHalfWidthM * Mathf.Sin(a)).normalized;}+ /// <summary>A Dakota's turn <paramref name="seconds"/> into its own loop, over its model's nose-east rotation: a yaw+ /// about the vertical from east (+x) to its heading (<paramref name="forward"/>; Unity's yaw turns +x toward -z), then+ /// its <paramref name="bank"/> about the heading (the loop turns left, anticlockwise seen from above: a positive turn+ /// lowers the left wing). DakotaLoop flies it; <see cref="DakotaKeepBox"/> keeps the names clear of it.</summary>+ public static Quaternion DakotaTurn(float seconds, out Vector3 forward, out float bank)+ {+ var heading = DakotaLoopHeading(seconds);+ forward = new Vector3(heading.x, 0f, heading.y);+ var yaw = Quaternion.Euler(0f, -Mathf.Atan2(heading.y, heading.x) * Mathf.Rad2Deg, 0f);+ bank = DakotaBankDegrees(seconds);+ return Quaternion.AngleAxis(bank, forward) * yaw;+ }+static float DakotaLoopAngle(float seconds) => 2f * Mathf.PI * Mathf.Repeat(seconds, DakotaLoopSeconds) / DakotaLoopSeconds;/// <summary>The loop's curvature (1/m) <paramref name="seconds"/> into it, as <see cref="LoopCurvature"/> for this ellipse.</summary>@@ -255,21 +274,20 @@ namespace Statecraft.Game.Map.Collectionvar cam = Camera.main;if (flag != null && cam != null) UnitFlagFacing.Face(flag, cam.transform.position);Placed.Add((go.name, Dakota, centre));- // At any heading and bank the aircraft lies within half its box's diagonal of its centre; the flag floats over its- // tail, at most the steepest bank's box top over the centre (SpitfireLoop.TopOver), as the Spitfire's (Fly).- float reach = 0.5f * b.size.magnitude + 1f, up = reach, round = reach;+ // The flag turns to the camera, so whatever its turn it lies within its mesh box's farthest corner from its pivot.+ float flagUp = 0f, flagRadius = 0f;if (flag != null){- var f = flag.GetComponent<MeshFilter>().sharedMesh.bounds; float k = flag.lossyScale.y;- up = Mathf.Max(up, SpitfireLoop.TopOver(half, UnitShowcase.BankDegrees) + DakotaLoop.FlagClearM + 2f * f.extents.y * k + 1f);- round = Mathf.Max(round, half.x + new Vector2(f.extents.x, f.extents.z).magnitude * k + 1f);+ var f = flag.GetComponent<MeshFilter>().sharedMesh.bounds; var s = flag.lossyScale;+ flagRadius = (f.center.magnitude + f.extents.magnitude) * Mathf.Max(s.x, Mathf.Max(s.y, s.z)) + 1f;+ flagUp = DakotaLoop.FlagClearM + loop.FlagHalf;}// The labels keep clear of where it is now, not of its whole loop (owner, 4 November 2026, on #2490: "Shrink the// keep-clear area (Recommended)"): its box follows it a DakotaKeepStepS step of the loop at a time (FollowDakotas).- var follow = new DakotaKeep(go, loop, centre, reach, up, round);+ var follow = new DakotaKeep(go, loop, centre, half, flagUp, flagRadius);dakotaKeeps.Add(follow);follow.Step = DakotaKeepStep(loop.PlacedAt);- Keep(go, DakotaKeepBox(centre, loop.Lag, follow.Step, reach, up, round));+ Keep(go, DakotaKeepBox(centre, loop.Lag, follow.Step, half, flagUp, flagRadius));}/// <summary>DESIGN VALUE: the labels' keep-clear box for a Dakota covers its flight over one step of this many seconds of@@ -282,34 +300,54 @@ namespace Statecraft.Game.Map.Collection/// <summary>The box (world) the map names keep clear of for a Dakota whose loop is centred at <paramref name="centre"/> (in/// the air), its clock <paramref name="lag"/> behind the loop's, through the loop's clock step <paramref name="step"/>- /// (<see cref="DakotaKeepStepS"/>): the aircraft at every heading and bank (<paramref name="reach"/> round its drawn- /// centre, <paramref name="round"/> across with its flag over the tail, <paramref name="up"/> above with its flag) at- /// every point of its path in that step, sampled finely enough that the path's bow between samples (under a metre on- /// this ellipse) is inside the pad. Owner, 4 November 2026, on #2490: "Shrink the keep-clear area (Recommended)": a name- /// hides only where an aircraft and its flag are, not over the whole loop as #2274's box did.</summary>- internal static Bounds DakotaKeepBox(Vector3 centre, float lag, long step, float reach, float up, float round)+ /// (<see cref="DakotaKeepStepS"/>): the aircraft as DakotaLoop flies it at every point of its path in that step, its box+ /// of half size <paramref name="half"/> (nose east, level) at that point's heading and bank (<see cref="DakotaTurn"/>),+ /// and its flag over the tail there (DakotaLoop.Place: <paramref name="flagUp"/> over the banked box's top, within+ /// <paramref name="flagRadius"/> of that point at any turn; no flag when 0). Sampled every eighth of the step, so the+ /// path's and the wingtips' bow between samples (about a metre on this ellipse) is inside the pad. Owner, 4 November+ /// 2026, on #2490: "Shrink the keep-clear area (Recommended)": a name hides only where an aircraft and its flag are.+ /// #2604: #2490's box held the aircraft at every heading and bank at once (half its box's 3D diagonal, about 6 km, every+ /// way, under it too), which reached about 3.7 km lower and up to 2.7 km wider than the aircraft ever is; seen from+ /// the board camera, 50 degrees down, that hid names in frame while the aircraft itself was off the frame's top edge.</summary>+ internal static Bounds DakotaKeepBox(Vector3 centre, float lag, long step, Vector3 half, float flagUp, float flagRadius){- const int Samples = 4; const float Pad = 10f;var box = new Bounds();- for (int i = 0; i <= Samples; i++)+ for (int i = 0; i <= DakotaKeepSamples; i++){- var o = DakotaLoopOffset((float)(step * (double)DakotaKeepStepS + i * (double)DakotaKeepStepS / Samples - lag));+ float u = (float)(step * (double)DakotaKeepStepS + i * (double)DakotaKeepStepS / DakotaKeepSamples - lag);+ var o = DakotaLoopOffset(u);+ var turn = DakotaTurn(u, out var forward, out float bank);var at = centre + new Vector3(o.x, 0f, o.y);- var b = new Bounds(); b.SetMinMax(at - new Vector3(round, reach, round), at + new Vector3(round, up, round));+ var b = new Bounds(at, 2f * Turned(turn, half));+ if (flagRadius > 0f)+ b.Encapsulate(new Bounds(at - forward * half.x + Vector3.up * (SpitfireLoop.TopOver(half, bank) + flagUp), 2f * flagRadius * Vector3.one));if (i == 0) box = b; else box.Encapsulate(b);}- box.Expand(2f * Pad);+ box.Expand(2f * DakotaKeepPadM);return box;}+ /// <summary>DESIGN VALUES for <see cref="DakotaKeepBox"/>: the points of a step's path it samples (every eighth of the step)+ /// and the pad (m) it keeps on every side beyond the aircraft and its flag there.</summary>+ internal const int DakotaKeepSamples = 8;+ internal const float DakotaKeepPadM = 25f;++ /// <summary>Half the world box of a box of half size <paramref name="half"/> turned by <paramref name="turn"/>, as a+ /// renderer's bounds are: each axis the sum of the turned half sides' reach along it.</summary>+ static Vector3 Turned(Quaternion turn, Vector3 half)+ {+ Vector3 x = turn * new Vector3(half.x, 0f, 0f), y = turn * new Vector3(0f, half.y, 0f), z = turn * new Vector3(0f, 0f, half.z);+ return new Vector3(Mathf.Abs(x.x) + Mathf.Abs(y.x) + Mathf.Abs(z.x), Mathf.Abs(x.y) + Mathf.Abs(y.y) + Mathf.Abs(z.y), Mathf.Abs(x.z) + Mathf.Abs(y.z) + Mathf.Abs(z.z));+ }+/// <summary>A drawn Dakota whose keep-clear box follows it: its loop, its loop's centre in the air, the box's sizes/// (<see cref="DakotaKeepBox"/>) and the clock step its box now covers.</summary>sealed class DakotaKeep{- public readonly GameObject Go; public readonly DakotaLoop Loop; public readonly Vector3 Centre; public readonly float Reach, Up, Round;+ public readonly GameObject Go; public readonly DakotaLoop Loop; public readonly Vector3 Centre, Half; public readonly float FlagUp, FlagRadius;public long Step;- public DakotaKeep(GameObject go, DakotaLoop loop, Vector3 centre, float reach, float up, float round)- { Go = go; Loop = loop; Centre = centre; Reach = reach; Up = up; Round = round; }+ public DakotaKeep(GameObject go, DakotaLoop loop, Vector3 centre, Vector3 half, float flagUp, float flagRadius)+ { Go = go; Loop = loop; Centre = centre; Half = half; FlagUp = flagUp; FlagRadius = flagRadius; }}readonly List<DakotaKeep> dakotaKeeps = new List<DakotaKeep>();@@ -327,7 +365,7 @@ namespace Statecraft.Game.Map.Collectionlong step = DakotaKeepStep(d.Loop.PlacedAt);if (step == d.Step) continue;d.Step = step;- keepOf[d.Go] = new[] { DakotaKeepBox(d.Centre, d.Loop.Lag, step, d.Reach, d.Up, d.Round) };+ keepOf[d.Go] = new[] { DakotaKeepBox(d.Centre, d.Loop.Lag, step, d.Half, d.FlagUp, d.FlagRadius) };moved = true;}if (moved) RebuildKeepAll();diff --git a/unity/Assets/Tests/EditMode/SeaAirCollectionTests.cs b/unity/Assets/Tests/EditMode/SeaAirCollectionTests.csindex bb0057855..7eb26588a 100644--- a/unity/Assets/Tests/EditMode/SeaAirCollectionTests.cs+++ b/unity/Assets/Tests/EditMode/SeaAirCollectionTests.cs@@ -480,6 +480,55 @@ public class SeaAirCollectionTestsAssert.AreNotSame(first, layer.KeepClear, "a new list a step on, so the labels re-place");}+ /// <summary>#2604: in the 31 km opening view, names in frame hid for a Dakota off the frame's top edge. #2490's keep-clear+ /// box held the aircraft at every heading and bank at once (half its box's 3D diagonal every way, about 6 km), so it+ /// reached about 3.7 km under the aircraft and 1.1 km past its wingtips, and the board camera, 50 degrees down, saw that+ /// overhang inside the frame. Now the box is the aircraft and its flag as they fly through the step: round the loop it+ /// never reaches more than 400 m under the aircraft's own lowest point (a step's change of bank in the turns), and on the+ /// pass in over Tel Aviv (nose east, level) it is no wider north-south than the wingspan and the pad.</summary>+ [Test]+ public void TheDakotasKeepClearBoxIsNoBiggerThanTheAircraftAndItsFlag()+ {+ var map = OpenMap();+ var (layer, planes, loops, _) = DrawnDakotas(map);+ float period = SeaAirCollection.DakotaLoopSeconds;+ for (int i = 0; i < 60; i++)+ {+ float t = i * period / 60f;+ for (int p = 0; p < planes.Length; p++)+ {+ loops[p].Place(t);+ var pb = WorldBounds(planes[p].gameObject); var keep = DakotaKeepOf(layer, planes[p].gameObject)!.Value;+ Assert.IsTrue(keep.Contains(pb.min) && keep.Contains(pb.max), $"{planes[p].name}'s box holds it at {t:0.0} s");+ Assert.Greater(keep.min.y, pb.min.y - 400f, $"{planes[p].name}'s box stops near its underside at {t:0.0} s, not 3.7 km under it");+ }+ }+ // On the pass in (the lead's first step, its clock lag 0): the box may be no wider north-south than the aircraft as drawn+ // at the box's own sample points through that step (its heading turns about 0.03 rad in the step, so the swept span+ // is wider than the level wingspan: by about 2 x half its length x 0.03, ~200 m, plus its bank and the path's drift),+ // plus the pad on both sides (DakotaKeepPadM), plus one more pad's slack for the propeller discs' reach past the+ // airframe and the bow between samples. #2613's first bound, the level wingspan + 300 m, ignored the step's turn.+ float step = SeaAirCollection.DakotaKeepStepS; int samples = SeaAirCollection.DakotaKeepSamples;+ Bounds swept = default;+ for (int k = 0; k <= samples; k++)+ {+ loops[0].Place(Mathf.Min(k * step / samples, step - 1e-3f)); // the step's last point, still in the step+ var drawn = WorldBounds(planes[0].gameObject);+ if (k == 0) swept = drawn; else swept.Encapsulate(drawn);+ }+ loops[0].Place(0f);+ var lead = WorldBounds(planes[0].gameObject); var box = DakotaKeepOf(layer, planes[0].gameObject)!.Value;+ float widest = swept.size.z + 2f * SeaAirCollection.DakotaKeepPadM + SeaAirCollection.DakotaKeepPadM;+ Assert.Less(box.size.z, widest, "on the pass in, no wider north-south than the aircraft through the step and the pad");+ // The bound still catches an oversized box: twice as wide, or only a pad wider on each side.+ var doubled = box; doubled.size = new Vector3(box.size.x, box.size.y, 2f * box.size.z);+ Assert.GreaterOrEqual(doubled.size.z, widest, "a doubled box fails the bound");+ var padded = box; padded.Expand(new Vector3(0f, 0f, 2f * SeaAirCollection.DakotaKeepPadM));+ Assert.GreaterOrEqual(padded.size.z, widest, "a box a pad wider on each side fails the bound");+ Assert.Less(box.size.x, lead.size.x + 0.5f * SeaAirCollection.SizeOf(SeaAirCollection.Dakota) + 2f * 640f,+ "no longer east-west than its length, the flag over its tail and a step's flight");+ }+/// <summary>The world point is on one of Tel Aviv's hexes (content/map/settlement_hexes.yaml), by the map's own click/// picker (MapPointer.Pick: lon/lat and tools/hexgrid.py's rounding), a different route from the layer's own grid test.</summary>@@ -980,6 +1029,80 @@ public class SeaAirCollectionTestsTestContext.WriteLine($"{all.Count} smoke columns over Tel Aviv");}+ /// <summary>#2604: the columns read in play as "two flat, dark-brown blobs" over the city, their feet hidden, dark top to+ /// bottom. The column's curves now: its height share rises from 0 at the impact to 1 at the top, slowly at first; its+ /// width only grows with height, from a thin foot (DakotaColumnFootM) under a quarter of the top's width; its shade (the tint times the flipbook's 0.44 grey) only lightens, from under+ /// 0.15 at the foot to over 0.6 aloft; and above its first 1% (a newborn puff's fade-in) its alpha only falls, from over+ /// 0.8 near the foot to under 0.1 at 90% of the height and nothing at the top.</summary>+ [Test]+ public void TheSmokeColumnsCurvesStartThinDarkAndDenseAndEndWidePaleAndThin()+ {+ Assert.AreEqual(0f, DakotaBombRun.ColumnHeightShare(0f), 1e-6f, "a puff starts on the impact");+ Assert.AreEqual(1f, DakotaBombRun.ColumnHeightShare(1f), 1e-6f, "and ends at the column's top");+ Assert.Less(DakotaBombRun.ColumnWidth(0f), 0.25f * DakotaBombRun.ColumnWidth(1f), "a thin foot under a wide top");+ Assert.AreEqual(SeaAirCollection.DakotaColumnFootM, DakotaBombRun.ColumnWidth(0f), 1e-3f);+ float lastH = 0f, lastW = DakotaBombRun.ColumnWidth(0f), lastShade = DakotaBombRun.ColumnTint(0f).r, lastA = float.MaxValue;+ for (int i = 1; i <= 200; i++)+ {+ float x = i / 200f;+ float h = DakotaBombRun.ColumnHeightShare(x);+ Assert.Greater(h, lastH, $"it only rises ({x:0.000})");+ Assert.Less(h, x + 1e-6f, $"slower than an even pace, so the puffs crowd at the foot ({x:0.000})");+ float w = DakotaBombRun.ColumnWidth(x), shade = DakotaBombRun.ColumnTint(x).r, a = DakotaBombRun.ColumnAlphaAt(x);+ Assert.Greater(w, lastW, $"it only widens with height ({x:0.000})");+ Assert.GreaterOrEqual(shade, lastShade - 1e-6f, $"it only pales with height ({x:0.000})");+ if (x > DakotaBombRun.ColumnFadeInShare) Assert.LessOrEqual(a, lastA + 1e-6f, $"above the fade-in its alpha only falls ({x:0.000})");+ lastH = h; lastW = w; lastShade = shade; lastA = a;+ }+ const float FlipbookGrey = 0.44f;+ Assert.Less(FlipbookGrey * DakotaBombRun.ColumnTint(0f).r, 0.15f, "near-black at the foot");+ Assert.Greater(FlipbookGrey * DakotaBombRun.ColumnTint(1f).r, 0.6f, "light grey aloft");+ Assert.Greater(DakotaBombRun.ColumnAlphaAt(0.05f), 0.8f, "dense near the foot");+ Assert.Less(DakotaBombRun.ColumnAlphaAt(0.9f), 0.1f, "thin near the top");+ Assert.AreEqual(0f, DakotaBombRun.ColumnAlphaAt(1f), 1e-6f, "gone at the top");+ Assert.AreEqual(0f, DakotaBombRun.ColumnAlphaAt(0f), 1e-6f, "a newborn puff fades in, no pop");+ }++ /// <summary>#2604 in the scene, over Tel Aviv's hex: each standing column's puffs in its lowest quarter are under 0.6 of+ /// the width of the widest in its upper part (above 60% of DakotaColumnM); its lowest puff is thin (under twice+ /// DakotaColumnFootM) and its lower edge within 150 m of the ground, so the column's foot stands on its impact; its+ /// lower quarter is on average over twice as opaque as its upper part, every upper puff under half opaque, and it is over+ /// twice as light aloft as at the foot. Every puff is over Tel Aviv's hex (MapPointer.Pick).</summary>+ [Test]+ public void EachStandingColumnIsThinAndDarkAtItsFootAndWidePaleAndSeeThroughAloftOverTelAviv()+ {+ var map = OpenMap();+ var (_, planes, loops, _) = DrawnDakotas(map);+ float life = SeaAirCollection.DakotaColumnLifeS, M = SeaAirCollection.DakotaColumnM;+ int P = SeaAirCollection.DakotaColumnPuffs;+ for (int p = 0; p < planes.Length; p++)+ {+ var loop = loops[p]; var run = loop.Bombs!;+ for (int c = 0; c < run.ColumnSites.Count; c++)+ {+ var site = run.ColumnSites[c]; float from = (float)run.ColumnFrom(c);+ foreach (float later in new[] { 1.5f * life, 2.5f * life + 3.3f, 4f * life + 7.9f })+ {+ loop.Place(loop.Lag + from + later);+ var on = run.Columns.Skip(c * P).Take(P).Where(r => r.enabled).ToList();+ Assert.AreEqual(P, on.Count, "standing whole");+ float Up(Renderer r) => r.transform.position.y - site.y;+ var low = on.Where(r => Up(r) < 0.25f * M).ToList(); var high = on.Where(r => Up(r) > 0.6f * M).ToList();+ string at = $"{planes[p].name} column {c}, {later:0.0} s after its first hit";+ Assert.IsNotEmpty(low, $"{at}: puffs at its foot"); Assert.IsNotEmpty(high, $"{at}: puffs aloft");+ Assert.Less(low.Max(r => r.transform.localScale.x), 0.6f * high.Max(r => r.transform.localScale.x), $"{at}: narrower at the foot");+ var lowest = on.OrderBy(Up).First();+ Assert.Less(lowest.transform.localScale.x, 2f * SeaAirCollection.DakotaColumnFootM, $"{at}: thin where it meets the impact");+ Assert.Less(Up(lowest) - 0.5f * lowest.transform.localScale.y, 150f, $"{at}: its foot on the ground");+ Assert.Greater(low.Average(r => DakotaBombRun.Colour(r).a), 2f * high.Average(r => DakotaBombRun.Colour(r).a), $"{at}: denser at the foot");+ Assert.Less(high.Max(r => DakotaBombRun.Colour(r).a), 0.5f, $"{at}: see-through aloft");+ Assert.Greater(high.Average(r => DakotaBombRun.Colour(r).r), 2f * low.Average(r => DakotaBombRun.Colour(r).r), $"{at}: paler aloft");+ foreach (var r in on) Assert.IsTrue(OnTelAviv(map, r.transform.position), $"{at}: over Tel Aviv ({r.transform.position})");+ }+ }+ }+ }+/// <summary>Sampling the bombs, blasts, dust and columns, and turning them to a camera, allocates nothing (DakotaBombRun),/// as the gun's shot (UnitGunFireTests).</summary>[Test]