183{
184 auto pRightNode = a_pNode->
m_pRight;
185 auto pNode = a_pNode;
186
187 while ( pRightNode !=
TNULL )
188 {
189 pNode = pRightNode;
190 pRightNode = pRightNode->m_pRight;
191 }
192
193 CellSphereTreeBranchNode endNode;
196
197 auto pStackValue1 = s_pStack + 0;
198 auto pStackValue2 = s_pStack + 1;
199
200 pStackValue1->pNextNode = a_pNode;
201 pStackValue1->pPrevNode = &endNode;
203
204 pStackValue2->pNextNode = a_pNode;
205 pStackValue2->pPrevNode = &endNode;
207
208 TINT iNumVisibleSpheres = 0;
209 pStackValue1 = pStackValue2;
210
211 for ( ;; )
212 {
213 auto pStackValue2Node = pStackValue2->pNextNode;
215
216 if ( pStackValue2Node->IsLeaf() )
217 {
219 iNumVisibleSpheres -= 1;
220
221 pStackValue2 = pStackValue1 - 1;
222 pStackValue2->pNextNode = pStackValue2->pNextNode->m_pRight;
223 pStackValue1 = pStackValue2;
224 }
225 else
226 {
229
231 {
232
235
236 auto pEndNode = pStackValue2->pPrevNode->m_pRight;
237 while ( pStackValue2Node < pEndNode )
238 {
239 if ( pStackValue2Node->IsLeaf() )
240 {
241 for (
TUINT i = 0; i < pStackValue2Node->GetLeafNode()->m_uiNumMeshes; i++ )
242 {
245 a_pRenderData
246 );
247 }
248
249 pStackValue2Node = pStackValue2Node->GetLeafNode()->End();
250 }
251 else
252 {
253 pStackValue2Node = pStackValue2Node->GetSubNode();
254 }
255 }
256
258 }
259
261 {
262
263
264 iNumVisibleSpheres++;
265 pStackValue2 = pStackValue1 + 1;
267 pStackValue2->pNextNode = pStackValue2Node->GetSubNode();
268 pStackValue2->pPrevNode = pStackValue2Node;
269 pStackValue1 = pStackValue2;
270 }
271 else
272 {
273
274 iNumVisibleSpheres--;
275 pStackValue2 = pStackValue1 - 1;
276 pStackValue2->pNextNode = pStackValue2->pNextNode->m_pRight;
277 pStackValue1 = pStackValue2;
278 }
279 }
280
281 if ( iNumVisibleSpheres < 0 ) break;
282 }
283}
FrustumIntersectSphereResult
struct CellSphereTreeBranchNode * End()
CellSphereTreeBranchNode * m_pRight
Toshi::TSphere m_BoundingSphere
void RenderLeafNodeIntersect(CellSphereTreeBranchNode *a_pNode, RenderData *a_pRenderData)