Fixed some comments

This commit is contained in:
cake
2025-12-28 03:15:15 +01:00
parent deb99628f6
commit a3ea48c6e1

View File

@@ -679,7 +679,7 @@ public unsafe class LightFinderPlateHandler : IHostedService, IMediatorSubscribe
ImGui.PopStyleVar(2); ImGui.PopStyleVar(2);
// --- Debug settings (wired via handler fields; no hotkey / no extra debug window here) --- // Debug flags
bool dbgEnabled = false; bool dbgEnabled = false;
bool dbgDisableOcc = false; bool dbgDisableOcc = false;
bool dbgDrawUiRects = false; bool dbgDrawUiRects = false;
@@ -737,11 +737,9 @@ public unsafe class LightFinderPlateHandler : IHostedService, IMediatorSubscribe
var scale = baseFontSize > 0 ? (info.FontSize / baseFontSize) : 1f; var scale = baseFontSize > 0 ? (info.FontSize / baseFontSize) : 1f;
var size = baseSize * scale; var size = baseSize * scale;
// label rect for occlusion checking (in game screen coords, NOT viewport-pos-adjusted)
var topLeft = info.ScreenPosition - new Vector2(size.X * info.Pivot.X, size.Y * info.Pivot.Y); var topLeft = info.ScreenPosition - new Vector2(size.X * info.Pivot.X, size.Y * info.Pivot.Y);
var labelRect = new RectF(topLeft.X, topLeft.Y, topLeft.X + size.X, topLeft.Y + size.Y); var labelRect = new RectF(topLeft.X, topLeft.Y, topLeft.X + size.X, topLeft.Y + size.Y);
// "Would this be occluded?" (we track this even if we force-draw)
bool wouldOcclude = IsOccludedByAnyUi(labelRect); bool wouldOcclude = IsOccludedByAnyUi(labelRect);
if (wouldOcclude) if (wouldOcclude)
occludedThisFrame++; occludedThisFrame++;
@@ -769,7 +767,7 @@ public unsafe class LightFinderPlateHandler : IHostedService, IMediatorSubscribe
drawList.AddScreenText(drawPos, info.Text, info.TextColor, info.FontSize, info.Pivot, info.EdgeColor, font); drawList.AddScreenText(drawPos, info.Text, info.TextColor, info.FontSize, info.Pivot, info.EdgeColor, font);
} }
// Debug: draw UI rects (occluders) // Debug: draw UI rects if any
if (dbgEnabled && dbgDrawUiRects && _uiRects.Count > 0) if (dbgEnabled && dbgDrawUiRects && _uiRects.Count > 0)
{ {
var useOff = useViewportOffset ? vpPos : Vector2.Zero; var useOff = useViewportOffset ? vpPos : Vector2.Zero;
@@ -788,7 +786,6 @@ public unsafe class LightFinderPlateHandler : IHostedService, IMediatorSubscribe
} }
#if DEBUG #if DEBUG
// --- Publish per-frame debug counters for the UI Debug tab ---
DebugLabelCountLastFrame = copyCount; DebugLabelCountLastFrame = copyCount;
DebugUiRectCountLastFrame = _uiRects.Count; DebugUiRectCountLastFrame = _uiRects.Count;
DebugOccludedCountLastFrame = occludedThisFrame; DebugOccludedCountLastFrame = occludedThisFrame;
@@ -951,13 +948,16 @@ public unsafe class LightFinderPlateHandler : IHostedService, IMediatorSubscribe
if (addon == null) if (addon == null)
return false; return false;
// Addon must be visible
if (!addon->IsVisible) if (!addon->IsVisible)
return false; return false;
// Root must be visible
var root = addon->RootNode; var root = addon->RootNode;
if (root == null || !root->IsVisible()) if (root == null || !root->IsVisible())
return false; return false;
// Must have multiple nodes to be useful
var nodeCount = addon->UldManager.NodeListCount; var nodeCount = addon->UldManager.NodeListCount;
var nodeList = addon->UldManager.NodeList; var nodeList = addon->UldManager.NodeList;
if (nodeCount <= 1 || nodeList == null) if (nodeCount <= 1 || nodeList == null)
@@ -968,7 +968,6 @@ public unsafe class LightFinderPlateHandler : IHostedService, IMediatorSubscribe
if (!IsFinite(rsx) || rsx <= 0f) rsx = 1f; if (!IsFinite(rsx) || rsx <= 0f) rsx = 1f;
if (!IsFinite(rsy) || rsy <= 0f) rsy = 1f; if (!IsFinite(rsy) || rsy <= 0f) rsy = 1f;
// clamp insane root scales (rare but prevents explosions)
// clamp insane root scales (rare but prevents explosions) // clamp insane root scales (rare but prevents explosions)
rsx = MathF.Min(rsx, 6f); rsx = MathF.Min(rsx, 6f);
rsy = MathF.Min(rsy, 6f); rsy = MathF.Min(rsy, 6f);
@@ -998,10 +997,11 @@ public unsafe class LightFinderPlateHandler : IHostedService, IMediatorSubscribe
if (rootR <= rootL || rootB <= rootT) if (rootR <= rootL || rootB <= rootT)
return false; return false;
// Root dimensions
var rootW = rootR - rootL; var rootW = rootR - rootL;
var rootH = rootB - rootT; var rootH = rootB - rootT;
// --- Union of drawable-ish nodes, but constrained by root rect --- // Find union of all probably-drawable nodes intersecting root
bool any = false; bool any = false;
float l = float.MaxValue, t = float.MaxValue, r = float.MinValue, b = float.MinValue; float l = float.MaxValue, t = float.MaxValue, r = float.MinValue, b = float.MinValue;
@@ -1082,6 +1082,7 @@ public unsafe class LightFinderPlateHandler : IHostedService, IMediatorSubscribe
return true; return true;
} }
// Validate final union rect
var uw = r - l; var uw = r - l;
var uh = b - t; var uh = b - t;
if (uw < 4f || uh < 4f) if (uw < 4f || uh < 4f)
@@ -1090,6 +1091,7 @@ public unsafe class LightFinderPlateHandler : IHostedService, IMediatorSubscribe
return true; return true;
} }
// If union is excessively larger than root, fallback to root rect
if (uw > rootW * 1.35f || uh > rootH * 1.35f) if (uw > rootW * 1.35f || uh > rootH * 1.35f)
{ {
rect = new RectF(rootL, rootT, rootR, rootB); rect = new RectF(rootL, rootT, rootR, rootB);
@@ -1105,9 +1107,11 @@ public unsafe class LightFinderPlateHandler : IHostedService, IMediatorSubscribe
if (n == null || !n->IsVisible()) if (n == null || !n->IsVisible())
return false; return false;
if (n->Color.A == 0) // Check alpha
if (n->Color.A == 16)
return false; return false;
// Check node type
return n->Type switch return n->Type switch
{ {
NodeType.Text => true, NodeType.Text => true,