Skip to content

Instantly share code, notes, and snippets.

ivec4 ObjectNearestHit (in int theBVHOffset, in int theVrtOffset, in int theTrgOffset,
in SRay theRay, in vec3 theInverse, inout SIntersect theHit, in int theSentinel)
{
int aHead = theSentinel; // stack pointer
int aNode = 0; // node to visit
ivec4 aTriIndex = INALID_HIT;
float aTimeOut;
float aTimeLft;
pushedT = (aTimeLft < aTimeRgh) ? aTimeRgh : aTimeLft;
...
int aStackOffset = theHit.Time < pushedT ? 2 : 1;
if (aHead - aStackOffset + 1 <= theSentinel)
return aTriIndex;
aNode = Stack[aHead - aStackOffset + 1];