72void AWorldVis::Build(
const Toshi::TMatrix44& a_rModelView,
const Toshi::TMatrix44& a_rProjection,
TINT a_iCellIndex,
const CullBox& a_rCullBox )
76 TASSERT( a_iCellIndex < m_pWorld->m_iNumCells );
78 if (
ISZERO( s_uiBuildFlags & 1 ) )
83 auto pCell =
m_pWorld->m_ppCells[ a_iCellIndex ];
90 auto pNode = pCell->pNode;
97 pNode->iCellIndex = a_iCellIndex;
98 pNode->pCellSettings =
TNULL;
105 pCellSettings->pNext = pNode->pCellSettings;
106 pCellSettings->oCullBox = a_rCullBox;
107 pNode->pCellSettings = pCellSettings;
109 for (
TINT i = 0; i < pCell->m_iSomeCount; i++ )
112 TASSERT( !
"Well, we are fucked up" );
115 pCell->uiFlags &=
~Cell::FLAGS_BUILDING;
143 AWorldVis::s_pStack = aStack;
155 pRenderContext->GetViewportParameters(),
156 pRenderContext->GetProjectionParams()
166 for (
auto pSettings = pCell->pNode->pCellSettings; pSettings !=
TNULL; pSettings = pSettings->pNext )
168 CreatePortalFrustum( portalFrustum, pSettings->oCullBox, projection );
169 frustum.
Transform( portalFrustum, viewModel );
173 renderData.
pCell = pCell;
184 auto pRightNode = a_pNode->
m_pRight;
185 auto pNode = a_pNode;
187 while ( pRightNode !=
TNULL )
190 pRightNode = pRightNode->m_pRight;
197 auto pStackValue1 = s_pStack + 0;
198 auto pStackValue2 = s_pStack + 1;
200 pStackValue1->pNextNode = a_pNode;
201 pStackValue1->pPrevNode = &endNode;
204 pStackValue2->pNextNode = a_pNode;
205 pStackValue2->pPrevNode = &endNode;
208 TINT iNumVisibleSpheres = 0;
209 pStackValue1 = pStackValue2;
213 auto pStackValue2Node = pStackValue2->pNextNode;
216 if ( pStackValue2Node->IsLeaf() )
219 iNumVisibleSpheres -= 1;
221 pStackValue2 = pStackValue1 - 1;
222 pStackValue2->pNextNode = pStackValue2->pNextNode->m_pRight;
223 pStackValue1 = pStackValue2;
236 auto pEndNode = pStackValue2->pPrevNode->m_pRight;
237 while ( pStackValue2Node < pEndNode )
239 if ( pStackValue2Node->IsLeaf() )
241 for (
TUINT i = 0; i < pStackValue2Node->GetLeafNode()->m_uiNumMeshes; i++ )
249 pStackValue2Node = pStackValue2Node->GetLeafNode()->End();
253 pStackValue2Node = pStackValue2Node->GetSubNode();
264 iNumVisibleSpheres++;
265 pStackValue2 = pStackValue1 + 1;
267 pStackValue2->pNextNode = pStackValue2Node->GetSubNode();
268 pStackValue2->pPrevNode = pStackValue2Node;
269 pStackValue1 = pStackValue2;
274 iNumVisibleSpheres--;
275 pStackValue2 = pStackValue1 - 1;
276 pStackValue2->pNextNode = pStackValue2->pNextNode->m_pRight;
277 pStackValue1 = pStackValue2;
281 if ( iNumVisibleSpheres < 0 )
break;