BuildPerspectiveMatrix
function · gxumath · primitive
- Address
0x5c3cc0· 207 bytes, up to0x5c3d8e- Signature
void __thiscall (void *this, float fov, float aspect, float near, float far)- Meaning
- Builds a perspective matrix; the half-angle is fov / (2·sqrt(aspect² + 1)); error 0x57 on bad input
- Confidence
- verified, proof one
- Finding
- gxumath#perspective-matrix
- Test
gxumath::perspective_difftest
Finding: Perspective matrix in gxumath
0x5c3cc0 (ecx the output; fov, aspect, near, far on the stack; ret 0x10) writes the
perspective matrix. With t = tan(0.5·fov/√(aspect² + 1)) and d = far − near: m0 = near/(aspect·(t·near)), m5 = near/(t·near), m10 = (near + far)/d, m14 = near·far·(−2)/d,
m11 = 1. The other floats, m15 included, are 0. It needs 0 < fov < π, aspect > 0 and
near < far, NaN failing each; a failed test raises error 0x57 and writes nothing.
The derivation is in the doc.
Callers 6
- ApplyCameraProjectionAndView models
- CCamera::ClipNearBox uicamera
- CullLowDetailTiles terrain
- DrawFarBand terrain
- BuildProjectorVolume terrain
- CCamera::SetDeviceTransforms camera
Callees 1
- SErrSetLastError storm
Calls and jumps by a bare address, from tables/calls.tsv.