- Timestamp:
- 09/16/05 08:27:42 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r275 r276 147 147 PolygonContainer *frontPolys, 148 148 PolygonContainer *backPolys, 149 PolygonContainer *coincident, 149 150 int &splits, bool storePolys) 150 151 { 151 152 #ifdef _Debug 152 //if (BspTree::displayDebug)Debug << "Splitting polygons of node " << this << " with plane " << mPlane << endl;153 if (BspTree::displayDebug)Debug << "Splitting polygons of node " << this << " with plane " << mPlane << endl; 153 154 #endif 154 bool inside = false;155 156 155 while (!polys->empty()) 157 156 { … … 170 169 { 171 170 case Polygon3::COINCIDENT: 172 173 if ( !inside)174 // same surface normal175 inside = (DotProd(mPlane.mNormal, poly->GetSupportingPlane().mNormal) > 0);176 //if (BspTree::displayDebug) Debug << "coincident" << endl;177 // discard polygons or saves them in node178 ProcessPolygon(poly, storePolys);179 break;171 // same surface normal 172 if (DotProd(mPlane.mNormal, poly->GetSupportingPlane().mNormal) > 0) 173 { 174 coincident->push_back(poly); 175 break; 176 } 177 //if (BspTree::displayDebug) Debug << "coincident" << endl; 178 180 179 case Polygon3::FRONT_SIDE: 181 180 //if (BspTree::displayDebug)Debug << "front" << endl; … … 183 182 break; 184 183 case Polygon3::BACK_SIDE: 185 inside = true;//if (BspTree::displayDebug)Debug << "back" << endl;184 //if (BspTree::displayDebug)Debug << "back" << endl; 186 185 backPolys->push_back(poly); 187 186 break; 188 187 case Polygon3::SPLIT: 189 inside = true; 190 191 front_piece = new Polygon3(); 192 back_piece = new Polygon3(); 188 front_piece = new Polygon3(poly->GetParent()); 189 back_piece = new Polygon3(poly->GetParent()); 193 190 194 191 //-- split polygon … … 201 198 if (BspTree::displayDebug)Debug << "split " << *poly << endl << *front_piece << endl << *back_piece << endl; 202 199 #endif 203 // save or discard polygons204 200 ProcessPolygon(poly, storePolys); 205 201 … … 213 209 // contains nothing 214 210 delete polys; 215 216 return inside;217 211 } 218 212 … … 390 384 PolygonContainer *frontPolys = new PolygonContainer(); 391 385 PolygonContainer *backPolys = new PolygonContainer(); 386 PolygonContainer *coincident = new PolygonContainer(); 392 387 393 388 int splits = 0; … … 396 391 bool inside = interior->SplitPolygons(tData.mPolygons, 397 392 frontPolys, 398 backPolys, 393 backPolys, 394 coincident, 399 395 splits, 400 396 mStorePolys); 401 397 402 398 //Debug << "split node on level " << tData.mDepth << " bk: " << backPolys->size() << " frnt: " << frontPolys->size() << endl; 403 399 mStat.splits += splits; 404 400 405 401 // push the children on the stack 406 tStack.push(BspTraversalData(interior->GetFront(), frontPolys, tData.mDepth + 1 , false));407 tStack.push(BspTraversalData(interior->GetBack(), backPolys, tData.mDepth + 1 , inside));402 tStack.push(BspTraversalData(interior->GetFront(), frontPolys, tData.mDepth + 1)); 403 tStack.push(BspTraversalData(interior->GetBack(), backPolys, tData.mDepth + 1)); 408 404 409 405 } … … 578 574 std::stack<BspTraversalData> tStack; 579 575 580 BspTraversalData tData(new BspLeaf(), polys, 0, true );576 BspTraversalData tData(new BspLeaf(), polys, 0, true, viewCells); 581 577 582 578 tStack.push(tData); … … 589 585 tStack.pop(); 590 586 587 //TODO 591 588 ViewCell *viewCell = NULL; 592 589 593 if (viewCells) // generate new view cell in leaf590 /*if (viewCells) // generate new view cell in leaf 594 591 { 595 592 viewCell = new ViewCell(); 596 593 viewCells->push_back(viewCell); 597 } 594 }*/ 598 595 599 596 // subdivide leaf node … … 625 622 626 623 // add view cell if inside object) 627 if (viewCell && tData.m IsInside) // || (tData.mGeometry->size() > 0) // or if there is still geometry left624 if (viewCell && tData.mCoincident && (tData.mCoincident->size() > 0))) // || (tData.mGeometry->size() > 0) // or if there is still geometry left 628 625 { 629 626 BspLeaf *leaf = dynamic_cast<BspLeaf *>(tData.mNode); … … 634 631 //leaf->mViewCellIdx = counter; 635 632 //Debug << "insert view cell" << endl; 636 leaf->SetViewCell(viewCell); 633 634 leaf->SetViewCell(coincident[0]->GetParent()); 637 635 } 638 636 639 637 // add or delete remaining polygons 640 638 tData.mNode->ProcessPolygons(tData.mPolygons, mStorePolys); 639 tData.mNode->ProcessPolygons(tData.coincident, mStorePolys); 641 640 642 641 return tData.mNode; 643 642 } 643 644 tData.mNode->ProcessPolygons(tData.coincident, mStorePolys); 644 645 645 646 //-- create new subdivided node 646 647 PolygonContainer *backPolys = new PolygonContainer(); 647 648 PolygonContainer *frontPolys = new PolygonContainer(); 648 649 bool inside = false; 650 649 PolygonContainer *coincident = new PolygonContainer(); 650 651 651 BspInterior *interior = SubdivideNode(dynamic_cast<BspLeaf *>(tData.mNode), 652 652 tData.mPolygons, 653 653 frontPolys, 654 backPolys, inside); 654 backPolys, 655 coincident); 655 656 656 657 // push the children on the stack 657 658 // inside information is only propagated with the back leaf 658 tStack.push(BspTraversalData(interior->GetBack(), backPolys, tData.mDepth + 1, inside));659 tStack.push(BspTraversalData(interior->GetFront(), frontPolys, tData.mDepth + 1 , false));659 tStack.push(BspTraversalData(interior->GetBack(), backPolys, tData.mDepth + 1, coincident)); 660 tStack.push(BspTraversalData(interior->GetFront(), frontPolys, tData.mDepth + 1)); 660 661 661 662 return interior; … … 665 666 BspInterior *BspTree::SubdivideNode(BspLeaf *leaf, 666 667 PolygonContainer *polys, 667 PolygonContainer *frontPolys, 668 PolygonContainer *frontPolys, 669 PolygonContainer *coincident, 668 670 PolygonContainer *backPolys, bool &inside) 669 671 { … … 680 682 int splits = 0; 681 683 682 inside = interior->SplitPolygons(polys, frontPolys, backPolys, splits, mStorePolys);684 inside = interior->SplitPolygons(polys, frontPolys, backPolys, coincident, splits, mStorePolys); 683 685 684 686 mStat.splits += splits;
Note: See TracChangeset
for help on using the changeset viewer.