NeroReflex

Untitled

Nov 7th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.95 KB | None | 0 0
  1. /**
  2.  * Update a leaf in in TLAS and all its parent to the root.
  3.  * The index of the leaf (that is NOT the index of the internal node) is also the index of the associated BLAS.
  4.  *
  5.  * @param indexOfLeafInTLAS the index of the BLAS leaf that has to be updated
  6.  */
  7. void updateTLASLeaf(const uint indexOfLeafInTLAS) {
  8.     uint indexOfLastUpdatedNodeInTLAS = ((1 << expOfTwo_maxModels) - 1) + indexOfLeafInTLAS;
  9.  
  10.     tlas.tree[indexOfLastUpdatedNodeInTLAS].aabb = transformAABB(tlasBLAS[indexOfLeafInTLAS].tree[0].aabb, tlasBLAS[indexOfLeafInTLAS].ModelMatrix);
  11.  
  12.     while (!isRootNode(indexOfLastUpdatedNodeInTLAS)) {
  13.         memoryBarrier();
  14.  
  15.         // Target the parent node for update
  16.         indexOfLastUpdatedNodeInTLAS = parentNode(indexOfLastUpdatedNodeInTLAS);
  17.  
  18.         // Update the current node
  19.         tlas.tree[indexOfLastUpdatedNodeInTLAS].aabb = joinAABBs(
  20.                 tlas.tree[leftNode(indexOfLastUpdatedNodeInTLAS)].aabb,
  21.                 tlas.tree[rightNode(indexOfLastUpdatedNodeInTLAS)].aabb);
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment