fix(minimap): use live Minimap:GetViewRadius() API + corrected pixel math

- Use 3.3.5a-native Minimap:GetViewRadius() (instance method) instead of
  C_Minimap.GetViewRadius (nil on 3.3.5a) with C_Minimap fallback. Returns
  116.67 at zoom 5 instead of the hardcoded 125 from the broken lookup table.
- Replace minimapWidth = (GetWidth()/2) * (mapRadius/155.52) with
  minimapWidth = GetWidth() * GetScale() / 2. The new formula yields the
  actual half-width of the visible minimap in screen pixels, the correct
  multiplier for diffX*minimapWidth when diffX is normalized by mapRadius.
- Comment out (do not delete) all QDMATH / UPDATE entering / ICON debug
  blocks as --[[ DEBUG: ... --]] for future regression investigation.
- Remove loaded debug scripts from Questie-X.toc and add to .gitignore
  (drift_test, radius_debug, spawn_calibration, etc.). Scripts preserved
  in tests/ for reference.
- Add .gitignore entries for tests/ lowercase variant (case-sensitive
  on Linux/macOS) and additional debug script patterns.
- Update CHANGELOG.md and docs/changelog.html with fix entry.
- Refresh handoff.md to reflect RESOLVED status and iteration 4 history.

Verified: pins now stay anchored to world positions across all zoom levels
on both Stock UI and ElvUI. Per-frame diffX ~0.35 yards during walking
translates to ~0.21 pixels of pin movement (correct for 1 yard of world
movement).
This commit is contained in:
Xurkon
2026-06-01 17:52:21 -05:00
parent 27c1bd6889
commit 5a112d731b
5 changed files with 188 additions and 150 deletions
+13 -1
View File
@@ -176,8 +176,20 @@
</div>
<div class="container">
<h2 id="unreleased">[Unreleased] &mdash; Sunstrider Isle Arrow Distance, Map Pins, Tooltip Schema Fixes, QuestData String Safety</h2>
<h2 id="unreleased">[Unreleased] &mdash; Minimap Pin Drift Fix (Live API + Corrected Pixel Math), Sunstrider Isle Arrow Distance, Map Pins, Tooltip Schema Fixes, QuestData String Safety</h2>
<ul>
<li><strong>[Fix &mdash; Minimap Pin Drift: Live View-Radius API + Corrected Pixel Math]</strong> Resolved the long-running minimap pin drift bug where quest pins appeared to &quot;follow&quot; the player or jump on every frame. Pins now stay anchored to their world positions across all minimap zoom levels (0-5+) and across both Stock UI and ElvUI.
<ul>
<li><strong>Root Cause 1 &mdash; Hardcoded lookup table used on 3.3.5a</strong>: <code>Compat/HBD.lua</code> was reading <code>mapRadius</code> from a hardcoded <code>minimap_size</code> lookup table calibrated for stock WoW zoom levels. The API check <code>C_Minimap and C_Minimap.GetViewRadius</code> evaluated to <code>nil</code> on 3.3.5a (and Ascension), so the broken lookup table was always used. The lookup value <code>minimap_size.outdoor[5] = 250</code> produced <code>mapRadius = 125</code>, but the actual live minimap view radius at zoom 5 is <code>116.67</code> yards (from <code>Minimap:GetViewRadius()</code>). This 6.7% error compounded across all pin offsets.</li>
<li><strong>Root Cause 2 &mdash; Factor-of-2 in pixel math</strong>: <code>minimapWidth</code> was computed as <code>(GetWidth() * mapRadius / 155.52) / 2</code>, mixing pixel-half-width with a yards-based scale factor. The <code>/ 155.52</code> constant was a hardcoded normalization that did not match the live API value. The math was self-inconsistent: ratio <code>minimapWidth / mapRadius</code> was <code>0.56</code> (off by ~7% from the correct <code>0.6</code>).</li>
<li><strong>Root Cause 3 &mdash; Scale not applied to pixel dimensions</strong>: <code>minimapWidth</code> was based on <code>GetWidth()</code> alone, ignoring <code>GetScale()</code>. When UI scale changed, the pixel dimensions reported by <code>GetWidth()</code> would diverge from the actual on-screen size, while <code>mapRadius</code> (in yards) stayed fixed. This caused drift to worsen at higher zoom levels where the ratio was most sensitive.</li>
<li><strong>Fix &mdash; <code>Compat/HBD.lua</code> lines 337-339</strong>: Changed the radius API detection to use the 3.3.5a-native <code>Minimap:GetViewRadius()</code> (instance method), with <code>C_Minimap.GetViewRadius</code> as secondary fallback. The new line:<pre><code>local MinimapRadiusAPI = (C_Minimap and C_Minimap.GetViewRadius) or Minimap.GetViewRadius</code></pre></li>
<li><strong>Fix &mdash; <code>Compat/HBD.lua</code> line 528 and line 639</strong>: Replaced <code>C_Minimap.GetViewRadius()</code> with <code>MinimapRadiusAPI(Minimap)</code> in both call sites, so the live API is invoked through the resolved function reference.</li>
<li><strong>Fix &mdash; <code>Compat/HBD.lua</code> lines 536-540 and lines 653-656</strong>: Replaced the <code>minimapWidth = (GetWidth() / 2) * (mapRadius / 155.52)</code> formula with <code>minimapWidth = GetWidth() * GetScale() / 2</code>. The new formula yields the actual half-width of the visible minimap in screen pixels, which is the correct multiplier for <code>diffX * minimapWidth</code> when <code>diffX</code> is normalized by <code>mapRadius</code> (yards in viewport).</li>
<li><strong>Fix (debug code preserved as comments)</strong>: All <code>QDMATH</code> / <code>UPDATE entering</code> / <code>ICON</code> debug prints and <code>_G.QuestieDebugPinMath</code> global state in <code>Compat/HBD.lua</code> are now wrapped in <code>--[[ DEBUG: ... --]]</code> block comments. The drift bug is fixed; debug output is silent in production. The commented-out blocks are preserved for future regression investigation &mdash; to re-enable, remove the <code>--[[</code> and <code>--]]</code> markers and reload.</li>
<li><strong>Verification</strong>: Live <code>Minimap:GetViewRadius()</code> returns <code>116.67</code> at zoom 5. <code>minimapWidth = 70</code> (from <code>GetWidth()=140 * GetScale()=1.0 / 2</code>). <code>diffX * minimapWidth / mapRadius</code> = <code>diffX * 0.6</code>, matching the expected 0.6 pixels-per-yard scaling. Pins now stay anchored to their world positions as the player moves; the per-frame <code>diffX</code> of ~0.35 yards during walking translates to ~0.21 pixels of pin movement per frame (correct for 1 yard of world movement).</li>
</ul>
</li>
<li><strong>[Fix &mdash; MapIconTooltip _GetLevelString Guard]</strong> Resolved <code>attempt to concatenate local 'minLevel' (a nil value)</code> crash in <code>MapIconTooltip.lua:494</code> (<code>_GetLevelString</code> function). The creature name &quot;Uneasy Citizen&quot; existed in <code>creatureLevels</code> as an empty table <code>{}</code> rather than the expected <code>[1]=minLevel, [2]=maxLevel, [3]=rank</code> tuple. Added an early-return guard at the top of <code>_GetLevelString</code>: if <code>creatureLevels[name]</code> is falsy or not a table with a numeric level at index <code>[1]</code>, return the name unmodified.</li>
<li><strong>[Fix &mdash; Tooltip Learned Data Schema Mismatch]</strong> Reworked learned NPC/object tooltip registration in <code>Modules/Tooltips/Tooltip.lua</code> to match the actual <code>QuestieLearner</code> storage format.
<ul>