benilla-re systems structs docs

BuildPortalVolume

function · terrain · primitive

Address
0x682930 · 1119 bytes, up to 0x682d8e
Signature
void __fastcall (void *out, const float *rect)
Meaning
Builds a frustum through a portal's screen rectangle
Confidence
inferred
Finding
terrain/scene#portal-volumes
Test
terrain::frustum_push_rect_difftest

Finding: Portal volumes in terrain: scene

A volume is six planes, 16 bytes each (n, d), then eight corners from +0x60, 12 bytes apart. The corners are in the frustum corner order: c0 to c3 on the near plane (bottom-left, top-left, top-right, bottom-right) and c4 to c7 the same on the far plane. 0x682930 makes the eight corners of a portal window from the frustum rays: two passes of four corners, each narrowed to the window's rectangle. It hands them to 0x6865f0, which copies them to the volume at the top of the frustum stack and builds the planes with 0x686640, then sorts a local copy of the corners that nothing reads.

planesidenormald = −n·anchor
0top(c5 − c1) × (c6 − c1)c1
1bottom(c7 − c0) × (c4 − c0)c0
2left(c4 − c0) × (c5 − c0)c0
3right(c6 − c3) × (c7 − c3)c3
4far(c4 − c5) × (c6 − c5)c5
5near−(plane 4 normal)c2

The derivation is in the doc.

Callers 4

Callees 6

Calls and jumps by a bare address, from tables/calls.tsv.