Cut 14b Soul Pass #1 fixes: chyron whole-msg eviction, panel-aware target tags, F9 chrome, cargo ellipsis, Euclidean AA

This commit is contained in:
Meta Vens 2026-12-06 01:43:12 +01:00
commit 5e737a48ff
4 changed files with 216 additions and 46 deletions

View file

@ -1061,7 +1061,9 @@ layout(location = 4) flat in uvec2 v_clip_packed;
layout(location = 0) out vec4 frag_color; layout(location = 0) out vec4 frag_color;
void main() {{ void main() {{
vec2 em_px = fwidth(v_em); vec2 dx = dFdx(v_em);
vec2 dy = dFdy(v_em);
vec2 em_px = vec2(length(vec2(dx.x, dy.x)), length(vec2(dx.y, dy.y)));
vec2 pixelsPerEm = 1.0 / max(em_px, vec2(1e-6)); vec2 pixelsPerEm = 1.0 / max(em_px, vec2(1e-6));
float cov; float cov;

View file

@ -160,6 +160,7 @@ public partial class Hud : CanvasLayer
private IClientArenaSession? _latestSession; private IClientArenaSession? _latestSession;
private string? _cachedChassisName; private string? _cachedChassisName;
private string _cachedChassisUpper = "CHASSIS"; private string _cachedChassisUpper = "CHASSIS";
private bool _inputBlocked;
private bool _dirtyEmit; private bool _dirtyEmit;
private bool _emittedThisFrame; private bool _emittedThisFrame;
@ -324,11 +325,17 @@ public partial class Hud : CanvasLayer
_dirtyEmit = true; _dirtyEmit = true;
} }
public void SetInputBlocked(bool blocked)
{
_inputBlocked = blocked;
}
public void SetMatchHudActive(bool active) public void SetMatchHudActive(bool active)
{ {
Visible = active; Visible = active;
if (!active) if (!active)
{ {
_inputBlocked = false;
if (_netPanel.Visible) if (_netPanel.Visible)
{ {
_netPanel.Visible = false; _netPanel.Visible = false;
@ -345,7 +352,7 @@ public partial class Hud : CanvasLayer
public override void _Input(InputEvent @event) public override void _Input(InputEvent @event)
{ {
if (!Visible || _netPanel.Visible) if (!Visible || _inputBlocked || _netPanel.Visible)
{ {
return; return;
} }
@ -757,10 +764,10 @@ public partial class Hud : CanvasLayer
EmitOutcomeBanner(session, state, player, net); EmitOutcomeBanner(session, state, player, net);
} }
// 8. Optional [F9] Network panel corner brackets // 8. Optional [F9] Network panel chrome + cyan brackets (drawn behind transparent _netPanel controls)
if (_netPanel.Visible) if (_netPanel.Visible)
{ {
_hbCanvas.DrawPanelFrame(_netPanel.GetGlobalRect(), new Color(0f, 0f, 0f, 0f), CyanCol, CyanCol, cornerLen: 14f, borderPx: 1.5f, drawBg: false); _hbCanvas.DrawPanelFrame(_netPanel.GetGlobalRect(), BgDark, CyanCol, CyanCol, cornerLen: 14f, borderPx: 1.5f, drawBg: true);
} }
_hbCanvas.EndFrameAndSubmit(); _hbCanvas.EndFrameAndSubmit();
@ -1534,13 +1541,16 @@ public partial class Hud : CanvasLayer
_hbCanvas.DrawRectOutline(rowRect.Position.X, rowRect.Position.Y, rowRect.Size.X, rowRect.Size.Y, 1.0f, rowBorder); _hbCanvas.DrawRectOutline(rowRect.Position.X, rowRect.Position.Y, rowRect.Size.X, rowRect.Size.Y, 1.0f, rowBorder);
Color txtCol = selected ? OrangeCol : (mod.IsImperial ? GoldCol : TextLight); Color txtCol = selected ? OrangeCol : (mod.IsImperial ? GoldCol : TextLight);
HbGpuCommandWriter.PackClipRect(rowRect.Position.X + 3f, rowRect.Position.Y, rowRect.Size.X - 6f, rowRect.Size.Y, out uint cMin, out uint cMax);
float nameX = rowRect.Position.X + 5f; float nameX = rowRect.Position.X + 5f;
float maxTextW = rowRect.Size.X - 10f;
if (mod.IsImperial) if (mod.IsImperial)
{ {
nameX += _hbCanvas.DrawText("* ", nameX, rowRect.Position.Y + 13f, 10f, GoldCol, wght: 700f, clipMinPacked: cMin, clipMaxPacked: cMax); float starW = _hbCanvas.DrawText("* ", nameX, rowRect.Position.Y + 13f, 10f, GoldCol, wght: 700f);
nameX += starW;
maxTextW = MathF.Max(8f, maxTextW - starW);
} }
_hbCanvas.DrawText(mod.Name, nameX, rowRect.Position.Y + 13f, 10f, txtCol, wght: 450f, clipMinPacked: cMin, clipMaxPacked: cMax); ReadOnlySpan<char> displayName = TruncateWithEllipsis(mod.Name, maxTextW, 10f, 450f, _scratch);
_hbCanvas.DrawText(displayName, nameX, rowRect.Position.Y + 13f, 10f, txtCol, wght: 450f);
Color fitBg = fitHovered ? new Color(0.22f, 0.28f, 0.20f, 0.96f) : BgInner; Color fitBg = fitHovered ? new Color(0.22f, 0.28f, 0.20f, 0.96f) : BgInner;
_hbCanvas.DrawRectFilled(fitRect.Position.X, fitRect.Position.Y, fitRect.Size.X, fitRect.Size.Y, fitBg); _hbCanvas.DrawRectFilled(fitRect.Position.X, fitRect.Position.Y, fitRect.Size.X, fitRect.Size.Y, fitBg);
@ -1711,7 +1721,18 @@ public partial class Hud : CanvasLayer
// Pointing down chevron above ally head (+PI/2 in screen coords) // Pointing down chevron above ally head (+PI/2 in screen coords)
_hbCanvas.DrawChevron(sp.X, sp.Y, 12f, MathF.PI * 0.5f, AlliedCol); _hbCanvas.DrawChevron(sp.X, sp.Y, 12f, MathF.PI * 0.5f, AlliedCol);
float lw = _hbCanvas.MeasureTextWidth(label, 10.5f, wght: 550f); float lw = _hbCanvas.MeasureTextWidth(label, 10.5f, wght: 550f);
_hbCanvas.DrawText(label, sp.X - lw * 0.5f, sp.Y - 10f, 10.5f, AlliedCol, wght: 550f); float lx = Math.Clamp(sp.X - lw * 0.5f, 6f, MathF.Max(6f, viewSize.X - lw - 6f));
float ly = sp.Y - 10f;
var aboveBox = new Rect2(lx - 1f, ly - 11f, lw + 2f, 13f);
if (IntersectsStaticHudPanel(aboveBox) || aboveBox.Position.Y < 2f)
{
ly = sp.Y + 19f;
}
var finalBox = new Rect2(lx - 1f, ly - 11f, lw + 2f, 13f);
if (!IntersectsStaticHudPanel(finalBox))
{
_hbCanvas.DrawText(label, lx, ly, 10.5f, AlliedCol, wght: 550f);
}
} }
else else
{ {
@ -1866,10 +1887,10 @@ public partial class Hud : CanvasLayer
Vector2 boxCenter = new((minX + maxX) * 0.5f, (minY + maxY) * 0.5f); Vector2 boxCenter = new((minX + maxX) * 0.5f, (minY + maxY) * 0.5f);
var rect = new Rect2(boxCenter.X - boxW * 0.5f, boxCenter.Y - boxH * 0.5f, boxW, boxH); var rect = new Rect2(boxCenter.X - boxW * 0.5f, boxCenter.Y - boxH * 0.5f, boxW, boxH);
EmitTargetBox(rect, col, dist, hpRatio, isLockedOnLocal); EmitTargetBox(rect, col, dist, hpRatio, isLockedOnLocal, viewSize);
} }
private void EmitTargetBox(Rect2 rect, Color col, float dist, float hpRatio, bool isLockedOnLocal) private void EmitTargetBox(Rect2 rect, Color col, float dist, float hpRatio, bool isLockedOnLocal, Vector2 viewSize)
{ {
float x0 = rect.Position.X; float x0 = rect.Position.X;
float y0 = rect.Position.Y; float y0 = rect.Position.Y;
@ -1891,14 +1912,7 @@ public partial class Hud : CanvasLayer
_hbCanvas.DrawTargetBracketCorner(x1, y1, arm, 2.0f, 2, strokeCol); _hbCanvas.DrawTargetBracketCorner(x1, y1, arm, 2.0f, 2, strokeCol);
_hbCanvas.DrawTargetBracketCorner(x0, y1, arm, 2.0f, 3, strokeCol); _hbCanvas.DrawTargetBracketCorner(x0, y1, arm, 2.0f, 3, strokeCol);
// Thin HP bar right above top bracket // Format distance + LOCK tag
float barW = Math.Clamp(rect.Size.X, 22f, 64f);
float barX = (x0 + x1) * 0.5f - barW * 0.5f;
float barY = y0 - 7f;
_hbCanvas.DrawRectFilled(barX - 1f, barY - 1f, barW + 2f, 4f, shadowCol);
_hbCanvas.DrawRectFilled(barX, barY, barW * Math.Clamp(hpRatio, 0f, 1f), 2f, strokeCol);
// Distance + LOCK tag above HP bar
SpanWriter sw = new(_scratch); SpanWriter sw = new(_scratch);
sw.AppendFloat(dist, "F0"); sw.AppendFloat(dist, "F0");
sw.Append("m"); sw.Append("m");
@ -1908,10 +1922,102 @@ public partial class Hud : CanvasLayer
} }
ReadOnlySpan<char> label = sw.Span; ReadOnlySpan<char> label = sw.Span;
float textW = _hbCanvas.MeasureTextWidth(label, 10.5f, wght: 600f); float textW = _hbCanvas.MeasureTextWidth(label, 10.5f, wght: 600f);
float tx = (x0 + x1) * 0.5f - textW * 0.5f;
float ty = barY - 3f; float barW = Math.Clamp(rect.Size.X, 22f, 64f);
_hbCanvas.DrawText(label, tx + 1f, ty + 1f, 10.5f, ShadowCol, wght: 600f); float centerX = (x0 + x1) * 0.5f;
_hbCanvas.DrawText(label, tx, ty, 10.5f, strokeCol, wght: 600f); float barX = Math.Clamp(centerX - barW * 0.5f, 6f, MathF.Max(6f, viewSize.X - barW - 6f));
float tx = Math.Clamp(centerX - textW * 0.5f, 6f, MathF.Max(6f, viewSize.X - textW - 6f));
// Prefer above-box; flip below-box if obstructed by static HUD panels (e.g. TopLeft/TopRight) or top edge
float aboveBarY = y0 - 7f;
float aboveTextY = aboveBarY - 3f;
Rect2 aboveBounds = MakeTagBounds(barX, aboveBarY, barW, tx, aboveTextY, textW, above: true);
float belowBarY = y1 + 5f;
float belowTextY = belowBarY + 14f;
Rect2 belowBounds = MakeTagBounds(barX, belowBarY, barW, tx, belowTextY, textW, above: false);
float chosenBarY;
float chosenTextY;
if (!IntersectsStaticHudPanel(aboveBounds) && aboveBounds.Position.Y >= 2f)
{
chosenBarY = aboveBarY;
chosenTextY = aboveTextY;
}
else if (!IntersectsStaticHudPanel(belowBounds) && belowBounds.End.Y <= viewSize.Y - 2f)
{
chosenBarY = belowBarY;
chosenTextY = belowTextY;
}
else
{
// Both top and bottom overlap static HUD panels: nudge horizontally out of top corner panels if possible, else omit unobstructed tag
float nudgedTx = tx;
float nudgedBarX = barX;
if (aboveBounds.Intersects(_topLeftRect))
{
float shift = _topLeftRect.End.X + 8f - MathF.Min(tx, barX);
if (shift > 0f && MathF.Max(tx + textW, barX + barW) + shift < _topRightRect.Position.X - 8f)
{
nudgedTx += shift;
nudgedBarX += shift;
}
}
else if (aboveBounds.Intersects(_topRightRect))
{
float shift = MathF.Max(tx + textW, barX + barW) - (_topRightRect.Position.X - 8f);
if (shift > 0f && MathF.Min(tx, barX) - shift > _topLeftRect.End.X + 8f)
{
nudgedTx -= shift;
nudgedBarX -= shift;
}
}
Rect2 nudgedBounds = MakeTagBounds(nudgedBarX, aboveBarY, barW, nudgedTx, aboveTextY, textW, above: true);
if (!IntersectsStaticHudPanel(nudgedBounds) && nudgedBounds.Position.Y >= 2f)
{
barX = nudgedBarX;
tx = nudgedTx;
chosenBarY = aboveBarY;
chosenTextY = aboveTextY;
}
else
{
return;
}
}
_hbCanvas.DrawRectFilled(barX - 1f, chosenBarY - 1f, barW + 2f, 4f, shadowCol);
_hbCanvas.DrawRectFilled(barX, chosenBarY, barW * Math.Clamp(hpRatio, 0f, 1f), 2f, strokeCol);
_hbCanvas.DrawText(label, tx + 1f, chosenTextY + 1f, 10.5f, ShadowCol, wght: 600f);
_hbCanvas.DrawText(label, tx, chosenTextY, 10.5f, strokeCol, wght: 600f);
}
private static Rect2 MakeTagBounds(float barX, float barY, float barW, float tx, float ty, float textW, bool above)
{
float left = MathF.Min(barX - 1f, tx - 1f);
float right = MathF.Max(barX + barW + 1f, tx + textW + 1f);
if (above)
{
float top = ty - 11f;
float bottom = barY + 3f;
return new Rect2(left, top, right - left, bottom - top);
}
else
{
float top = barY - 1f;
float bottom = ty + 3f;
return new Rect2(left, top, right - left, bottom - top);
}
}
private bool IntersectsStaticHudPanel(Rect2 rect)
{
return rect.Intersects(_topLeftRect)
|| rect.Intersects(_topRightRect)
|| rect.Intersects(_bottomLeftRect)
|| rect.Intersects(_chyronRect);
} }
private void EmitOffscreenArrow(OffscreenMarker m, Vector2 viewSize, Vector2 center, float halfW, float halfH) private void EmitOffscreenArrow(OffscreenMarker m, Vector2 viewSize, Vector2 center, float halfW, float halfH)
@ -2183,6 +2289,38 @@ public partial class Hud : CanvasLayer
WrapTextInto(hint, 376f, 10.0f, 350f, _hintLines); WrapTextInto(hint, 376f, 10.0f, 350f, _hintLines);
} }
private ReadOnlySpan<char> TruncateWithEllipsis(string text, float maxWidthPx, float fontSizePx, float wght, char[] scratch)
{
if (string.IsNullOrEmpty(text) || _hbCanvas is null || _hbCanvas.MeasureTextWidth(text, fontSizePx, wght: wght) <= maxWidthPx)
{
return text;
}
const string ellipsis = "...";
int maxCopy = Math.Min(text.Length, scratch.Length - ellipsis.Length);
int bestLen = 0;
for (int len = 1; len <= maxCopy; len++)
{
scratch[len - 1] = text[len - 1];
scratch[len] = '.';
scratch[len + 1] = '.';
scratch[len + 2] = '.';
if (_hbCanvas.MeasureTextWidth(scratch.AsSpan(0, len + 3), fontSizePx, wght: wght) > maxWidthPx)
{
break;
}
bestLen = len;
}
for (int i = 0; i < bestLen; i++)
{
scratch[i] = text[i];
}
scratch[bestLen] = '.';
scratch[bestLen + 1] = '.';
scratch[bestLen + 2] = '.';
return scratch.AsSpan(0, bestLen + 3);
}
private void SyncBroadcastChyron(BroadcastFeed broadcast) private void SyncBroadcastChyron(BroadcastFeed broadcast)
{ {
var lines = broadcast.Lines; var lines = broadcast.Lines;
@ -2194,36 +2332,61 @@ public partial class Hud : CanvasLayer
_lastBroadcastFeed = broadcast; _lastBroadcastFeed = broadcast;
_lastChyronVersion = broadcast.Version; _lastChyronVersion = broadcast.Version;
// Wrap recent messages cleanly to 548px so nothing overflows or clips mid-word // Evict by whole message from newest backwards so partial tail fragments of evicted messages never appear
int startMsg = Math.Max(0, lines.Count - _chyronDisplayLines.Length); int capacity = _chyronDisplayLines.Length;
int outIdx = 0; int remaining = capacity;
for (int m = startMsg; m < lines.Count; m++) int writeBack = capacity;
for (int m = lines.Count - 1; m >= 0 && remaining > 0; m--)
{ {
var line = lines[m]; var line = lines[m];
bool isLatestMsg = m == lines.Count - 1; bool isLatestMsg = m == lines.Count - 1;
string formatted = $"[{line.Timestamp:00.0}s] {line.Text}"; string formatted = $"[{line.Timestamp:00.0}s] {line.Text}";
WrapTextInto(formatted, 548f, isLatestMsg ? 11.5f : 10.8f, isLatestMsg ? 500f : 380f, _chyronWrapScratch); WrapTextInto(formatted, 548f, isLatestMsg ? 11.5f : 10.8f, isLatestMsg ? 500f : 380f, _chyronWrapScratch);
for (int w = 0; w < _chyronWrapScratch.Count; w++)
int msgLineCount = _chyronWrapScratch.Count;
if (msgLineCount == 0)
{ {
if (outIdx < _chyronDisplayLines.Length) continue;
}
if (isLatestMsg && msgLineCount > remaining)
{
int skip = msgLineCount - remaining;
for (int w = msgLineCount - 1; w >= skip; w--)
{ {
_chyronDisplayLines[outIdx] = _chyronWrapScratch[w]; writeBack--;
_chyronIsLatest[outIdx] = isLatestMsg; _chyronDisplayLines[writeBack] = _chyronWrapScratch[w];
outIdx++; _chyronIsLatest[writeBack] = true;
}
else
{
for (int s = 1; s < _chyronDisplayLines.Length; s++)
{
_chyronDisplayLines[s - 1] = _chyronDisplayLines[s];
_chyronIsLatest[s - 1] = _chyronIsLatest[s];
}
_chyronDisplayLines[^1] = _chyronWrapScratch[w];
_chyronIsLatest[^1] = isLatestMsg;
} }
remaining = 0;
break;
}
if (msgLineCount > remaining)
{
// Whole-message eviction: stop before emitting a partial tail of an older message
break;
}
for (int w = msgLineCount - 1; w >= 0; w--)
{
writeBack--;
_chyronDisplayLines[writeBack] = _chyronWrapScratch[w];
_chyronIsLatest[writeBack] = isLatestMsg;
}
remaining -= msgLineCount;
}
int total = capacity - writeBack;
if (writeBack > 0 && total > 0)
{
for (int i = 0; i < total; i++)
{
_chyronDisplayLines[i] = _chyronDisplayLines[writeBack + i];
_chyronIsLatest[i] = _chyronIsLatest[writeBack + i];
} }
} }
_chyronLineCount = outIdx; _chyronLineCount = total;
} }
private void OnHardpointClicked(string hardpointId) private void OnHardpointClicked(string hardpointId)
@ -2484,14 +2647,14 @@ public partial class Hud : CanvasLayer
{ {
var panelStyle = new StyleBoxFlat var panelStyle = new StyleBoxFlat
{ {
BgColor = BgDark, BgColor = new Color(0f, 0f, 0f, 0f),
BorderColor = BorderCol, BorderColor = new Color(0f, 0f, 0f, 0f),
ContentMarginLeft = 10, ContentMarginLeft = 10,
ContentMarginRight = 10, ContentMarginRight = 10,
ContentMarginTop = 8, ContentMarginTop = 8,
ContentMarginBottom = 8 ContentMarginBottom = 8
}; };
panelStyle.SetBorderWidthAll(1); panelStyle.SetBorderWidthAll(0);
_netPanel = new PanelContainer _netPanel = new PanelContainer
{ {

View file

@ -559,6 +559,7 @@ public partial class Main : Node3D
switch (mode) switch (mode)
{ {
case ClientScreenMode.MainMenu: case ClientScreenMode.MainMenu:
_hud.SetInputBlocked(true);
_hud.SetMatchHudActive(false); _hud.SetMatchHudActive(false);
_serverBrowser.SetBrowserVisible(false); _serverBrowser.SetBrowserVisible(false);
_lobbyScreen.SetLobbyVisible(false); _lobbyScreen.SetLobbyVisible(false);
@ -568,6 +569,7 @@ public partial class Main : Node3D
break; break;
case ClientScreenMode.ServerBrowser: case ClientScreenMode.ServerBrowser:
_hud.SetInputBlocked(true);
_hud.SetMatchHudActive(false); _hud.SetMatchHudActive(false);
_mainMenu.SetOverlayKind(MainMenu.OverlayKind.Hidden); _mainMenu.SetOverlayKind(MainMenu.OverlayKind.Hidden);
_lobbyScreen.SetLobbyVisible(false); _lobbyScreen.SetLobbyVisible(false);
@ -578,6 +580,7 @@ public partial class Main : Node3D
break; break;
case ClientScreenMode.Lobby: case ClientScreenMode.Lobby:
_hud.SetInputBlocked(true);
_hud.SetMatchHudActive(false); _hud.SetMatchHudActive(false);
_mainMenu.SetOverlayKind(MainMenu.OverlayKind.Hidden); _mainMenu.SetOverlayKind(MainMenu.OverlayKind.Hidden);
_serverBrowser.SetBrowserVisible(false); _serverBrowser.SetBrowserVisible(false);
@ -592,6 +595,7 @@ public partial class Main : Node3D
_lobbyScreen.SetLobbyVisible(false); _lobbyScreen.SetLobbyVisible(false);
_arena.Visible = true; _arena.Visible = true;
_hud.SetMatchHudActive(true); _hud.SetMatchHudActive(true);
_hud.SetInputBlocked(false);
break; break;
case ClientScreenMode.PauseOverlay: case ClientScreenMode.PauseOverlay:
@ -599,6 +603,7 @@ public partial class Main : Node3D
_lobbyScreen.SetLobbyVisible(false); _lobbyScreen.SetLobbyVisible(false);
_arena.Visible = true; _arena.Visible = true;
_hud.SetMatchHudActive(true); _hud.SetMatchHudActive(true);
_hud.SetInputBlocked(true);
_mainMenu.SetPauseContext(BuildPauseContextLine()); _mainMenu.SetPauseContext(BuildPauseContextLine());
_mainMenu.SetOverlayKind(MainMenu.OverlayKind.PauseOverlay); _mainMenu.SetOverlayKind(MainMenu.OverlayKind.PauseOverlay);
break; break;

View file

@ -1151,7 +1151,7 @@ public partial class Smoke : Node
$"Expected PomDecalPool to hold >= 1 active decal, got {_main.Arena.PomDecals.ActiveCount}"); $"Expected PomDecalPool to hold >= 1 active decal, got {_main.Arena.PomDecals.ActiveCount}");
_main.Hud.PushTestHitArc(localC.X + 20f, localC.Z + 10f, WeaponVisualClass.Explosive); _main.Hud.PushTestHitArc(localC.X + 20f, localC.Z + 10f, WeaponVisualClass.Explosive);
Check(_main.Hud.ActiveHitArcCount >= 1, "Expected CrosshairOverlay to accept incoming hit arc"); Check(_main.Hud.ActiveHitArcCount >= 1, "Expected Hud HbGpuCanvas to accept incoming hit arc");
} }
// 11. Finding 1: Merged MultiMeshPartPool meshes preserve real non-white material albedos and intact COLOR_0.R AO // 11. Finding 1: Merged MultiMeshPartPool meshes preserve real non-white material albedos and intact COLOR_0.R AO