Changeset 325 for trunk/VUT/GtpVisibilityPreprocessor
- Timestamp:
- 10/13/05 13:10:21 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r324 r325 613 613 leaf->SetViewCell(tData.mViewCell); 614 614 615 // clean up 615 //-- clean up 616 616 617 // remaining polygons are discarded or added to node 617 618 leaf->ProcessPolygons(tData.mPolygons, sStoreSplitPolys); 618 619 DEL_PTR(tData.mPolygons); 620 621 if (tData.mRays()) 622 CLEAR_CONTAINER(*tData.mRays); 623 DEL_PTR(tData.mRays); 619 624 620 625 return leaf; … … 631 636 *frontPolys, 632 637 *backPolys, 633 coincident); 638 coincident, 639 *tData.mRays); 634 640 635 641 ViewCell *frontViewCell = mRootCell; … … 655 661 interior->ProcessPolygons(&coincident, sStoreSplitPolys); 656 662 663 // split rays 664 RayContainer *frontRays = NULL; 665 RayContainer *backRays = NULL; 666 667 if (tData.mRays) 668 { 669 RayContainer *frontRays = new RayContainer(); 670 RayContainer *backRays = new RayContainer(); 671 672 Plane3 plane; 673 SplitRays(plane, *tData.mRays, *frontRays, *backRays); 674 } 675 657 676 // push the children on the stack 658 677 tStack.push(BspTraversalData(interior->GetBack(), 659 678 backPolys, 660 679 tData.mDepth + 1, 661 backViewCell)); 680 backViewCell, 681 backRays)); 662 682 663 683 tStack.push(BspTraversalData(interior->GetFront(), 664 684 frontPolys, 665 685 tData.mDepth + 1, 666 frontViewCell)); 686 frontViewCell, 687 frontRays)); 667 688 668 689 // cleanup 669 690 DEL_PTR(tData.mNode); 670 691 DEL_PTR(tData.mPolygons); 692 DEL_PTR(tData.mRays); 671 693 672 694 return interior; … … 707 729 PolygonContainer &frontPolys, 708 730 PolygonContainer &backPolys, 709 PolygonContainer &coincident) 731 PolygonContainer &coincident, 732 const RayContainer &rays) 710 733 { 711 734 mStat.nodes += 2; 712 735 713 736 // add the new nodes to the tree + select subdivision plane 714 BspInterior *interior = new BspInterior(SelectPlane(leaf, polys ));737 BspInterior *interior = new BspInterior(SelectPlane(leaf, polys, rays)); 715 738 716 739 #ifdef _DEBUG … … 726 749 coincident, 727 750 splits, 728 sStoreSplitPolys);751 mStoreSplitPolys); 729 752 730 753 mStat.splits += splits; … … 849 872 850 873 Plane3 BspTree::SelectPlane(BspLeaf *leaf, 851 PolygonContainer &polys) 874 PolygonContainer &polys, 875 const RayContainer &rays) 852 876 { 853 877 if (polys.size() == 0) … … 898 922 899 923 // use heuristics to find appropriate plane 900 return SelectPlaneHeuristics(polys, sMaxCandidates);924 return SelectPlaneHeuristics(polys, rays, sMaxCandidates); 901 925 } 902 926 903 927 Plane3 BspTree::SelectPlaneHeuristics(PolygonContainer &polys, 928 const RayContainer &rays, 904 929 const int maxTests) 905 930 { … … 918 943 919 944 // evaluate current candidate 920 float candidateCost = SplitPlaneCost(polys, candidatePlane );945 float candidateCost = SplitPlaneCost(polys, candidatePlane, rays); 921 946 922 947 if (candidateCost < lowestCost) … … 945 970 946 971 float BspTree::SplitPlaneCost(PolygonContainer &polys, 947 const Plane3 &candidatePlane) 972 const Plane3 &candidatePlane, 973 const RayContainer &rays) 948 974 { 949 975 float val = 0; … … 1356 1382 } 1357 1383 } 1384 1385 void BspTree::SplitRays(const Plane3 plane, 1386 RayContainer &rays, 1387 RayContainer &frontRays, 1388 RayContainer &backRays) 1389 { 1390 while (!rays.empty()) 1391 { 1392 //TODO 1393 } 1394 } 1358 1395 //} // GtpVisibilityPreprocessor -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h
r322 r325 234 234 /// the view cell associated with this subdivsion 235 235 ViewCell *mViewCell; 236 236 /// rays piercing this node 237 RayContainer *mRays; 238 237 239 BspTraversalData(): 238 240 mNode(NULL), 239 241 mPolygons(NULL), 240 242 mDepth(0), 241 mViewCell(NULL) 243 mViewCell(NULL), 244 mRays(NULL) 242 245 {} 243 246 … … 245 248 PolygonContainer *polys, 246 249 const int depth, 247 ViewCell *viewCell): 250 ViewCell *viewCell, 251 RayContainer *rays = NULL): 248 252 mNode(node), 249 253 mPolygons(polys), 250 254 mDepth(depth), 251 mViewCell(viewCell) 255 mViewCell(viewCell), 256 mRays(rays) 252 257 {} 253 258 }; … … 353 358 */ 354 359 float SplitPlaneCost(PolygonContainer &polys, 355 const Plane3 &candidatePlane); 360 const Plane3 &candidatePlane, 361 const RayContainer &rays); 356 362 357 363 /** Evaluates tree stats in the BSP tree leafs. … … 369 375 @param leaf the leaf to be split 370 376 @param polys the polygon list on which the split decition is based 371 @Returns the split plane 377 @param rays ray container on which selection may be based 378 Returns the split plane 372 379 */ 373 380 Plane3 SelectPlane(BspLeaf *leaf, 374 PolygonContainer &polys); 381 PolygonContainer &polys, 382 const RayContainer &ray); 375 383 376 384 /** Filters next view cell down the tree and inserts it into the appropriate leaves … … 390 398 @param backPolys returns the polygons in the back of the split plane 391 399 @param coincident returns the polygons coincident to the split plane 400 @param rays ray container used to guide the split process 392 401 @returns the root of the subdivision 393 402 */ … … 396 405 PolygonContainer &frontPolys, 397 406 PolygonContainer &backPolys, 398 PolygonContainer &coincident); 407 PolygonContainer &coincident, 408 const RayContainer &rays); 399 409 400 410 /** Filters polygons down the tree. … … 413 423 2.5d aligned) 414 424 @param polygons container of polygons 425 @param rays bundle of rays on which the split can be based 415 426 @param maxTests the maximal number of candidate tests 416 427 */ 417 428 Plane3 SelectPlaneHeuristics(PolygonContainer &polys, 418 const int maxTests); 429 const RayContainer &rays, 430 const int maxTests); 419 431 420 432 /** Extracts the meshes of the objects and adds them to polygons. … … 490 502 vector<SortableEntry> &splitCandidates) const; 491 503 504 /** Splits the rays into front and back rays according to split plane 505 @param rays contains the rays to be split. The rays are 506 distributed to front and back rays. 507 @param frontRays returns rays on the front side of the plane 508 @param backRays returns rays on the back side of the plane 509 */ 510 void BspTree::SplitRays(const Plane3 plane, 511 RayContainer &rays, 512 RayContainer &frontRays, 513 RayContainer &backRays); 514 492 515 /// Pointer to the root of the tree 493 516 BspNode *mRoot;
Note: See TracChangeset
for help on using the changeset viewer.