refactor(model): call the engine's math and read its constants live

The ModelScene mover and contact sweep carried their own copies of engine
code and data. They now use the client's.

Constants: every float the transcribed mover reads from 1.12.1's .rdata
(and the two fall-speed caps in .data, the 2pi the static initializer
fills at 0x00CF5D00) is an Offsets.h entry read where it is used, through
Game::Live<T>. Each value was checked against WoW.exe's bytes. The pooled
floats other modules already named for one use (0x00801360, 0x008026BC,
0x008029D4, 0x00803568, 0x008022CC, 0x00801620, 0x0080306C, 0x00801628)
are renamed by value, since the mover reads them too.

Leaf math: the pure geometry helpers the mover calls are now called, not
copied: DotVector3 0x00602630, PlaneFromTriangle 0x00637480,
PlaneDistanceAlongRay 0x006329E0, ClipPolygonByPlane(s/Except) 0x006318C0
/ 0x00631870 / 0x00632980, IntersectThreePlanes 0x00634FC0 and
PointToLineDistanceSquared 0x00634F40. Each is __fastcall with callee
cleanup and reads only its arguments and .rdata (Ghidra). Two stay
transcribed: FindNearestTriangleEdge 0x00634DA0 reads the client's facet
list at 0x00C4E534, and SelectBevelContactNormal 0x00636610 reads an
unwritten stack slot as an index when three bevels have no odd one out.

Wrappers: engine calls that several files cast themselves get one typed
home: M2.h (key-bone animation state, sequence info, base transform,
scene draw, model lights, the IsXAnimation tests, whose death test is
__stdcall and the rest __fastcall), gx/Matrix.h (the 0x007BxXXX matrix
helpers), gx/Device.h (render-state journal, state setters, transform
stacks, clear), Frame::Layout (DDC/NDC conversion), Texture::DeviceTexture,
Xml::ReadColor and Frame::Subclass's slot types.
This commit is contained in:
Brues
2026-11-10 01:38:43 -06:00
parent 7b9fc5f076
commit be3c8a0a42
36 changed files with 793 additions and 621 deletions
+2 -2
View File
@@ -27,6 +27,7 @@
#include "Game.h"
#include "Offsets.h"
#include "frame/Layout.h"
#include "tick/FrameTick.h"
namespace Input::CursorDelta {
@@ -44,7 +45,6 @@ bool g_sampled = false;
// What GetCursorPosition pushes now, or false before the UI top exists.
bool ReadCursor(Position &out) {
using NdcToDdc_t = void(__fastcall *)(float *outX, float *outY, float x, float y);
const void *top = Game::Read<const void *>(Offsets::VAR_UI_CONTEXT_PTR);
if (top == nullptr)
return false;
@@ -52,7 +52,7 @@ bool ReadCursor(Position &out) {
const float ndcY = Game::Read<float>(top, Offsets::OFF_UI_CONTEXT_MOUSE_POSITION + 4);
float ddcX = 0.0f;
float ddcY = 0.0f;
reinterpret_cast<NdcToDdc_t>(Offsets::FUN_COORD_NDC_TO_DDC)(&ddcX, &ddcY, ndcX, ndcY);
Frame::Layout::NdcToDdc(&ddcX, &ddcY, ndcX, ndcY);
out = {Game::InternalToPixel(ddcX), Game::InternalToPixel(ddcY)};
return true;
}