benilla-re systems structs docs

IntersectRaySphereAlgebraic

function · cmath · unreached

Address
0x7c1c40 · 390 bytes, up to 0x7c1dc5
Signature
uint8_t __fastcall (const NTempest::C3Ray *ray, const NTempest::CAaSphere *sphere, float *outT, NTempest::C3Vector *outPoint)
Meaning
Intersects a ray with a sphere by the quadratic, the near root only, scaled back by the direction length
Confidence
verified, proof two
Finding
cmath/geometry#ray-and-sphere-by-the-quadratic

Finding: Ray and sphere by the quadratic in cmath: intersections

0x7c1c40(outT, outPoint) takes the same arguments with the ray in ecx and the sphere in edx. It normalizes the direction (nD=dir/|dir|) and forms L=origin−centre, A=nD·nD, B=2(L·nD), c=L·L−r² and disc=B²−4Ac, and returns 0 for disc<0. The root is t=(−B−√disc)/(2A), the near root even for an origin inside the sphere, and −B/(2A) for disc=0. t is multiplied by 1/|dir| and written to outT, and the point is origin+t·dir with the original direction. A null outT returns 1 after the test.

The derivation is in the doc.

Callers 0

None by a direct call or jump.

Callees 2

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