benilla-re systems structs docs

BuildConvexPlanes

function · terrain · primitive

Address
0x686640 · 477 bytes, up to 0x68681c
Signature
void __thiscall (void *this)
Meaning
Builds a volume's six planes from its eight corners: top, bottom, left, right, far, near
Confidence
verified, proof one
Finding
terrain/scene#portal-volumes
Test
terrain::side_plane_d_negate_difftest, terrain::plane5_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 5

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