benilla-re systems structs docs

IntersectRaySphere

function · cmath · unreached

Address
0x7c1af0 · 321 bytes, up to 0x7c1c30
Signature
uint8_t __fastcall (const NTempest::C3Ray *ray, const NTempest::CAaSphere *sphere, float *outT, NTempest::C3Vector *outPoint)
Meaning
Intersects a ray with a sphere, the near root outside and the exit root inside
Confidence
verified, proof two
Finding
cmath/geometry#ray-and-sphere

Finding: Ray and sphere in cmath: intersections

0x7c1af0(outT, outPoint) intersects the ray in ecx (direction taken as a unit vector) with the sphere in edx (centre at +0, radius at +0xc). L = centre − origin, tca = L·dir, L² = L·L. It misses when tca < 0 and L² > r², and when L² − tca² > r². Otherwise thc = √(r² − (L² − tca²)) and t = tca − thc for an origin outside the sphere (L² > r²), t = tca + thc inside or on it. The point is origin + t·dir with every term rounded to a float.

The derivation is in the doc.

Callers 0

None by a direct call or jump.

Callees 1

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