Changeset 234 for trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
- Timestamp:
- 08/10/05 18:07:51 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r233 r234 247 247 248 248 BspTree::BspTree(const ViewCellContainer &viewCells): 249 mMaxPolys(0), mMaxDepth( 0), mRoot(NULL)249 mMaxPolys(0), mMaxDepth(999999), mRoot(NULL) // null => until we stripped all polygons 250 250 { 251 251 //mRootCell = cell; … … 298 298 CopyMesh2Polygon(viewCell->GetMesh(), polys); 299 299 300 tStack.push(BspTraversalData(mRoot, NULL, &polys, 0 , viewCell));300 tStack.push(BspTraversalData(mRoot, NULL, &polys, 0)); 301 301 302 302 while (!tStack.empty()) … … 318 318 319 319 // push the children on the stack 320 if (frontPolys->size() > 0) 320 if (frontPolys->size() > 0) // if polygons on this side of bsp tree 321 321 tStack.push(BspTraversalData(interior->GetFront(), interior->GetParent(), frontPolys, tData.mDepth + 1)); 322 322 else 323 323 delete frontPolys; 324 324 325 if (backPolys > 0) 326 tStack.push(BspTraversalData(interior->GetBack(), interior->GetParent(), backPolys, tData.mDepth + 1)); // TODO: really need to keep viewcell??325 if (backPolys > 0) // if polygons on this side of bsp tree 326 tStack.push(BspTraversalData(interior->GetBack(), interior->GetParent(), backPolys, tData.mDepth + 1)); 327 327 else 328 328 delete backPolys; … … 330 330 else // reached leaf and must split 331 331 { 332 BuildTree(tStack, tData); 333 } 334 } 335 /* BspNode *currentNode = mRoot; 336 337 std::stack<BspTraversalData> tStack; 338 // stack<STraversalData> tStack; 339 340 //tStack.push(tdata); 341 342 while (!tStack.empty()) 343 { 344 BspTraversalData data = tStack.top(); 345 346 tStack.pop(); 347 348 Mesh backPolys; 349 Mesh frontPolys; 350 351 if (data.mNode->IsLeaf()) // if we have a leaf => subdivide 352 { 353 BspNode *node = SubdivideNode(dynamic_cast<BspLeaf *>(data.mNode), 354 data.mParent, 355 data.mPolys, 356 data.mDepth, 357 data.viewCell, 358 backPolys, 359 frontPolys); 360 361 if (!node->IsLeaf()) // node was subdivided 362 { 363 BspInterior *interior = dynamic_cast<BspInterior *>(node); 364 365 // push the children on the stack (there are always two children) 366 //tStack.push(BspTraversalData(interior->GetBack(), interior, backPolys, data.mDepth + 1)); 367 //tStack.push(BspTraversalData(interior->GetFront(), interior, frontPolys, data.mDepth + 1)); 368 } 369 } 370 }*/ 332 BuildTree(tStack, tData, NULL); 333 } 334 } 371 335 } 372 336 … … 415 379 Copy2PolygonSoup(objects, *polys); 416 380 417 BspTraversalData tData(mRoot, mRoot->GetParent(), polys, 0 , NULL);381 BspTraversalData tData(mRoot, mRoot->GetParent(), polys, 0); 418 382 tStack.push(tData); 419 383 … … 428 392 } 429 393 430 void BspTree::BuildTree(BspTraversalStack &tStack, BspTraversalData ¤tData )394 void BspTree::BuildTree(BspTraversalStack &tStack, BspTraversalData ¤tData, ViewCell *viewCell) 431 395 { 432 396 PolygonQueue *backPolys = new PolygonQueue(); … … 437 401 currentData.mPolys, 438 402 currentData.mDepth, 439 currentData.mViewCell,403 viewCell, 440 404 backPolys, 441 405 frontPolys); … … 446 410 447 411 // push the children on the stack (there are always two children) 448 tStack.push(BspTraversalData(interior->GetBack(), interior, backPolys, currentData.mDepth + 1 , NULL));449 tStack.push(BspTraversalData(interior->GetFront(), interior, frontPolys, currentData.mDepth + 1 , currentData.mViewCell));412 tStack.push(BspTraversalData(interior->GetBack(), interior, backPolys, currentData.mDepth + 1)); 413 tStack.push(BspTraversalData(interior->GetFront(), interior, frontPolys, currentData.mDepth + 1)); 450 414 } 451 415 }
Note: See TracChangeset
for help on using the changeset viewer.