Skip to content

Expose Noesis visual coordinate conversion and hit testing to Lua - #592

Open
nnn149 wants to merge 1 commit into
Norbyte:mainfrom
nnn149:noesis-visual-coordinates
Open

Expose Noesis visual coordinate conversion and hit testing to Lua#592
nnn149 wants to merge 1 commit into
Norbyte:mainfrom
nnn149:noesis-visual-coordinates

Conversation

@nnn149

@nnn149 nnn149 commented Jul 27, 2026

Copy link
Copy Markdown

Summary

Expose three Noesis visual-coordinate operations to Client Lua:

local clientPoint = visual:PointToScreen({ X = localX, Y = localY })
local localPoint = visual:PointFromScreen({ X = clientX, Y = clientY })
local hitVisual = visual:HitTest(localPoint)

The methods are registered on Noesis::Visual, so registered derived types inherit them. HitTest() returns the topmost hit Visual, or nil when there is no hit.

Implementation

  • Add optional binary mappings and static symbols for:
    • Noesis::Visual::PointFromScreen
    • Noesis::Visual::PointToScreen
    • Noesis::VisualTreeHelper::HitTest
  • Add { X, Y } serialization for Noesis::Point.
  • Invoke the coordinate conversion methods with their real C++ member-function type so MSVC emits the hidden structure-return ABI correctly.
  • Invoke HitTest with its real HitTestResult return type and expose only visualHit to Lua.
  • Reject calls outside Client Lua, outside the Client owning thread, or when a mapping is unavailable.
  • Keep the existing Lua lifetime checks for both receivers and returned visual proxies.

The mapped "screen" coordinate space is the game client/SDL logical coordinate space, with the origin at the client area's top-left.

Binary mapping evidence

Validated against game version 4.1.1.7209685.

  • DX11 SHA-256: 3D3C703C4B94596876697C709C42024F2ADA5CCE4AF88F11D3B6408D61930D0F
  • Vulkan SHA-256: 8A9D7A37844D294F7C55476D0EF02C4F033F41666F8FA1F4DA12DB1A41EFBD55
Symbol DX11 RVA Vulkan RVA
Visual::PointFromScreen 0x45E0700 0x45FA500
Visual::PointToScreen 0x45E0A20 0x45FA820
VisualTreeHelper::HitTest 0x46190A0 0x4632EA0

The production PointToScreen entry signature and the shared
PointFromScreen -> HitTest semantic call-site signature each match exactly
once in both executables. The shared call sites are at DX11 RVA 0x465C9FB
and Vulkan RVA 0x46767FB.

An independent 60-byte PointFromScreen entry signature also matches exactly
once in each executable and resolves to the same target as the semantic call
site. The independent entry signature is retained as a regression check rather
than duplicated in the production mappings.

DX11 function-body checks:

  • PointFromScreen: 789 bytes,
    7A15A7AAE7CD0843FD1249C104CBB3BF1C8E0A45B616D03328F2E5ECE08B6DA8
  • PointToScreen: 309 bytes,
    FBC1DBE8DBA93ABE475428EE0FE984668B09402025AA79D65033AB9212210182
  • VisualTreeHelper::HitTest: 41 bytes,
    20700C73D891F268DEA9D8054AB09F266A6538AE063F6A4496FD782A2A677576

All three mappings use AllowFail. Missing mappings produce a descriptive Lua
error instead of invoking a null address.

Validation

  • Built Game Debug|x64.
  • Built Game Release|x64.
  • Ran the property-map generator twice; the second run produced no changes.
  • git diff --check passes.
  • Verified all production and regression signatures are unique in both DX11
    and Vulkan.
  • Performed live DX11 tests at:
    • 1280x720 windowed, 96 DPI
    • 1440x900 windowed, 96 DPI
    • 1440x900 windowed, 120 DPI
    • 1440x900 windowed after moving the window on the desktop
  • Tested a visible inventory slot at its center, four corners, four inset
    corners, and an outside control point.
  • Maximum local round-trip error: 0.000224517.
  • Maximum client-coordinate round-trip error: 0.000062914.
  • Center and inset points hit the target slot or one of its descendants; the
    outside point did not.
  • SDL client-coordinate mouse movement to the returned center selected the same
    slot at every tested resolution and DPI.
  • After closing and reopening the inventory, calls on saved old visual proxies
    failed with lifetime has expired; reacquired proxies succeeded.
  • No ABI crash, stack/register corruption, or unstable coordinates were
    observed.

@nnn149
nnn149 marked this pull request as ready for review July 27, 2026 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant